diff options
-rw-r--r-- | layout.ld | 36 | ||||
-rw-r--r-- | setup.c | 8 |
2 files changed, 17 insertions, 27 deletions
@@ -1,10 +1,9 @@ MEMORY { - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K - RAM (rw!x) : ORIGIN = 0x1FFF8000, LENGTH = 64K + flash : ORIGIN = 0x00000000, LENGTH = 256K + ram : ORIGIN = 0x1FFF8000, LENGTH = 64K } SECTIONS { - . = 0x00000000; .text : { KEEP(*(.vectors)) . = 0x400; @@ -12,27 +11,18 @@ SECTIONS { *(.startup*) *(.text*) *(.rodata*) - . = ALIGN(4); - } > FLASH + } >flash - .data : { - . = ALIGN(4); - _sflashdata = LOADADDR(.data); - _sdata = .; - *(.fastrun*) - *(.data*) - . = ALIGN(4); - _edata = .; - } > RAM AT > FLASH + .data : { *(.data*) } >ram AT>flash - .bss : { - . = ALIGN(4); - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(4); - _ebss = .; - } > RAM + .bss : { *(.bss*) } >ram - _estack = ORIGIN(RAM) + LENGTH(RAM); + _sdata = ADDR(.data); + _edata = ADDR(.data) + SIZEOF(.data); + _ldata = LOADADDR(.data); + + _sbss = ADDR(.bss); + _ebss = ADDR(.bss) + SIZEOF(.bss); + + _estack = ORIGIN(ram) + LENGTH(ram); } @@ -5,8 +5,8 @@ #include "asm.h" #include "usb/usb.h" -extern char _sflashdata[], _sdata[], _edata[]; -extern char _sbss[], _ebss[]; +extern unsigned char _ldata[], _sdata[], _edata[]; +extern unsigned char _sbss[], _ebss[]; #define RANGE0_VAL 2 /* Very High Frequency */ #define HGO0_VAL 0 /* High Gain Mode Disabled */ @@ -31,8 +31,8 @@ void setup(void) UNSET_BIT(WDOG_STCTRLH, STCTRLH_WDOGEN); /* Copy data and clear bss */ - memcpy(_sdata, _sflashdata, _edata - _sdata); - memset(_sbss, 0, _ebss - _sdata); + memcpy(_sdata, _ldata, _edata - _sdata); + memset(_sbss, 0, _ebss - _sbss); /* Enable port clocks */ SIM_SCGC5 |= BV(SCGC5_PORTE) | BV(SCGC5_PORTD) | BV(SCGC5_PORTC) |