Compiling multiple projects in S32DS IDE?

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

Compiling multiple projects in S32DS IDE?

Jump to solution
7,469 Views
gearhead1107
Contributor IV

I'd like to compile two separate S32DS projects into one binary to flash onto my S32 - one to act as a bootloader and one to act as firmware. In Project> Properties> Project References I see that I can make a project refer to other projects in my workspace. How do I refer to the other project, and how would I -say- make "bootloader" start loading at the base of PFlash, while "firmware" gets loaded into address 0xA000?

1 Solution
5,923 Views
stanish
NXP Employee
NXP Employee

Hi Andrew,

You can merge your bootloader binary with the application project and load it as a single .elf/srec/bin.

There are several ways how this can be done. See below just one of the approaches:

Let's first have a look at bootloader project:

1) Adjust the bootloader linker file. E.g. the bootloader should fit into 0x0000..0xA000

(Note: Bootloader and Application must not overlap in the Flash memory)

MEMORY
{
 /* Flash */
 m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
 m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
 m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x9BF0
...
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

2) Enable creation of flash image for the bootloader project to generate binary image (.bin)

pastedImage_1.png

and select binary file format:

pastedImage_2.png

3) Build the bootloader project and you should see the bootloader .bin file in the project output directory:

pastedImage_3.png

Now let's switch to application project which will link the bootloader bin file.

1) Application shall start above 0xA000 to avoid overlap with bootloader image.  Add a new MEMORY area where the bootloader bin file is placed into:

MEMORY
{
 /* Flash */
m_bootloader (RX) : ORIGIN = 0x0000000, LENGTH = 0x0000A000
m_text (RX) : ORIGIN = 0x0000A000, LENGTH = 0x00060000
...
}

2) add the lines that describe binary file name and formats. Create a new linker section that places binary file into bootloader memory:

MEMORY
{
 /* Flash */
 m_bootloader (RX) : ORIGIN = 0x00000000, LENGTH = 0x0000A000
 m_text (RX) : ORIGIN = 0x0000A000, LENGTH = 0x00060000
 ...
}

TARGET(binary)                 /* specify the file format of binary file */
INPUT (S32K144_bootloader.bin) /* provide the file name */
OUTPUT_FORMAT(default)         /* restore the out file format */

SECTIONS
{
 /* The bootloader binary is placed into 0x0000 - 0xA000 */
 .my_boot :
 { 
   S32K144_bootloader.bin (.data)
 } > m_bootloader
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

3)  add the path to bootloader.bin file into the application project settings as a library search path:

pastedImage_4.png

4) Build the application project and check the generated .map file to confirm the bootloader.bin has been included:

.my_boot 0x00000000 0x594
 S32K144_bootloader.bin(.data)
 .data 0x00000000 0x594 C:/workARM_2.0/S32K144_bootloader/Debug\S32K144_bootloader.bin
 0x00000000 _binary_C__workARM_2_0_S32K144_bootloader_Debug_S32K144_bootloader_bin_start
 0x00000594 _binary_C__workARM_2_0_S32K144_bootloader_Debug_S32K144_bootloader_bin_end

Now the application elf/binary image contains both application and bootloader.

Hope it helps.

Stan

View solution in original post

9 Replies
4,528 Views
saurabhkulkarni123
Contributor II

Hello.

I want to compile MATLAB generated code in to s32 ide but it shows error like "fatal error: cannot specify -o with -c, -S or -E with multiple files".

 

0 Kudos
Reply
4,529 Views
saurabhkulkarni123
Contributor II

Hello.. 

I want to compile MATLAB generated code in to s32 ide ,but it shows the error. "fatal error: cannot specify -o with -c, -S or -E with multiple files" .

how can i resolve this error.

0 Kudos
Reply
5,923 Views
barkly_lin
Contributor III

Hi Stanislav

I have two projects, one is bootloader, another is a simple LED application.

bootloader:

boot header:0x00FA0000

 flash start 0x01000000, size=1MB

LED app:

boot header:0x00FA4000

 flash start 0x01100000, size=2MB

bootloader will wait 10sec then jump to LED app's boot header

My S32 IDE has different format *.ld, merger bootloader doesn't work.

Here is my flash mapping:

1.bootloader

bootloader_flash.ld

MEMORY
{

flash_rchw : org = 0x00FA0000, len = 0x4
cpu0_reset_vec : org = 0x00FA0000+0x10, len = 0x4
cpu1_reset_vec : org = 0x00FA0000+0x14, len = 0x4
cpu2_reset_vec : org = 0x00FA0000+0x04, len = 0x4

m_text : org = 0x1000000, len = 1024K
m_vectors_ram : org = 0x40000000, len = 0xC00
m_data : org = (0x40000000+0xC00), len = 768K-0xC00
}

2.LED application

LED_flash.ld

MEMORY
{

flash_rchw : org = 0x00FA4000, len = 0x4
cpu0_reset_vec : org = 0x00FA4000+0x10, len = 0x4
cpu1_reset_vec : org = 0x00FA4000+0x14, len = 0x4
cpu2_reset_vec : org = 0x00FA4000+0x04, len = 0x4

m_bootloader : org = 0x1000000, len = 1024K
m_text : org = 0x1100000, len = 2048K
m_vectors_ram : org = 0x40000000, len = 0xC00
m_data : org = (0x40000000+0xC00), len = 768K-0xC00
}

SECTIONS
{
.rchw :
{
KEEP(*(.rchw))
} > flash_rchw

.cpu0_reset_vector :
{
KEEP(*(.cpu0_reset_vector))
} > cpu0_reset_vec

.cpu1_reset_vector :
{
KEEP(*(.cpu1_reset_vector))
} > cpu1_reset_vec

.cpu2_reset_vector :
{
KEEP(*(.cpu2_reset_vector))
} > cpu2_reset_vec

.bootloader :
{
KEEP(*(V31_Bootloader_20180716_Z4_0_Z4_0.bin))
} > m_bootloader

I'm sure something missing, because bootloader is not working after memory is flashed.

Any suggestion about it?

Regards,

0 Kudos
Reply
5,923 Views
stanish
NXP Employee
NXP Employee

Hello Lin,

Could you check in the map file of the LED App if the Bootloader binary has been indeed linked with the application? e.g.check the size and address space of your .bootloader section.

Another approach to "merge"  bootloader and application using debugger. PEMicro debug configuration allows loading of multiple .elf/srec files  (they call it additional object file).

First of all enable creation of srecord image for the bootloader project:

https://community.nxp.com/message/631160#comment-631306 

then enter generated srec as the additional Object file for the boot core debug configuration:

pastedImage_4.png

When you launch the group or debug this configuration - bootloader srec will be loaded with the elf file.

Hope it helps.

Stan

0 Kudos
Reply
5,924 Views
stanish
NXP Employee
NXP Employee

Hi Andrew,

You can merge your bootloader binary with the application project and load it as a single .elf/srec/bin.

There are several ways how this can be done. See below just one of the approaches:

Let's first have a look at bootloader project:

1) Adjust the bootloader linker file. E.g. the bootloader should fit into 0x0000..0xA000

(Note: Bootloader and Application must not overlap in the Flash memory)

MEMORY
{
 /* Flash */
 m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
 m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
 m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x9BF0
...
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

2) Enable creation of flash image for the bootloader project to generate binary image (.bin)

pastedImage_1.png

and select binary file format:

pastedImage_2.png

3) Build the bootloader project and you should see the bootloader .bin file in the project output directory:

pastedImage_3.png

Now let's switch to application project which will link the bootloader bin file.

1) Application shall start above 0xA000 to avoid overlap with bootloader image.  Add a new MEMORY area where the bootloader bin file is placed into:

MEMORY
{
 /* Flash */
m_bootloader (RX) : ORIGIN = 0x0000000, LENGTH = 0x0000A000
m_text (RX) : ORIGIN = 0x0000A000, LENGTH = 0x00060000
...
}

2) add the lines that describe binary file name and formats. Create a new linker section that places binary file into bootloader memory:

MEMORY
{
 /* Flash */
 m_bootloader (RX) : ORIGIN = 0x00000000, LENGTH = 0x0000A000
 m_text (RX) : ORIGIN = 0x0000A000, LENGTH = 0x00060000
 ...
}

TARGET(binary)                 /* specify the file format of binary file */
INPUT (S32K144_bootloader.bin) /* provide the file name */
OUTPUT_FORMAT(default)         /* restore the out file format */

SECTIONS
{
 /* The bootloader binary is placed into 0x0000 - 0xA000 */
 .my_boot :
 { 
   S32K144_bootloader.bin (.data)
 } > m_bootloader
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

3)  add the path to bootloader.bin file into the application project settings as a library search path:

pastedImage_4.png

4) Build the application project and check the generated .map file to confirm the bootloader.bin has been included:

.my_boot 0x00000000 0x594
 S32K144_bootloader.bin(.data)
 .data 0x00000000 0x594 C:/workARM_2.0/S32K144_bootloader/Debug\S32K144_bootloader.bin
 0x00000000 _binary_C__workARM_2_0_S32K144_bootloader_Debug_S32K144_bootloader_bin_start
 0x00000594 _binary_C__workARM_2_0_S32K144_bootloader_Debug_S32K144_bootloader_bin_end

Now the application elf/binary image contains both application and bootloader.

Hope it helps.

Stan

5,923 Views
laplk
Contributor I

Hi Stan,

Sorry, but why in area MEMORY of application you not leave space for interrupt vector table.

Have a specific reason?

Regards,

Akai

0 Kudos
Reply
5,923 Views
stanish
NXP Employee
NXP Employee

Hi Akai,

There is no issue at all with having interrupt vector table in the application linker file. I probably removed to simplify.

Anywya please keep the appropriate alignment when moving the interrupt section from its default address to a new one and adjust Vector Table Offset Register (VTOR) in NVIC module accordingly.

Hope it helps.

Stan

0 Kudos
Reply
5,923 Views
cholland
Contributor V

2nd Awesome! It's perfect.

0 Kudos
Reply
5,923 Views
gearhead1107
Contributor IV

This is awesome - thank you for the time you spent making this detailed write-up!!

0 Kudos
Reply