Hardfault handler log saving

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hardfault handler log saving

Jump to solution
6,268 Views
Seongyon_Jeong
Contributor III

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?

Labels (1)
0 Kudos
Reply
1 Solution
6,247 Views
Sam_Gao
NXP Employee
NXP Employee

Hi @Seongyon_Jeong 

It seems there are some issues about hardFault handle which are developed from your side. Generally speaking, it is out of our support role.

Here I would like to give advice that it's hard to handle flash sections, please follow flash_componment_nor_flexspi example to see how to use Nor_Flash_Erase_Sector Nor_Flash_Read functions.

View solution in original post

0 Kudos
Reply
5 Replies
6,248 Views
Sam_Gao
NXP Employee
NXP Employee

Hi @Seongyon_Jeong 

It seems there are some issues about hardFault handle which are developed from your side. Generally speaking, it is out of our support role.

Here I would like to give advice that it's hard to handle flash sections, please follow flash_componment_nor_flexspi example to see how to use Nor_Flash_Erase_Sector Nor_Flash_Read functions.

0 Kudos
Reply
6,210 Views
Seongyon_Jeong
Contributor III

This is my SDK version for RT1020 EVK

스크린샷 2025-03-13 171055.png

 
 

I download two example  from SDK

스크린샷 2025-03-13 171013.png

freertos_hello_flash_operation works fine. 

rtos_flash.jpg

But  flash component nor  is not.

 Just Only ,  Import SDK example -> select  this example -> finish (no  change,  just default)
But.  Build & Download the image Using GUI Flash Tool of MCUXpressoIDE. ,

and. Nothing.......  so,  I  Enter  debug mode  of this project.

then....

 

스크린샷 2025-03-13 171627.png  

 

스크린샷 2025-03-13 171718.png

 

스크린샷 2025-03-13 172237.png

I do not  change anything  in this project.  just import & build & down.

 but this faced to  Hardfault   directly..... 

So,  I tested another project,   they work fine  with Default SDK Example Project state.

 I think  the Example project  has problem

Tags (1)
0 Kudos
Reply
6,205 Views
Sam_Gao
NXP Employee
NXP Employee

Hi @Seongyon_Jeong 

I used the latest SDK(v24.12 or v2.16.0) which need IDE v24 to run the same example (evkmimxrt1020_flash_component_nor_flexspi), but both of them all works fine.

Please double check from your side.

https://github.com/nxp-mcuxpresso/mcux-sdk-examples/tree/5a158afe9cdb70ca449667ed71490afd29655710/ev... 

 

***NOR Flash Component Demo Start!***


***NOR Flash Page 0 Read/Write Success!***


***NOR Flash Page 1 Read/Write Success!***


***NOR Flash Page 2 Read/Write Success!***


***NOR Flash Page 3 Read/Write Success!***


***NOR Flash Page 4 Read/Write Success!***


***NOR Flash Page 5 Read/Write Success!***


***NOR Flash Page 6 Read/Write Success!***


***NOR Flash Page 7 Read/Write Success!***


***NOR Flash Page 8 Read/Write Success!***


***NOR Flash Page 9 Read/Write Success!***


***NOR Flash Page 10 Read/Write Success!***


***NOR Flash Page 11 Read/Write Success!***


***NOR Flash Page 12 Read/Write Success!***


***NOR Flash Page 13 Read/Write Success!***


***NOR Flash Page 14 Read/Write Success!***


***NOR Flash Page 15 Read/Write Success!***

***NOR Flash All Pages Read/Write Success!***

 

0 Kudos
Reply
6,167 Views
Seongyon_Jeong
Contributor III

I did  double checks.  but  Still  hardfault occures
But I change SDK version or RT1020... SDK 2.13 -> SDK 24.12   then  It works fine

After comparing two version with diff sw tool,  
Now I   guess , previous SDK version Example has problem. 

anyway. thanks for your  f/up

 

 

6,260 Views
Seongyon_Jeong
Contributor III

Ease the first sector of hardfault_log_save_sc is successfully executed

  => Erasing the first sector of hardfault_log_save_sc is successfully executed

Miss spelling..

0 Kudos
Reply