From 441633d6556229c89909c9a51ec3dbfec762833a Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Mon, 6 Mar 2023 22:07:28 +0100 Subject: [PATCH] hide registers in bootloader error screen for error_display() function --- sw/bootloader/src/exception.c | 27 ++++++++++++++++----------- sw/bootloader/src/menu.c | 22 +++++++++++----------- sw/deployer/src/main.rs | 2 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/sw/bootloader/src/exception.c b/sw/bootloader/src/exception.c index 9c967ee..f8bc750 100644 --- a/sw/bootloader/src/exception.c +++ b/sw/bootloader/src/exception.c @@ -47,20 +47,25 @@ void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, display_init((uint32_t *) (&assets_sc64_logo_640_240_dimmed)); + display_printf("[ SC64 bootloader metadata ]\n"); display_printf("branch: %s | tag: %s\n", version->git_branch, version->git_tag); display_printf("sha: %s\n", version->git_sha); - display_printf("%s\n\n", version->git_message); + display_printf("msg: %s\n\n", version->git_message); - display_printf("%s\n", exception_get_description(exception_code)); - display_printf(" pc: 0x%08lX sr: 0x%08lX cr: 0x%08lX va: 0x%08lX\n", e->epc.u32, e->sr, e->cr, e->badvaddr.u32); - display_printf(" zr: 0x%08lX at: 0x%08lX v0: 0x%08lX v1: 0x%08lX\n", e->zr.u32, e->at.u32, e->v0.u32, e->v1.u32); - display_printf(" a0: 0x%08lX a1: 0x%08lX a2: 0x%08lX a3: 0x%08lX\n", e->a0.u32, e->a1.u32, e->a2.u32, e->a3.u32); - display_printf(" t0: 0x%08lX t1: 0x%08lX t2: 0x%08lX t3: 0x%08lX\n", e->t0.u32, e->t1.u32, e->t2.u32, e->t3.u32); - display_printf(" t4: 0x%08lX t5: 0x%08lX t6: 0x%08lX t7: 0x%08lX\n", e->t4.u32, e->t5.u32, e->t6.u32, e->t7.u32); - display_printf(" s0: 0x%08lX s1: 0x%08lX s2: 0x%08lX s3: 0x%08lX\n", e->s0.u32, e->s1.u32, e->s2.u32, e->s3.u32); - display_printf(" s4: 0x%08lX s5: 0x%08lX s6: 0x%08lX s7: 0x%08lX\n", e->s4.u32, e->s5.u32, e->s6.u32, e->s7.u32); - display_printf(" t8: 0x%08lX t9: 0x%08lX k0: 0x%08lX k1: 0x%08lX\n", e->t8.u32, e->t9.u32, e->k0.u32, e->k1.u32); - display_printf(" gp: 0x%08lX sp: 0x%08lX s8: 0x%08lX ra: 0x%08lX\n\n", e->gp.u32, e->sp.u32, e->s8.u32, e->ra.u32); + if (exception_code != EXCEPTION_SYSCALL) { + display_printf("%s\n", exception_get_description(exception_code)); + display_printf(" pc: 0x%08lX sr: 0x%08lX cr: 0x%08lX va: 0x%08lX\n", e->epc.u32, e->sr, e->cr, e->badvaddr.u32); + display_printf(" zr: 0x%08lX at: 0x%08lX v0: 0x%08lX v1: 0x%08lX\n", e->zr.u32, e->at.u32, e->v0.u32, e->v1.u32); + display_printf(" a0: 0x%08lX a1: 0x%08lX a2: 0x%08lX a3: 0x%08lX\n", e->a0.u32, e->a1.u32, e->a2.u32, e->a3.u32); + display_printf(" t0: 0x%08lX t1: 0x%08lX t2: 0x%08lX t3: 0x%08lX\n", e->t0.u32, e->t1.u32, e->t2.u32, e->t3.u32); + display_printf(" t4: 0x%08lX t5: 0x%08lX t6: 0x%08lX t7: 0x%08lX\n", e->t4.u32, e->t5.u32, e->t6.u32, e->t7.u32); + display_printf(" s0: 0x%08lX s1: 0x%08lX s2: 0x%08lX s3: 0x%08lX\n", e->s0.u32, e->s1.u32, e->s2.u32, e->s3.u32); + display_printf(" s4: 0x%08lX s5: 0x%08lX s6: 0x%08lX s7: 0x%08lX\n", e->s4.u32, e->s5.u32, e->s6.u32, e->s7.u32); + display_printf(" t8: 0x%08lX t9: 0x%08lX k0: 0x%08lX k1: 0x%08lX\n", e->t8.u32, e->t9.u32, e->k0.u32, e->k1.u32); + display_printf(" gp: 0x%08lX sp: 0x%08lX s8: 0x%08lX ra: 0x%08lX\n\n", e->gp.u32, e->sp.u32, e->s8.u32, e->ra.u32); + } else { + display_printf("[ Runtime error ]\n"); + } if (exception_code == EXCEPTION_INTERRUPT) { if (interrupt_mask & INTERRUPT_MASK_TIMER) { diff --git a/sw/bootloader/src/menu.c b/sw/bootloader/src/menu.c index de75ea9..ebad210 100644 --- a/sw/bootloader/src/menu.c +++ b/sw/bootloader/src/menu.c @@ -41,7 +41,7 @@ static const char *fatfs_error_codes[] = { #define FF_CHECK(x, message, ...) { \ fresult = x; \ if (fresult != FR_OK) { \ - error_display(message " [%s]:\n %s\n", __VA_ARGS__ __VA_OPT__(,) #x, fatfs_error_codes[fresult]); \ + error_display(message ".\nReason: %s", __VA_ARGS__ __VA_OPT__(,) fatfs_error_codes[fresult]); \ } \ } @@ -55,11 +55,11 @@ static void menu_check_load_address (void *address, size_t size) { void *bootloader_end = (void *) (&__bootloader_end); if ((menu_start < usable_ram_start) || (menu_end > usable_ram_end)) { - error_display("Incorrect menu load address/size:\n Outside of usable RAM space\n"); + error_display("Incorrect menu load address/size.\nReason: Outside of usable RAM space\n"); } if ((menu_start < bootloader_end) && (bootloader_start < menu_end)) { - error_display("Incorrect menu load address/size:\n Overlapping bootloader space\n"); + error_display("Incorrect menu load address/size.\nReason: Overlapping bootloader space\n"); } } @@ -72,21 +72,21 @@ void menu_load_and_run (void) { UINT br; size_t size = ROM_MAX_LOAD_SIZE; - FF_CHECK(f_mount(&fs, "", 1), "Couldn't mount drive"); - FF_CHECK(f_open(&fil, "sc64menu.n64", FA_READ), "Couldn't open menu file"); - FF_CHECK(f_lseek(&fil, ROM_ENTRY_OFFSET), "Couldn't seek to entry point offset"); - FF_CHECK(f_read(&fil, &menu, sizeof(menu), &br), "Couldn't read entry point"); - FF_CHECK(f_lseek(&fil, ROM_CODE_OFFSET), "Couldn't seek to code start offset"); + FF_CHECK(f_mount(&fs, "", 1), "SD card initialize error. No SD card or invalid partition table"); + FF_CHECK(f_open(&fil, "sc64menu.n64", FA_READ), "Could not open menu executable (sc64menu.n64)"); + FF_CHECK(f_lseek(&fil, ROM_ENTRY_OFFSET), "Could not seek to entry point offset"); + FF_CHECK(f_read(&fil, &menu, sizeof(menu), &br), "Could not read entry point"); + FF_CHECK(f_lseek(&fil, ROM_CODE_OFFSET), "Could not seek to code start offset"); if ((f_size(&fil) - ROM_CODE_OFFSET) < size) { size = (size_t) (f_size(&fil) - ROM_CODE_OFFSET); } menu_check_load_address(menu, size); cache_data_hit_writeback_invalidate(menu, size); cache_inst_hit_invalidate(menu, size); - FF_CHECK(f_read(&fil, menu, size, &br), "Couldn't read menu file"); + FF_CHECK(f_read(&fil, menu, size, &br), "Could not read menu file"); FF_CHECK((br != size) ? FR_INT_ERR : FR_OK, "Read size is different than expected"); - FF_CHECK(f_close(&fil), "Couldn't close menu file"); - FF_CHECK(f_unmount(""), "Couldn't unmount drive"); + FF_CHECK(f_close(&fil), "Could not close menu file"); + FF_CHECK(f_unmount(""), "Could not unmount drive"); deinit(); diff --git a/sw/deployer/src/main.rs b/sw/deployer/src/main.rs index 7ae33af..4e79392 100644 --- a/sw/deployer/src/main.rs +++ b/sw/deployer/src/main.rs @@ -404,7 +404,7 @@ fn handle_debug_command(connection: Connection, args: &DebugArgs) -> Result<(), if args.isv.is_some() { sc64.configure_is_viewer_64(args.isv)?; println!( - "IS-Viewer configured and listening at ROM offset [0x{:08X}]", + "IS-Viewer 64 configured and listening at ROM offset [0x{:08X}]", args.isv.unwrap() ); }