Skip to content

Commit a31a6fa

Browse files
committed
Makefile: Changed from openocd to probe-rs for better stability
1 parent 770d7e5 commit a31a6fa

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

boards/nucleo_u545re_q/Makefile

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,44 @@
77

88
include ../Makefile.common
99

10-
OPENOCD=openocd
11-
OPENOCD_OPTIONS=-f interface/stlink.cfg -f target/stm32u5x.cfg
10+
# Toolchain Variables
11+
PROBE_RS ?= probe-rs
12+
CHIP = STM32U545RETx
13+
OBJCOPY ?= arm-none-eabi-objcopy
14+
15+
# NOTE: STM32U5 Metadata Stripping
16+
# The standard ELF file produced by the compiler contains metadata sections
17+
# (like .ARM.attributes) that sometimes point to System Memory addresses
18+
# (e.g., 0x0BFA0000). Many flashing tools, including probe-rs, will attempt
19+
# to write to these addresses, which are protected on the STM32U5, causing
20+
# the flash process to crash.
21+
#
22+
# We use 'objcopy -j' to extract ONLY the sections that belong
23+
# in the physical Flash memory (0x0C000000). This ensures a clean,
24+
# safe deployment to the hardware.
1225

1326
# Default target for installing the kernel.
1427
.PHONY: install
1528
install: flash
1629

1730
.PHONY: flash-debug
1831
flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).elf
19-
$(OPENOCD) $(OPENOCD_OPTIONS) -c "init; halt; stm32l4x mass_erase 0; program $< verify reset exit"
32+
@echo "--- Preparing Clean Debug Kernel ELF ---"
33+
$(OBJCOPY) -j .text -j .ARM.exidx -j .storage -j .relocate $< $<.clean
34+
@echo "--- Flashing Debug Kernel via probe-rs ---"
35+
$(PROBE_RS) download --chip $(CHIP) --allow-erase-all $<.clean
36+
$(PROBE_RS) reset --chip $(CHIP)
2037

2138
.PHONY: flash
2239
flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).elf
23-
$(OPENOCD) $(OPENOCD_OPTIONS) -c "init; halt; stm32l4x mass_erase 0; program $< verify reset exit"
40+
@echo "--- Preparing Clean Release Kernel ELF ---"
41+
$(OBJCOPY) -j .text -j .ARM.exidx -j .storage -j .relocate $< $<.clean
42+
@echo "--- Flashing Release Kernel via probe-rs ---"
43+
$(PROBE_RS) download --chip $(CHIP) --allow-erase-all $<.clean
44+
$(PROBE_RS) reset --chip $(CHIP)
2445

2546
.PHONY: program
2647
program:
27-
tockloader install --openocd --board nucleo_u545re_q $(APP)
48+
# Note: tockloader does not natively wrap probe-rs yet.
49+
# The --openocd flag was removed; tockloader will use its default method (usually serial/jlink).
50+
tockloader install --board nucleo_u545re_q $(APP)

0 commit comments

Comments
 (0)