-
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.
Introduce side parameter in the flash.sh script.
- Loading branch information
1 parent
4792709
commit 2007322
Showing
1 changed file
with
34 additions
and
11 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 |
---|---|---|
@@ -1,25 +1,48 @@ | ||
#!/bin/sh | ||
|
||
# Function to display help message | ||
display_help() { | ||
echo "Usage: $0 [side]" | ||
echo "Mounts the nice!nano MCU for flashing the specified side (left or right) of the keyboard." | ||
echo "Example: $0 left" | ||
exit 1 | ||
} | ||
|
||
# Check if the script is run as root | ||
if [[ $UID != 0 ]]; then | ||
echo "Please run this script with sudo:" | ||
echo "sudo $0 $*" | ||
if [[ $EUID -ne 0 ]]; then | ||
echo "Please run this script as root" | ||
exit 1 | ||
fi | ||
|
||
# Check if argument is provided | ||
if [ $# -eq 0 ]; then | ||
echo "Error: No side specified" | ||
display_help | ||
fi | ||
|
||
# Check if the argument is valid | ||
if [ "$1" != "left" ] && [ "$1" != "right" ]; then | ||
echo "Error: Invalid side specified" | ||
display_help | ||
fi | ||
|
||
# Give some time to the user to mount the device. | ||
sleep 5 | ||
|
||
# Create a mount point | ||
mkdir -p /media/usb | ||
|
||
# Right | ||
sudo mount /dev/disk/by-id/usb-Adafruit_nRF_UF2_97A391CF144F945C-0:0 /media/usb | ||
sudo cp ./build/right/zephyr/zmk.uf2 /media/usb/ | ||
# Mount the USB drive based on the specified side | ||
if [ "$1" == "left" ]; then | ||
sudo mount /dev/disk/by-id/usb-Adafruit_nRF_UF2_38F4230B63B3DA6E-0:0 /media/usb | ||
sudo cp build/left/zephyr/zmk.uf2 /media/usb/ | ||
elif [ "$1" == "right" ]; then | ||
sudo mount /dev/disk/by-id/usb-Adafruit_nRF_UF2_97A391CF144F945C-0:0 /media/usb | ||
sudo cp build/right/zephyr/zmk.uf2 /media/usb/ | ||
fi | ||
|
||
# Left | ||
# sudo mount /dev/disk/by-id/usb-Adafruit_nRF_UF2_38F4230B63B3DA6E-0:0 /media/usb | ||
# sudo cp build/left/zephyr/zmk.uf2 /media/usb/ | ||
# End message | ||
echo "Flashing to $1 side completed." | ||
|
||
# sudo cp build/reset/zephyr/zmk.uf2 /media/usb | ||
# sudo cp ~/Downloads/zmk_clear.uf2 /media/usb | ||
# Exit script | ||
exit 0 |