Skip to content

Commit 8f57225

Browse files
authored
Merge branch 'stm32-rs:master' into h723_ethernet
2 parents e8269a3 + a91052c commit 8f57225

24 files changed

+826
-375
lines changed

.github/bors.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
on:
22
push:
3-
branches: [ staging, trying, master ]
3+
branches: master
44
pull_request:
5+
merge_group:
56

67
name: Continuous integration
78

89
jobs:
910
ci:
11+
name: CI
12+
runs-on: ubuntu-latest
13+
needs: [check]
14+
if: always()
15+
steps:
16+
- name: Done
17+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
18+
19+
check:
1020
runs-on: ubuntu-latest
1121
strategy:
1222
matrix: # All permutations of {rust, mcu}

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"stm32h743v",
55
"defmt"
66
],
7-
"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
8-
}
7+
"rust-analyzer.check.allTargets": false,
8+
"rust-analyzer.check.targets": "thumbv7em-none-eabihf",
9+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

33
## Unreleased
4+
5+
* remove unused `bitflags` dependency
6+
* bors bot replaced with GH merge queue
47
* Update `smoltcp` dependency to `0.9.0`
58
* MSRV increased to 1.65.0
9+
* add `IntoAf` trait to restrict `into_alternate` [#346]
610

711
## [v0.14.0] 2023-03-22
812

@@ -335,6 +339,7 @@
335339
[#341]: https://github.com/stm32-rs/stm32h7xx-hal/pull/341
336340
[#344]: https://github.com/stm32-rs/stm32h7xx-hal/pull/344
337341
[#345]: https://github.com/stm32-rs/stm32h7xx-hal/pull/345
342+
[#346]: https://github.com/stm32-rs/stm32h7xx-hal/pull/346
338343
[#347]: https://github.com/stm32-rs/stm32h7xx-hal/pull/347
339344
[#350]: https://github.com/stm32-rs/stm32h7xx-hal/pull/350
340345
[#354]: https://github.com/stm32-rs/stm32h7xx-hal/pull/354

Cargo.toml

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@ nb = "1.0.0"
3939
paste = "1.0.1"
4040
bare-metal = "1.0.0"
4141
sdio-host = { version = "0.9", optional = true }
42-
embedded-sdmmc = { version = "0.4", optional = true }
42+
embedded-sdmmc = { version = "0.5", optional = true }
4343
stm32-fmc = { version = "0.3", optional = true }
4444
synopsys-usb-otg = { version = "^0.3.0", features = ["cortex-m"], optional = true }
4545
embedded-display-controller = { version = "^0.1.0", optional = true }
4646
log = { version = "0.4.14", optional = true} # see also the dev-dependencies section
47-
fdcan = { version = "0.1", optional = true }
48-
bitflags = { version = "2.0.0" }
47+
fdcan = { version = "0.2", optional = true }
4948
embedded-storage = "0.3"
5049

5150
[dependencies.smoltcp]
52-
version = "0.9.0"
51+
version = "0.10.0"
5352
default-features = false
5453
features = ["medium-ethernet", "proto-ipv4", "socket-raw"]
5554
optional = true
@@ -80,22 +79,27 @@ panic-semihosting = "0.6"
8079
usb-device = "0.2.5"
8180
usbd-serial = "0.1.0"
8281
numtoa = "0.2.3"
83-
tinybmp = "0.4"
84-
embedded-graphics = "0.7"
82+
tinybmp = "0.5"
83+
embedded-graphics = "0.8"
8584

8685
[dev-dependencies.smoltcp]
87-
version = "0.9.0"
86+
version = "0.10.0"
8887
default-features = false
8988
features = ["medium-ethernet", "proto-ipv4", "proto-ipv6", "socket-raw"]
9089

9190
[features]
9291
default = ["rt"]
9392
device-selected = []
9493
revision_v = []
95-
rm0433 = [] # aka. "single core" devices
96-
rm0399 = [] # aka. "dual core" devices
97-
rm0455 = [] # aka. "high memory integration" devices
98-
rm0468 = [] # aka. "high speed" devices
94+
rm0433 = ["gpio-h747"] # aka. "single core" devices
95+
rm0399 = ["gpio-h747"] # TODO: fix gpio # aka. "dual core" devices
96+
rm0455 = ["gpio-h7a2"] # aka. "high memory integration" devices
97+
rm0468 = ["gpio-h72"] # aka. "high speed" devices
98+
99+
gpio-h72 = []
100+
gpio-h747 = []
101+
gpio-h7a2 = []
102+
99103
dsi = []
100104
cm4 = []
101105
cm7 = []
@@ -143,45 +147,53 @@ debug = true # symbols are nice and they don't increase the size in flash
143147
lto = true # better optimizations
144148
opt-level = "s" # optimize for binary size
145149

150+
# The following examples do not build for all feature flag combinations. The
151+
# `required-features` field specifies the hal features and/or the hardware
152+
# configuration required by the example.
153+
146154
[[example]]
147-
name = "rtic"
148-
required-features = ["rt"]
155+
name = "can-echo"
156+
required-features = ["can"]
149157

150158
[[example]]
151-
name = "rtic_timers"
152-
required-features = ["rt", "rm0433"]
159+
name = "can-fd"
160+
required-features = ["can"]
153161

154162
[[example]]
155-
name = "vos0"
156-
required-features = ["revision_v", "rm0433"]
163+
name = "crc"
164+
required-features = ["crc"]
157165

158166
[[example]]
159-
name = "fmc"
160-
required-features = ["fmc", "rm0399"]
167+
name = "embedded-graphics"
168+
required-features = ["ltdc", "xspi", "rm0468"]
161169

162170
[[example]]
163-
name = "fmc_nand_flash"
164-
required-features = ["fmc"]
171+
name = "ethernet-stm32h747i-disco"
172+
required-features = ["rt", "stm32h747cm7", "ethernet"]
165173

166174
[[example]]
167-
name = "can-echo"
168-
required-features = ["can"]
175+
name = "ethernet-rtic-stm32h747i-disco"
176+
required-features = ["rt", "stm32h747cm7", "ethernet"]
169177

170178
[[example]]
171-
name = "can-fd"
172-
required-features = ["can"]
179+
name = "ethernet-rtic-stm32h735g-dk"
180+
required-features = ["rt", "stm32h735", "ethernet"]
173181

174182
[[example]]
175-
name = "qspi"
176-
required-features = ["xspi", "rm0433"]
183+
name = "ethernet-rtic-nucleo-h723zg"
184+
required-features = ["rt", "stm32h735", "ethernet"]
177185

178186
[[example]]
179-
name = "qspi_mdma"
180-
required-features = ["xspi", "rm0433"]
187+
name = "ethernet-nucleo-h743zi2"
188+
required-features = ["rt", "revision_v", "stm32h743v", "ethernet"]
181189

182190
[[example]]
183-
name = "qspi_flash_memory"
184-
required-features = ["xspi", "rm0433"]
191+
name = "fmc"
192+
required-features = ["fmc", "rm0399"]
193+
194+
[[example]]
195+
name = "fmc_nand_flash"
196+
required-features = ["fmc"]
185197

186198
[[example]]
187199
name = "octospi"
@@ -192,44 +204,48 @@ name = "octospi_hyperram"
192204
required-features = ["xspi", "rm0468"]
193205

194206
[[example]]
195-
name = "sdmmc"
196-
required-features = ["sdmmc"]
207+
name = "qspi"
208+
required-features = ["xspi", "rm0433"]
197209

198210
[[example]]
199-
name = "sdmmc_fat"
200-
required-features = ["sdmmc", "sdmmc-fatfs"]
211+
name = "qspi_mdma"
212+
required-features = ["xspi", "rm0433"]
201213

202214
[[example]]
203-
name = "embedded-graphics"
204-
required-features = ["ltdc", "xspi", "rm0468"]
215+
name = "qspi_flash_memory"
216+
required-features = ["xspi", "rm0433"]
205217

206218
[[example]]
207-
name = "ethernet-stm32h747i-disco"
208-
required-features = ["rt", "stm32h747cm7", "ethernet"]
219+
name = "rtc"
220+
required-features = ["rt", "rtc"]
209221

210222
[[example]]
211-
name = "ethernet-rtic-stm32h747i-disco"
212-
required-features = ["rt", "stm32h747cm7", "ethernet"]
223+
name = "rtic"
224+
required-features = ["rt"]
213225

214226
[[example]]
215-
name = "ethernet-rtic-stm32h735g-dk"
216-
required-features = ["rt", "stm32h735", "ethernet"]
227+
name = "rtic_timers"
228+
required-features = ["rt", "rm0433"]
217229

218230
[[example]]
219-
name = "ethernet-rtic-nucleo-h723zg"
220-
required-features = ["rt", "stm32h735", "ethernet"]
231+
name = "sdmmc"
232+
required-features = ["sdmmc"]
221233

222234
[[example]]
223-
name = "ethernet-nucleo-h743zi2"
224-
required-features = ["rt", "revision_v", "stm32h743v", "ethernet"]
235+
name = "sdmmc_fat"
236+
required-features = ["sdmmc", "sdmmc-fatfs"]
237+
238+
[[example]]
239+
name = "spi-dma-rtic"
240+
required-features = ["rt"]
225241

226242
[[example]]
227243
name = "tick_timer"
228244
required-features = ["rt"]
229245

230246
[[example]]
231247
name = "usb_serial"
232-
required-features = ["usb_hs"]
248+
required-features = ["usb_hs", "gpio-h747"]
233249

234250
[[example]]
235251
name = "usb_rtic"
@@ -244,17 +260,5 @@ name = "usb_phy_serial_interrupt"
244260
required-features = ["rt", "usb_hs", "rm0433"]
245261

246262
[[example]]
247-
name = "rtc"
248-
required-features = ["rt", "rtc"]
249-
250-
[[example]]
251-
name = "sai_dma_passthru"
252-
required-features = ["rm0433"]
253-
254-
[[example]]
255-
name = "spi-dma-rtic"
256-
required-features = ["rm0433","rt"]
257-
258-
[[example]]
259-
name = "crc"
260-
required-features = ["crc", "rt"]
263+
name = "vos0"
264+
required-features = ["revision_v"]

examples/ethernet-nucleo-h743zi2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//! The ethernet ring buffers are placed in SRAM3, where they can be
77
//! accessed by both the core and the Ethernet DMA.
88
//!
9-
//! This demo doesn't use smoltcp - see the stm32h747i-disco-rtic demo
9+
//! This demo does not use smoltcp - see the ethernet-rtic-stm32h747i-disco demo
10+
//! for an example of smoltcp
1011
#![deny(warnings)]
1112
#![no_main]
1213
#![no_std]

examples/ethernet-rtic-stm32h735g-dk.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#[allow(unused)]
1616
mod utilities;
1717

18+
use core::mem::MaybeUninit;
19+
use core::ptr::addr_of_mut;
1820
use core::sync::atomic::AtomicU32;
1921

2022
use smoltcp::iface::{Config, Interface, SocketSet, SocketStorage};
@@ -45,14 +47,13 @@ const MAC_ADDRESS: [u8; 6] = [0x02, 0x00, 0x11, 0x22, 0x33, 0x44];
4547
#[link_section = ".axisram.eth"]
4648
static mut DES_RING: ethernet::DesRing<4, 4> = ethernet::DesRing::new();
4749

48-
/// Net storage with static initialisation - another global singleton
50+
// This data will be held by Net through a mutable reference
4951
pub struct NetStorageStatic<'a> {
5052
socket_storage: [SocketStorage<'a>; 8],
5153
}
52-
static mut STORE: NetStorageStatic = NetStorageStatic {
53-
// Garbage
54-
socket_storage: [SocketStorage::EMPTY; 8],
55-
};
54+
// MaybeUninit allows us write code that is correct even if STORE is not
55+
// initialised by the runtime
56+
static mut STORE: MaybeUninit<NetStorageStatic> = MaybeUninit::uninit();
5657

5758
pub struct Net<'a> {
5859
iface: Interface,
@@ -64,11 +65,10 @@ impl<'a> Net<'a> {
6465
store: &'a mut NetStorageStatic<'a>,
6566
mut ethdev: ethernet::EthernetDMA<4, 4>,
6667
ethernet_addr: HardwareAddress,
68+
now: Instant,
6769
) -> Self {
68-
let mut config = Config::new();
69-
config.hardware_addr = Some(ethernet_addr);
70-
71-
let mut iface = Interface::new(config, &mut ethdev);
70+
let config = Config::new(ethernet_addr);
71+
let mut iface = Interface::new(config, &mut ethdev, now);
7272
// Set IP address
7373
iface.update_ip_addrs(|addrs| {
7474
let _ = addrs.push(IpCidr::new(IpAddress::v4(192, 168, 1, 99), 0));
@@ -188,8 +188,21 @@ mod app {
188188
unsafe { ethernet::enable_interrupt() };
189189

190190
// unsafe: mutable reference to static storage, we only do this once
191-
let store = unsafe { &mut STORE };
192-
let net = Net::new(store, eth_dma, mac_addr.into());
191+
let store = unsafe {
192+
let store_ptr = STORE.as_mut_ptr();
193+
194+
// Initialise the socket_storage field. Using `write` instead of
195+
// assignment via `=` to not call `drop` on the old, uninitialised
196+
// value
197+
addr_of_mut!((*store_ptr).socket_storage)
198+
.write([SocketStorage::EMPTY; 8]);
199+
200+
// Now that all fields are initialised we can safely use
201+
// assume_init_mut to return a mutable reference to STORE
202+
STORE.assume_init_mut()
203+
};
204+
205+
let net = Net::new(store, eth_dma, mac_addr.into(), Instant::ZERO);
193206

194207
// 1ms tick
195208
systick_init(ctx.core.SYST, ccdr.clocks);

0 commit comments

Comments
 (0)