Skip to content

Commit e309cc5

Browse files
committed
Stub for stm32h7 built-in bootloader
1 parent f230fa2 commit e309cc5

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

src/platform/stm32h7/boot/isr.S

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.syntax unified
2+
.text
3+
.thumb
4+
.section .bootloader_vector,"a",%progbits
5+
.align 2
6+
.global bootloader_vectors
7+
.type bootloader_vectors, %object
8+
9+
10+
11+
bootloader_vectors:
12+
.long _sdata // Main stack (MSP) start before data-section
13+
.long bl_start
14+
.long bl_nmi
15+
.long bl_hard_fault
16+
17+
.long bl_mm_fault
18+
.long bl_bus_fault
19+
.long bl_usage_fault
20+
21+
.size bootloader_vectors, . - bootloader_vectors
22+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <stdint.h>
2+
3+
extern uint32_t vectors[];
4+
5+
void __attribute__((section("bltext"),noinline,noreturn)) bl_start(void)
6+
{
7+
void (*init)(void) __attribute__((noreturn)) = (void *)vectors[1];
8+
init();
9+
}
10+
11+
void __attribute__((section("bltext"),noinline))
12+
bl_nmi(void)
13+
{
14+
while(1) {}
15+
}
16+
17+
void __attribute__((section("bltext"),noinline))
18+
bl_hard_fault(void)
19+
{
20+
while(1) {}
21+
}
22+
23+
void __attribute__((section("bltext"),noinline))
24+
bl_mm_fault(void)
25+
{
26+
while(1) {}
27+
}
28+
29+
void __attribute__((section("bltext"),noinline))
30+
bl_bus_fault(void)
31+
{
32+
while(1) {}
33+
}
34+
35+
void __attribute__((section("bltext"),noinline))
36+
bl_usage_fault(void)
37+
{
38+
while(1) {}
39+
}
40+

src/platform/stm32h7/stm32h7.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ GLOBALDEPS += ${P}/stm32h7.mk
44

55
CPPFLAGS += -iquote${P} -include ${P}/stm32h7.h
66

7-
LDSCRIPT = ${P}/stm32h7.ld
7+
LDSCRIPT ?= ${P}/stm32h7$(if $(subst no,,${ENABLE_BUILTIN_BOOTLOADER}),_bootloader,).ld
8+
9+
ENTRYPOINT ?= $(if $(subst no,,${ENABLE_BUILTIN_BOOTLOADER}),bl_start,start)
810

911
include ${SRC}/cpu/cortexm/cortexm7.mk
1012

@@ -31,3 +33,8 @@ SRCS-${ENABLE_NET_IPV4} += \
3133

3234
${MOS}/platform/stm32h7/%.o : CFLAGS += ${NOFPU}
3335

36+
SRCS-${ENABLE_BUILTIN_BOOTLOADER} += \
37+
${P}/boot/stm32h7_bootloader.c \
38+
${P}/boot/isr.s \
39+
40+
${MOS}/platform/stm32h7/boot/stm32h7_bootloader.o : CFLAGS = -Os -ffreestanding -Wall -Werror -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -mgeneral-regs-only -include ${BOOTLOADER_DEFS}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MEMORY {
2+
BOOT (rx) : ORIGIN = 0x08000000, LENGTH = 128K
3+
VTBL (rx) : ORIGIN = 0x08020000, LENGTH = 1K
4+
FLASH (rx) : ORIGIN = 0x08020400, LENGTH = 383K
5+
RAM (xrw): ORIGIN = 0x20000400, LENGTH = 128K
6+
}
7+
8+
NOCROSSREFS(.boot .text)
9+
10+
SECTIONS {
11+
.boot : {
12+
. = ALIGN(4);
13+
KEEP(*(.bootloader_vector))
14+
*(bltext)
15+
*(bldata)
16+
. = ALIGN(4);
17+
} >BOOT
18+
}
19+
20+
INCLUDE cpu/cortexm/cortexm.ld

0 commit comments

Comments
 (0)