Skip to content

Commit 44310bd

Browse files
authored
Merge pull request tock#4803 from OxidosAutomotive/board_nucleo_u545re_q
boards: Added board nucleo_u545re_q
2 parents 7caac25 + a31a6fa commit 44310bd

25 files changed

Lines changed: 3656 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,20 @@ dependencies = [
11121112
"tock_build_scripts",
11131113
]
11141114

1115+
[[package]]
1116+
name = "nucleo_u545re_q"
1117+
version = "0.2.3-dev"
1118+
dependencies = [
1119+
"capsules-core",
1120+
"capsules-extra",
1121+
"capsules-system",
1122+
"components",
1123+
"cortexm33",
1124+
"kernel",
1125+
"stm32u545",
1126+
"tock_build_scripts",
1127+
]
1128+
11151129
[[package]]
11161130
name = "opaque-debug"
11171131
version = "0.3.1"
@@ -1601,6 +1615,23 @@ dependencies = [
16011615
"kernel",
16021616
]
16031617

1618+
[[package]]
1619+
name = "stm32u545"
1620+
version = "0.2.3-dev"
1621+
dependencies = [
1622+
"cortexm33",
1623+
"kernel",
1624+
"stm32u5xx",
1625+
]
1626+
1627+
[[package]]
1628+
name = "stm32u5xx"
1629+
version = "0.2.3-dev"
1630+
dependencies = [
1631+
"cortexm33",
1632+
"kernel",
1633+
]
1634+
16041635
[[package]]
16051636
name = "stm32wle5jc"
16061637
version = "0.2.3-dev"

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ members = [
4040
"boards/sma_q3",
4141
"boards/nucleo_f429zi",
4242
"boards/nucleo_f446re",
43+
"boards/nucleo_u545re_q",
4344
"boards/particle_boron",
4445
"boards/pico_explorer_base",
4546
"boards/raspberry_pi_pico",
@@ -110,6 +111,8 @@ members = [
110111
"chips/stm32f429zi",
111112
"chips/stm32f446re",
112113
"chips/stm32f412g",
114+
"chips/stm32u545",
115+
"chips/stm32u5xx",
113116
"chips/stm32f4xx",
114117
"chips/veer_el2",
115118
"chips/stm32wle5xx",

arch/cortex-m33/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub mod mpu {
2525
}
2626
}
2727

28+
pub use cortexm::dma_fence;
2829
pub use cortexm::initialize_ram_jump_to_main;
2930
pub use cortexm::interrupt_mask;
3031
pub use cortexm::nvic;

boards/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ but the approximate definitions:
8989
| Board | Architecture | MCU | Interface | App deployment | QEMU Support? |
9090
|-------------------------------------------------------------------|------------------|----------------|------------|-----------------------------|---------------|
9191
| [WeAct F401CCU6 Core Board](weact_f401ccu6/README.md) | ARM Cortex-M4 | STM32F401CCU6 | openocd | custom | No |
92+
| [ST Nucleo U545RE-Q (skeleton)](nucleo_u545re_q/README.md) | ARM Cortex-M33 | STM32U545RE-Q | openocd | custom | No |
9293
| [SparkFun RedBoard Red-V](redboard_redv/README.md) | RISC-V | FE310-G002 | openocd | tockloader | Yes (5.1) |
9394
| [SiFive HiFive1 Rev B](hifive1/README.md) | RISC-V | FE310-G002 | openocd | tockloader | Yes (5.1) |
9495
| [BBC HiFive Inventor](hifive_inventor/README.md) | RISC-V | FE310-G003 | tockloader | tockloader | No |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Licensed under the Apache License, Version 2.0 or the MIT License.
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
# Copyright Tock Contributors 2024.
4+
5+
include = [
6+
"../../cargo/tock_flags.toml",
7+
"../../cargo/unstable_flags.toml",
8+
]
9+
10+
[build]
11+
target = "thumbv8m.main-none-eabi"
12+
13+
[unstable]
14+
config-include = true

boards/nucleo_u545re_q/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed under the Apache License, Version 2.0 or the MIT License.
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
# Copyright Tock Contributors 2024.
4+
5+
[package]
6+
name = "nucleo_u545re_q"
7+
version.workspace = true
8+
authors.workspace = true
9+
build = "../build.rs"
10+
edition.workspace = true
11+
12+
[dependencies]
13+
components = { path = "../components" }
14+
cortexm33 = { path = "../../arch/cortex-m33" }
15+
kernel = { path = "../../kernel" }
16+
stm32u545 = { path = "../../chips/stm32u545" }
17+
18+
capsules-core = { path = "../../capsules/core" }
19+
capsules-extra = { path = "../../capsules/extra" }
20+
capsules-system = { path = "../../capsules/system" }
21+
22+
[build-dependencies]
23+
tock_build_scripts = { path = "../build_scripts" }
24+
25+
[lints]
26+
workspace = true

boards/nucleo_u545re_q/Makefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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)

boards/nucleo_u545re_q/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# NUCLEO-U545RE-Q
2+
3+
The [NUCLEO-U545RE-Q](https://www.st.com/en/evaluation-tools/nucleo-u545re-q.html)
4+
is a development board based on the STM32U545RE microcontroller.
5+
6+
## Building
7+
8+
To build the kernel for this board, run `make` in this directory:
9+
10+
```bash
11+
cd boards/nucleo_u545re_q
12+
make
13+
```
14+
15+
## Programming and Deployment
16+
17+
The Makefile for this board is simplified to focus on OpenOCD-based deployment.
18+
19+
### Makefile Targets
20+
21+
| Target | Description |
22+
| :--- | :--- |
23+
| **`make`** | Compiles the Tock kernel for the Nucleo-U545RE-Q. |
24+
| **`make flash`** | Flashes the release kernel using `openocd`. |
25+
| **`make flash-debug`** | Flashes the debug kernel using `openocd`. |
26+
| **`make program`** | Installs apps using `tockloader` via `openocd`. Requires `APP`. |
27+
| **`make install`** | Alias for `make flash`. |
28+
29+
### Usage Examples
30+
31+
**1. Flash the release kernel:**
32+
```bash
33+
make flash
34+
```
35+
36+
**2. Flash the debug kernel:**
37+
```bash
38+
make flash-debug
39+
```
40+
41+
**3. Install an application:**
42+
Note: This requires a `.tab` (Tock Application Bundle) file.
43+
```bash
44+
make program APP=/path/to/your/app.tab
45+
```
46+
47+
## Flashing Notes
48+
49+
This board is flashed using **`openocd`**. The Makefile handles the necessary
50+
initialization and mass erase before programming.
51+
52+
### OpenOCD Requirements
53+
54+
The STM32U545 is a newer chip and is **not supported** by OpenOCD 0.12.0 or
55+
earlier. To use the OpenOCD targets, you must use **OpenOCD 0.12.0+dev** built
56+
from source.
57+
58+
#### Compiling OpenOCD from Source
59+
60+
If your system's OpenOCD is too old, follow these steps to compile a
61+
compatible version:
62+
63+
1. **Install dependencies**:
64+
```bash
65+
sudo apt update
66+
sudo apt install build-essential libusb-1.0-0-dev libftdi1-dev \
67+
libtool autoconf automake texinfo pkg-config
68+
```
69+
70+
2. **Clone and build**:
71+
```bash
72+
git clone https://github.com/openocd-org/openocd.git
73+
cd openocd
74+
git submodule update --init --recursive
75+
./bootstrap
76+
./configure --enable-stlink
77+
make -j$(nproc)
78+
sudo make install
79+
```
80+
81+
3. **Verify version**:
82+
```bash
83+
openocd --version
84+
# Should report 0.12.0+dev
85+
```
86+
87+
## Console
88+
89+
The kernel console is available on USART1 via the ST-LINK USB connection at
90+
115200 baud.

boards/nucleo_u545re_q/layout.ld

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Licensed under the Apache License, Version 2.0 or the MIT License. */
2+
/* SPDX-License-Identifier: Apache-2.0 OR MIT */
3+
/* Copyright Tock Contributors 2024. */
4+
/* Copyright OxidOS Automotive 2026. */
5+
6+
/* Memory layout for the STM32U545 (Secure Mode Aliases)
7+
* FLASH: 512 KB Total
8+
* KERNEL: 256 KB
9+
* APPS: 256 KB
10+
* RAM: 160 KB */
11+
12+
MEMORY
13+
{
14+
rom (rx) : ORIGIN = 0x0C000000, LENGTH = 0x00040000 /* 256 KB Kernel */
15+
prog (rx) : ORIGIN = 0x0C040000, LENGTH = 0x00040000 /* 256 KB Apps */
16+
ram (rwx) : ORIGIN = 0x30000000, LENGTH = 0x00028000 /* 160 KB */
17+
}
18+
19+
/*
20+
* Tock's generic linker script (tock_kernel_layout.ld) usually defines
21+
* _estack at the START of RAM for overflow protection.
22+
*
23+
* However, for this board in Secure Mode, we need it at the END of RAM
24+
* to prevent an immediate HardFault.
25+
*/
26+
_estack = ORIGIN(ram) + LENGTH(ram);
27+
28+
PAGE_SIZE = 8K;
29+
30+
INCLUDE tock_kernel_layout.ld

boards/nucleo_u545re_q/src/io.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed under the Apache License, Version 2.0 or the MIT License.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// Copyright Tock Contributors 2024.
4+
// Copyright OxidOS Automotive 2026.
5+
6+
use core::panic::PanicInfo;
7+
use kernel::debug;
8+
9+
/// Panic handler.
10+
#[panic_handler]
11+
pub unsafe fn panic_fmt(info: &PanicInfo) -> ! {
12+
let writer_config = stm32u545::usart::UsartPanicWriterConfig {
13+
base: stm32u545::usart::USART1_BASE,
14+
};
15+
16+
debug::panic_print::<stm32u545::usart::Usart, crate::ChipHw, crate::ProcessPrinterInUse>(
17+
writer_config,
18+
info,
19+
&cortexm33::support::nop,
20+
crate::PANIC_RESOURCES.get(),
21+
);
22+
23+
loop {}
24+
}

0 commit comments

Comments
 (0)