I.MXRT1020-EVK board. MCUXpressoIDE 24.12 , SDK_2.x_EVK-MIMXRT1020 2.13.0
When hardfault occurred, I tried to move the previously logged content to flash.
This coding-job was based on an example that included Shell among an example using FreeRTOS.
1. fsl_debug_console.c
Before delivering the printbuffer to the DbgConsole_Vprintf function, we delivered the same content to the ringbuffer allocated 8KB using pvMalloc so that it can be stored continuously.
2. semihost_hardfault.c
In this function, if it is not under the _semihost_return condition of the existing code, jump to a function called hardfault_handler_main in BL.
Hardfault_handler_main call hardfault_log_save_sc.
In hardfault_log_save_sc, the logs in the area 8KB assigned to the malloc defined in fsl_debug_console.c were sorted so that they were stored in the 3F0 and 3F1 sectors of flash from the very first log.
In RT1020, the 3F0 sector number of flash corresponds to 0x603F_0000 .
The reason why I'm posting the question here is. After creating a trigger_hardfault CMD command and function that deliberately attempts to write a value to the null point in the shell
volatile int *ptr = (int *)0x00000000; // NULL pointer
*ptr = 42; // trigger hardfault
If intentionally causing hardfault.
Ease the first sector of hardfault_log_save_sc is successfully executed, but then the second sector erase and dump to Dram -> flash do not work.
How do I fix the file semihost_hardfault.c for hardfault handlers in SDK so that I can write what's in DRAM in flash correctly and fall out indefinitely?