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
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:
Regards,
Lukas
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
Hi,
did you updated linker file of the hello world application? It should be like:
This is to compile "position dependent" code to Firmware 1 slot:
For second slot, you should use base address 0x00042000.
Regards,
Lukas
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
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
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.
I thought that if I debug the firmware linker file as shown in the image, the FW1 header will be created, is that wrong?
How can I solve this problem?
Regards,
KK2
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:
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.
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
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
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:
Regards,
Lukas
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
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