SAME54 FreeRTOS crashing after trying to write into internal flash

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
I am trying to implement FW update through ethernet on SAME54 so briefly I am booting from BANKA and will write new FW to BANKB and then switch banks and reboot. There is an application note for SAM4S from Atmel (no FreeRTOS).
I am building my project based on one of Atmel-start sample projects (LwIPsocketapiexample) with FreeRTOS and LWIP. This project is working fine. I have added the flash driver to that project in Atmel -start and tried to test writing one page (512 B) into starting address of BANKB (0x80000).
The sample project has three existing tasks two for LWIP and one of them just blinking a LED. I used the example function (FLASH_0_example) in the LED blinking task before the infinite loop.
Surprisingly, it is crashing after writing the data into the flash. I am using SAME54 explain pro board and can see the data is written in the flash correctly but after finishing the flash_write function it is throwing hard_fault exception. I tried to disable interrupts also completely suspend other tasks during flash access but still no luck.
Any thought that what can cause the problem or suggestion that how I can debug this.
Thanks a lot,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you using a debugger to determine exactly what operation is causing the hard fault?

 

If so, you can examine the fault status registers (SCB->CFSR, SCB->HFSR, and SCB->BFAR) and the Flash controller status registers (NVMCTRL.STATUS, NVMCTRL.INTFLAG) to get a better idea of what's going on.

 

Steve

Maverick Embedded Technologies Ltd. Home of Maven and wAVR.

Maven: WiFi ARM Cortex-M Debugger/Programmer

wAVR: WiFi AVR ISP/PDI/uPDI Programmer

https://www.maverick-embedded.co...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the point. The problem turned out to be the Stack overflow. Seems that we need a big stack to perform write to flash since the driver bringing the full page into the RAM and then erasing the flash page and writes the page back.