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 May 22, 2024
1 parent cc918a9 commit fe142d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

- fido-authenticator: Implement the largeBlobKey extension and the largeBlobs command ([fido-authenticator#38][])
- piv: Fix crash when changing PUK ([piv-authenticator#38][])
- Improve external flash mounting to decrease startup time ([#440][])

[#440]: https://github.com/Nitrokey/nitrokey-3-firmware/issues/440
[fido-authenticator#38]: https://github.com/Nitrokey/fido-authenticator/issues/38
[piv-authenticator#38]: https://github.com/Nitrokey/piv-authenticator/issues/38

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trussed = { git = "https://github.com/Nitrokey/trussed.git", tag = "v0.1.0-nitro
apdu-dispatch = { git = "https://github.com/Nitrokey/apdu-dispatch.git", tag = "v0.1.2-nitrokey.3" }
ctap-types = { git = "https://github.com/trussed-dev/ctap-types.git", rev = "a9f8003a1d9f05f9eea39e615b9159bc0613fcb5" }
ctaphid-dispatch = { git = "https://github.com/Nitrokey/ctaphid-dispatch.git", tag = "v0.1.1-nitrokey.3" }
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "960e57d9fc0d209308c8e15dc26252bbe1ff6ba8" }
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "2ad77859559c02c7a464ab4d3290a318cf81422d" }
littlefs2-sys = { git = "https://github.com/trussed-dev/littlefs2-sys.git", rev = "39626c0dbc2f6c38b74889a5bf9d5a200614f121" }
usbd-ctaphid = { git = "https://github.com/trussed-dev/usbd-ctaphid.git", rev = "1db2e014f28669bc484c81ab0406c54b16bba33c" }
usbd-ccid = { git = "https://github.com/Nitrokey/usbd-ccid", tag = "v0.2.0-nitrokey.1" }
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::NoSpace) {
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 fe142d7

Please sign in to comment.