Skip to content

Commit

Permalink
Mount EFS only once
Browse files Browse the repository at this point in the history
With this patch, the EFS is only mounted once if it is mountable.  This
significantly reduces bootup time by approximately 0.5 s.

Fixes: #440
  • Loading branch information
robin-nitrokey committed Oct 25, 2024
1 parent 53f8d89 commit 4a04517
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
- admin-app: Add command to list all supported config fields ([admin-app#28][])
- admin-app: Add `opcard.disabled` configuration option to disable OpenPGP ([#539][])
- piv: Use SE050 and encrypt data on external flash ([#534][])
- Improve external flash mounting to decrease startup time ([#440][])

[admin-app#28]: https://github.com/Nitrokey/admin-app/issues/28
[fido-authenticator#38]: https://github.com/Nitrokey/fido-authenticator/issues/38
[piv-authenticator#38]: https://github.com/Nitrokey/piv-authenticator/issues/38
[#440]: https://github.com/Nitrokey/nitrokey-3-firmware/issues/440
[#524]: https://github.com/Nitrokey/nitrokey-3-firmware/pull/524
[#534]: https://github.com/Nitrokey/nitrokey-3-firmware/pull/534
[#539]: https://github.com/Nitrokey/nitrokey-3-firmware/pull/539
Expand Down
11 changes: 6 additions & 5 deletions components/boards/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,17 @@ fn init_efs<B: Board>(
simulated_efs: bool,
status: &mut InitStatus,
) -> LfsResult<Filesystem<'static, B::ExternalStorage>> {
if !Filesystem::is_mountable(efs_storage) {
let fmt_ext = Filesystem::format(efs_storage);
Filesystem::mount_or_else(efs_alloc, efs_storage, |_err, storage| {
error_now!("EFS Mount Error {:?}", _err);
let fmt_ext = Filesystem::format(storage);
if simulated_efs && fmt_ext == Err(littlefs2::io::Error::NO_SPACE) {
info_now!("Formatting simulated EFS failed as expected");
} else {
error_now!("EFS Mount Error, Reformat {:?}", fmt_ext);
error_now!("EFS Reformat {:?}", fmt_ext);
status.insert(InitStatus::EXTERNAL_FLASH_ERROR);
}
};
Filesystem::mount(efs_alloc, efs_storage)
Ok(())
})
}

#[inline(always)]
Expand Down

0 comments on commit 4a04517

Please sign in to comment.