I am writing MCU firmware update software for S32K144. Can I get some guide on the logic followed inside S32 Design studio while updating ELF file to P-flash(program flash).
a. How the boot loader is flashed for the first time and to which address in P-flash.
b. How boot loader updates MCU application firmware to P-flash and to which memory address.
I could flash ELF file of 1MB to S32K144. I understand P-flash size in S32K144 is 512KB. How this is possible?
For reference - you can look at bootloader example - part of S32DS installation. This example uses RAppID tool - https://www.nxp.com/webapp/Download?colCode=RAPPID_BOOTLOADER_UTILITY&appType=license .
Basically - boot loader for S32K144 is standard application with these features:
- check if firmware exists
- communication interface on some port (can/uart//ethernet/whatever)
- data parser (srec or any other format)
- flashing algorithm
- optional - cryptography engine
If you want write your own bootloader - its completely up to you how to define "existing firmware", firmware update request (for example pressing button for more than 3 sec or magic number on communication line..) and of course you need to maintain memory spaces (to avoid rewriting boot loader itself by firmware).
About second question - you can start with elf file description - Executable and Linkable Format - Wikipedia
So - the elf file is way bigger than binary data because it contain additional info. Into MCU flash is written only raw binary data taken from elf file.
For now I am thinking of using default boot loader that got flashed to S32K144-EVB when first program was flashed.
I would like to update only application firmware with the help of existing boot loader.
a. I will trigger reboot by triggering software reset by using SYSRESETREQ.
b. On reboot, execution should stop at boot loader and boot loader will receive firmware buffer in part by part over UART from other processor. So boot loader will start updating the application firmware to the dedicated address.
c. After firmware updation, boot loader will send success/failure acknowledgement to processor and reboots to application.
Can you give your thoughts/idea to implement above use case.
it is again task for custom boot loader. Second option may be implementing JTAG on your Master MCU and re-use for example Open On-Chip Debugger with reduced functionality. This is the same way how S32K144 EVB is designed (OpenSDA on on Kinetis K20).