I would like to implement FOTA on the MPC5748G but I am not able to find out how to get started. I have found tons of information telling me what it is and how good it is but nothing about how to start using it on my processor. I still do not know if it is a boot loader or is it a library you compile with your operational code. can some one give me a link to where I can download what I need to get started?
Solved! Go to Solution.
Hi,
in the mentioned AN5319, I added this asm code right to the beginning of __start:
;******************************************************************************
; Check if Bootloader or User Application is supposed to be executed
; Pin PA[1] is used. PA[1] signal is routed to SW3 on EVB board.
; If PA[1] == 0 - execute User Application
; If PA[1] == 1 - execute Bootloader
;configure pin PA[1] as input - write SIUL2.MSCR[1].R = 0x00080000
;load address of SIUL2.MSCR[1] to r12
e_lis r12,0xFFFC
e_or2i r12,0x0244
;load immediate value to r11 which will enable the buffer
e_lis r11,0x0008
;write the value to SIUL2.MSCR[1]
e_stw r11,0(r12)
;check if SW3 is pushed down - if SIUL.GPDI[1] == 0x01
;load address of SIUL.GPDI[1] to r12
e_lis r12,0xFFFC
e_or2i r12,0x1501
;read the SIUL.GPDI[1] register
e_lbz r0,0(r12)
;compare the values - is the SW1 pushed?
se_cmpli r0,0x01
;execute bootloader or user application
;if pushed,executed bootloader
e_beq bootloader
;otherwise jump to user application
;but first check, if there's valid boot header at address 0xF9_4000
;load address of boot header to r12
e_lis r12,0x00F9
e_or2i r12,0x4000
;load upper half of boot header word to r0
;(lower half is application dependent)
e_lhz r0,0(r12)
;boot header should be 0x005A
e_cmpl16i r0,0x005A
;if the boot header is not valid, execute bootloader
e_bne bootloader
;if the boot header is valid, execute application
;load address of reset vector to r12
e_lis r12,0x00F9
e_or2i r12,0x4010
;load reset vector to r0
e_lwz r0,0(r12)
;move reset vector to link register
mtlr r0
;branch to address in link register
se_blrl
;******************************************************************************
bootloader:
;******************************************************************************
; When bootloader is going to be executed, disable Software watchdog 0
; The watchdog is kept enabled if user application is executed.
;SWT_0.SR.R = 0xc520;
e_lis r12,0xFC05
...
This code can be found in file crt0.ppc.
When you want to jump to the application later in C code, you can use something like:
typedef void (*func_ptr)();
(*(func_ptr)ADDRESS_OF_ENTRY_POINT)();
If you do not jump to the application right after reset (like in the asm code above), it is a good practice to disable all interrupts before the jump (by MSR[EE], by local enable bits in peripherals, by priorities in INTC) and also deinit all used peripherals to default reset state.
Regards,
Lukas
I am using the DEVKIT-MPC5748G
Trying to get the bootloader to work has caused to make negative progress. I am in a worse state know then I was before I I tried to get the bootloader run. I uses to be able to upload an application to flash and when I pressed the reset button the dev board run the application. How do i get back to at least that state.
I think this is the last question and it should be a simple one. How do I load the application from the bootloader. I can not seem to find any example code on how to jump to the location in flash where the application is.
Hi,
in the mentioned AN5319, I added this asm code right to the beginning of __start:
;******************************************************************************
; Check if Bootloader or User Application is supposed to be executed
; Pin PA[1] is used. PA[1] signal is routed to SW3 on EVB board.
; If PA[1] == 0 - execute User Application
; If PA[1] == 1 - execute Bootloader
;configure pin PA[1] as input - write SIUL2.MSCR[1].R = 0x00080000
;load address of SIUL2.MSCR[1] to r12
e_lis r12,0xFFFC
e_or2i r12,0x0244
;load immediate value to r11 which will enable the buffer
e_lis r11,0x0008
;write the value to SIUL2.MSCR[1]
e_stw r11,0(r12)
;check if SW3 is pushed down - if SIUL.GPDI[1] == 0x01
;load address of SIUL.GPDI[1] to r12
e_lis r12,0xFFFC
e_or2i r12,0x1501
;read the SIUL.GPDI[1] register
e_lbz r0,0(r12)
;compare the values - is the SW1 pushed?
se_cmpli r0,0x01
;execute bootloader or user application
;if pushed,executed bootloader
e_beq bootloader
;otherwise jump to user application
;but first check, if there's valid boot header at address 0xF9_4000
;load address of boot header to r12
e_lis r12,0x00F9
e_or2i r12,0x4000
;load upper half of boot header word to r0
;(lower half is application dependent)
e_lhz r0,0(r12)
;boot header should be 0x005A
e_cmpl16i r0,0x005A
;if the boot header is not valid, execute bootloader
e_bne bootloader
;if the boot header is valid, execute application
;load address of reset vector to r12
e_lis r12,0x00F9
e_or2i r12,0x4010
;load reset vector to r0
e_lwz r0,0(r12)
;move reset vector to link register
mtlr r0
;branch to address in link register
se_blrl
;******************************************************************************
bootloader:
;******************************************************************************
; When bootloader is going to be executed, disable Software watchdog 0
; The watchdog is kept enabled if user application is executed.
;SWT_0.SR.R = 0xc520;
e_lis r12,0xFC05
...
This code can be found in file crt0.ppc.
When you want to jump to the application later in C code, you can use something like:
typedef void (*func_ptr)();
(*(func_ptr)ADDRESS_OF_ENTRY_POINT)();
If you do not jump to the application right after reset (like in the asm code above), it is a good practice to disable all interrupts before the jump (by MSR[EE], by local enable bits in peripherals, by priorities in INTC) and also deinit all used peripherals to default reset state.
Regards,
Lukas
I kind figured that was the case. I just wanted to make sure.
I noticed the example is for the S32K144 and S32K146. Is there an example for the MPC5748G family?
Unfortunately no. There's only mentioned AN5319.
There is a lot of information to go over and it will take some time to go over but I think this is what I need.
Hello Matt,
you can find a lot of documents to read here:
https://www.google.com/search?client=firefox-b-d&q=MPC5748G+AND+OTA+site%3Acommunity.nxp.com
To have some examples for the beginning:
Simple serial bootloader for MPC5748G:
https://www.nxp.com/docs/en/application-note/AN5319.pdf
https://www.nxp.com/docs/en/application-note-software/AN5319SW.zip
It does not implement a swap of applications, it only loads one application to the flash (always to the same area).
Then you can take a look at this application note written for S32K1 devices:
https://www.nxp.com/docs/en/application-note/AN12323.pdf
https://www.nxp.com/docs/en/application-note-software/AN12323SW.zip
Yes, it's different device but I believe it will be also helpful.
Regards,
Lukas
Generally, FOTA is a feature of the bootloader.
The new application flashing is started from a remote-server, not a technician beside your car.
So, if the flashing failed, the bootloader should roll-back to a correct application
And the Flash space in the processor should be sufficient for two copies of applicaton codes.