IMX RT 1052 Build and random hardfault

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

IMX RT 1052 Build and random hardfault

863 Views
YodaC
Contributor III

Hi,

The programm of IMX RT1050 run on a serial flash IS25WP064 in XIP mode.

There is function that get data from this flash during init, as shown below :
AT_QUICKACCESS_SECTION_CODE(void ReadDataInFlash(uint32_t AddrTo,uint32_t AddrFrom,uint16_t Size))
{
uint8_t *ptTo=(uint8_t *)AddrTo;
uint8_t *ptFrom=(uint8_t *)(NOR_FLEXSPI_AMBA_BASE+(AddrFrom));
while(Size--)
{
*ptTo++ =*ptFrom++;
}

}

Sometimes when i modify the code anywhere i have a hardfault when running this function.
if i ad a line that change value of a variable (doesn't matter wich one) before calling this function the hardfault does not occure.

if in a next change hardfault ocures again , i just have to comment the line before the call of the function to suppress hardfault.

I suspect alignement in the code but i dont know how to solve this.

Here is the setting of my card:

YodaC_0-1721636773176.png

Optimize (-O1)

Preprocessor:

YodaC_1-1721636974100.png

Best regards,

Christian

 

 

 

Labels (1)
Tags (1)
0 Kudos
Reply
9 Replies

839 Views
Habib_MS
NXP Employee
NXP Employee

Hello @YodaC ,
In the case that you are currently using XIP mode you cannot use the same FLASH to storage, this because the XIP needs to obtain the next instruction from the flash, and in the case that you want to read/write the core probably does not obtain the next instruction and consequently, the code becomes nonsense.

If this is the case, you can use non XIP, this means that the code is going to run in RAM obtaining the code from the FLASH. If you wish to try running it in RAM, you can consult this app note.
Also, if you experience any issue, do not hesitate to let me know.

BR

Habib.

0 Kudos
Reply

819 Views
YodaC
Contributor III

Hello Habib,

Thank you for the reply.

I am aware of this constraint, which is why I put all the codes that access the flash in RAM.

When everything goes well, it works all the time.

But sometimes when I change something in the code anywhere, flash reading doesn't work anymore.

The solution I found is to change the value of a variable (it doesn't matter which one) just before calling the read function.

If after a new modification in the code I can no longer read the flash, I just need to comment out the line which modifies the variable and it works again.

This is very annoying because I'm not sure if other parts of the code are affected.

Best regards,

Christian

 

0 Kudos
Reply

802 Views
Habib_MS
NXP Employee
NXP Employee

Hello again @YodaC,

In order to support you better, could you please provide me the next information?

  • The function called "ReadDataInFlash".
  • The steps that you followed for put all the codes that access the flash in RAM.

Also, the SDK (version 2.16) provides an example that uses this FLASH, this example is called "flexspi_nor_polling_transfer". I highly recommend consult it, in order to discard a wrong alignment or some point not seen.

 

BR

Habib.

0 Kudos
Reply

784 Views
YodaC
Contributor III

Hello Habib,

Thank you for reply

My code is derived from evkbimxrt1050_flexspi_nor_polling_transfer of SDK V2.15.

The steps are as follows:

 flexspi_nor_flash_init(NOR_FLEXSPI);//Init

UsbStatus=USB_UNCONNECTED;//this line is commented or not if hardfault

SAVE_DATA_FLASH sVarLoad;//Simple structure of variables

ReadDataInFlash((uint32_t)&sVarLoad,FLASH_DATAS,sizeof(sVarLoad));

 

details of ReadDataInFlash:

AT_QUICKACCESS_SECTION_CODE(void ReadDataInFlash(uint32_t AddrTo,uint32_t AddrFrom,uint16_t Size))

{

uint8_t *ptTo=(uint8_t *)AddrTo;

uint8_t *ptFrom=(uint8_t *)(NOR_FLEXSPI_AMBA_BASE+(AddrFrom));

while(Size--)

{

*ptTo++ =*ptFrom++;

}

}

Best regards,

Christian

 

0 Kudos
Reply

705 Views
Habib_MS
NXP Employee
NXP Employee

Hello again @YodaC,
Sorry for taking a while to get back to you. Thanks for the information, however, I apologize because I will need more. Can you please provide me the next information?

 

  • For what purpose do you need to get data from the flash and what are the characteristics of that data?
  • Is there any reason to use your function to read from the flash instead of the form that uses the example "flexspi_nor_polling_transfer"? More specifically the next line of code:

Habib_MS_0-1722291948582.png

On the other hand. In order to try a pinpoint if the issue is related to XIP mode, can you change your application to Non XIP mode?

BR

Habib.

0 Kudos
Reply

688 Views
YodaC
Contributor III

Hello Habib,

I' using Flash to store somme datas like serial number language ...

I don't use memcpy because I don't how to make it run from SRAM.

I can't run all the code in SRAM because I need this SRAM.

I would like to know why somme times that work and somme time not, depend on line add or not.

Perhaps there is a flag or config in build that i don't set.

 

Best regards,

Christian

 

 

0 Kudos
Reply

674 Views
Habib_MS
NXP Employee
NXP Employee

Hello again @YodaC,

In order to replicate your issue and understand better what is happening, can you share me your code or can you explain me what were the steps that you followed to modify the example called "flexspi_nor_polling_transfer"?

BR
Habib.

0 Kudos
Reply

645 Views
YodaC
Contributor III

Hello Habib,

I can,t share the code, because it the full code of the application and it work on a custom board.

I think there is no problem with the access of the flash, because when it's work, it's work all the time.

Best regards,

Christian

 

0 Kudos
Reply

612 Views
Habib_MS
NXP Employee
NXP Employee

Hello again @YodaC,

I replicated the section code that presents intermittent issues in my RT1050-EVKB changing the SDK (version 2.16) example called "flexspi_nor_polling_transfer", but it worked fine all time. Since you mentioned that is a custom board, the issue could be a hardware issue by the DQS pin or the connections directly of the FLASH. Another cause of the issue could be the actions of the cache, you can try deactivating this.

 

Since I am unable to replicate the issue presented in your project, I cannot continue to assist you, it is unfortunately getting out of scope for community support.

 

I apologize for the inconveniences this may cause.

BR,
Habib.

0 Kudos
Reply