Hello,
Actually I am working on Bootloader of AN12218SW for S32K148 and S32K146 Evaluation Board.
The Default Linker file for S32K146-Q144 is given below;
Bootloader
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x10000000, LENGTH = 0x00002000
Application
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00001000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00001400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00001410, LENGTH = 0x000FFBF0
Actually, we have interchanged the Linker vice versa, which is given below;
Application
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x10000000, LENGTH = 0x00002000
Bootloader
/* Flash */
m_interrupts (RX) : ORIGIN = 0x10001000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x10001400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x10001410, LENGTH = 0x000FFBF0
The following are the doubts points;
1. By interchanging the Vector We are trying to Flash the new application through Bootloader which start at 0x10001000.
2. we have use 0x00000000 Vector for Application.
3. Actually Once we Reset our Micro-Controller, it is going to Application First, then if it receives any INPUT through LPUART it will jump to Bootloader Code. We are able to achieve this. We can easily Jump from Application to Bootloader through LPUART.
But after a Jump into Bootloader it has to perform Bootloader Function comm_download_app(); Which I am unable to Achieve. It is detecting the COM, we are able to Load the new .SREC File, it is completely loading but it is unable to Write and Flash with new .SREC file.
How we can resolve this issue.
I hope to hear from you soon.
解決済! 解決策の投稿を見る。
You can use some tools to merge the generated APP and BOOTLOADER files together, and then burn them into the MCU through the tools. This is the method I often use.
for example, use j-flash, after merge the file, you can download it to the MCU directly.
I see address overlap in the highlight part, please double check it,
App range is :0x1000_0000 ~ 0x1000_2000
Bootloader range is :0x1000_1410 ~ 0x1010_1000
You can see that BOOTLOADER is stored in FLEXNVM.
The default size we set for it is only 4KB. This storage address is not suitable for storing APP.
I don’t understand why you want to make such a modification.
In fact, the routine we provide ,the allocated space is very reasonable and you don't need to make any
other modifications at all.
please let me know if you still have question regarding this.
we're taking about S32K146 not S32K148 here. I have two suggestions for you.
1.According to your idea, this is the linker file I modified
Application:
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000820, LENGTH = 0x000FF7DF
Bootloader:
m_interrupts (RX) : ORIGIN = 0x00000410, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000810, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x10000000, LENGTH = 0x00001000
1. Reset and enter the APP first
2. Receive requests from some commanders to enter the Bootloader
3. Enter the Bootloader to receive the new APP file. After the APP is successfully updated, it will jump to the APP again.
There are some issues you must consider here. You must burn both the APP and BOOTLOADER into the MCU using the debugger.
2.you don't have to change AN12218's linker file.
My suggestion is that if you want to shorten the time for the Bootloader to enter the App, you can do it through some shared variables, for example:
1. Enter Bootloader after reset
2.Bootloader checks the variable, which indicates that the APP update is not currently requested.
3. If APP already exists in the current MCU, jump to APP
4. If you receive a request to update the APP, modified the variable then jump into the Bootloader
Hi @Senlent
The Following are the errors that I am getting, after modifying as per your suggestions to change the Vectors for;
Application:
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000820, LENGTH = 0x000FF7DF
Bootloader:
m_interrupts (RX) : ORIGIN = 0x00000410, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000810, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x10000000, LENGTH = 0x00001000
c:/users/nxp _ s32/s32ds/build_tools/gcc_v4.9/gcc-arm-none-eabi-4_9/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: NXP_Bootloader.elf section `.text' will not fit in region `m_text'
c:/users/nxp _ s32/s32ds/build_tools/gcc_v4.9/gcc-arm-none-eabi-4_9/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `m_text' overflowed by 1200 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:36: NXP_Bootloader.elf] Error 1
One more Question @Senlent
Do I have to Preserve any Memory?
while on Compiling time?
the space for bootloader is too small, you can change it like below.
" Do I have to Preserve any Memory?"
I don't know why you want to set this option. The function of this option is to keep the area from being erased.
Hi
@Senlent
Thank You very much for your quick response.
Actually I am using Memory Save in order to be safe from erasing, you're right.
Actually in Bootloader Code, User can Upload the .SREC file through LPUART before timeout occurs.
But after changing this Vector we can't Program Bootloader first. Firstly I am uploading Application through SWD which start from 0000 0000 and also I will upload Bootloader Code Serially (SWD) which start from this Vector 0x00000410.
See once both the Program is uploaded, then only we can perform Bootloading function through LPUART, that I have understood from the code.
Hello @Senlent
I have done modifications as per your suggestion, Actually to perform Bootloading function through LPUART, firstly I need to upload my Application and Bootloader through Serial SWD. So When I am uploading one code, it is completely erasing the other sectors of memory through SWD.
So how I have to perform this Testing @Senlent
Will you please inform me briefly regarding this testing.
If I really have to Save the Memory Sector then what are the range that I have to Save ?
You can use some tools to merge the generated APP and BOOTLOADER files together, and then burn them into the MCU through the tools. This is the method I often use.
for example, use j-flash, after merge the file, you can download it to the MCU directly.
Hello @Senlent
Do we have to Preserve any Memory Space for Application and Bootloader.
I have attached one screenshot for your kind reference.
I hope to hear from you soon!
Thank You
if you just download APP program to MCU then there is no need to do so.
Hello @Senlent
I have attached my code, if you can check that will be more helpful for me.
Actually I am preserving some Memory, do we have to preserve any memory for it?
Hi @Senlent
That is Right only I guess,
Because by using this Vector 0x00000410, I am jumping from Application to Bootloader.
#define BOOT_START_ADDRESS 0x00000410
JumpToUserBootloader(*((uint32_t*)BOOT_START_ADDRESS), *((uint32_t*)(BOOT_START_ADDRESS + 4)));
This is what I modified. In the file you sent me, this part is wrong.
Hello @Senlent
Do we have to Preserve any Memory Space for Application and Bootloader.
I have attached one screenshot for your kind reference.