Last active
February 21, 2025 12:46
-
-
Save a-sakharov/cdd130a5bfe18745a886ce823adebe01 to your computer and use it in GitHub Desktop.
Simple ESP32 ImHex pattern file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma author A.Sakharov | |
| #pragma description ESP32 firmware file | |
| #pragma endian little | |
| struct FileHeader { | |
| u8 magick;// 0xe9 | |
| u8 SegmentsCount; | |
| u8 FlashMode; | |
| u8 Flash; | |
| u32 EntryPoint; | |
| }; | |
| struct ExtendedFileHeader { | |
| u8 WP; | |
| u8 DriveSerrings[3]; | |
| u16 ChipId; | |
| u8 MinimalChipRevisionLegacy; | |
| u16 MinimalChipRevision; | |
| u16 MaximalChipRevision; | |
| u8 reserved[4]; | |
| u8 HashAvailable; | |
| }; | |
| struct Segment { | |
| u32 MemoryOffset; | |
| u32 SegmentSize; | |
| u8 Data[SegmentSize]; | |
| }; | |
| struct Image { | |
| FileHeader fh; | |
| ExtendedFileHeader efh; | |
| Segment s[fh.SegmentsCount]; | |
| u8 pad[while((($ + 1) % 16) != 0)]; | |
| u8 checksum; | |
| if (efh.HashAvailable) u8 sha256[32]; | |
| }; | |
| struct esp_app_sedc { | |
| u32 magic_word; | |
| u32 secure_version; | |
| u32 reserv1[2]; | |
| char version[32]; | |
| char project_name[32]; | |
| char time[16]; | |
| char date[16]; | |
| char idf_ver[32]; | |
| u8 app_elf_sha256[32]; | |
| u16 min_efuse_blk_rev_full; | |
| u16 max_efuse_blk_rev_full; | |
| u8 mmu_page_size; | |
| u8 reserv3[3]; | |
| u32 reserv2[18]; | |
| }; | |
| Image i @ 0; | |
| u32 app_struct_base; | |
| for (u8 sector_no=0, sector_no<i.fh.SegmentsCount, sector_no = sector_no + 1) { | |
| if( | |
| i.s[sector_no].MemoryOffset >= 0x3F400000 && | |
| (i.s[sector_no].MemoryOffset + i.s[sector_no].SegmentSize) < 0x3F800000 | |
| ) { | |
| app_struct_base = addressof(i.s[sector_no].Data); | |
| break; | |
| } | |
| } | |
| esp_app_sedc app @ app_struct_base; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment