|
| 1 | +/* |
| 2 | + GNU linker script for STM32F405 via Micropython |
| 3 | +*/ |
| 4 | + |
| 5 | +/* Specify the memory areas */ |
| 6 | +MEMORY |
| 7 | +{ |
| 8 | + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* entire flash */ |
| 9 | + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ |
| 10 | + FLASH_TEXT (rx) : ORIGIN = 0x08004000, LENGTH = 1008K /* sectors 0-7*/ |
| 11 | + CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K |
| 12 | + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K |
| 13 | +} |
| 14 | + |
| 15 | +/* produce a link error if there is not this amount of RAM for these sections */ |
| 16 | +_minimum_stack_size = 2K; |
| 17 | +_minimum_heap_size = 16K; |
| 18 | + |
| 19 | +/* Define tho top end of the stack. The stack is full descending so begins just |
| 20 | + above last byte of RAM. Note that EABI requires the stack to be 8-byte |
| 21 | + aligned for a call. */ |
| 22 | +_estack = ORIGIN(RAM) + LENGTH(RAM); |
| 23 | + |
| 24 | +/* RAM extents for the garbage collector */ |
| 25 | +_ram_start = ORIGIN(RAM); |
| 26 | +_ram_end = ORIGIN(RAM) + LENGTH(RAM); |
| 27 | + |
| 28 | +ENTRY(Reset_Handler) |
| 29 | + |
| 30 | +/* define output sections */ |
| 31 | +SECTIONS |
| 32 | +{ |
| 33 | + /* The startup code goes first into FLASH */ |
| 34 | + .isr_vector : |
| 35 | + { |
| 36 | + . = ALIGN(4); |
| 37 | + KEEP(*(.isr_vector)) /* Startup code */ |
| 38 | + |
| 39 | + /* This first flash block is 16K annd the isr vectors only take up |
| 40 | + about 400 bytes. Micropython pads this with files, but this didn't |
| 41 | + work with the size of Circuitpython's ff object. */ |
| 42 | + |
| 43 | + . = ALIGN(4); |
| 44 | + } >FLASH_ISR |
| 45 | + |
| 46 | + /* The program code and other data goes into FLASH */ |
| 47 | + .text : |
| 48 | + { |
| 49 | + . = ALIGN(4); |
| 50 | + *(.text*) /* .text* sections (code) */ |
| 51 | + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ |
| 52 | + /* *(.glue_7) */ /* glue arm to thumb code */ |
| 53 | + /* *(.glue_7t) */ /* glue thumb to arm code */ |
| 54 | + |
| 55 | + . = ALIGN(4); |
| 56 | + _etext = .; /* define a global symbol at end of code */ |
| 57 | + } >FLASH_TEXT |
| 58 | + |
| 59 | + /* used by the startup to initialize data */ |
| 60 | + _sidata = LOADADDR(.data); |
| 61 | + |
| 62 | + /* This is the initialized data section |
| 63 | + The program executes knowing that the data is in the RAM |
| 64 | + but the loader puts the initial values in the FLASH (inidata). |
| 65 | + It is one task of the startup to copy the initial values from FLASH to RAM. */ |
| 66 | + .data : |
| 67 | + { |
| 68 | + . = ALIGN(4); |
| 69 | + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ |
| 70 | + *(.data*) /* .data* sections */ |
| 71 | + |
| 72 | + . = ALIGN(4); |
| 73 | + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ |
| 74 | + } >RAM AT> FLASH_TEXT |
| 75 | + |
| 76 | + /* Uninitialized data section */ |
| 77 | + .bss : |
| 78 | + { |
| 79 | + . = ALIGN(4); |
| 80 | + _sbss = .; /* define a global symbol at bss start; used by startup code */ |
| 81 | + *(.bss*) |
| 82 | + *(COMMON) |
| 83 | + |
| 84 | + . = ALIGN(4); |
| 85 | + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ |
| 86 | + } >RAM |
| 87 | + |
| 88 | + /* this is to define the start of the heap, and make sure we have a minimum size */ |
| 89 | + .heap : |
| 90 | + { |
| 91 | + . = ALIGN(4); |
| 92 | + . = . + _minimum_heap_size; |
| 93 | + . = ALIGN(4); |
| 94 | + } >RAM |
| 95 | + |
| 96 | + /* this just checks there is enough RAM for the stack */ |
| 97 | + .stack : |
| 98 | + { |
| 99 | + . = ALIGN(4); |
| 100 | + . = . + _minimum_stack_size; |
| 101 | + . = ALIGN(4); |
| 102 | + } >RAM |
| 103 | + |
| 104 | + .ARM.attributes 0 : { *(.ARM.attributes) } |
| 105 | +} |
| 106 | + |
| 107 | + |
0 commit comments