How to merge app and bootloader S record file into a new S file?

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

How to merge app and bootloader S record file into a new S file?

1,829 Views
terrybogard
Contributor II

How to merge app and bootloader S record file into a new S file?

0 Kudos
2 Replies

1,606 Views
Lorenzo_Mch_IT
Contributor IV

To merge bootloader and app SREC files so that in production you can program the device with a single .S file, you have to merge them in a slightly modified new SREC file.


Start the bootloader+app file with an "header" (S0) record containing an identification string of your choice, so in case it is sent to the bootloader by mistake it can be rejected instead of damaging it (if the bootloader executes directly from flash memory).

Then open in sequence the original srec files and append their their "data" (S1,S2 or S3) records in the new file, counting how many you append.

After you have sent all the "data" records from both files, append the  the optional "data record count" (S5 or S6) record with the count of how many "data" records have been appended.

Finally append as "termination/start"  (S7,S8 or S9) record the same  record  previously found as bootloader's "termination/start address".

 

The procedure described above can be automated with a small program.
It works correctly if the application's start address is always the same (and is directly encoded in the bootloader) AND if app and bootloader are stored in indipendently writable blocks/sections.

If you want to be able to update both app and bootloader sending them to an already installed bootloader (or if app and bootloader are mapped in the same block/section), you must encode the bootloader so it copies its code into RAM at boot and then executes the rest of itself from ram (so it can "rewrite itself" without hanging the microcontroller).

0 Kudos

1,818 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I do not think the merging of application code and bootloader code is necessary and possible, nobody has done it.

This is the bootloader procedure, you can download the bootloader project to on-chip flash of MC56F82xxx via JTAG, after power-on or Reset, the bootloader will be executed, the SCI port is monitored, once it receives character, the characters will be saved in memory and written to flash to replace old application code. If the SCI port does not receive any characters in a fixed interval, the bootloader will jump to application code.

So for the application code project, you have to modify based on the Bootloader requirement, for example defines the delay.

Pls refer to the the an4759.pdf

https://www.nxp.com.cn/docs/en/application-note/AN4759.pdf

Hope it can help you

BR

XiangJun Rong

0 Kudos