diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-30 14:08:02 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-30 14:08:02 +0100 |
commit | 4d01168b9bcdb8c060604cbd851e4ea13b4aa9b5 (patch) | |
tree | bee76112f4066f60e80fa5d0511a27cef3224a6c /bootloader/x1000 | |
parent | e05aa27124461ccf85109ae8d249924895f07a3e (diff) | |
download | rockbox-4d01168b9bcdb8c060604cbd851e4ea13b4aa9b5.tar.gz rockbox-4d01168b9bcdb8c060604cbd851e4ea13b4aa9b5.zip |
x1000: add flash probe tool to bootloader
The flash probe mimics the boot ROM's flash read routines and
dumps the manufacturer & device IDs and 16-byte parameter data
to a file on the SD card.
Change-Id: I3d413bd0cc05a9d7f2285b85454420c3e90274e9
Diffstat (limited to 'bootloader/x1000')
-rw-r--r-- | bootloader/x1000/recovery.c | 1 | ||||
-rw-r--r-- | bootloader/x1000/utils.c | 73 | ||||
-rw-r--r-- | bootloader/x1000/x1000bootloader.h | 1 |
3 files changed, 75 insertions, 0 deletions
diff --git a/bootloader/x1000/recovery.c b/bootloader/x1000/recovery.c index c53fa376b9..e6cc041d99 100644 --- a/bootloader/x1000/recovery.c +++ b/bootloader/x1000/recovery.c | |||
@@ -68,6 +68,7 @@ static const struct menuitem debug_menu_items[] = { | |||
68 | #ifdef HAVE_SCREENDUMP | 68 | #ifdef HAVE_SCREENDUMP |
69 | {MENUITEM_ACTION, "Enable screenshots", &screenshot_enable}, | 69 | {MENUITEM_ACTION, "Enable screenshots", &screenshot_enable}, |
70 | #endif | 70 | #endif |
71 | {MENUITEM_ACTION, "Flash info", &show_flash_info}, | ||
71 | #ifdef OF_PLAYER_ADDR | 72 | #ifdef OF_PLAYER_ADDR |
72 | {MENUITEM_ACTION, "Dump OF player", &dump_of_player}, | 73 | {MENUITEM_ACTION, "Dump OF player", &dump_of_player}, |
73 | #endif | 74 | #endif |
diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c index 4d3fb69e57..17eb502e1b 100644 --- a/bootloader/x1000/utils.c +++ b/bootloader/x1000/utils.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "linuxboot.h" | 31 | #include "linuxboot.h" |
32 | #include "screendump.h" | 32 | #include "screendump.h" |
33 | #include "nand-x1000.h" | 33 | #include "nand-x1000.h" |
34 | #include "sfc-x1000.h" | ||
34 | 35 | ||
35 | /* Set to true if a SYS_USB_CONNECTED event is seen | 36 | /* Set to true if a SYS_USB_CONNECTED event is seen |
36 | * Set to false if a SYS_USB_DISCONNECTED event is seen | 37 | * Set to false if a SYS_USB_DISCONNECTED event is seen |
@@ -338,3 +339,75 @@ void dump_entire_flash(void) | |||
338 | dump_flash_file("/flash.img", 0, 2048 * 64 * 1024); | 339 | dump_flash_file("/flash.img", 0, 2048 * 64 * 1024); |
339 | #endif | 340 | #endif |
340 | } | 341 | } |
342 | |||
343 | static void probe_flash(int log_fd) | ||
344 | { | ||
345 | static uint8_t buffer[CACHEALIGN_UP(32)] CACHEALIGN_ATTR; | ||
346 | |||
347 | /* Use parameters from maskrom */ | ||
348 | const uint32_t clock_freq = X1000_EXCLK_FREQ; /* a guess */ | ||
349 | const uint32_t dev_conf = jz_orf(SFC_DEV_CONF, | ||
350 | CE_DL(1), HOLD_DL(1), WP_DL(1), | ||
351 | CPHA(0), CPOL(0), | ||
352 | TSH(0), TSETUP(0), THOLD(0), | ||
353 | STA_TYPE_V(1BYTE), CMD_TYPE_V(8BITS), | ||
354 | SMP_DELAY(0)); | ||
355 | const size_t readid_len = 4; | ||
356 | |||
357 | /* NOTE: This assumes the NAND driver is inactive. If this is not true, | ||
358 | * this will seriously mess up the NAND driver. */ | ||
359 | sfc_open(); | ||
360 | sfc_set_dev_conf(dev_conf); | ||
361 | sfc_set_clock(clock_freq); | ||
362 | |||
363 | /* Issue reset */ | ||
364 | sfc_exec(NANDCMD_RESET, 0, NULL, 0); | ||
365 | mdelay(10); | ||
366 | |||
367 | /* Try various read ID commands (cf. Linux's SPI NAND identify routine) */ | ||
368 | sfc_exec(NANDCMD_READID(0, 0), 0, buffer, readid_len|SFC_READ); | ||
369 | fdprintf(log_fd, "readID opcode = %02x %02x %02x %02x\n", | ||
370 | buffer[0], buffer[1], buffer[2], buffer[3]); | ||
371 | |||
372 | sfc_exec(NANDCMD_READID(1, 0), 0, buffer, readid_len|SFC_READ); | ||
373 | fdprintf(log_fd, "readID address = %02x %02x %02x %02x\n", | ||
374 | buffer[0], buffer[1], buffer[2], buffer[3]); | ||
375 | |||
376 | sfc_exec(NANDCMD_READID(0, 8), 0, buffer, readid_len|SFC_READ); | ||
377 | fdprintf(log_fd, "readID dummy = %02x %02x %02x %02x\n", | ||
378 | buffer[0], buffer[1], buffer[2], buffer[3]); | ||
379 | |||
380 | /* Try reading Ingenic SFC boot block */ | ||
381 | sfc_exec(NANDCMD_PAGE_READ(3), 0, NULL, 0); | ||
382 | mdelay(500); | ||
383 | sfc_exec(NANDCMD_READ_CACHE_SLOW(2), 0, buffer, 16|SFC_READ); | ||
384 | |||
385 | fdprintf(log_fd, "sfc params0 = %02x %02x %02x %02x\n", | ||
386 | buffer[ 0], buffer[ 1], buffer[ 2], buffer[ 3]); | ||
387 | fdprintf(log_fd, "sfc params1 = %02x %02x %02x %02x\n", | ||
388 | buffer[ 4], buffer[ 5], buffer[ 6], buffer[ 7]); | ||
389 | fdprintf(log_fd, "sfc params2 = %02x %02x %02x %02x\n", | ||
390 | buffer[ 8], buffer[ 9], buffer[10], buffer[11]); | ||
391 | fdprintf(log_fd, "sfc params3 = %02x %02x %02x %02x\n", | ||
392 | buffer[12], buffer[13], buffer[14], buffer[15]); | ||
393 | |||
394 | sfc_close(); | ||
395 | } | ||
396 | |||
397 | void show_flash_info(void) | ||
398 | { | ||
399 | if(check_disk(true) != DISK_PRESENT) | ||
400 | return; | ||
401 | |||
402 | int fd = open("/flash_info.txt", O_WRONLY|O_CREAT|O_TRUNC); | ||
403 | if(fd < 0) { | ||
404 | splashf(5*HZ, "Cannot create log file"); | ||
405 | return; | ||
406 | } | ||
407 | |||
408 | splashf(0, "Probing flash..."); | ||
409 | probe_flash(fd); | ||
410 | |||
411 | close(fd); | ||
412 | splashf(3*HZ, "Dumped flash info\nSee flash_info.txt"); | ||
413 | } | ||
diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h index 81c7f2aaa4..e74a6a3b68 100644 --- a/bootloader/x1000/x1000bootloader.h +++ b/bootloader/x1000/x1000bootloader.h | |||
@@ -197,6 +197,7 @@ int dump_flash_file(const char* file, uint32_t addr, uint32_t length); | |||
197 | void dump_of_player(void); | 197 | void dump_of_player(void); |
198 | void dump_of_recovery(void); | 198 | void dump_of_recovery(void); |
199 | void dump_entire_flash(void); | 199 | void dump_entire_flash(void); |
200 | void show_flash_info(void); | ||
200 | 201 | ||
201 | void recovery_menu(void) __attribute__((noreturn)); | 202 | void recovery_menu(void) __attribute__((noreturn)); |
202 | 203 | ||