Conversation
|
The test is done on ast2600 DC-SCM2.0 board. It requires to release ast2600 which depends on spi monitor functions in #36 |
|
Files reviewed:
Summary Table
Soundness1. No singleton enforcement — aliased hardware access
The canonical embedded-Rust pattern is to consume the PAC peripheral tokens so the type system enforces exclusive ownership at compile time. // Current — a second call creates aliased &'static references
pub fn new(logger: L) -> Self {
let i2cfilter_glb = unsafe { &*I2cfilter::PTR };
...
}
// Idiomatic — moves the PAC tokens in, preventing a second instantiation
pub fn new(
glb: I2cfilter,
thr0: I2cFilterThr,
thr1: I2cFilterThr1,
thr2: I2cFilterThr2,
thr3: I2cFilterThr3,
logger: L,
) -> Self { ... }2. Stack address written to hardware as a DMA/table pointer// src/i2cmonitor.rs — set_dev_white_list_tbl
let table_ptr = core::ptr::from_ref::<AstI2cFMTbl>(&self.i2cfilter_tbl[index]) as u32;
self.i2cfilter_thrs[index]
.i2cfilterthr08()
.write(|w| unsafe { w.addr().bits(table_ptr) });Two problems:
// Required on both types
#[repr(C)]
pub struct AstI2cFBitmap { ... }
#[repr(C)]
pub struct AstI2cFMTbl { ... }Bugs3.
|
|
No description provided.