From a20fe4a3fff33a014f5dace75903b5440969c12e Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Sun, 6 Jul 2025 17:29:37 +0300 Subject: [PATCH] Add debug menu option that dumps the boot flash of iPod 6G to a file Change-Id: I7d7c3294cb45500297b903c40a3ec93c8a8ea33c --- apps/debug_menu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index b267930b12..af28de9005 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -2714,6 +2714,37 @@ static bool dbg_syscfg(void) { return simplelist_show_list(&info); } + +#define FLASH_PAGES (FLASH_SIZE >> 12) +#define FLASH_PAGE_SIZE (FLASH_SIZE >> 8) + +static bool dbg_bootflash_dump(void) { + splashf(HZ, "Please wait..."); + + int fd; + + fd = creat("/bootflash.bin", 0666); + + if (fd < 0) + { + splashf(HZ * 3, "Error opening file"); + return false; + } + + uint8_t page[FLASH_PAGE_SIZE]; + bootflash_init(SPI_PORT); + + for (int i = 0; i < FLASH_PAGES; i++) { + bootflash_read(SPI_PORT, i << 12, FLASH_PAGE_SIZE, page); + write(fd, page, FLASH_PAGE_SIZE); + } + + bootflash_close(SPI_PORT); + close(fd); + splashf(HZ * 3, "Dump saved to /bootflash.bin"); + + return false; +} #endif /****** The menu *********/ @@ -2833,6 +2864,7 @@ static const struct { #if defined(IPOD_6G) && !defined(SIMULATOR) {"View SysCfg", dbg_syscfg }, + {"Dump bootflash to file", dbg_bootflash_dump }, #endif };