feat: Update flash script and modify to use MT for ctrl

This commit is contained in:
uttarayan21
2025-10-13 03:56:58 +05:30
parent 8052adf8a6
commit 4cfa9b3c52
2 changed files with 52 additions and 1 deletions

51
flash.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/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."