From f2a36675939f45e2e36222058e9db6aa1043b434 Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Wed, 15 Jan 2025 09:47:10 -0500 Subject: [PATCH] fix for blank/3dots screen crash --- stm32/COLDCARD_MK4/psramdisk.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stm32/COLDCARD_MK4/psramdisk.c b/stm32/COLDCARD_MK4/psramdisk.c index 99c189c5..bcfa9ffc 100644 --- a/stm32/COLDCARD_MK4/psramdisk.c +++ b/stm32/COLDCARD_MK4/psramdisk.c @@ -501,31 +501,31 @@ static void psram_init_vfs(fs_user_mount_t *vfs, bool readonly) { // psram_memset4() // - static inline void -psram_memset4(void *dest_addr, uint32_t value, uint32_t byte_len) + static void +psram_memset4(void *dest_addr, uint32_t byte_len) { // Fast, aligned, and bug-fixing memset // - PSRAM can starve the internal bus with too many writes, too fast // - leads to a weird crash where SRAM bus (at least) is locked up, but flash works + // - and/or just call w/ interrupts off for reliable non-crashing behaviour uint32_t *dest = (uint32_t *)dest_addr; for(; byte_len; byte_len-=4, dest++) { - *dest = value; - - asm("nop; nop; nop;"); // tested value, do not reduce - asm("nop; nop; nop;"); // more margin - asm("nop; nop; nop;"); // more margin - asm("nop; nop; nop;"); // more margin + *dest = 0x12345678; } } +// mp_obj_t psram_wipe_and_setup() +// mp_obj_t psram_wipe_and_setup(mp_obj_t unused_self) { // Erase and reformat filesystem // - you probably should unmount it, before calling this // Wipe contents for security. - psram_memset4(PSRAM_TOP_BASE, 0x12345678, BLOCK_SIZE * BLOCK_COUNT); + mp_uint_t before = disable_irq(); + psram_memset4(PSRAM_TOP_BASE, BLOCK_SIZE * BLOCK_COUNT); + enable_irq(before); // Build obj to handle blockdev protocol fs_user_mount_t vfs = {0};