diff --git a/README.md b/README.md index cb091ca..ade10e1 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,32 @@ This guide is designed for the general user who is not incompetant with computers and is looking to secure **less** than $100,000 (in 2023 prices) worth of bitcoin. +## Table of Contents + +- [What is a Jade?](#what-is-a-jade) +- [Motivation](#motivation) +- [Who Should NOT Follow This Guide?](#who-should-not-follow-this-guide) +- [Overview of Hardware Options](#overview-of-hardware-options) + - [TTGO T-Display](#ttgo-t-display) + - [M5Stack M5StickC PLUS](#m5stack-m5stickc-plus) + - [M5Stack Core Basic](#m5stack-core-basic) + - [M5Stack FIRE v2.6](#m5stack-fire-v2.6) +- [Current Limitations of Third-Party DIY Hardware](#current-limitations-of-third-party-diy-hardware) +- [Set Up Instructions](#set-up-instructions) + - [Use the Semi-Automated Script](#use-the-semi-automated-script) + - [Use a Device-Specific Script](#use-a-device-specific-script) + - [Run the Commands Manually](#run-the-commands-manually) +- [Acknowledgements](#acknowledgements) + ## What is a Jade? [The Blockstream Jade](https://blockstream.com/jade) is a bitcoin-only hardware wallet that runs 100% on Open Source code. The firmware that runs Jade can also run other general purpose hardware that shares the same ESP32 microcontroller. -## Motivation (Why Should I Follow This Guide?) +## Motivation + +Why Should I Follow This Guide? Three words: **supply chain attacks**. @@ -57,8 +76,8 @@ You are better off buying the hardware directly from the hardware vendor than th ## Current Limitations of Third-Party DIY Hardware -- No camera support... yet -- Need to document how to perform firmware updates +- No camera support. To build a DIY Jade with camera support, [please refer here](https://www.youtube.com/watch?v=V2yVKag2wlc). +- Need a documented process for updating firmware. ## Set Up Instructions @@ -67,7 +86,7 @@ There are three options for flashing your device: - [**Install with a Device-Specific Script**](#install-with-a-device-specific-script) (other easy way) - [**Install by Running the Code Manually**](#install-by-running-the-code-manually) (harder way) -### Install with the Semi-Automated Script +### Use the Semi-Automated Script This option is recommended for the average user who doesn't know how to read and write bash. @@ -75,16 +94,16 @@ This option is recommended for the average user who doesn't know how to read and - On Linux, press `Ctrl+Alt+T`. - On macOS, press `Command+Space`, type terminal, and press `return`. -2. Clone (download) this repository and start the scipt. Run the following in Terminal: +2. Copy-paste the following full command in Terminal (you might have to scroll right): ```bash - sudo /bin/bash -c "$(curl -sSL https://raw.githubusercontent.com/epiccurious/jade-diy/master/flash_your_device)" + /bin/bash -c "$(curl -sSL https://github.com/epiccurious/jade-diy/raw/master/flash_your_device)" ``` 3. When the script asks, choose your device (#1-#4). After the script completes, you should see the Jade initialization screen on your device. -### Install with a Device-Specific Script +### Use a Device-Specific Script 1. Open the Terminal. On Linux, press `Ctrl+Alt+T`. On macOS, press `Command+Space`, type terminal, and press `return`. @@ -115,7 +134,7 @@ After the script completes, you should see the Jade initialization screen on you After the script completes, you should see the Jade initialization screen on your device. -### Install by Running the Code Manually +### Run the Commands Manually This options is provided for people who want to run the commands themselves. @@ -131,6 +150,7 @@ This options is provided for people who want to run the commands themselves. ./install.sh esp32 . ./export.sh ``` +TODO: Add instructions for installing macOS dependendies. 3. Download the Jade source code. Copy-and-paste the following lines into Terminal: ```bash @@ -171,6 +191,7 @@ This options is provided for people who want to run the commands themselves. [ -f /dev/ttyACM0 ] && sudo chmod o+rw /dev/ttyACM0 [ -f /dev/ttyUSB0 ] && sudo chmod a+rw /dev/ttyUSB0 ``` +TODO: Add macOS instructions. 8. Flash (install) Jade onto your device. On a slow computer, this step can take over 10 minutes. Run the following command in Terminal: ```bash @@ -182,5 +203,5 @@ After the build and flash process completes, you should see the Jade initializat ## Acknowledgements Inspiration for this project came from: -- the Blockstream Jade team ([link to contributors](https://github.com/Blockstream/Jade/graphs/contributors)) -- [@YTCryptoGuide](https://twitter.com/YTCryptoGuidelink) ([Link to his YouTube](https://youtube.com/CryptoGuide)). +- [Blockstream Jade](https://github.com/Blockstream/Jade/graphs/contributors) +- [@YTCryptoGuide](https://twitter.com/YTCryptoGuidelink) ([YouTube](https://youtube.com/CryptoGuide)). diff --git a/flash_your_device b/flash_your_device index ac526e0..63f8810 100755 --- a/flash_your_device +++ b/flash_your_device @@ -1,17 +1,18 @@ #!/bin/bash set -e -if [ "$(whoami)" != root ]; then - echo -e "ERROR: Please run the script with elevated permissions like this:\n sudo ~/jade-diy/flash_your_device.sh" - exit 1 -fi +working_directory="${HOME}/Downloads/diy_jade" +temp_directory="${working_directory}/temp" +trap 'rm -rf -- "${temp_directory}"' EXIT -tmp_dir="$(mktemp -d)" -trap 'rm -rf -- "${tmp_dir}"' EXIT -esp_idf_git_dir="${tmp_dir}/esp-idf" -esp_idf_git_tag="v5.1.1" -jade_git_dir="${tmp_dir}/jade" jade_git_tag="1.0.26" +jade_save_directory="${working_directory}/jade" +jade_repo_url="https://github.com/blockstream/jade.git" + +esp_idf_git_tag="v5.1.1" +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" device1="TTGO T-Display" device2="M5Stack M5StickC PLUS" @@ -30,14 +31,18 @@ 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 + case "$(uname -s)" in Linux*) machine="Linux" echo "Detected ${machine}." echo -n "Checking for cmake, git, pip, and venv... " #[ -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 + sudo apt-get -qq update + sudo apt-get -qq install -y -o=Dpkg::Use-Pty=0 cmake git python3-pip python3-venv &> /dev/null echo "ok." ;; Darwin*) @@ -68,7 +73,7 @@ case "$(uname -s)" in echo -e "\n************************************************************" echo "ERROR: Automatic installation of CMake is not supported yet." - echo "Please manually install \"${cmake_macos_dmg}\"." + echo "Please manually install ${cmake_macos_dmg}." echo "Please open the file from your Downloads folder." echo -e "************************************************************\n" exit 1 @@ -90,28 +95,35 @@ case "$(uname -s)" in esac echo -n "Checking for the Espressif IoT Development Framework... " -if [ ! -f "${esp_idf_git_dir}"/export.sh ]; then +if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then echo -ne "\n Downloading the framework... " - 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 + git -c advice.detachedHead=false clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 --quiet "${esp_idf_repo_url}" "${esp_idf_temp_directory}" + cd "${esp_idf_temp_directory}"/ + git submodule update --depth 1 --quiet --init --recursive &> /dev/null + ./install.sh esp32 &>/dev/null + # shellcheck source=/dev/null + source ./export.sh 1>/dev/null + mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}" echo "ok." - echo -n " Installing the framework... " - ./install.sh esp32 1>/dev/null +else + echo fi -. "${esp_idf_git_dir}"/export.sh 1>/dev/null +cd "${esp_idf_save_directory}" +echo -ne " Installing the framework... " +./install.sh esp32 1>/dev/null +echo -ne "ok.\n Exporting the framework... " +# shellcheck source=/dev/null +source ./export.sh 1>/dev/null echo "ok." echo -n "Checking for the Blockstream Jade repository... " -if [ ! -d "${jade_git_dir}" ]; then +if [ ! -d "${working_directory}"/jade ]; then echo -ne "\n Downloading Jade... " - git clone --quiet https://github.com/blockstream/jade.git "${jade_git_dir}" - cd "${jade_git_dir}" - git checkout --quiet "${jade_git_tag}" - git submodule update --quiet --init --recursive + git -c advice.detachedHead=false 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 --quiet --init --recursive &> /dev/null fi -cd "${jade_git_dir}" +cd "${jade_save_directory}" jade_version="$(git describe --tags)" echo "ok." @@ -164,7 +176,7 @@ case "${machine}" in while [ ! -c "${tty_device}" ]; do read -srn1 -p "Connect your ${chosen_device} and PRESS ANY KEY to continue... " && echo done - chmod o+rw "${tty_device}" + sudo chmod o+rw "${tty_device}" ;; macOS*) #macos_usb_serial=$(ioreg -p IOUSB -n "USB Single Serial" | grep "USB Serial Number" | cut -c 34-43) @@ -178,8 +190,8 @@ case "${machine}" in # macos_usb_serial=$(ioreg -p IOUSB -n "USB Single Serial" | grep "USB Serial Number" | cut -c 34-43) #done - echo -e "Connect your ${chosen_device} with a USB-C cable,\n click \"Allow\" if you see a macOS security popup," - read -srn1 -p " and PRESS ANY KEY to continue... " && echo + echo -e "Connect your ${chosen_device} with a USB-C cable,\n and click Allow if you see a security popup." + read -srn1 -p " PRESS ANY KEY to continue... " && echo && echo ;; *) echo "Unsupported OS: $(uname -s)" && exit 0 esac @@ -188,9 +200,10 @@ echo -e "Ready to install Jade ${jade_version} on your ${chosen_device}.\n (Thi read -srn1 -p " PRESS ANY KEY to continue... " && echo final_confirmation_sleep_time="10" -echo -ne "\nPlease wait ${final_confirmation_sleep_time} seconds or press Ctrl+C to cancel... " +echo -ne "\nJade ${jade_version} installion will begin in ${final_confirmation_sleep_time} seconds.\nPress Ctrl+C to cancel... " sleep "${final_confirmation_sleep_time}" echo + ${flash_command} -echo -e "\nSUCCESS! Jade ${jade_version} is now installed on your ${chosen_device}." +echo -e "\nSUCCESS! Jade ${jade_version} is now installed on your ${chosen_device}.\nYou can close this window now.\n"