From 5f5c4ac7ae9fe6ab71cd5b83252e567ecaab3906 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 12 Mar 2018 22:48:05 -0700 Subject: [PATCH] blue-pill: copying linker script over --- blue-pill/blinky/bluepill.ld | 13 ++++++++++--- blue-pill/blinky/startup.s | 31 ++++++++++++++----------------- blue-pill/draugr/blink.cc | 2 -- blue-pill/draugr/stm32f103.ld | 5 ++--- blue-pill/skeleton/bluepill.ld | 13 ++++++++++--- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/blue-pill/blinky/bluepill.ld b/blue-pill/blinky/bluepill.ld index 9d7fa01..d00ebd2 100644 --- a/blue-pill/blinky/bluepill.ld +++ b/blue-pill/blinky/bluepill.ld @@ -1,11 +1,18 @@ MEMORY { - flash (rx) : ORIGIN = 0x00000000, LENGTH = 128K + flash (rx) : ORIGIN = 0x08000000, LENGTH = 64K sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K } +EXTERN(vectors); +ENTRY(reset_handler); + SECTIONS { - .text : { *(.text*) } > flash - .bss : { *(.bss*) } > sram + .text : { + *(.vectors*) + *(.text*) + . = ALIGN(4); + } > flash + .bss : { *(.bss*) } > sram } diff --git a/blue-pill/blinky/startup.s b/blue-pill/blinky/startup.s index f55d87c..88b415a 100644 --- a/blue-pill/blinky/startup.s +++ b/blue-pill/blinky/startup.s @@ -8,29 +8,26 @@ .cpu cortex-m3 .thumb -.globl vectors +.section .text +.global vectors vectors: .align 2 -.long 0x20002000 /* best guess at stack pointer */ +.long 0x100 /* best guess at stack pointer */ .long reset_handler /* reset handler */ -.long hang /* NMI handler */ -.long hang /* hard_fault_handler */ -.long hang /* memory management handler */ -.long hang /* bus fault handler */ -.long hang /* usage fault handler */ +.long 0 /* NMI handler */ +.long 0 /* hard_fault_handler */ +.long 0 /* memory management handler */ +.long 0 /* bus fault handler */ +.long 0 /* usage fault handler */ .skip 0x20 /* reserved */ -.long hang /* svcall handler */ -.long hang /* debug handler */ +.long 0 /* svcall handler */ +.long 0 /* debug handler */ .skip 4 /* reserved */ -.long hang /* pendsv handler */ -.long hang /* systick handler */ -.skip 0x100 /* remaining / IRQ vectors */ - - -.thumb_func -hang: b . - +.long 0 /* pendsv handler */ +.long 0 /* systick handler */ +.skip 0xf4 /* remaining / IRQ vectors */ .thumb_func +.global reset_handler reset_handler: bl main diff --git a/blue-pill/draugr/blink.cc b/blue-pill/draugr/blink.cc index 81b9729..5bd45c7 100644 --- a/blue-pill/draugr/blink.cc +++ b/blue-pill/draugr/blink.cc @@ -4,7 +4,6 @@ constexpr uint32_t LED = 13; constexpr unsigned long SDELAY = 100000; constexpr unsigned long LDELAY = (SDELAY * 10) - (3 * SDELAY); -// void __attribute__ ((weak, naked)) reset_handler(void) { int main() { GPIO_C->enable_clock(); @@ -21,4 +20,3 @@ main() { delay(SDELAY); } } - diff --git a/blue-pill/draugr/stm32f103.ld b/blue-pill/draugr/stm32f103.ld index d00ebd2..8a190bb 100644 --- a/blue-pill/draugr/stm32f103.ld +++ b/blue-pill/draugr/stm32f103.ld @@ -1,6 +1,6 @@ MEMORY { - flash (rx) : ORIGIN = 0x08000000, LENGTH = 64K + flash (rx) : ORIGIN = 0x08000000, LENGTH = 128K sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K } @@ -10,9 +10,8 @@ ENTRY(reset_handler); SECTIONS { .text : { - *(.vectors*) + *(.vectors) *(.text*) . = ALIGN(4); } > flash - .bss : { *(.bss*) } > sram } diff --git a/blue-pill/skeleton/bluepill.ld b/blue-pill/skeleton/bluepill.ld index 9d7fa01..d00ebd2 100644 --- a/blue-pill/skeleton/bluepill.ld +++ b/blue-pill/skeleton/bluepill.ld @@ -1,11 +1,18 @@ MEMORY { - flash (rx) : ORIGIN = 0x00000000, LENGTH = 128K + flash (rx) : ORIGIN = 0x08000000, LENGTH = 64K sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K } +EXTERN(vectors); +ENTRY(reset_handler); + SECTIONS { - .text : { *(.text*) } > flash - .bss : { *(.bss*) } > sram + .text : { + *(.vectors*) + *(.text*) + . = ALIGN(4); + } > flash + .bss : { *(.bss*) } > sram }