summaryrefslogtreecommitdiff
path: root/linker_script.ld
blob: 347a8c4af84288b4d4e6173d67b4ec914b385690 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
MEMORY
{
  flash : org = 0x08000000, len = 256k
  sram1 : org = 0x20000000, len = 48k
  sram2 : org = 0x10000000, len = 16k
}

SECTIONS
{
  __Periph_base = 0x40000000;
  __Pwr_base = __Periph_base + 0x7000;

  /* By default the start of the stack is at the top of sram1. */
  PROVIDE(_stack_start = ORIGIN(sram1) + LENGTH(sram1));

  /* Vector-offset table. */
  .vectors ORIGIN(flash) : ALIGN(0x04) {
    LONG(_stack_start); /* Store the start of the stack. */
    KEEP(*(.on_reset));

    . = ORIGIN(flash) + 0x0dc;
  } >flash

  /** Init routines */
  _sinits = ADDR(.vectors) + SIZEOF(.vectors);
  .inits _sinits : ALIGN(0x04) {
    KEEP(*(SORT_BY_NAME(.inits .inits.*)));
    _einits = .;
    . = ALIGN(0x04);
  } > flash

  /** Text data is stored after the vector table. */
  PROVIDE(_stext = ADDR(.inits) + SIZEOF(.inits));
  .text _stext : ALIGN(0x04) {
    *(.text .text.*);
    . = ALIGN(0x04);
    _etext = .;

    /* Readonly data should be stored in flash. */
    *(.rodata .rodata.*)
  } >flash

  /* the data segment where static data is stored. This is linked to reference
   * variables in sram2, but the data is stored persistently in the flash. 
   *
   * The Application has to load the data from the flash to */
  .data : ALIGN(0x04) {
    __data_load = LOADADDR(.data);
    __data_store_start = .;
    *(.data .data.*);
    __data_store_end = .;
  } > sram2 AT > flash

  /* block starting symbol (bss). This is data initialized to 0. The application
   * is responsible for zeroing out this data. */
  .bss : ALIGN(0x04) {
    __bss_start = .;
    *(.bss .bss.*);
    __bss_end = .;
  } > sram2

  /* Sections that should be discarded. */
  /DISCARD/ :
  {
    *(.ARM.exidx);
    *(.ARM.exidx.*);
    *(.ARM.extab.*);
  }
}