Relocating Code and Data Using the KDS GCC Linker File for Kinetis

cancel
Showing results for 
Search instead for 
Did you mean: 

Relocating Code and Data Using the KDS GCC Linker File for Kinetis

Relocating Code and Data Using the KDS GCC Linker File for Kinetis

This document provides guidance for relocating Code and Data within the MCU memory map. As part of this process it explains how create new memory segments and sections by editing the GCC Linker File (.ld) for Kinetis Architectures.

 

Contents:

 

1.- Introduction

2.- Preliminary Backgrounds

3.- Linker File (.ld) Overview

4.- Relocating Code

4.1.- Prerequisites

4.2.- Relocating Code in ROM

4.3.- Relocating Code in RAM

4.4.- Relocating Code in a Specific RAM address

4.5.- Relocating Code in External RAM

5.- Relocating Data

6.- Linker File for RAM Project

 

Best Regards,

Carlos Mendoza

Technical Support Engineer

Labels (1)
Attachments
Comments

In MCUXpresso, it appears that manual editing of the .ld file is no longer the approved technique, having been replaced by the Managed Linker / Freemarker / Memory Editor system.  Is there an updated version of the "Relocating Code ..." doc for MCUXpresso?

Hi Robert,

You are correct, the above approach is not recommended for MCUXpresso IDE. You can find more information on how to place variables and functions into different memory blocks in MCUXpresso in the chapter 16.7 Modifying the Generated Linker Script / Memory Layout.


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

Carlos:

Thanks for the info.  I've pored over chapter 16.7 and have created a set of linkscripts, but I have not yet succeeded in properly relocating all the pieces of the target program for loading by the KBOOT protocol.  Is there an updated document that addresses relocating a program for KBOOT?

Some specific questions:

  • The program needs to place the Bootloader Configuration Area at a specific location.  I already have specified that in the memory map, but what code is required in which .ldt file?  I current have it in boot_hdr.ldt.
  • Which .ldt file is responsible for relocating the VTOR?  And what should go in that file?  (I put it in section_top.ldt, but I don't believe that's correct.)

Here's what I currently have:

/* boot_hdr.ldt: */

.bca :
{
. = ALIGN(4);
KEEP(*(.BootloaderConfig))
. = ALIGN(4);
} > m_bootloader_cfg

/* section_top.ldt */

.interrupts :
{
__VECTOR_TABLE = .;
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} > m_interrupts

Hi Robert,

 

There is no need to modify the linker scripts to make your application usable with MCUBOOT, you can keep using the managed linker scripts fucntionality and just add an offset to the start of your application, you just have to open the project properties go to C/C++ Build > MCU settings and change the Flash start Location of your application:
pastedImage_1.png
The VTOR register will be uptated to match the new start address of the application.

Hope it helps!

 

Best Regards,
Carlos Mendoza
Technical Support Engineer

Hi Carlos_Mendoza‌, I've done that step to relocate the application in PROGRAM_FLASH to the BL_APP_VECTOR_TABLE_ADDRESS (e.g. 0xA000 on my target or 0x8000 in your example). However, robertpoor‌'s question is about defining a section to the application for the BCA (bootloader configuration area) in flash. Is there updated documentation for MCUXpresso that describes how to do this properly using the managed linker files? Everything I have found does not cover relocating data to FLASH or and doesn't handle the case for the Flash Config Block (section FlashConfig) at flash offset 0x400.

Relocating Code and Data Using the MCUXpresso IDE (https://community.nxp.com/docs/DOC-335283?comment...) from Alice_Yang only mentions relocating data into RAM for example.

Version history
Revision #:
1 of 1
Last update:
‎04-01-2015 03:41 PM
Updated by: