Skip to content

Commit

Permalink
Update device-specific scripts to not require sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
epiccurious committed Dec 2, 2023
1 parent 03955c6 commit 597f888
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 127 deletions.
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,24 @@ After the script completes, you should see the Jade initialization screen on you

1. Open the Terminal. On Linux, press `Ctrl+Alt+T`. On macOS, press `Command+Space`, type terminal, and press `return`.

2. Clone (download) this repository and changie to the directory. Run the following in Terminal:
```bash
git clone --quiet https://github.com/epiccurious/jade-diy "${HOME}"/jade-diy && cd "${HOME}"/jade-diy/
```

3. Connect your device to your computer via USB.
2. Connect your device to your computer via USB.

4. Run the device-specific script corresponding to the hardware you're using. This process can take up to 30 minutes on a slow computer.
3. Run one of the following in Terminal:
- If you're using the TTGO T-Dispay, run:
```
sudo device_specific/flash_the_ttgo_tdisplay
/bin/bash -c "$(curl -sSL https://github.com/epiccurious/jade-diy/raw/master/device_specific/flash_the_ttgo_tdisplay)"
```
- If you're using the M5Stack M5StickC PLUS, run:
```
sudo device_specific/flash_the_m5stack_m5stickc_plus
/bin/bash -c "$(curl -sSL https://github.com/epiccurious/jade-diy/raw/master/device_specific/flash_the_m5stack_m5stickc_plus)"
```
- If you're using the M5Stack Core Basic, run:
```
sudo device_specific/flash_the_m5stack_core_basic
/bin/bash -c "$(curl -sSL https://github.com/epiccurious/jade-diy/raw/master/device_specific/flash_the_m5stack_core_basic)"
```
- If you're using the M5Stack FIRE, run:
```
sudo device_specific/flash_the_m5stack_fire
/bin/bash -c "$(curl -sSL https://github.com/epiccurious/jade-diy/raw/master/device_specific/flash_the_m5stack_fire)"
```

After the script completes, you should see the Jade initialization screen on your device.
Expand Down
94 changes: 66 additions & 28 deletions device_specific/flash_the_m5stack_core_basic
Original file line number Diff line number Diff line change
@@ -1,48 +1,86 @@
#!/bin/bash
set -e

if [ "$(whoami)" != root ]; then
echo -e "ERROR: Please run the script with elevated permissions like this:\n sudo ~/jade-diy/device_specific/flash_the_m5stack_core_basic.sh"
exit 1
fi
working_directory="${HOME}/Downloads/diy_jade"
temp_directory="${working_directory}/temp"
trap 'rm -rf -- "${temp_directory}"' EXIT

jade_git_tag="1.0.26"
jade_save_directory="${working_directory}/jade"
jade_repo_url="https://github.com/blockstream/jade.git"

esp_dir="${HOME}/esp"
esp_idf_git_dir="${esp_dir}/esp-idf"
esp_idf_git_tag="v5.1.1"
jade_git_dir="${HOME}/jade"
esp_idf_temp_directory="${temp_directory}/esp-idf"
esp_idf_save_directory="${working_directory}/esp-idf"
esp_idf_repo_url="https://github.com/espressif/esp-idf.git"

device="M5Stack Core Basic"
tty_device="/dev/ttyACM0"

clear
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo "--- ---"
echo "--- Do-It-Yourself Jade Install Script ---"
echo "--- Written by Epic Curious ---"
echo "--- Twitter: @epic_curious ---"
echo "--- ---"
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo

if [ "$(whoami)" = "root" ]; then
echo -e "ALERT: You're running the script as root/superuser.\nYou may notice PIP 'sudo -H' warnings.\n"
fi

echo "LINUX ONLY. Flashing the ${device}..."

#[ -f /var/lib/apt/lists/lock ] && echo "ERROR: `apt` is locked. Are you installing system updates?" && exit 1
apt-get -qq update
apt-get -qq install -y -o=Dpkg::Use-Pty=0 cmake git python3-pip python3-venv &> /dev/null

if [ ! -f "${esp_idf_git_dir}"/export.sh ]; then
[ -d "${esp_dir}" ] || mkdir "${esp_dir}"
git clone --quiet https://github.com/espressif/esp-idf.git "${esp_idf_git_dir}"
cd "${esp_idf_git_dir}"/
git checkout --quiet "${esp_idf_git_tag}"
git submodule update --quiet --init --recursive
./install.sh esp32 1>/dev/null
if ! command -v cmake &>/dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git --branch "${esp_idf_git_tag}" --single-branch --depth 1 --quiet "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_git_dir}"/
git submodule update --depth 1 --init --recursive --quiet
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
. "${esp_idf_git_dir}"/export.sh 1>/dev/null
./install.sh esp32
source "${esp_idf_git_dir}"/export.sh

if [ ! -d "${jade_git_dir}" ]; then
git clone --quiet https://github.com/blockstream/jade.git "${jade_git_dir}"
cd "${jade_git_dir}"
git checkout --quiet "$(git tag | grep -v miner | sort -V | tail -1)"
git submodule update --quiet --init --recursive
if [ ! -d "${jade_save_directory}" ]; then
git clone --branch "${jade_git_tag}" --single-branch --depth 1 --quiet "${jade_repo_url}" "${jade_save_directory}"
cd "${jade_save_directory}"
git submodule update --depth 1 --init --recursive --quiet &> /dev/null
fi
cd "${jade_git_dir}"
cd "${jade_save_directory}"

cp configs/sdkconfig_display_m5blackgray.defaults sdkconfig.defaults
sed -i.bak '/CONFIG_DEBUG_MODE/d' ./sdkconfig.defaults
sed -i.bak '1s/^/CONFIG_LOG_DEFUALT_LEVEL_NONE=y\n/' sdkconfig.defaults
rm sdkconfig.defaults.bak

chmod a+rw /dev/ttyACM0
while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${device} and PRESS ANY KEY to continue... " && echo
done
tty_device_permissions="$(stat -c '%a' ${tty_device})"
if [ "${tty_device_permissions:2}" -lt 6 ]; then
echo -e "ERROR:\nYou need elevated permissions to write to the device.\nPlease update your device permissoins by running:\n\nsudo chmod o+rw ${tty_device}\n"
exit 1
fi

idf.py flash

opt="M5Stack Core Basic"
echo -e "\nSUCCESS! Your ${opt} is now running Jade."
echo -e "\nSUCCESS! Your ${device} is now running Jade."
94 changes: 66 additions & 28 deletions device_specific/flash_the_m5stack_fire
Original file line number Diff line number Diff line change
@@ -1,48 +1,86 @@
#!/bin/bash
set -e

if [ "$(whoami)" != root ]; then
echo -e "ERROR: Please run the script with elevated permissions like this:\n sudo ~/jade-diy/device_specific/flash_the_m5stack_fire.sh"
exit 1
fi
working_directory="${HOME}/Downloads/diy_jade"
temp_directory="${working_directory}/temp"
trap 'rm -rf -- "${temp_directory}"' EXIT

jade_git_tag="1.0.26"
jade_save_directory="${working_directory}/jade"
jade_repo_url="https://github.com/blockstream/jade.git"

esp_dir="${HOME}/esp"
esp_idf_git_dir="${esp_dir}/esp-idf"
esp_idf_git_tag="v5.1.1"
jade_git_dir="${HOME}/jade"
esp_idf_temp_directory="${temp_directory}/esp-idf"
esp_idf_save_directory="${working_directory}/esp-idf"
esp_idf_repo_url="https://github.com/espressif/esp-idf.git"

device="M5Stack FIRE"
tty_device="/dev/ttyACM0"

clear
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo "--- ---"
echo "--- Do-It-Yourself Jade Install Script ---"
echo "--- Written by Epic Curious ---"
echo "--- Twitter: @epic_curious ---"
echo "--- ---"
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo

if [ "$(whoami)" = "root" ]; then
echo -e "ALERT: You're running the script as root/superuser.\nYou may notice PIP 'sudo -H' warnings.\n"
fi

echo "LINUX ONLY. Flashing the ${device}..."

#[ -f /var/lib/apt/lists/lock ] && echo "ERROR: `apt` is locked. Are you installing system updates?" && exit 1
apt-get -qq update
apt-get -qq install -y -o=Dpkg::Use-Pty=0 cmake git python3-pip python3-venv &> /dev/null

if [ ! -f "${esp_idf_git_dir}"/export.sh ]; then
[ -d "${esp_dir}" ] || mkdir "${esp_dir}"
git clone --quiet https://github.com/espressif/esp-idf.git "${esp_idf_git_dir}"
cd "${esp_idf_git_dir}"/
git checkout --quiet "${esp_idf_git_tag}"
git submodule update --quiet --init --recursive
./install.sh esp32 1>/dev/null
if ! command -v cmake &>/dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git --branch "${esp_idf_git_tag}" --single-branch --depth 1 --quiet "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_git_dir}"/
git submodule update --depth 1 --init --recursive --quiet
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
. "${esp_idf_git_dir}"/export.sh 1>/dev/null
./install.sh esp32
source "${esp_idf_git_dir}"/export.sh

if [ ! -d "${jade_git_dir}" ]; then
git clone --quiet https://github.com/blockstream/jade.git "${jade_git_dir}"
cd "${jade_git_dir}"
git checkout --quiet "$(git tag | grep -v miner | sort -V | tail -1)"
git submodule update --quiet --init --recursive
if [ ! -d "${jade_save_directory}" ]; then
git clone --branch "${jade_git_tag}" --single-branch --depth 1 --quiet "${jade_repo_url}" "${jade_save_directory}"
cd "${jade_save_directory}"
git submodule update --depth 1 --init --recursive --quiet &> /dev/null
fi
cd "${jade_git_dir}"
cd "${jade_save_directory}"

cp configs/sdkconfig_display_m5fire.defaults sdkconfig.defaults
sed -i.bak '/CONFIG_DEBUG_MODE/d' ./sdkconfig.defaults
sed -i.bak '1s/^/CONFIG_LOG_DEFUALT_LEVEL_NONE=y\n/' sdkconfig.defaults
rm sdkconfig.defaults.bak

chmod a+rw /dev/ttyACM0
while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${device} and PRESS ANY KEY to continue... " && echo
done
tty_device_permissions="$(stat -c '%a' ${tty_device})"
if [ "${tty_device_permissions:2}" -lt 6 ]; then
echo -e "ERROR:\nYou need elevated permissions to write to the device.\nPlease update your device permissoins by running:\n\nsudo chmod o+rw ${tty_device}\n"
exit 1
fi

idf.py flash

opt="M5Stack FIRE"
echo -e "\nSUCCESS! Your ${opt} is now running Jade."
echo -e "\nSUCCESS! Your ${device} is now running Jade."
94 changes: 66 additions & 28 deletions device_specific/flash_the_m5stack_m5stickc_plus
Original file line number Diff line number Diff line change
@@ -1,48 +1,86 @@
#!/bin/bash
set -e

if [ "$(whoami)" != root ]; then
echo -e "ERROR: Please run the script with elevated permissions like this:\n sudo ~/jade-diy/device_specific/flash_the_m5stack_m5stickc_plus.sh"
exit 1
fi
working_directory="${HOME}/Downloads/diy_jade"
temp_directory="${working_directory}/temp"
trap 'rm -rf -- "${temp_directory}"' EXIT

jade_git_tag="1.0.26"
jade_save_directory="${working_directory}/jade"
jade_repo_url="https://github.com/blockstream/jade.git"

esp_dir="${HOME}/esp"
esp_idf_git_dir="${esp_dir}/esp-idf"
esp_idf_git_tag="v5.1.1"
jade_git_dir="${HOME}/jade"
esp_idf_temp_directory="${temp_directory}/esp-idf"
esp_idf_save_directory="${working_directory}/esp-idf"
esp_idf_repo_url="https://github.com/espressif/esp-idf.git"

device="M5Stack M5StickC PLUS"
tty_device="/dev/ttyUSB0"

clear
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo "--- ---"
echo "--- Do-It-Yourself Jade Install Script ---"
echo "--- Written by Epic Curious ---"
echo "--- Twitter: @epic_curious ---"
echo "--- ---"
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo

if [ "$(whoami)" = "root" ]; then
echo -e "ALERT: You're running the script as root/superuser.\nYou may notice PIP 'sudo -H' warnings.\n"
fi

echo "LINUX ONLY. Flashing the ${device}..."

#[ -f /var/lib/apt/lists/lock ] && echo "ERROR: `apt` is locked. Are you installing system updates?" && exit 1
apt-get -qq update
apt-get -qq install -y -o=Dpkg::Use-Pty=0 cmake git python3-pip python3-venv &> /dev/null

if [ ! -f "${esp_idf_git_dir}"/export.sh ]; then
[ -d "${esp_dir}" ] || mkdir "${esp_dir}"
git clone --quiet https://github.com/espressif/esp-idf.git "${esp_idf_git_dir}"
cd "${esp_idf_git_dir}"/
git checkout --quiet "${esp_idf_git_tag}"
git submodule update --quiet --init --recursive
./install.sh esp32 1>/dev/null
if ! command -v cmake &>/dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git --branch "${esp_idf_git_tag}" --single-branch --depth 1 --quiet "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_git_dir}"/
git submodule update --depth 1 --init --recursive --quiet
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
. "${esp_idf_git_dir}"/export.sh 1>/dev/null
./install.sh esp32
source "${esp_idf_git_dir}"/export.sh

if [ ! -d "${jade_git_dir}" ]; then
git clone --quiet https://github.com/blockstream/jade.git "${jade_git_dir}"
cd "${jade_git_dir}"
git checkout --quiet "$(git tag | grep -v miner | sort -V | tail -1)"
git submodule update --quiet --init --recursive
if [ ! -d "${jade_save_directory}" ]; then
git clone --branch "${jade_git_tag}" --single-branch --depth 1 --quiet "${jade_repo_url}" "${jade_save_directory}"
cd "${jade_save_directory}"
git submodule update --depth 1 --init --recursive --quiet &> /dev/null
fi
cd "${jade_git_dir}"
cd "${jade_save_directory}"

cp configs/sdkconfig_display_m5stickcplus.defaults sdkconfig.defaults
sed -i.bak '/CONFIG_DEBUG_MODE/d' ./sdkconfig.defaults
sed -i.bak '1s/^/CONFIG_LOG_DEFUALT_LEVEL_NONE=y\n/' sdkconfig.defaults
rm sdkconfig.defaults.bak

chmod a+rw /dev/ttyUSB0
while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${device} and PRESS ANY KEY to continue... " && echo
done
tty_device_permissions="$(stat -c '%a' ${tty_device})"
if [ "${tty_device_permissions:2}" -lt 6 ]; then
echo -e "ERROR:\nYou need elevated permissions to write to the device.\nPlease update your device permissoins by running:\n\nsudo chmod o+rw ${tty_device}\n"
exit 1
fi

idf.py -b 115200 flash

opt="M5Stack M5StickC PLUS"
echo -e "\nSUCCESS! Your ${opt} is now running Jade."
echo -e "\nSUCCESS! Your ${device} is now running Jade."
Loading

0 comments on commit 597f888

Please sign in to comment.