S32K144 Firmware update

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

S32K144 Firmware update

3,083 Views
KK2
Contributor II

Hello,

I want to perform a firmware update while the application is running (e.g. by sending a CAN command).
I have tried firmware update according to AN12323.

1. How can I start the bootloader without resetting the microcontroller?

2. How do I create the binary file required for firmware update? Please let me know if you have any reference material.

 

Best regards,

KK2

 

0 Kudos
11 Replies

3,070 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

1. Reset is the best option. It could be possible to jump directly to entry point of the bootloader but it would be necessary to completely de-init all the resources used by the application. I would definitely recommend the reset, it is much simpler option.

2. See please this "how to" document:

https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/HOWTO-Generate-S-Record-Intel-HEX-Bina...

Regards,

Lukas

3,051 Views
KK2
Contributor II

Thanks for the answer!

I tried to create a binary file and replace the created binary file to run the AN12323 demo, but it did not work.
The procedure is as follows.

1. I created the binary file by referring to the documentation I received. At this time, I set the 'Output file format' to 'Raw binary' (first figure).

2. The created binary file was moved to the same location as 'S32K144_Blue_LED_pic.bin' in the S32K144_FOTA_Gateway folder (second figure).

3. Replaced 'S32K144_Blue_LED_pic.bin' with 'hello_world_s32k144.bin' in two places in the source code of 'S32K1xx_flexnvm.ld' of S32K144_FOTA_Gateway (third figure).

4. When I ran the demo, I was able to update the firmware for the red LED, but not hello_world.

Can you see where I am going wrong?
Hope you can help!

Regards,
KK2

RawBinary.png

bin.png

  

replace.png

0 Kudos

3,027 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

did you updated linker file of the hello world application? It should be like:

lukaszadrapa_0-1633348530743.png

This is to compile "position dependent" code to Firmware 1 slot:

lukaszadrapa_1-1633348637121.png

For second slot, you should use base address 0x00042000.

Regards,

Lukas

3,010 Views
KK2
Contributor II

Thank you, I forgot to set the linker file of the Hello world application.
But still the firmware update of Hello world does not work.
Is there anything I am still doing wrong?

Regards,
KK2

0 Kudos

2,992 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I forgot to mention one more thing - S32 Design Studio does not support generation of position independent project. So, if you compiled your hello world project in S32DS, you need to track the firmware versions to load new version to the right space. In other words, you need to know if hello world project will be loaded to address 0x2000 or to 0x42000. The project needs to be compiled to the right address, so it may be necessary to update the linker file. I guess that this could be the reason.

More description can be found in the application note in section "6.3 A/B swap using Position Independent Code (PIC) ". As mentioned, IAR compiler supports PIC code.

Regards,

Lukas

0 Kudos

2,968 Views
KK2
Contributor II

Thank you very much, the firmware update of the Hello world application worked.


However, when I try it on another microcontroller, the latest_fw_version=xFFFFFFFF in the main.c of the bootloader, and it does not work. I think this is due to the fact that the firmware header has not been created.

KK2_0-1634013813960.png

I thought that if I debug the firmware linker file as shown in the image, the FW1 header will be created, is that wrong?

KK2_1-1634013953900.png

How can I solve this problem?

Regards,
KK2

0 Kudos

2,943 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

the FW header is updated after successful download of new application.

If you have bootloader programmed only (no application yet) then the bootloader stays in this endless loop waiting for transmission_complete (it's set once new application is loaded). After that, FW headers are updated in loader_code() function and it will jump to the new application:

lukaszadrapa_0-1634197911562.png

If there already is an application (or applications), it waits for timeout to start the application or it downloads new application from gateway - there's exactly the same code waiting for transmission_complete and it updates the headers after that.

lukaszadrapa_1-1634198203362.png

If the header was not updated then the application obviously was not downloaded. Or it was downloaded only partially. Therefore I would check the content of flash - if whole application is present.

Regards,

Lukas

0 Kudos

2,883 Views
KK2
Contributor II

Hi,
the reason why the firmware update does not work seems to be that the CAN communication is not working due to the SBC settings.
If the SBC is in Forced Normal mode, it will succeed, otherwise it will fail. I would like it to succeed with the SBC in Normal mode.

In this case, the
1. do I have to implement SBC_SetMode(SBC_UJA_MODE_MC_NORMAL) in Bootloader?
2. can't I use Components in the FW of Bootloader or Gateway?
3. how can I implement the SBC_SetMode function without Components?

Best regards,
KK2

0 Kudos

2,848 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I'm sorry for delayed response.

yes, it's necessary to implement function similar to SBC_SetMode.

The bootloader project does not use SDK, so it's not possible to use SDK components.

I can provide generic drivers for UJA1169 (attached), it's just necessary to implement SPI functions.

And here can be downloaded application hints for the SBC:

https://community.nxp.com/t5/S32K/Unable-to-communicate-with-UJA1169TK-F-3Z-by-Flexio-SPI/m-p/984088...

Regards,

Lukas

0 Kudos

2,789 Views
KK2
Contributor II

Hi,

I am running the application in Normal mode. Therefore, Bootloader must also run in Normal mode.

I still can't get the firmware update to work in Normal mode. Please help me a little more.

I have not been able to use the generic drivers for UJA1169 that you gave me because the SPI implementation is too difficult for my abilities.

Instead, I tried to implement a function similar to SBC_SetMode by sending a command directly using LPSPI_s32k144 in Example.
SPI communication is working, but changing or reading the SBC settings does not seem to work. I am attaching the source code.

Could you please help me with either of the following?
1. SPI functions that can be used with generic drivers for UJA1169
2. Problems with the attached source code

Also, I have one question.
After setting the SBC settings in the application, when I reset and start Bootloader, won't the SBC settings be the same as the application?
If the SBC settings are retained, then I don't think the SBC_SetMode function is necessary, but am I correct in understanding that it is necessary and not retained?

regards,

KK2

0 Kudos

2,739 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I found out that there’s simple example for SPI in AN5413 which reads Identification register IDS of UJA1169 on S32K144EVB:

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

https://www.nxp.com/webapp/Download?colCode=AN5413SW&location=null

 

Search for example “S32K144_Project_LPSPI”.

I did quick test on my EVB and it is working as expected. So, you can re-use this code to communicate with the SBC.

 

RSTN on UJA1169 is bidirectional reset pin. If it is connected to reset pin of S32K144 and if S32K144 is reset, the SBC chip will reset too.

 

Regards,

Lukas 

0 Kudos