I want to write a program from a file on an SD card to flash and run it.

The content is the same as devzone.nordicsemi.com/.../i-want-to-perform-firmware-updates-from-an-sd-card-for-firmware-created-with-the-nrf5-sdk.

This ticket is a question about performing firmware updates without using MCU Boot, etc., and instead, manually performing the update.


I have considered the following steps to achieve this:

(1) Read the program to be executed from the SD card and write it to the free space in the flash
(Saved in SREC format on the SD card)
All subsequent operations are performed within functions placed in RAM
(2) Disable all interrupts
(3) Write the program saved in the flash during (1) to the address specified in the SREC format
During this process, also rewrite interrupt vectors, etc.
(4) CPU reset
Perform an operation equivalent to 'NVIC_SystemReset()' (manipulating 'SCB->AIRCR') to reset the CPU

After implementing the above steps, I believe there are no errors, and the CPU reset is executed successfully. However, the loaded program does not run.

I have confirmed that the loaded program works when written in hex format.

Is there anything else necessary besides the above steps? If there is anything missing in the steps or settings, I would appreciate it if you could let me know.

Parents
  • Hi,

    For this ticket I will assume that you are using nRF Connect SDK also for your application (if you are making a new application it normally makes more sense to use nRF Connect SDK. See nRF Connect SDK and nRF5 SDK statement).

    After implementing the above steps, I believe there are no errors, and the CPU reset is executed successfully. However, the loaded program does not run.

    I have confirmed that the loaded program works when written in hex format.

    Is there anything else necessary besides the above steps? If there is anything missing in the steps or settings, I would appreciate it if you could let me know.

    I am not familiar with the details of what you do here, but if you think the content of the flash should be identical at this point, but it is not, I would start by dumping the flash of the workin case (where you programmed the .hex direclty), and the faling case (where you did DFU). Diff the dumps, and investigate the difference. What is different. What is storet at that location? (you can check the map file or useaddr2line or similar tools).

    A simple way to dump the flash in a easily readable format is "nrfjprog --memrd 0 --n <size_of_flash> > dump.txt".

    PS: I will be out for Holiday the next week. DevZone will have reduced staffing during that time.

Reply
  • Hi,

    For this ticket I will assume that you are using nRF Connect SDK also for your application (if you are making a new application it normally makes more sense to use nRF Connect SDK. See nRF Connect SDK and nRF5 SDK statement).

    After implementing the above steps, I believe there are no errors, and the CPU reset is executed successfully. However, the loaded program does not run.

    I have confirmed that the loaded program works when written in hex format.

    Is there anything else necessary besides the above steps? If there is anything missing in the steps or settings, I would appreciate it if you could let me know.

    I am not familiar with the details of what you do here, but if you think the content of the flash should be identical at this point, but it is not, I would start by dumping the flash of the workin case (where you programmed the .hex direclty), and the faling case (where you did DFU). Diff the dumps, and investigate the difference. What is different. What is storet at that location? (you can check the map file or useaddr2line or similar tools).

    A simple way to dump the flash in a easily readable format is "nrfjprog --memrd 0 --n <size_of_flash> > dump.txt".

    PS: I will be out for Holiday the next week. DevZone will have reduced staffing during that time.

Children
No Data
Related