Skip to content

Commit c48d046

Browse files
committed
Upgrade cortex-m-rt and PACs to ~2022
I noticed that our cortex-m-rt version was generating potentially invalid code in the Reset function -- setting up and tearing down a stack frame, before we've turned on RAM! This bug got fixed in the upstream cortex-m-rt crate, but we haven't upgraded in ... quite a while. This upgrades to a compromise point -- 0.15 of the stm32 pacs. Upgrading farther than that causes massive API incompatibilities, since it looks like they've comprehensively changed the svd2rust generated code. Rather than touch literally every driver in the system, I've settled on 0.15 and left 0.16 as a trap for the future. As you can see, this still required a fair amount of churn, mostly due to renamed enum variants.
1 parent ffa88b0 commit c48d046

File tree

8 files changed

+67
-74
lines changed

8 files changed

+67
-74
lines changed

Cargo.lock

Lines changed: 17 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ colored = { version = "2.0", default-features = false }
6363
convert_case = { version = "0.4", default-features = false }
6464
corncobs = { version = "0.1.1", default-features = false }
6565
cortex-m = { version = "0.7", default-features = false, features = ["inline-asm"]}
66-
cortex-m-rt = { version = "0.6.12", default-features = false }
66+
cortex-m-rt = { version = "0.7.5", default-features = false }
6767
cortex-m-semihosting = { version = "0.5.0", default-features = false }
6868
crc = { version = "3.0.0", default-features = false }
6969
critical-section = { version = "1.1.2" }
@@ -89,7 +89,7 @@ indexmap = { version = "1.4.0", default-features = false, features = ["serde-1"]
8989
indoc = { version = "2.0.3", default-features = false }
9090
itertools = { version = "0.10.5", default-features = false }
9191
leb128 = { version = "0.2.5", default-features = false }
92-
lpc55-pac = { version = "0.4", default-features = false }
92+
lpc55-pac = { version = "0.5", default-features = false }
9393
memchr = { version = "2.4", default-features = false }
9494
memoffset = { version = "0.6.5", default-features = false }
9595
minicbor = { version = "2.1.1", default-features = false }
@@ -127,10 +127,10 @@ ssh-key = { version = "0.6.6", default-features = false, features = ["std", "p25
127127
spin = { version = "0.9.4", default-features = false, features = ["mutex", "spin_mutex"]}
128128
ssmarshal = { version = "1.0.0", default-features = false }
129129
static_assertions = { version = "1", default-features = false }
130-
stm32f3 = { version = "0.13.0", default-features = false }
131-
stm32f4 = { version = "0.13.0", default-features = false }
132-
stm32h7 = { version = "0.14", default-features = false }
133-
stm32g0 = { version = "0.15.1", default-features = false }
130+
stm32f3 = { version = "0.15", default-features = false }
131+
stm32f4 = { version = "0.15", default-features = false }
132+
stm32h7 = { version = "0.15", default-features = false }
133+
stm32g0 = { version = "0.15", default-features = false }
134134
strsim = { version = "0.10.0", default-features = false }
135135
syn = { version = "2", default-features = false, features = ["derive", "parsing", "proc-macro", "extra-traits", "full", "printing"] }
136136
toml = { version = "0.9.6", default-features = false, features = ["parse", "display", "serde", "preserve_order"] }

app/gimlet/base.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ input = {port = "E", pin = 5, af = 5}
12881288
[config.spi.spi4.devices.rot]
12891289
mux = "rot"
12901290
cs = [{port = "E", pin = 4}]
1291-
clock_divider = "DIV256"
1291+
clock_divider = "Div256"
12921292

12931293
# VLAN configuration
12941294
[config.net.vlans.sidecar1]

app/gimlet/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ fn system_init() {
137137
// the prescaler.
138138
divm: 1,
139139
// VCO must tolerate an 8MHz input range:
140-
vcosel: device::rcc::pllcfgr::PLL1VCOSEL_A::WIDEVCO,
141-
pllrange: device::rcc::pllcfgr::PLL1RGE_A::RANGE8,
140+
vcosel: device::rcc::pllcfgr::PLL1VCOSEL_A::WideVco,
141+
pllrange: device::rcc::pllcfgr::PLL1RGE_A::Range8,
142142
// DIVN governs the multiplication of the VCO input frequency to produce
143143
// the intermediate frequency. We want an IF of 800MHz, or a
144144
// multiplication of 100x.
@@ -148,23 +148,23 @@ fn system_init() {
148148
divn: 100 - 1,
149149
// P is the divisor from the VCO IF to the system frequency. We want
150150
// 400MHz, so:
151-
divp: device::rcc::pll1divr::DIVP1_A::DIV2,
151+
divp: device::rcc::pll1divr::DIVP1_A::Div2,
152152
// Q produces kernel clocks; we set it to 200MHz:
153153
divq: 4 - 1,
154154
// R is mostly used by the trace unit and we leave it fast:
155155
divr: 2 - 1,
156156

157157
// We run the CPU at the full core rate of 400MHz:
158-
cpu_div: device::rcc::d1cfgr::D1CPRE_A::DIV1,
158+
cpu_div: device::rcc::d1cfgr::D1CPRE_A::Div1,
159159
// We down-shift the AHB by a factor of 2, to 200MHz, to meet its
160160
// constraints:
161-
ahb_div: device::rcc::d1cfgr::HPRE_A::DIV2,
161+
ahb_div: device::rcc::d1cfgr::HPRE_A::Div2,
162162
// We configure all APB for 100MHz. These are relative to the AHB
163163
// frequency.
164-
apb1_div: device::rcc::d2cfgr::D2PPRE1_A::DIV2,
165-
apb2_div: device::rcc::d2cfgr::D2PPRE2_A::DIV2,
166-
apb3_div: device::rcc::d1cfgr::D1PPRE_A::DIV2,
167-
apb4_div: device::rcc::d3cfgr::D3PPRE_A::DIV2,
164+
apb1_div: device::rcc::d2cfgr::D2PPRE1_A::Div2,
165+
apb2_div: device::rcc::d2cfgr::D2PPRE2_A::Div2,
166+
apb3_div: device::rcc::d1cfgr::D1PPRE_A::Div2,
167+
apb4_div: device::rcc::d3cfgr::D3PPRE_A::Div2,
168168

169169
// Flash runs at 200MHz: 2WS, 2 programming cycles. See reference manual
170170
// Table 13.

build/spi/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,24 @@ pub struct DeviceDescriptorConfig {
8585
pub cs: Vec<GpioPinConfig>,
8686
}
8787

88+
// N.B. the names in this enum _must_ match those used in the PAC!
8889
#[derive(Copy, Clone, Debug, Deserialize)]
8990
pub enum ClockDivider {
90-
DIV2,
91-
DIV4,
92-
DIV8,
93-
DIV16,
94-
DIV32,
95-
DIV64,
96-
DIV128,
97-
DIV256,
91+
Div2,
92+
Div4,
93+
Div8,
94+
Div16,
95+
Div32,
96+
Div64,
97+
Div128,
98+
Div256,
9899
}
99100

100101
impl Default for ClockDivider {
101102
fn default() -> ClockDivider {
102103
// When this config mechanism was introduced, we had everything set at
103-
// DIV64 for a ~1.5625 MHz SCK rate.
104-
Self::DIV64
104+
// Div64 for a ~1.5625 MHz SCK rate.
105+
Self::Div64
105106
}
106107
}
107108

drv/stm32h7-hash/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ impl Hash {
318318
// The hash is read out as words into little endian ARM world.
319319
// Since the bit order needs to be maintained, read as B.E.
320320
let result = [
321-
u32::from_be(self.reg.hash_hr0.read().bits()),
322-
u32::from_be(self.reg.hash_hr1.read().bits()),
323-
u32::from_be(self.reg.hash_hr2.read().bits()),
324-
u32::from_be(self.reg.hash_hr3.read().bits()),
325-
u32::from_be(self.reg.hash_hr4.read().bits()),
326-
u32::from_be(self.reg.hash_hr5.read().bits()),
327-
u32::from_be(self.reg.hash_hr6.read().bits()),
328-
u32::from_be(self.reg.hash_hr7.read().bits()),
321+
u32::from_be(self.reg.hash_hr[0].read().bits()),
322+
u32::from_be(self.reg.hash_hr[1].read().bits()),
323+
u32::from_be(self.reg.hash_hr[2].read().bits()),
324+
u32::from_be(self.reg.hash_hr[3].read().bits()),
325+
u32::from_be(self.reg.hash_hr[4].read().bits()),
326+
u32::from_be(self.reg.hash_hr[5].read().bits()),
327+
u32::from_be(self.reg.hash_hr[6].read().bits()),
328+
u32::from_be(self.reg.hash_hr[7].read().bits()),
329329
];
330330
out.clone_from_slice(result.as_bytes());
331331
Ok(())

drv/stm32h7-spi-server-core/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ impl SpiServerCore {
136136

137137
// This should correspond to '0' in the standard SPI parlance
138138
spi.initialize(
139-
device::spi1::cfg1::MBR_A::DIV64,
139+
device::spi1::cfg1::MBR_A::Div64,
140140
8,
141-
device::spi1::cfg2::COMM_A::FULLDUPLEX,
142-
device::spi1::cfg2::LSBFRST_A::MSBFIRST,
143-
device::spi1::cfg2::CPHA_A::FIRSTEDGE,
144-
device::spi1::cfg2::CPOL_A::IDLELOW,
145-
device::spi1::cfg2::SSOM_A::ASSERTED,
141+
device::spi1::cfg2::COMM_A::FullDuplex,
142+
device::spi1::cfg2::LSBFRST_A::Msbfirst,
143+
device::spi1::cfg2::CPHA_A::FirstEdge,
144+
device::spi1::cfg2::CPOL_A::IdleLow,
145+
device::spi1::cfg2::SSOM_A::Asserted,
146146
);
147147

148148
// Configure all devices' CS pins to be deasserted (set).

lib/endoscope/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const CLOCK_CONFIG: ClockConfig = ClockConfig {
2424
// the prescaler.
2525
divm: 1,
2626
// VCO must tolerate an 8MHz input range:
27-
vcosel: device::rcc::pllcfgr::PLL1VCOSEL_A::WIDEVCO,
28-
pllrange: device::rcc::pllcfgr::PLL1RGE_A::RANGE8,
27+
vcosel: device::rcc::pllcfgr::PLL1VCOSEL_A::WideVco,
28+
pllrange: device::rcc::pllcfgr::PLL1RGE_A::Range8,
2929
// DIVN governs the multiplication of the VCO input frequency to produce
3030
// the intermediate frequency. We want an IF of 800MHz, or a
3131
// multiplication of 100x.
@@ -35,23 +35,23 @@ const CLOCK_CONFIG: ClockConfig = ClockConfig {
3535
divn: 100 - 1,
3636
// P is the divisor from the VCO IF to the system frequency. We want
3737
// 400MHz, so:
38-
divp: device::rcc::pll1divr::DIVP1_A::DIV2,
38+
divp: device::rcc::pll1divr::DIVP1_A::Div2,
3939
// Q produces kernel clocks; we set it to 200MHz:
4040
divq: 4 - 1,
4141
// R is mostly used by the trace unit and we leave it fast:
4242
divr: 2 - 1,
4343

4444
// We run the CPU at the full core rate of 400MHz:
45-
cpu_div: device::rcc::d1cfgr::D1CPRE_A::DIV1,
45+
cpu_div: device::rcc::d1cfgr::D1CPRE_A::Div1,
4646
// We down-shift the AHB by a factor of 2, to 200MHz, to meet its
4747
// constraints:
48-
ahb_div: device::rcc::d1cfgr::HPRE_A::DIV2,
48+
ahb_div: device::rcc::d1cfgr::HPRE_A::Div2,
4949
// We configure all APB for 100MHz. These are relative to the AHB
5050
// frequency.
51-
apb1_div: device::rcc::d2cfgr::D2PPRE1_A::DIV2,
52-
apb2_div: device::rcc::d2cfgr::D2PPRE2_A::DIV2,
53-
apb3_div: device::rcc::d1cfgr::D1PPRE_A::DIV2,
54-
apb4_div: device::rcc::d3cfgr::D3PPRE_A::DIV2,
51+
apb1_div: device::rcc::d2cfgr::D2PPRE1_A::Div2,
52+
apb2_div: device::rcc::d2cfgr::D2PPRE2_A::Div2,
53+
apb3_div: device::rcc::d1cfgr::D1PPRE_A::Div2,
54+
apb4_div: device::rcc::d3cfgr::D3PPRE_A::Div2,
5555

5656
// Flash runs at 200MHz: 2WS, 2 programming cycles. See reference manual
5757
// Table 13.

0 commit comments

Comments
 (0)