forked from Nitrokey/nitrokey-3-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts to expose the Trussed store via FUSE
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ solo-bee.code-workspace | |
ref/ | ||
memory.x | ||
solo-state.bin | ||
bee.littlefs2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,8 @@ bacon: | |
run-dev: | ||
make -C $(RUNNER) run-dev | ||
|
||
mount-fs: | ||
scripts/fuse-bee | ||
|
||
umount-fs: | ||
scripts/defuse-bee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/bash -xe | ||
|
||
# load variable | ||
state=/tmp/bee-mount.state | ||
source ${state} | ||
|
||
# unmount | ||
umount ${mount} | ||
sudo losetup -d ${loop_device} | ||
rm ${state} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/bash -xe | ||
|
||
# Prerequisites: | ||
# | ||
# - lpc55: install via `cargo install lpc55-host` | ||
# - lfs: install via `yay -S littlefs2-fuse` | ||
# - the bee needs to be in ROM bootloader | ||
# - the mountpoint has to exist | ||
|
||
fs=./bee.littlefs2 | ||
fs_offset=$((512 * 1024)) # 512K, start of 3rd PRINCE section | ||
expected_fs_size=$((239 * 512)) # 119.5K, or 239 flash pages | ||
mount=/mnt/bee | ||
state=/tmp/bee-mount.state | ||
|
||
# check no previous mount | ||
if test -f $state; then | ||
set +x | ||
echo | ||
echo "File ${state} exists, this may indicate a mount already exists." | ||
echo "Clean up (scripts/defuse-bee), then try again." | ||
echo | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d $mount ]]; then | ||
set +x | ||
echo | ||
echo "Mountpoint ${mount} does not exist." | ||
echo "Create it and make it user accessible (chown ${USER} ${mount})." | ||
echo | ||
exit 1 | ||
fi | ||
|
||
# fetch the FS dump | ||
lpc55 read-memory --output-file ${fs} ${fs_offset} ${expected_fs_size} | ||
fs_size=$(stat -c%s ${fs}) | ||
if (( ${fs_size} != ${expected_fs_size} )); then | ||
exit 1 | ||
fi | ||
|
||
# mount it | ||
sudo modprobe loop | ||
loop_device=$(sudo losetup --find --show ${fs}) # block size default is our 512B | ||
sudo chmod a+rw ${loop_device} | ||
# mkdir -p ${mount} | ||
lfs ${loop_device} ${mount} | ||
printf "loop_device=${loop_device}\nmount=${mount}" > ${state} | ||
tree -h ${mount} |