@@ -34,7 +34,13 @@ include ../../../py/mkenv.mk
3434include $(BOARD_DIR ) /mpconfigboard.mk
3535
3636# A board can set MBOOT_TEXT0_ADDR to a custom location where mboot should reside.
37+ ifeq ($(MCU_SERIES ) ,n6)
38+ MBOOT_TEXT0_ADDR ?= 0x34180400
39+ MBOOT_LD_FILES ?= stm32_memory_n6.ld stm32_sections.ld
40+ else
3741MBOOT_TEXT0_ADDR ?= 0x08000000
42+ MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld
43+ endif
3844
3945# The string in MBOOT_VERSION (default defined in version.c if not defined by a
4046# board) will be stored in the final MBOOT_VERSION_ALLOCATED_BYTES bytes of mboot flash.
@@ -89,7 +95,6 @@ CFLAGS += -DMBOOT_VERSION=\"$(MBOOT_VERSION)\"
8995endif
9096CFLAGS += -DMBOOT_VERSION_ALLOCATED_BYTES=$(MBOOT_VERSION_ALLOCATED_BYTES ) -DMBOOT_VERSION_INCLUDE_OPTIONS=$(MBOOT_VERSION_INCLUDE_OPTIONS )
9197
92- MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld
9398LDFLAGS += -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES ) ) -Map=$(@:.elf=.map ) --cref
9499LDFLAGS += --defsym mboot_version_len=$(MBOOT_VERSION_ALLOCATED_BYTES )
95100LIBS += $(shell $(CC ) $(CFLAGS ) -print-libgcc-file-name)
@@ -137,12 +142,11 @@ SRC_C += \
137142 drivers/bus/softqspi.c \
138143 drivers/memory/spiflash.c \
139144 ports/stm32/flash.c \
140- ports/stm32/flashbdev.c \
141145 ports/stm32/i2cslave.c \
142146 ports/stm32/powerctrlboot.c \
143147 ports/stm32/qspi.c \
144- ports/stm32/spibdev.c \
145148 ports/stm32/usbd_conf.c \
149+ ports/stm32/xspi.c \
146150 $(wildcard $(BOARD_DIR ) /* .c)
147151
148152SRC_O += \
@@ -169,16 +173,22 @@ SRC_HAL += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_,\
169173 hal.c \
170174 hal_cortex.c \
171175 hal_dma.c \
172- hal_flash.c \
173- hal_flash_ex.c \
174176 hal_pcd.c \
175177 hal_pcd_ex.c \
176178 hal_pwr_ex.c \
177179 hal_rcc.c \
178180 hal_rcc_ex.c \
181+ ll_rcc.c \
179182 ll_usb.c \
180183 )
181184
185+ ifneq ($(MCU_SERIES ) ,n6)
186+ SRC_HAL += $(addprefix $(STM32LIB_HAL_BASE ) /Src/stm32$(MCU_SERIES ) xx_,\
187+ hal_flash.c \
188+ hal_flash_ex.c \
189+ )
190+ endif
191+
182192ifeq ($(MCU_SERIES ) ,$(filter $(MCU_SERIES ) ,f4 f7 h7) )
183193SRC_HAL += $(addprefix $(STM32LIB_HAL_BASE ) /Src/stm32$(MCU_SERIES ) xx_,\
184194 hal_mmc.c \
@@ -187,6 +197,12 @@ SRC_HAL += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_,\
187197 )
188198endif
189199
200+ ifeq ($(MCU_SERIES ) ,n6)
201+ SRC_HAL += $(addprefix $(STM32LIB_HAL_BASE ) /Src/stm32$(MCU_SERIES ) xx_,\
202+ hal_bsec.c \
203+ )
204+ endif
205+
190206SRC_USBDEV += $(addprefix ports/stm32/$(USBDEV_DIR ) /,\
191207 core/src/usbd_core.c \
192208 core/src/usbd_ctlreq.c \
@@ -206,7 +222,7 @@ $(TOP)/lib/stm32lib/README.md:
206222 $(ECHO ) " stm32lib submodule not found, fetching it now..."
207223 (cd $( TOP) && git submodule update --init lib/stm32lib)
208224
209- .PHONY : deploy deploy-stlink
225+ .PHONY : deploy deploy-stlink deploy-trusted
210226
211227deploy : $(BUILD ) /firmware.dfu
212228 $(ECHO ) " Writing $< to the board"
@@ -216,9 +232,15 @@ deploy-stlink: $(BUILD)/firmware.dfu
216232 $(ECHO ) " Writing $< to the board via ST-LINK"
217233 $(Q )$(STFLASH ) write $(BUILD ) /firmware.bin $(MBOOT_TEXT0_ADDR )
218234
219- $(BUILD ) /firmware.dfu : $(BUILD ) /firmware.elf
235+ deploy-trusted : $(BUILD ) /firmware-trusted.bin
236+ $(STM32_CUBE_PROGRAMMER ) /bin/STM32_Programmer.sh -c port=SWD mode=HOTPLUG ap=1 -el $(DKEL ) -w $^ 0x70000000 -hardRst
237+
238+ $(BUILD ) /firmware.bin : $(BUILD ) /firmware.elf
220239 $(ECHO ) " Create $@ "
221240 $(Q )$(OBJCOPY ) -O binary -j .isr_vector -j .text -j .data -j .mboot_version_text $^ $(BUILD ) /firmware.bin
241+
242+ $(BUILD ) /firmware.dfu : $(BUILD ) /firmware.bin
243+ $(ECHO ) " Create $@ "
222244 $(Q )$(PYTHON ) $(DFU ) -b $(MBOOT_TEXT0_ADDR ) :$(BUILD ) /firmware.bin $@
223245
224246$(BUILD ) /firmware.hex : $(BUILD ) /firmware.elf
@@ -230,6 +252,10 @@ $(BUILD)/firmware.elf: $(OBJ)
230252 $(Q )$(LD ) $(LDFLAGS ) -o $@ $^ $(LIBS )
231253 $(Q )$(SIZE ) $@
232254
255+ $(BUILD ) /firmware-trusted.bin : $(BUILD ) /firmware.bin
256+ /bin/rm -f $@
257+ $(STM32_CUBE_PROGRAMMER ) /bin/STM32_SigningTool_CLI -bin $^ -nk -of 0x80000000 -t fsbl -o $@ -hv $(STM32_N6_HEADER_VERSION )
258+
233259# ########################################
234260# Rules to generate header files
235261
0 commit comments