mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-19 04:37:54 -06:00
stm32f1: Add support for building with bootloader support
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
215b4c5a1e
commit
75fa74313c
5 changed files with 167 additions and 9 deletions
|
@ -18,6 +18,19 @@ config CLOCK_FREQ
|
|||
int
|
||||
default 8000000 # 72000000 / 9
|
||||
|
||||
choice
|
||||
prompt "Bootloader offset"
|
||||
config STM_FLASH_START_0000
|
||||
bool "No bootloader"
|
||||
config STM_FLASH_START_2000
|
||||
bool "8KiB bootloader (stm32duino)"
|
||||
endchoice
|
||||
|
||||
config FLASH_START
|
||||
hex
|
||||
default 0x2000 if STM_FLASH_START_2000
|
||||
default 0x0000
|
||||
|
||||
config USBSERIAL
|
||||
bool "Use USB for communication (instead of serial)"
|
||||
default y
|
||||
|
|
|
@ -13,8 +13,7 @@ CFLAGS += -Ilib/hal-stm32f1/include
|
|||
CFLAGS += -DSTM32F103xB
|
||||
CFLAGS += -O3
|
||||
|
||||
CFLAGS_klipper.elf += -Llib/cmsis-stm32f1/source/
|
||||
CFLAGS_klipper.elf += -Tlib/cmsis-stm32f1/source/stm32f1.ld
|
||||
CFLAGS_klipper.elf += -T $(OUT)stm32f1.ld
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
|
||||
# Add source files
|
||||
|
@ -33,6 +32,13 @@ $(OUT)%.o: %.s $(OUT)autoconf.h $(OUT)board-link
|
|||
|
||||
$(OUT)klipper.elf: $(patsubst %.s, $(OUT)src/%.o,$(asmsrc-y))
|
||||
|
||||
# Build the linker script
|
||||
target-y := $(OUT)stm32f1.ld $(target-y)
|
||||
|
||||
$(OUT)stm32f1.ld: src/stm32f1/stm32f1.ld $(OUT)board-link
|
||||
@echo " Preprocessing $@"
|
||||
$(Q)$(CPP) -P -MD -MT $@ -DFLASH_START=$(CONFIG_FLASH_START) $< -o $@
|
||||
|
||||
# Binary output file rules
|
||||
target-y += $(OUT)klipper.bin
|
||||
|
||||
|
|
|
@ -135,6 +135,8 @@ int
|
|||
main(void)
|
||||
{
|
||||
SystemInit();
|
||||
SCB->VTOR += CONFIG_FLASH_START;
|
||||
|
||||
LL_Init1msTick(SystemCoreClock);
|
||||
clock_config();
|
||||
adc_config();
|
||||
|
|
113
src/stm32f1/stm32f1.ld
Normal file
113
src/stm32f1/stm32f1.ld
Normal file
|
@ -0,0 +1,113 @@
|
|||
/* Cortex-M linker script
|
||||
|
||||
This file is taken from lib/cmsis-stm32f1/source/stm32f1.ld . It
|
||||
has been modified to support a bootloader offset.
|
||||
*/
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000 + FLASH_START, LENGTH = 64K - FLASH_START
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
}
|
||||
|
||||
/* highest address of the user mode stack */
|
||||
_estack = 0x20005000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Interrupt vector table */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector))
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* Program code and constant data */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text)
|
||||
*(.text*)
|
||||
*(.rodata)
|
||||
*(.rodata*)
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
} >FLASH
|
||||
|
||||
/* Exception handling */
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
/* Static constructor initialization (C++) */
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
|
||||
/* Initialized data, needs to be handled by startup code */
|
||||
_sidata = .;
|
||||
.data : AT (_sidata)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = . ;
|
||||
_data = . ;
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.RAMtext)
|
||||
. = ALIGN(4);
|
||||
_edata = . ;
|
||||
} >RAM
|
||||
|
||||
/* Uninitialized data */
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = .;
|
||||
__bss_start__ = .;
|
||||
_bss = .;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_ebss = .;
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* Pointers to end of data for dynamic memory management */
|
||||
PROVIDE (end = _ebss);
|
||||
PROVIDE (_end = _ebss);
|
||||
|
||||
/* Remove debugging from standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a (*)
|
||||
libm.a (*)
|
||||
libgcc.a (*)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue