Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the NUCLEO-STM32F429ZI board. #1917

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ spin = { version = "0.9.4", default-features = false, features = ["mutex", "spin
ssmarshal = { version = "1.0.0", default-features = false }
static_assertions = { version = "1", default-features = false }
stm32f3 = { version = "0.13.0", default-features = false }
stm32f4 = { version = "0.13.0", default-features = false }
stm32f4 = { version = "0.15.1", default-features = false }
stm32h7 = { version = "0.14", default-features = false }
stm32g0 = { version = "0.15.1", default-features = false }
strsim = { version = "0.10.0", default-features = false }
Expand Down
19 changes: 14 additions & 5 deletions app/demo-stm32f4-discovery/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,30 @@ start = true
stacksize = 1536
notifications = ["fault", "timer"]

[tasks.sys]
name = "drv-stm32xx-sys"
priority = 1
max-sizes = {flash = 2048, ram = 256}
uses = ["rcc", "gpio"]
start = true
features = ["f407", "no-ipc-counters"]
stacksize = 256
task-slots = ["jefe"]

[tasks.rcc_driver]
name = "drv-stm32fx-rcc"
features = ["f4"]
features = ["f407"]
priority = 1
max-sizes = {flash = 8192, ram = 1024}
uses = ["rcc"]
start = true

[tasks.usart_driver]
name = "drv-stm32fx-usart"
features = ["stm32f4"]
features = ["f407"]
priority = 2
max-sizes = {flash = 8192, ram = 1024}
uses = ["usart2", "gpioa"]
uses = ["usart2", "gpio"]
start = true
notifications = ["usart-irq"]
interrupts = {"usart2.irq" = "usart-irq"}
Expand All @@ -41,9 +51,8 @@ name = "drv-user-leds"
features = ["stm32f4"]
priority = 2
max-sizes = {flash = 8192, ram = 1024}
uses = ["gpiod"]
start = true
task-slots = ["rcc_driver"]
task-slots = ["rcc_driver", "sys"]
notifications = ["timer"]

[tasks.ping]
Expand Down
30 changes: 30 additions & 0 deletions app/demo-stm32f4-nucleo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
edition = "2021"
readme = "README.md"
name = "demo-stm32f4-nucleo"
version = "0.1.0"

[features]
f429 = ["stm32f4/stm32f429", "kern/nano"]
dump = ["kern/dump"]

[dependencies]
cortex-m = { workspace = true }
cortex-m-rt = { workspace = true }
cfg-if = { workspace = true }
stm32f4 = { workspace = true, features = ["stm32f429", "rt"] }

kern = { path = "../../sys/kern" }

[build-dependencies]
build-util = {path = "../../build/util"}

# this lets you use `cargo fix`!
[[bin]]
name = "demo-stm32f4-nucleo"
test = false
doctest = false
bench = false

[lints]
workspace = true
1 change: 1 addition & 0 deletions app/demo-stm32f4-nucleo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# STM32F4 demo application for the NUCLEO-F429ZI board
86 changes: 86 additions & 0 deletions app/demo-stm32f4-nucleo/app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name = "demo-stm32f4-nucleo"
target = "thumbv7em-none-eabihf"
board = "stm32f429-nucleo"
chip = "../../chips/stm32f4"
stacksize = 896

[kernel]
name = "demo-stm32f4-nucleo"
requires = {flash = 20000, ram = 3072}

[tasks.jefe]
name = "task-jefe"
priority = 0
max-sizes = {flash = 8192, ram = 2048}
start = true
stacksize = 1536
notifications = ["fault", "timer"]

[tasks.sys]
name = "drv-stm32xx-sys"
priority = 1
max-sizes = {flash = 2048, ram = 256}
uses = ["rcc", "gpio"]
start = true
features = ["f429", "no-ipc-counters"]
stacksize = 256
task-slots = ["jefe"]

[tasks.rcc_driver]
name = "drv-stm32fx-rcc"
features = ["f429"]
priority = 1
max-sizes = {flash = 8192, ram = 1024}
uses = ["rcc"]
start = true

[tasks.usart_driver]
name = "drv-stm32fx-usart"
features = ["f429"]
priority = 2
max-sizes = {flash = 8192, ram = 1024}
uses = ["usart2", "gpio"]
start = true
notifications = ["usart-irq"]
interrupts = {"usart2.irq" = "usart-irq"}
task-slots = ["rcc_driver"]

[tasks.user_leds]
name = "drv-user-leds"
features = ["stm32f4"]
priority = 2
max-sizes = {flash = 8192, ram = 1024}
start = true
task-slots = ["rcc_driver", "sys"]
notifications = ["timer"]

[tasks.ping]
name = "task-ping"
features = ["uart"]
priority = 4
max-sizes = {flash = 8192, ram = 1024}
stacksize = 512
start = true
task-slots = [{peer = "pong"}, "usart_driver"]

[tasks.pong]
name = "task-pong"
priority = 3
max-sizes = {flash = 8192, ram = 1024}
start = true
task-slots = ["user_leds"]
notifications = ["timer"]

[tasks.hiffy]
name = "task-hiffy"
priority = 3
max-sizes = {flash = 16384, ram = 16384 }
stacksize = 2048
start = true

[tasks.idle]
name = "task-idle"
priority = 5
max-sizes = {flash = 128, ram = 256}
stacksize = 256
start = true
7 changes: 7 additions & 0 deletions app/demo-stm32f4-nucleo/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

fn main() {
build_util::expose_target_board();
}
19 changes: 19 additions & 0 deletions app/demo-stm32f4-nucleo/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#![no_std]
#![no_main]

// We have to do this if we don't otherwise use it to ensure its vector table
// gets linked in.
extern crate stm32f4;

use cortex_m_rt::entry;

#[entry]
fn main() -> ! {
const CYCLES_PER_MS: u32 = 16_000;

unsafe { kern::startup::start_kernel(CYCLES_PER_MS) }
}
2 changes: 2 additions & 0 deletions boards/stm32f429-nucleo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[probe-rs]
chip-name = "STM32F429ZITx"
8 changes: 2 additions & 6 deletions chips/stm32f4/chip.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ interrupts = { irq = 38 }
address = 0x40023800
size = 1024

[gpioa]
[gpio]
address = 0x40020000
size = 1024

[gpiod]
address = 0x40020c00
size = 1024
size = 16384
3 changes: 2 additions & 1 deletion drv/stm32fx-rcc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ userlib = { path = "../../sys/userlib", features = ["panic-messages"] }

[features]
f3 = ["stm32f3/stm32f303"]
f4 = ["stm32f4/stm32f407"]
f407 = ["stm32f4/stm32f407"]
f429 = ["stm32f4/stm32f429"]

# This section is here to discourage RLS/rust-analyzer from doing test builds,
# since test builds don't work for cross compilation.
Expand Down
5 changes: 4 additions & 1 deletion drv/stm32fx-rcc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@
#[cfg(feature = "stm32f3")]
use stm32f3::stm32f303 as device;

#[cfg(feature = "stm32f4")]
#[cfg(feature = "f407")]
use stm32f4::stm32f407 as device;

#[cfg(feature = "f429")]
use stm32f4::stm32f429 as device;

use userlib::*;
use zerocopy::AsBytes;

Expand Down
6 changes: 5 additions & 1 deletion drv/stm32fx-usart/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ edition = "2021"
[dependencies]
num-traits = { workspace = true }
stm32f3 = { workspace = true, optional = true, features = ["stm32f303"] }
stm32f4 = { workspace = true, optional = true, features = ["stm32f407"] }
stm32f4 = { workspace = true, optional = true }
zerocopy = { workspace = true }

userlib = { path = "../../sys/userlib", features = ["panic-messages"] }

[features]
f407 = [ "stm32f4/stm32f407" ]
f429 = [ "stm32f4/stm32f429" ]

[build-dependencies]
build-util = { path = "../../build/util" }

Expand Down
13 changes: 8 additions & 5 deletions drv/stm32fx-usart/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
#![no_std]
#![no_main]

#[cfg(feature = "stm32f4")]
#[cfg(feature = "f429")]
use stm32f4::stm32f429 as device;

#[cfg(feature = "f407")]
use stm32f4::stm32f407 as device;

#[cfg(feature = "stm32f3")]
Expand Down Expand Up @@ -74,7 +77,7 @@ fn main() -> ! {
.write(|w| w.brr().bits((CLOCK_HZ / BAUDRATE) as u16));
}

#[cfg(feature = "stm32f4")]
#[cfg(any(feature = "f407", feature = "f429"))]
{
const CLOCK_HZ: u32 = 16_000_000;
const CYCLES_PER_BIT: u32 = (CLOCK_HZ + (BAUDRATE / 2)) / BAUDRATE;
Expand Down Expand Up @@ -126,7 +129,7 @@ fn main() -> ! {

#[cfg(feature = "stm32f3")]
let txe = usart.isr.read().txe().bit();
#[cfg(feature = "stm32f4")]
#[cfg(any(feature = "f407", feature = "f429"))]
let txe = usart.sr.read().txe().bit();
if txe {
// TX register empty. Do we need to send something?
Expand Down Expand Up @@ -208,7 +211,7 @@ fn turn_on_gpioa() {

#[cfg(feature = "stm32f3")]
let pnum = 17; // see bits in AHBENR
#[cfg(feature = "stm32f4")]
#[cfg(any(feature = "f407", feature = "f429"))]
let pnum = 0; // see bits in AHB1ENR

let (code, _) = userlib::sys_send(
Expand Down Expand Up @@ -250,7 +253,7 @@ fn step_transmit(
// Stuff byte into transmitter.
#[cfg(feature = "stm32f3")]
usart.tdr.write(|w| w.tdr().bits(u16::from(byte)));
#[cfg(feature = "stm32f4")]
#[cfg(any(feature = "f407", feature = "f429"))]
usart.dr.write(|w| w.dr().bits(u16::from(byte)));

txs.pos += 1;
Expand Down
Loading