Author Topic: Linker Files  (Read 8501 times)

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Linker Files
« on: May 18, 2010, 05:21:09 PM »

For the LM project linker files, I noticed some differences between the regular one (1) and the _BM one (2).  Namely:

(1)  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
(2)  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x0003f000

(1)  SRAM (wx) : ORIGIN  = 0x20000000, LENGTH = 0x00010000
(2)  SRAM (wx)  : ORIGIN = 0x20000000, LENGTH = 0x00008000

(1)  __HEAPSIZE__ = 4097;
(2)  __HEAPSIZE__ = 0;

(1)  __FLASH_segment_start__ = 0x00000000;
(2)  __FLASH_segment_start__ = 0x00000800;

I understand the FLASH_segment_start, but I'm not sure why the FLASH, SRAM and HEAPSIZE variables are different.

Granted, I'm not an expert, but I just wanted to make sure this is correct.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Linker Files
« Reply #1 on: May 19, 2010, 01:15:15 AM »
Hi Paul

The only real difference between application and boot loader is the start address in FLASH. This is controlled by the __FLASH_segment_start__

The SRAM size should match the chip. The values in the files don't match but this is presumable to match the last chip used in each case. In fact this is also only so that the linker can check that there is enough space for the variables so it is usually not at all critical (the stack pointer start address is taken form the SRAM size according to the processor type selected (in the LM3Sxxxx.h) - this is more critical).

__HEAPSIZE__ is used when a library malloc() is linked into the project. If only the uMalloc() is used this can be set to 0. If set to non-zero when not needed it may be 'wasting' a bit of RAM space but the files should be configured for a particular project in any case.

The FLASH size limit is also to reflect the fact that the boot loader is using some space. Again it is only used by the linker to verify that all fits into the available FLASH space. Unless you happened to have code which doesn't fit into FLASH it is not that important. If it doesn't fit you would also notice this very quickly when trying to program anyway...