Bootloader and Application of S32K148 & S32K146

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

Bootloader and Application of S32K148 & S32K146

Jump to solution
915 Views
Nibesh
Contributor III

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. 

0 Kudos
1 Solution
693 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

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.

Senlent_0-1715314776859.png

 

View solution in original post

20 Replies
888 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

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

 

Senlent_0-1715138608273.png

 

 

 

881 Views
Nibesh
Contributor III
Hi @Senlent
If you could recommend me new Vector than that will be helpful for me.
Thank You
0 Kudos
877 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

You can see that BOOTLOADER is stored in FLEXNVM.

Senlent_0-1715149582129.png

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.

 

 

867 Views
Nibesh
Contributor III
Actually as per our Project need, we want to reduce Bootup Delay Completely. We want to jump to Application first, then if we receive any command on Application through LPUART then only we will jump to Bootloader Code.

So I want your suggestion for this, How I can do this? What sort of change I have to do on Vector ?
I hope to hear from you Soon!

Thank You
0 Kudos
861 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

we're taking about S32K146 not S32K148 here. I have two suggestions for you.

Senlent_0-1715224101103.png

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

769 Views
Nibesh
Contributor III

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?

0 Kudos
760 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

the space for bootloader is too small, you can change it like below.

Senlent_0-1715246975034.png

" 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.

756 Views
Nibesh
Contributor III

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.



709 Views
Nibesh
Contributor III

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 ?

0 Kudos
694 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

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.

Senlent_0-1715314776859.png

 

686 Views
Nibesh
Contributor III

Hi @Senlent 

Thank you very much for your suggestion.

I will try this from my side @Senlent 


Thanks

0 Kudos
842 Views
Nibesh
Contributor III

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

0 Kudos
838 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

if you just download APP program to MCU then there is no need to do so.

826 Views
Nibesh
Contributor III

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? 

0 Kudos
790 Views
Senlent
NXP TechSupport
NXP TechSupport
784 Views
Nibesh
Contributor III

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)));

0 Kudos
781 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Nibesh

This is what I modified. In the file you sent me, this part is wrong.

773 Views
Nibesh
Contributor III
Thank You @Senlent
0 Kudos
831 Views
Nibesh
Contributor III

Hello @Senlent 
Do we have to Preserve any Memory Space for Application and Bootloader.
I have attached one screenshot for your kind reference.

0 Kudos
849 Views
Nibesh
Contributor III
Hi @Selent,
Thank You very much for your kind suggestions.
As per you, I will go for Test Case 1 and will modify it accordingly.

I will shortly informed you regarding the Progress.

With Regards,
Nibesh
0 Kudos