targets: move target-specific files to this directory

This commit is contained in:
Ayke van Laethem
2018-09-13 00:59:39 +02:00
parent e389d38dec
commit 76e77917d8
5 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -2,5 +2,5 @@
"llvm-target": "avr-atmel-none",
"build-tags": ["avr", "avr8", "atmega", "atmega328p", "js", "wasm"],
"linker": "avr-gcc",
"pre-link-args": ["-nostdlib", "-T", "avr.ld", "-Wl,--gc-sections", "avr.S"]
"pre-link-args": ["-nostdlib", "-T", "targets/avr.ld", "-Wl,--gc-sections", "targets/avr.S"]
}
+82
View File
@@ -0,0 +1,82 @@
MEMORY
{
FLASH_TEXT (rw) : ORIGIN = 0x00000000, LENGTH = 256K /* .text */
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
}
_stack_size = 2K;
/* define output sections */
SECTIONS
{
/* The program code and other data goes into FLASH */
.text :
{
_stext = .;
. = ALIGN(4);
KEEP(*(.isr_vector))
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH_TEXT
/* Put the stack at the bottom of RAM, so that the application will
* crash on stack overflow instead of silently corrupting memory.
* See: http://blog.japaric.io/stack-overflow-protection/ */
.stack :
{
. = ALIGN(4);
. += _stack_size;
__StackTop = .;
} >RAM
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM AT>FLASH_TEXT
/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
} >RAM
/DISCARD/ :
{
*(.ARM.exidx.*)
*(.ARM.attributes)
*(.stack) /* from nrfx */
*(.heap) /* from nrfx */
}
}
/* For the nrfx startup file. */
__etext = _etext;
__data_start__ = _sdata;
__bss_start__ = _sbss;
__bss_end__ = _ebss;
/* For the memory allocator. */
_heap_start = _ebss;
_heap_end = ORIGIN(RAM) + LENGTH(RAM);
+62
View File
@@ -0,0 +1,62 @@
.section .isr
isr:
rjmp reset
.org 0x18 ; WDT
rjmp wdt
; Startup code
.section .reset
.org 26
reset:
clr r1 ; r1 is expected to be 0 by the C calling convention
; Zero .bss
clear_bss:
ldi xl, lo8(_sbss)
ldi xh, hi8(_sbss)
clear_bss_loop:
ldi yl, lo8(_ebss)
ldi yh, hi8(_ebss)
cp xl, yl ; if x == y
cpc xh, yh
breq clear_bss_end
st x+, r1 ; zero byte in *x
rjmp clear_bss_loop
clear_bss_end:
; Set up the stack pointer.
ldi xl, lo8(_stack_top)
ldi xh, hi8(_stack_top)
out 0x3d, xl; SPL
out 0x3e, xh; SPH
; Enable interrupts.
; TODO: make sure interrupts are started after all initializers have run.
sei
; main will be placed right after here by the linker script so there's no
; need to jump.
; The only thing this WDT handler really does is disable itself, to get out of
; sleep mode.
.section .text.wdt
wdt:
push r16
clr r16
wdr ; Reset watchdog
out 0x34, r16 ; Clear reset reason (MCUSR)
; part 1: set WDCE and WDE to enable editing WDTCSR
lds r16, 0x60 ; r16 = WDTCSR
ori r16, 0x18 ; r16 |= WDCE | WDE
sts 0x60, r16 ; WDTCSR = r16
; part 2: within 4 clock cycles, set the new value for WDTCSR
clr r16
sts 0x60, r16 ; WDTCSR = 0
pop r16
reti
+43
View File
@@ -0,0 +1,43 @@
MEMORY
{
FLASH_TEXT (rw) : ORIGIN = 0, LENGTH = 32256
RAM (xrw) : ORIGIN = 0, LENGTH = 2K
}
_stack_size = 512;
SECTIONS
{
.text :
{
KEEP(*(.isr))
KEEP(*(.reset))
KEEP(*(.text.main)) /* main must follow the reset handler */
*(.text.*)
*(.rodata)
*(.rodata.*)
}
.stack :
{
. += _stack_size;
_stack_top = .;
} >RAM
.data :
{
*(.data)
*(.data*)
} >RAM AT>FLASH_TEXT
.bss :
{
_sbss = .;
*(.bss)
*(.bss*)
*(COMMON)
_ebss = .;
_heap_start = .;
} >RAM
}
+1 -1
View File
@@ -2,5 +2,5 @@
"llvm-target": "armv7m-none-eabi",
"build-tags": ["nrf", "nrf52", "nrf52832", "js", "wasm"],
"linker": "arm-none-eabi-gcc",
"pre-link-args": ["-nostdlib", "-nostartfiles", "-mcpu=cortex-m4", "-mthumb", "-T", "arm.ld", "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", "-Os", "-DNRF52832_XXAA", "-D__STARTUP_CLEAR_BSS", "-Ilib/CMSIS/CMSIS/Include", "lib/nrfx/mdk/gcc_startup_nrf51.S", "lib/nrfx/mdk/system_nrf52.c"]
"pre-link-args": ["-nostdlib", "-nostartfiles", "-mcpu=cortex-m4", "-mthumb", "-T", "targets/arm.ld", "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", "-Os", "-DNRF52832_XXAA", "-D__STARTUP_CLEAR_BSS", "-Ilib/CMSIS/CMSIS/Include", "lib/nrfx/mdk/gcc_startup_nrf51.S", "lib/nrfx/mdk/system_nrf52.c"]
}