Add build option for UF2 flash offset

This commit is contained in:
Lucian Copeland 2020-01-31 13:12:58 -05:00
parent d8016bd52b
commit b4dcecb266
7 changed files with 41 additions and 31 deletions

View File

@ -90,9 +90,6 @@ else
### CFLAGS += -flto ### CFLAGS += -flto
endif endif
ifndef BOOTLOADER_OFFSET
BOOTLOADER_OFFSET := 0x8000000
endif
C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU) C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU)
@ -115,6 +112,22 @@ CFLAGS += \
# TODO: check this # TODO: check this
CFLAGS += -D__START=main CFLAGS += -D__START=main
#need both command and valid file to use uf2 bootloader
ifndef LD_FILE
ifneq ($(and $(UF2_BOOTLOADER),$(LD_BOOT)),)
LD_FILE = $(LD_BOOT)
BOOTLOADER_OFFSET = $(UF2_OFFSET)
CFLAGS += -DUF2_BOOTLOADER_ENABLED
else
LD_FILE = $(LD_FS)
endif
endif
# Add bootloader specific items
ifndef BOOTLOADER_OFFSET
BOOTLOADER_OFFSET := 0x8000000
endif
LDFLAGS = $(CFLAGS) -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LDFLAGS = $(CFLAGS) -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
LIBS := -lgcc -lc LIBS := -lgcc -lc

View File

@ -41,7 +41,9 @@
#define SPI_FLASH_CS_PIN (&pin_PA15) #define SPI_FLASH_CS_PIN (&pin_PA15)
// Bootloader only // Bootloader only
#ifdef UF2_BOOTLOADER_ENABLED
#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader #define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
#endif
#define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SCL (&pin_PB06)
#define DEFAULT_I2C_BUS_SDA (&pin_PB07) #define DEFAULT_I2C_BUS_SDA (&pin_PB07)

View File

@ -9,12 +9,12 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = GD25Q16C EXTERNAL_FLASH_DEVICES = GD25Q16C
LONGINT_IMPL = MPZ LONGINT_IMPL = MPZ
BOOTLOADER_OFFSET = 0x8010000
MCU_SERIES = m4 MCU_SERIES = m4
MCU_VARIANT = stm32f4 MCU_VARIANT = stm32f4
MCU_SUB_VARIANT = stm32f405xx MCU_SUB_VARIANT = stm32f405xx
MCU_PACKAGE = 64 MCU_PACKAGE = 64
CMSIS_MCU = STM32F405xx CMSIS_MCU = STM32F405xx
LD_FILE = boards/STM32F405_boot.ld # use for bootloader (external fs only)
# LD_FILE = boards/STM32F405_fs.ld # use for internal filesystem LD_FS = boards/STM32F405_fs.ld # Default to internal FS
LD_BOOT = boards/STM32F405_boot.ld # UF2 boot option
UF2_OFFSET = 0x8010000

View File

@ -13,5 +13,4 @@ MCU_SUB_VARIANT = stm32f405xx
MCU_PACKAGE = 64 MCU_PACKAGE = 64
CMSIS_MCU = STM32F405xx CMSIS_MCU = STM32F405xx
LD_FILE = boards/STM32F405.ld LD_FILE = boards/STM32F405.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08010000

View File

@ -18,5 +18,4 @@ MCU_SUB_VARIANT = stm32f411xe
MCU_PACKAGE = 48 MCU_PACKAGE = 48
CMSIS_MCU = STM32F411xE CMSIS_MCU = STM32F411xE
LD_FILE = boards/STM32F411VETx_FLASH.ld LD_FILE = boards/STM32F411VETx_FLASH.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000

View File

@ -13,5 +13,3 @@ MCU_SUB_VARIANT = stm32f411xe
MCU_PACKAGE = 100 MCU_PACKAGE = 100
CMSIS_MCU = STM32F411xE CMSIS_MCU = STM32F411xE
LD_FILE = boards/STM32F411VETx_FLASH.ld LD_FILE = boards/STM32F411VETx_FLASH.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000

View File

@ -18,6 +18,5 @@ MCU_SUB_VARIANT = stm32f412zx
MCU_PACKAGE = 144 MCU_PACKAGE = 144
CMSIS_MCU = STM32F412Zx CMSIS_MCU = STM32F412Zx
LD_FILE = boards/STM32F412ZGTx_FLASH.ld LD_FILE = boards/STM32F412ZGTx_FLASH.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000