Skip to content

Commit b35abba

Browse files
authored
Update to nightly-2025-07-20 (#2160)
Currently, Hubris' Rust toolchain is pinned to `nightly-2024-09-17`, which is from 10 months ago. This is kind of unfortunate, especially because that nightly is too old to support the Rust 2024 edition, which means we cannot update our dependencies on any crates where the latest version is built with Rust 2024. Beyond just updating the toolchain, there were some noteworthy changes: - Naked functions are now stable (yay!), but the attribute changed to `#[unsafe(naked)]`. Inline assembly in naked functions must now use `core::arch::naked_asm!` rather than normal `asm!`. As far as I can tell, the only difference between this and regular `asm!` is that it does not support `options(noreturn)`, as I believe the `naked_asm!` block kind of implies at least some of the codegen differences for `noreturn`. - New warnings on creation of temporary shared references to mutable statics showed up in `stm32h7-update-server`, where we were using `[T]::as_ptr()` on zero-sized slices in mutable statics that were used to get linker-generated addresses. `[T]::as_ptr()` takes an `&self` receiver, so this was generating a temporary shared reference to the mutable static. I changed this to use `&raw const`, which takes the address of the static without creating a shared reference. - There was a substantial regression in flash and RAM usage on the new toolchain due to [a change in the behavior of the `#[used]` attribute][1] which revealed [an underlying issue where ringbufs were not zero initialized][2]. These issues were resolved separately in #2167, #2168, #2170, and oxidecomputer/idolatry#65. In addition, there were a variety of unremarkable linting changes, including slightly better dead code detection (which detected some new dead code), and some annoying clippy nonsense. Note that this branch requires oxidecomputer/idolatry#65, which updates `idol` to generate code that doesn't emit warnings with the new toolchain, and fixes some of the flash/RAM size regression in code generated by `idol`. Fixes #2165 [1]: #2165 (comment) [2]: #2165 (comment)
1 parent 86d3a0a commit b35abba

File tree

83 files changed

+395
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+395
-382
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ xtask = "run --package xtask --"
77
# version_detect is basically "if nightly { return true; }". This setting gets
88
# overridden within xtask for Hubris programs, so this only affects host tools like
99
# xtask.
10-
rustflags = ["-Zallow-features=proc_macro_diagnostic,asm_const,naked_functions,used_with_arg"]
10+
rustflags = ["-Zallow-features=proc_macro_diagnostic,used_with_arg"]
1111

1212
[unstable]
1313
bindeps = true

Cargo.lock

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

app/lpc55xpresso/app.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ priority = 3
115115
max-sizes = {flash = 16384, ram = 4096}
116116
uses = ["rng", "pmc"]
117117
start = true
118-
stacksize = 2200
118+
stacksize = 2216
119119
task-slots = ["syscon_driver"]
120120

121121
[tasks.pong]

app/medusa/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ version = "0.1.0"
66

77
[features]
88
dump = ["kern/dump"]
9+
traptrace = ["ringbuf"]
910

1011
[dependencies]
1112
cortex-m = { workspace = true }
1213
cortex-m-rt = { workspace = true }
1314
cfg-if = { workspace = true }
1415
stm32h7 = { workspace = true, features = ["rt", "stm32h753"] }
16+
ringbuf = { path = "../../lib/ringbuf", optional = true }
1517

1618
drv-stm32h7-startup = { path = "../../drv/stm32h7-startup", features = ["h753"] }
1719
kern = { path = "../../sys/kern" }

app/medusa/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ use drv_stm32h7_startup::ClockConfig;
1515

1616
use cortex_m_rt::entry;
1717

18+
#[cfg(feature = "traptrace")]
19+
mod tracing;
20+
1821
#[entry]
1922
fn main() -> ! {
2023
system_init();

app/medusa/src/tracing.rs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//
6+
// If you are cutting-and-pasting this code into another kernel (and that
7+
// kernel is armv6m), it is hoped that you will cut-and-paste this compile
8+
// error along with it and take heed of its admonition!
9+
//
10+
#[cfg(not(any(armv7m, armv8m)))]
11+
compile_error!("ringbuf is unsound in the kernel on armv6m");
12+
13+
use ringbuf::*;
14+
15+
#[derive(Copy, Clone, PartialEq)]
16+
enum Event {
17+
SyscallEnter(u32),
18+
SyscallExit,
19+
SecondarySyscallEnter,
20+
SecondarySyscallExit,
21+
IsrEnter,
22+
IsrExit,
23+
TimerIsrEnter,
24+
TimerIsrExit,
25+
ContextSwitch(usize),
26+
}
27+
28+
#[derive(Copy, Clone, PartialEq)]
29+
enum Trace {
30+
None,
31+
Event(Event),
32+
}
33+
34+
ringbuf!(Trace, 128, Trace::None);
35+
36+
fn trace(event: Event) {
37+
ringbuf_entry!(Trace::Event(event));
38+
}
39+
40+
fn syscall_enter(nr: u32) {
41+
trace(Event::SyscallEnter(nr));
42+
}
43+
44+
fn syscall_exit() {
45+
trace(Event::SyscallExit);
46+
}
47+
48+
fn secondary_syscall_enter() {
49+
trace(Event::SecondarySyscallEnter);
50+
}
51+
52+
fn secondary_syscall_exit() {
53+
trace(Event::SecondarySyscallExit);
54+
}
55+
56+
fn isr_enter() {
57+
trace(Event::IsrEnter);
58+
}
59+
60+
fn isr_exit() {
61+
trace(Event::IsrExit);
62+
}
63+
64+
fn timer_isr_enter() {
65+
trace(Event::TimerIsrEnter);
66+
}
67+
68+
fn timer_isr_exit() {
69+
trace(Event::TimerIsrExit);
70+
}
71+
72+
fn context_switch(addr: usize) {
73+
trace(Event::ContextSwitch(addr));
74+
}
75+
76+
static TRACING: kern::profiling::EventsTable = kern::profiling::EventsTable {
77+
syscall_enter,
78+
syscall_exit,
79+
secondary_syscall_enter,
80+
secondary_syscall_exit,
81+
isr_enter,
82+
isr_exit,
83+
timer_isr_enter,
84+
timer_isr_exit,
85+
context_switch,
86+
};
87+
88+
pub fn table() -> &'static kern::profiling::EventsTable {
89+
&TRACING
90+
}

app/rot-carrier/app.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ priority = 5
9595
max-sizes = {flash = 16384, ram = 4096}
9696
uses = ["rng", "pmc"]
9797
start = true
98-
stacksize = 2200
98+
stacksize = 2216
9999
task-slots = ["syscon_driver"]
100100

101101
[tasks.sprot]

build/call_rustfmt/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ pub fn rustfmt(path: impl AsRef<Path>) -> Result<()> {
2020

2121
let out_str = std::str::from_utf8(&which_out.stdout)?.trim();
2222

23-
println!("will invoke: {}", out_str);
23+
println!("will invoke: {out_str}");
2424

2525
let fmt_status = Command::new(out_str).arg(path.as_ref()).status()?;
2626
if !fmt_status.success() {
27-
bail!("rustfmt returned status {}", fmt_status);
27+
bail!("rustfmt returned status {fmt_status}");
2828
}
2929
Ok(())
3030
}

build/fpga-regmap/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn recurse_addr_map(
113113
)
114114
.unwrap();
115115
}
116-
_ => panic!("unexpected child {:?}", child),
116+
_ => panic!("unexpected child {child:?}"),
117117
}
118118
}
119119
}
@@ -607,10 +607,8 @@ pub fn build_peripheral(
607607

608608
let inst_name = inst_name.to_upper_camel_case();
609609
let struct_name: syn::Ident = syn::parse_str(&inst_name).unwrap();
610-
let handle_name: syn::Ident =
611-
syn::parse_str(&format!("{}Handle", inst_name)).unwrap();
612-
let view_name: syn::Ident =
613-
syn::parse_str(&format!("{}View", inst_name)).unwrap();
610+
let handle_name: syn::Ident = quote::format_ident!("{inst_name}Handle");
611+
let view_name: syn::Ident = quote::format_ident!("{inst_name}View");
614612
let reg_addr = base_addr
615613
+ u32::try_from(*periph_offset).unwrap()
616614
+ u32::try_from(*addr_offset).unwrap();
@@ -738,7 +736,7 @@ pub fn read_parse(p: &std::path::Path) -> anyhow::Result<Node> {
738736
std::fs::File::open(p)
739737
.with_context(|| format!("failed to open {p:?}"))?
740738
.read_to_end(&mut data)?;
741-
println!("cargo:rerun-if-changed={:?}", p);
739+
println!("cargo::rerun-if-changed={p:?}");
742740
let src = std::str::from_utf8(&data)?;
743741
let node: Node = serde_json::from_str(src)?;
744742
Ok(node)

0 commit comments

Comments
 (0)