From 9b572bb9d393ff8415110d88beee20523fa829cc Mon Sep 17 00:00:00 2001 From: kerms Date: Tue, 10 Mar 2026 12:59:46 +0100 Subject: [PATCH] feat: add hex dump viewer, show appended SHA256, remove custom app desc --- .../app-image-viewer/AppImageViewer.vue | 33 ++++---- components/app-image-viewer/HexDump.vue | 77 +++++++++++++++++++ lib/app-image/constants.ts | 6 -- lib/app-image/parser.ts | 11 --- lib/app-image/types.ts | 2 - 5 files changed, 97 insertions(+), 32 deletions(-) create mode 100644 components/app-image-viewer/HexDump.vue diff --git a/components/app-image-viewer/AppImageViewer.vue b/components/app-image-viewer/AppImageViewer.vue index 5f69864..a40e2a6 100644 --- a/components/app-image-viewer/AppImageViewer.vue +++ b/components/app-image-viewer/AppImageViewer.vue @@ -1,16 +1,19 @@ + + + + diff --git a/lib/app-image/constants.ts b/lib/app-image/constants.ts index f85cabe..95126a1 100644 --- a/lib/app-image/constants.ts +++ b/lib/app-image/constants.ts @@ -16,12 +16,6 @@ export const APP_DESC_MAGIC = 0xABCD5432; /** Size of esp_app_desc_t structure */ export const APP_DESC_SIZE = 256; -/** Offset of custom app desc within first segment data (immediately after esp_app_desc_t) */ -export const CUSTOM_DESC_OFFSET_IN_SEGMENT = APP_DESC_SIZE; // 256 - -/** How many raw bytes to extract for the custom app desc dump */ -export const CUSTOM_DESC_DUMP_SIZE = 64; - /** Chip ID to human-readable name */ export const CHIP_ID_NAMES: Record = { 0x0000: 'ESP32', diff --git a/lib/app-image/parser.ts b/lib/app-image/parser.ts index 8604822..a401740 100644 --- a/lib/app-image/parser.ts +++ b/lib/app-image/parser.ts @@ -5,7 +5,6 @@ import type { import { IMAGE_MAGIC, IMAGE_HEADER_SIZE, EXTENDED_HEADER_SIZE, SEGMENT_HEADER_SIZE, APP_DESC_MAGIC, APP_DESC_SIZE, CHIP_ID_NAMES, - CUSTOM_DESC_OFFSET_IN_SEGMENT, CUSTOM_DESC_DUMP_SIZE, } from './constants'; /** @@ -94,21 +93,11 @@ export function parseAppImage(data: Uint8Array): AppImageInfo { } } - // ── Custom App Description — fixed offset in first segment ── - let customDescRawBytes: Uint8Array | null = null; - if (segDataOffsets.length > 0) { - const customOff = segDataOffsets[0] + CUSTOM_DESC_OFFSET_IN_SEGMENT; - if (customOff + CUSTOM_DESC_DUMP_SIZE <= data.length) { - customDescRawBytes = new Uint8Array(data.subarray(customOff, customOff + CUSTOM_DESC_DUMP_SIZE)); - } - } - return { header, extendedHeader, segments, appDescription, - customDescRawBytes, valid: segments.length === segmentCount, // false if image was truncated mid-segment chipName: CHIP_ID_NAMES[chipId] ?? `Unknown (0x${chipId.toString(16)})`, }; diff --git a/lib/app-image/types.ts b/lib/app-image/types.ts index 4367269..274cc9d 100644 --- a/lib/app-image/types.ts +++ b/lib/app-image/types.ts @@ -63,8 +63,6 @@ export interface AppImageInfo { extendedHeader: ExtendedHeader; segments: SegmentHeader[]; appDescription: AppDescription | null; - /** Raw bytes at the custom app desc location (null if first segment too short) */ - customDescRawBytes: Uint8Array | null; valid: boolean; chipName: string; }