|
| 1 | +# Licensed under the Apache License, Version 2.0 or the MIT License. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 OR MIT |
| 3 | +# Copyright OxidOS Automotive 2026. |
| 4 | + |
| 5 | +# Makefile for building the tock kernel for the NUCLEO-U545RE-Q platform |
| 6 | +# |
| 7 | + |
| 8 | +include ../Makefile.common |
| 9 | + |
| 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. |
| 25 | + |
| 26 | +# Default target for installing the kernel. |
| 27 | +.PHONY: install |
| 28 | +install: flash |
| 29 | + |
| 30 | +.PHONY: flash-debug |
| 31 | +flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).elf |
| 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) |
| 37 | + |
| 38 | +.PHONY: flash |
| 39 | +flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).elf |
| 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) |
| 45 | + |
| 46 | +.PHONY: program |
| 47 | +program: |
| 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