Mentions légales du service

Skip to content
Snippets Groups Projects
Commit fc422e3d authored by DE ALMEIDA BRAGA Daniel's avatar DE ALMEIDA BRAGA Daniel
Browse files

Update installer - interactive mode for media path

parent fbb14b11
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
# Script for installing pico-ducky on a Raspberry Pi Pico 2
# Just plug in the Pi, and let the script guide you
# Should work in most versions of Ubuntu
CIRCUITPYTHON_BUNDLE_VERSION="9.x"
CIRCUITPYTHON_BUNDLE_FILE="adafruit-circuitpython-bundle-9.x-mpy-20241012.zip"
......@@ -10,22 +8,27 @@ CIRCUITPYTHON_VERSION="9.2.0-beta.1"
CIRCUITPYTHON_LANG="fr"
CIRCUITPYTHON_FILE="adafruit-circuitpython-raspberry_pi_pico2-${CIRCUITPYTHON_LANG}-${CIRCUITPYTHON_VERSION}.uf2"
MEDIA_PATH="/media"
PI_NAME="RP2350" # "RPI-RP2" for pico 1
waitForFile() {
FILETOWAITFOR=$1
set +e
while true
do
ls $FILETOWAITFOR &> /dev/null
if [ "$?" -eq 0 ]
then
break
fi
echo "Waiting for $FILETOWAITFOR to appear..."
sleep 2
done
set -e
FILETOWAITFOR=$1
set +e
while true
do
ls $FILETOWAITFOR &> /dev/null
if [ "$?" -eq 0 ]
then
break
fi
echo "Waiting for $FILETOWAITFOR to appear..."
read -p "Press [Enter] to retry or provide the correct path: " USER_INPUT
if [ -n "$USER_INPUT" ]; then
FILETOWAITFOR="$USER_INPUT"
fi
sleep 2
done
set -e
}
set -e
......@@ -40,9 +43,9 @@ CACHED=$?
set -e
if [ "$CACHED" -eq 0 ]
then
echo "Using cached ${CIRCUITPYTHON_FILE}"
echo "Using cached ${CIRCUITPYTHON_FILE}"
else
wget -nv https://downloads.circuitpython.org/bin/raspberry_pi_pico2/${CIRCUITPYTHON_LANG}/${CIRCUITPYTHON_FILE}
wget -nv https://downloads.circuitpython.org/bin/raspberry_pi_pico2/${CIRCUITPYTHON_LANG}/${CIRCUITPYTHON_FILE}
fi
echo "Downloading CircuitPython bundle $CIRCUITPYTHON_BUNDLE_VERSION"
......@@ -53,9 +56,9 @@ CACHED=$?
set -e
if [ "$CACHED" -eq 0 ]
then
echo "Using cached $CIRCUITPYTHON_BUNDLE_FILE"
echo "Using cached $CIRCUITPYTHON_BUNDLE_FILE"
else
wget -nv https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20241012/$CIRCUITPYTHON_BUNDLE_FILE
wget -nv https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20241012/$CIRCUITPYTHON_BUNDLE_FILE
fi
echo "Downloading flash_nuke.uf2"
......@@ -65,9 +68,9 @@ CACHED=$?
set -e
if [ "$CACHED" -eq 0 ]
then
echo "Using cached flash_nuke.uf2"
echo "Using cached flash_nuke.uf2"
else
wget -nv https://datasheets.raspberrypi.com/soft/flash_nuke.uf2
wget -nv https://datasheets.raspberrypi.com/soft/flash_nuke.uf2
fi
echo "Downloading additional keyboard layouts"
......@@ -78,35 +81,34 @@ CACHED=$?
set -e
if [ "$CACHED" -eq 0 ]
then
echo "Using cached circuitpython-keyboard-layouts-py-20231122.zip"
echo "Using cached circuitpython-keyboard-layouts-py-20231122.zip"
else
wget -nv https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/releases/download/20231122/circuitpython-keyboard-layouts-py-20231122.zip
wget -nv https://github.com/Neradoc/Circuitpython_Keyboard_Layouts/releases/download/20231122/circuitpython-keyboard-layouts-py-20231122.zip
fi
unzip -q -o "*.zip"
echo "Hold the button on the Pico 2 and plug it in so it shows up as mass storage device \"${PI_NAME}\""
waitForFile "/media/*/${PI_NAME}"
echo "Hold the button on the Pico 2 and plug it in so it shows up as mass storage device "${PI_NAME}""
waitForFile "${MEDIA_PATH}/*/${PI_NAME}"
echo "Installing flash_nuke"
cd /media/*/${PI_NAME}
cd ${MEDIA_PATH}/*/${PI_NAME}
cp $CACHEDIR/flash_nuke.uf2 .
echo "Done"
echo "Waiting for the Pico to reboot..."
sleep 3
waitForFile "/media/*/${PI_NAME}"
waitForFile "${MEDIA_PATH}/*/${PI_NAME}"
echo "Installing CircuitPython image"
cd /media/*/${PI_NAME}
cd ${MEDIA_PATH}/*/${PI_NAME}
cp $CACHEDIR/$CIRCUITPYTHON_FILE .
echo "Done"
echo "Waiting for the Pico 2 to reboot again..."
waitForFile "/media/*/CIRCUITPY"
waitForFile "${MEDIA_PATH}/*/CIRCUITPY"
echo "Installing pico-ducky and friends"
cd /media/*/CIRCUITPY
cd ${MEDIA_PATH}/*/CIRCUITPY
CPYDIR=`pwd`
CPBUNDLEDIR=$CACHEDIR/${CIRCUITPYTHON_BUNDLE_FILE/.zip}/
cp -r $CPBUNDLEDIR/lib/adafruit_hid lib/
......@@ -123,7 +125,7 @@ mkdir -p payloads
echo "Done"
echo "Installing azerty keyboard layout support"
cd /media/*/CIRCUITPY
cd ${MEDIA_PATH}/*/CIRCUITPY
CPYDIR=`pwd`
CPLAYOUTDIR=$CACHEDIR/circuitpython-keyboard-layouts-py-20231122/
cp -r $CPLAYOUTDIR/lib/keyboard_layout_win_fr.py lib/
......@@ -132,21 +134,4 @@ cp -r $CPLAYOUTDIR/lib/keyboard_layout_mac_fr.py lib/
cp -r $CPLAYOUTDIR/lib/keycode_win_fr.py lib/
echo "Done"
# printf "\nIf you want wireless AP mode enabled, type in SSID now. Press [Enter] to continue with AP disabled\n"
# read SSID
# if [ -z "$SSID" ]
# then
# echo "Leaving AP disabled"
# else
# echo "Type in password:"
# read PSK
# if [ -z "$PSK" ]
# then
# echo "Password was empty. Leaving AP disabled"
# else
# echo "Installing AP settings..."
# echo "secrets = { 'ssid' : \"$SSID\", 'password' : \"$PSK\" }" > $CPYDIR/secrets.py
# fi
# fi
printf "\nThe device is now ready, and you may install your playload.dd in $CPYDIR\n"
printf "\nThe device is now ready, and you may install your payload.dd in $CPYDIR\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment