52 lines
1.3 KiB
Bash
52 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
SOURCE_DIR="."
|
|
# Update this path if your system mounts the drive elsewhere
|
|
DEST_DIR="/run/media/$(whoami)/NICENANO"
|
|
|
|
CENTRAL_FILE="corne-rs-central.uf2"
|
|
PERIPHERAL_FILE="corne-rs-peripheral.uf2"
|
|
|
|
wait_and_copy() {
|
|
local file_to_copy=$1
|
|
local half_name=$2
|
|
|
|
echo ">>> Waiting to flash the $half_name half..."
|
|
echo " Connect the $half_name keyboard half to put it into bootloader mode."
|
|
|
|
while [[ ! -d "$DEST_DIR" ]]; do
|
|
sleep 1
|
|
done
|
|
|
|
echo " NICENANO drive detected for $half_name half."
|
|
# Brief pause to ensure the filesystem is fully mounted and ready
|
|
sleep 0.5
|
|
|
|
echo " Copying $file_to_copy..."
|
|
cp "$SOURCE_DIR/$file_to_copy" "$DEST_DIR/"
|
|
|
|
echo " Copy complete. Waiting for device to reboot and disconnect..."
|
|
|
|
while [[ -d "$DEST_DIR" ]]; do
|
|
sleep 1
|
|
done
|
|
|
|
echo " $half_name half has been flashed and disconnected."
|
|
echo
|
|
}
|
|
|
|
if [ ! -f "$SOURCE_DIR/$CENTRAL_FILE" ]; then
|
|
echo "Error: $CENTRAL_FILE not found in the current directory."
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$SOURCE_DIR/$PERIPHERAL_FILE" ]; then
|
|
echo "Error: $PERIPHERAL_FILE not found in the current directory."
|
|
exit 1
|
|
fi
|
|
|
|
wait_and_copy "$CENTRAL_FILE" "CENTRAL"
|
|
wait_and_copy "$PERIPHERAL_FILE" "PERIPHERAL"
|
|
|
|
echo ">>> All done. Both halves have been flashed."
|