keyboards/zofle/flash.fish

38 lines
905 B
Fish
Raw Permalink Normal View History

2021-11-08 23:20:01 -06:00
#!/usr/bin/env fish
test (whoami) != root && begin
2024-06-24 16:16:41 -05:00
echo must be root
exit 1
2021-11-08 23:20:01 -06:00
end
set flash_target /dev/disk/by-label/NICENANO
set firmware_file $argv[1]
2024-06-24 16:16:41 -05:00
if test -z $firmware_file
echo no firmware file argument specified
exit 2
end
2021-11-08 23:20:01 -06:00
mkdir -p /tmp/flashmnt
while not test -L $flash_target
2024-06-24 16:16:41 -05:00
echo Waiting for mountable device $flash_target to become available to flash $firmware_file...
echo ' This usually means you need to plugin the board and reset it.'
echo ' This is done by plugging in the board and double-tapping the'
echo ' reset button with the nice!nano controllers this build uses.'
sleep 1
2021-11-08 23:20:01 -06:00
end
echo Mounting $flash_target to /tmp/flashmnt...
mount $flash_target /tmp/flashmnt
echo Copying $firmware_file to /tmp/flashmnt...
cp $firmware_file /tmp/flashmnt
echo Syncing...
sync
echo Unmounting /tmp/flashmnt...
umount -R /tmp/flashmnt
echo Done!