mirror of
https://github.com/solokeys/solo2.git
synced 2026-03-11 17:15:15 -07:00
50 lines
1.2 KiB
Bash
Executable File
50 lines
1.2 KiB
Bash
Executable File
#!/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}
|