summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2016-11-24 21:53:23 +0000
committerTomasz Kramkowski <tk@the-tk.com>2016-11-24 21:53:23 +0000
commitc6419bba0cafa16e925b8bc5e028dba138c853b9 (patch)
treea5adcda31100cb6daa7363fb069cd61fdf5de297
parente927fb70d4f46dd686d8ad246cac587c219ddd9d (diff)
downloadfmk-c6419bba0cafa16e925b8bc5e028dba138c853b9.tar.gz
fmk-c6419bba0cafa16e925b8bc5e028dba138c853b9.tar.xz
fmk-c6419bba0cafa16e925b8bc5e028dba138c853b9.zip
simplify layout.ld
-rw-r--r--layout.ld36
-rw-r--r--setup.c8
2 files changed, 17 insertions, 27 deletions
diff --git a/layout.ld b/layout.ld
index 7431496..3be0978 100644
--- a/layout.ld
+++ b/layout.ld
@@ -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);
}
diff --git a/setup.c b/setup.c
index ad29e40..9cb0312 100644
--- a/setup.c
+++ b/setup.c
@@ -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)