Loader

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

Loader

443 Views
Markon
Contributor II

Hello,

I'm preparing loader for kl25 and I would like to know, how I may change location in flash memory of function:

__init_registers();

__init_hardware();

__init_harware();

__load_static_base();

__init_pic();

__copy_rom_sectons_to_ram();

__fp_init();

__call_static_initializers();

__init_user();

__init_semihost();

and what for are these functions?

Labels (1)
0 Kudos
1 Reply

313 Views
israelpz
Senior Contributor I

Hi ,

I don't know much about kinetis but in order to reallocate code in other memory region you need the following:

In compile time you need the following:

1) Your flash memory should be iomap that mean is mapped to a memory region and is not a SPI , etc device.

2) Depending of you linker you need to make or edit a linker control file in order to place the object file which those functions in the desired address.

A example of this lets take i.mx6 u-boot input file

ENTRY(_start)

SECTIONS

{

        . = 0x00000000;

        . = ALIGN(4);

        .text      :

        {

          /* WARNING - the following is hand-optimized to fit within    */

          /* the sector layout of our flash chips!      XXX FIXME XXX   */

          board/freescale/mx6q_sabreauto/flash_header.o (.text.flasheader)

          cpu/arm_cortexa8/start.o

          board/freescale/mx6q_sabreauto/libmx6q_sabreauto.a    (.text)

          lib_arm/libarm.a              (.text)

          net/libnet.a                  (.text)

          drivers/mtd/libmtd.a          (.text)

          drivers/mmc/libmmc.a          (.text)

On this one is creating a sections which start at address 00000 then all the .text section(only the code)  from all the object files are placed as they appear.

For more information about this you could read:

Using LD, the GNU linker - Command Language

In run time is more hard and you need to create a loader which place in flash those function track destiny address and parses all the references to those functions and fix that in code.

Some general information about that is available in  Linkers and Loaders

I don't know exactly which linker is using the Kinetis but maybe the compiler suit had some facilities which makes this more easy, I would recommend look in the compiler help if there's one .

Regards,

-Israel.

0 Kudos