LPC54606 FLASHIAP - FreeRtos

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

LPC54606 FLASHIAP - FreeRtos

1,311 Views
mpazzi
Contributor III

Hello to everyone,

I have implemented a TFTP file transfer for update binary (about 195 kByte) in my board via ethernet. During transfer I save data in external flash (I do not have chip RAM), after that, I read data from external flash and copy in internal flash of LPC54606.

The copy processing in internal flash is fine until index sector 4, after that it became hard fault.

If I copy the data from ext.flash from sector 8 to 15 all is going well (ok, no code in this part of flash).

Of course the functions that read from flash are in RAM.

I have tryed to insert in function that manage the reading from external flash and writing to internal flash this istruction vTaskSuspendAll();

What's wrong in all this procedure ?

Any suggestion or test to do ?

Thanks in advantage.

Best regards.

Marco

 

 

 

 

 

0 Kudos
6 Replies

1,237 Views
jforslof
Contributor II

Hello Marco,

I don't know the root cause of the problem concur with XiangJun that the most likely culprit is some remaining FLASH memory access during programming. Possibly some bit of the code or data involved may have been left in FLASH or some hidden access occurs such as through some C runtime library function, DMA accessor what not.

I would suggest trapping the hard fault in the debugger in the hopes of pinpointing the offending code and carefully reviewing code generated for the upgrade procedure.

However, this bootloader strategy strikes me as inherently brittle. Any reset or power outage should occurring half-way though an upgrade risks leaving the device without a valid firmware.

Have you considered a more traditional design using a separate and fixed bootloader stage running as the first stage on reset tasked with verifying and installing any upgrade image available in the external memory, before vectoring to the application? This would then be linked as a separate project within a dedicated FLASH area to avoid conflicts with the application code.

Regards,

Johan

0 Kudos

1,292 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Marco,

I suppose that your application code is saved and run from on-chip flash, in the case, when you are operating flash such as erasing or programming flash, any code running in flash will lead to issue. So when you are operating flash such as erasing or programming flash, you have to disable interrupt besides the vTaskSuspendAll(), because when interrupt happens, the core will fetch vector from flash and run code in flash, this will lead issue.

Hope it can help you

BR

XiangJun Rong

 

The flash memory is not accessible during a write or erase operation

0 Kudos

1,289 Views
mpazzi
Contributor III

Hi xiangjun,

thanks for your quickly replay.

Yes, my code run from on-chip flash.

I already disable interrupt before to operate in on-chip flash and I call the function vTaskSuspendAll(), but the issue still.

I can write without issue sector 0, 1, 2, 3 but when I write sector 4, 5 it become the issue. Why ?

My application use about 6/7 sector, it's about 195 kB

 

Thanks for your help.

Best Regards

Marco

0 Kudos

1,286 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Marco,

I think that the sector 4&5 are the same as the sector 1&2.

First of all, what is the error message you got when you operate flash? secondly, if you create a simple project without Freertos, just erase/programe sector 4&5, what is the result?

BR

XiangJun Rong

0 Kudos

1,277 Views
mpazzi
Contributor III

Hi Xiangjun,

this is the screenshot of error.

mpazzi_0-1608724225568.png

The error become at sector 5, simetime sector 4, I think depend where the code give error is placed in.

In previously project with LPC54608 I used FLASHIAP to update firmware through SD-card and it was fine, but in this project was not freertos.

I suppose that the reason of issue depend by Rtos, but I could not find the solution.

Any idea about that ?

 

Thanks for help

Best Regards

Marco

0 Kudos

1,244 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Marco,

I agree with you, this is a Freertos issue. As you know when you are operating flash such as erasing or programming flash, any flash operation such as fetching code from flash or reading data from flash or interrupt will leads to hard fault. The Freertos is a multi thread operation, you have to disable all interrupt, suspend all task.

but currently, I have not idea to identify which code is executing except for the flash operation which is executed in internal RAM.

Regard

XiangJun Rong

0 Kudos