Skip to content

Commit 3084591

Browse files
authored
Fix Cosmo flash capacity (#2098)
@rmustacc noticed that updating host flash didn't work over the management network on Cosmo. I reproduced this locally on a Grapefruit; this PR is the fix. The issue was that MGS uses `HostFlash::capacity` to decide how many sectors to erase. On Gimlet, this is the true capacity of a physical flash chip, of which there are two. On Cosmo, we instead split a single 1 GiB flash into 2× 32 MiB + 1× 64 MiB virtual devices. We were returning the full 1 GiB flash size, so MGS tried to erase outside the range of the 32 MiB virtual slot. On the bright side, Hubris correctly detects this and returned an `HfError::BadAddress`. The fix is to return a capacity of 32 MiB, because that's the capacity that MGS needs to know about.
1 parent 7032964 commit 3084591

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drv/cosmo-hf/src/hf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,16 @@ impl idl::InOrderHostFlashImpl for ServerImpl {
249249
Ok(self.drv.flash_read_id())
250250
}
251251

252+
/// Returns the capacity of each host flash slot
253+
///
254+
/// Note that this **is not** the total flash capacity; it's part of the
255+
/// `HostFlash` API, so we're pretending to be two distinct flash chips,
256+
/// each with a capacity of 32 MiB.
252257
fn capacity(
253258
&mut self,
254259
_: &RecvMessage,
255260
) -> Result<usize, RequestError<HfError>> {
256-
Ok(0x8000000) // 1 GBit = 128 MiB
261+
Ok(0x2000000) // 32 MiB
257262
}
258263

259264
/// Reads the STATUS_1 register from the SPI flash

0 commit comments

Comments
 (0)