Hard Fault getting triggered from ISR routine when compiled binary size is more than P flash

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

Hard Fault getting triggered from ISR routine when compiled binary size is more than P flash

2,423 Views
adargad
Contributor II

Chip used : KW36

IDE Used : MCUExpresso

We have partitioned D-flash as NVM of size 32K and remaining we are using as Code Flash, Hence we are using P Flash and D flash as Code Flash(around 470K)

We are observing Hard Fault in below operation.

1. When we reset the controller

OR

2. When we try pair/connect the device

We tried to follow all the post on NXP community to see from which location fault is getting generated and it is observed that it is coming from different ISR routine such as UART ISR or Timer ISR or RESET ISR

Also verified that Stack allocated for Tasks is not getting overflowed.

We have also observed that hard fault is getting triggered when the complied binary size is larger than 256K and it uses P-flash as well as D-flash.

Please let us know what can be done in above case to identify the root cause of the HardFault ?

I am attaching .map files for release and debug compilation.

Tags (1)
0 Kudos
Reply
5 Replies

2,277 Views
EdgarLomeli
NXP Employee
NXP Employee

Hello adargad@visteon.com‌,

Could you please provide more information about it?

How have you created the partition in the FlexNVM address range? Could you please provide the steps and changes done in the HID device example to replicate in our side such partition?

Best Regards.

Edgar Lomeli

0 Kudos
Reply

2,277 Views
adargad
Contributor II

Hi,

I am using FlexRAM for emulation of EEPROM, I have partitioned 32KB of Dflash for EEPROM-backup Size. 

Also my Application size is spanning over P-flash  + D-Flash. So there are ISRs which are located in D flash as well.

Going ahead after debug I found that the reason for Hard fault is ISR getting triggered in between when FLASH_EepromWrite() is executing. When I put critical section as below, I am not getting Hard fault.

pastedImage_1.png

This fix is done in inline with guidelines provided in Application note we found on internet, "Using S32K148 FlexNVM Memory", Chapter 5, as below:

pastedImage_2.png

Now I have question to SDK development team, whether this fix is correct, or have any side effects?

Also if it is already known to SDK development team?

0 Kudos
Reply

2,277 Views
EdgarLomeli
NXP Employee
NXP Employee

Hello adargad@visteon.com‌,

We have contacted our SDK SW team to get more information and we are waiting for a response. Meanwhile, we would like to know the following to reproduce it on our side. Which SDK version are you using for your application?, Is it BM or freertos version?. Another concern is about which #define have you enabled under "preinclude.h" file to enable FlexNVM. Are gAppUseNvm_d = 1 and gNvUseFlexNVM_d = 1?, Could you please share with us AppPoolsDetails_c?

How did you configure the software for creating the partition of 32KB? Could you please share with us the value of gEEPROM_DATA_SET_SIZE_CODE_c and gFLEXNVM_PARTITION_CODE_c macros located in "NV_Flash.c"?

Regards.

0 Kudos
Reply

2,276 Views
adargad
Contributor II

Hello,

SDK version 2.2.2 also has same issue. I am using HID FreeRTOS sample project.

But to use FlexNVM, I am referring flash_flexnvm_eeprom sample project from SDK.

I have kept below settings in App_preinclude.h file.

#define gAppUseNvm_d 0

So definition of “#define gNvUseFlexNVM_d (0)”

Does not matter.

AppPoolsDetails_c are defined as below:

#define AppPoolsDetails_c \

blocksize_ 32 numberof_blocks_ 6 eol \

blocksize_ 64 numberof_blocks_ 3 eol \

blocksize_ 128 numberof_blocks_ 10 eol \

blocksize_ 512 numberof_blocks_ 4 eol

For configuring partition, I have reused code from flash_flexnvm_eeprom sample project.

I am using below definitions for partitioning.

#define EEPROM_DATA_SET_SIZE_CODE (0x35U)

#define FLEXNVM_PARTITION_CODE (0x3U)

Please find the attached file which is coded for creating partition.

The code for creating partition is kept commented, because it is part of SW which will be flashed first for creating partition and then the Application SW will only use it.

0 Kudos
Reply

2,277 Views
EdgarLomeli
NXP Employee
NXP Employee

Hello adargad@visteon.com‌,

We will investigate which is the proper way to handle such scenario in software with our SDK SW team. As soon as we receive a response, I'll be updating on this thread.

Best regards.    

0 Kudos
Reply