Linker script for Flash/SDRAM code?

cancel
Showing results for 
Search instead for 
Did you mean: 

Linker script for Flash/SDRAM code?

617 Views
Contributor I

Hi,

Straight to the point. I want to execute code from Flash AND External RAM. Both parts compiled separately. How can this be achieved? 

I've been working with LPC1768 some years now, and I have a simple bootloader that reads the new firmware from an SPI flash and writes it into the internal Flash, then replaces the VTOR and jumps into the "user app".

The project grew (RAM-wise) and we ported to LPC1788 (LPC4088 in the near future). Now I would like to implement a more complex bootloader, splitting the whole solution into 3 or 4 parts: bootloader, OS, drivers and application. All parts except the application will run on internal Flash, but I would like the application to be loaded from some external memory (EMC external Flash, SPIFI, USB, SD, etc) into the SDRAM, and be executed from there.

The thing is the user application will be calling to OS and driver methods, and I can't figure out how all parts are going to be linked. 

Any information will be really appreciated.

Thanks,

Mariano.

Labels (3)
0 Kudos
9 Replies

54 Views
NXP TechSupport
NXP TechSupport

Hi Mariano Renzi,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
To achieve the purpose, it's necessary to manage the linker script according to the requirements of your actual project, different IDEs always provide their own specific linker script, you can learn how to manage these linker scripts in corresponding IDE's user guide.
Hope it helps.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

54 Views
Contributor I

Thanks for your reply, jeremyzhou.

I'm using MCUXpresso. I already read the User Manual, and the FreeMarker templates section, and there are interesting things where I can look into. For example, moving an entire folder into RAM is functional to my needs, but there are still things that are not clear:

  • I want to compile the different pieces of the project in different .bin files. How can I achieve that?
  • The linker templates to move code to RAM seem to copy from Flash to RAM, using Flash space. But I want to copy the application to RAM by myself, and the "core" and "application" to be aware (in context) of each other anyway.
  • Do I need to compile the whole project (core and app) together?

You may already know Particle Photon. You can compile the application and download it OTA. The core will connect to the cloud, download the user app and install it. The user app will only have user code, while the core has the OS and drivers. I want to implement something similar to that.

Basically, I want to run the "core" code independently. The "core" code will check on an external memory if there is any "user application", and if there is, copy it to RAM and execute a startup function placed in a known address. The application should be compiled alongside the "core", to know its references, but the "core" code should not be included in the resulting .bin file for "user app".

I hope I was clearer this time. Any project reference, manual or tutorial are very welcome. I know it's a really complex area.

Thanks in advance.

0 Kudos

54 Views
NXP TechSupport
NXP TechSupport

Hi Mariano Renzi,

Thanks for your reply.
According to your statement, you may need three independent areas in the flash to store the bootloader, application and driver codes, in further, the bootloader is capable of updating the application and driver. Meanwhile,
both bootloader and application codes are able to call the driver code.
1) I want to compile the different pieces of the project in different bin files. How can I achieve that?
-- To implement it, you need to create three projects for these three demos respectively.
2) The linker templates to move code to RAM seem to copy from Flash to RAM, using Flash space. But I want to copy the application to RAM by myself, and the "core" and "application" to be aware (in context) of each other anyway.
-- To achieve it, the bootloader stores the bootloader in the RAM area at first, then write the application code in the Flash later via the IAP command.
3) Do I need to compile the whole project (core and app) together?
-- No.

Hope it helps.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

54 Views
Senior Contributor I

I was just about to ask a very similar question. I am just embarking on my first attempt at a bootloader (just a simple one that writes flash from SD card).

I understand the basics of it, but it leaves me with two questions:

1) Is VTOR volatile?  Does it have to be rewritten every time the processor starts, even it has not done a bootload?

2) How do I obtain the .bin file of the software to put on the SD card which the bootloader is going to load?

0 Kudos

54 Views
NXP TechSupport
NXP TechSupport

Hi Ian Benton,

1) Is VTOR volatile?  Does it have to be rewritten every time the processor starts, even it has not done a bootload?
-- Yes, you need to write the VTOR every time when you want to jump to a new application code.
2) How do I obtain the .bin file of the software to put on the SD card which the bootloader is going to load?
-- IDEs provide the function which can generate the BIN file after compiling the project, I'd like to suggest you refer to the User guide to learn how to implement it.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

54 Views
Senior Contributor I

Does the IAP command to copy to the flash require that the memory first be erased? Or does it automatically do the erase when the "copy" command is invoked?

I cannot find the address for VTOR in the LPC15xx manual. Joseph Yiu's book gives it as 0xE000ED08. Is that correct for all devices?

0 Kudos

54 Views
NXP TechSupport
NXP TechSupport

Hi Ian Benton,

Thanks for your reply.
1) Does the IAP command to copy to the flash requires that the memory first been erased?
-- Yes, it does.
2) I cannot find the address for VTOR in the LPC15xx manual. Joseph Yiu's book gives it as 0xE000ED08?
-- You can learn some information about the VTOR register via the link:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/CIHFDJCA.html
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

54 Views
Senior Contributor I

When I compile the code, how do I make it start compiling at the address where I want to load in the new code?

e.g. the code to be bootloaded goes at address 0x8000. Do I edit the start of Flash in the linker? Or make a section that starts at 0x8000? Or is there a better way of doing it?

0 Kudos

54 Views
NXP TechSupport
NXP TechSupport

Hi Ian Benton,

1) Do I edit the start of Flash in the linker?
-- Yes, editing the linker file is enough.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos