Openblt to dfu jump fixed (#4367)

* OpenBLT: supress "target 'startup_xxxxxx.o' given more than once in the same rule" warning

* OpenBLT: check for DFU request, do not ignore dead beef
This commit is contained in:
Andrey G 2022-07-22 14:43:15 +03:00 committed by GitHub
parent 2a7cfbf3f5
commit bdaf1587d7
4 changed files with 48 additions and 3 deletions

View File

@ -85,7 +85,6 @@ PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/led.h
# CPU-dependent sources # CPU-dependent sources
ifeq ($(PROJECT_CPU),ARCH_STM32F4) ifeq ($(PROJECT_CPU),ARCH_STM32F4)
PROJ_FILES += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f4/openblt/lib/startup_stm32f429xx.s
# Collect bootloader port files # Collect bootloader port files
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM4_STM32F4/*.c) PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM4_STM32F4/*.c)
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM4_STM32F4/*.h) PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM4_STM32F4/*.h)
@ -97,7 +96,6 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F4)
# Port specific options # Port specific options
PORTFLAGS += -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 PORTFLAGS += -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
else ifeq ($(PROJECT_CPU),ARCH_STM32F7) else ifeq ($(PROJECT_CPU),ARCH_STM32F7)
PROJ_FILES += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/openblt/lib/startup_stm32f767xx.s
# Collect bootloader port files # Collect bootloader port files
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32F7/*.c) PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32F7/*.c)
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32F7/*.h) PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32F7/*.h)
@ -109,7 +107,6 @@ else ifeq ($(PROJECT_CPU),ARCH_STM32F7)
# Port specific options # Port specific options
PORTFLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 PORTFLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16
else ifeq ($(PROJECT_CPU),ARCH_STM32H7) else ifeq ($(PROJECT_CPU),ARCH_STM32H7)
# todo: do we need startup_stmXX.s here?
# Collect bootloader port files # Collect bootloader port files
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32H7/*.c) PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32H7/*.c)
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32H7/*.h) PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32H7/*.h)

View File

@ -59,6 +59,16 @@ defined in linker script */
.weak Reset_Handler .weak Reset_Handler
.type Reset_Handler, %function .type Reset_Handler, %function
Reset_Handler: Reset_Handler:
// Clive Two.Zero is the God of ST community forum
// Device specific, if in doubt RTFM
LDR R0, =0x2001FFF0 // End of SRAM for your CPU
LDR R1, =0xDEADBEEF // magic value
LDR R2, [R0, #0]
STR R0, [R0, #0] // Invalidate
CMP R2, R1
BEQ UseDFU
// DFU bootloader not needed, continue with OpenBLT
ldr sp, =_estack /* set stack pointer */ ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */ /* Copy the data segment initializers from flash to SRAM */
@ -98,6 +108,12 @@ LoopFillZerobss:
bx lr bx lr
.size Reset_Handler, .-Reset_Handler .size Reset_Handler, .-Reset_Handler
UseDFU:
// AN2606 Application note
// STM32 microcontroller system memory boot mode
.include "../../dfu_init.h"
BX R0 // this jumps to DFU bootloader
/** /**
* @brief This is the code that gets called when the processor receives an * @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving * unexpected interrupt. This simply enters an infinite loop, preserving

View File

@ -75,6 +75,16 @@ defined in linker script */
.weak Reset_Handler .weak Reset_Handler
.type Reset_Handler, %function .type Reset_Handler, %function
Reset_Handler: Reset_Handler:
// Clive Two.Zero is the God of ST community forum
// Device specific, if in doubt RTFM
LDR R0, =0x2001FFF0 // End of SRAM for your CPU
LDR R1, =0xDEADBEEF // magic value
LDR R2, [R0, #0]
STR R0, [R0, #0] // Invalidate
CMP R2, R1
BEQ UseDFU
// DFU bootloader not needed, continue with OpenBLT
ldr sp, =_estack /* set stack pointer */ ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */ /* Copy the data segment initializers from flash to SRAM */
@ -114,6 +124,12 @@ LoopFillZerobss:
bx lr bx lr
.size Reset_Handler, .-Reset_Handler .size Reset_Handler, .-Reset_Handler
UseDFU:
// AN2606 Application note
// STM32 microcontroller system memory boot mode
.include "../../dfu_init.h"
BX R0 // this jumps to DFU bootloader
/** /**
* @brief This is the code that gets called when the processor receives an * @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving * unexpected interrupt. This simply enters an infinite loop, preserving

View File

@ -59,6 +59,16 @@ defined in linker script */
.weak Reset_Handler .weak Reset_Handler
.type Reset_Handler, %function .type Reset_Handler, %function
Reset_Handler: Reset_Handler:
// Clive Two.Zero is the God of ST community forum
// Device specific, if in doubt RTFM
LDR R0, =0x2001FFF0 // End of SRAM for your CPU
LDR R1, =0xDEADBEEF // magic value
LDR R2, [R0, #0]
STR R0, [R0, #0] // Invalidate
CMP R2, R1
BEQ UseDFU
// DFU bootloader not needed, continue with OpenBLT
ldr sp, =_estack /* set stack pointer */ ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */ /* Copy the data segment initializers from flash to SRAM */
@ -98,6 +108,12 @@ LoopFillZerobss:
bx lr bx lr
.size Reset_Handler, .-Reset_Handler .size Reset_Handler, .-Reset_Handler
UseDFU:
// AN2606 Application note
// STM32 microcontroller system memory boot mode
.include "../../dfu_init.h"
BX R0 // this jumps to DFU bootloader
/** /**
* @brief This is the code that gets called when the processor receives an * @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving * unexpected interrupt. This simply enters an infinite loop, preserving