Created
August 26, 2019 21:27
-
-
Save sleepdefic1t/d040e156fdc3e31d12160de4d08425b7 to your computer and use it in GitHub Desktop.
Ledger Blue/NanoS/NanoX Environment Setup
This file contains hidden or 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
## Install Development Environment | |
There are two options for setting up our environment | |
**Option 1**: Using Ledger Vagrant | |
- Clone ledger-vagrant | |
> `git clone https://github.com/fix/ledger-vagrant` | |
- Connect to the vagrant machine | |
> `vagrant ssh` | |
- Move to the app | |
> `cd apps/ark-ledger` | |
**Option 2**: Using Python3-env. | |
Linux: | |
- > `sudo apt install python3-venv` | |
macOS: | |
- > `brew install python3` | |
- > `pip3 install virtualenv` | |
Now we prepare the Ledger device environment. | |
- > `source prepare-devenv.sh x` | |
> _(x or s, depending on your device)_ | |
> *_note: `deactivate` to exit python3-env | |
## Building and flashing our app | |
- Connect your ledger Nano S | |
- Run the script | |
> `sh ./rebuild.sh` (ie. build, delete and load app on ledger) | |
# shellcheck disable=SC1091,SC2155 | |
# SOURCE THIS FILE | |
# . prepare-devenv blue|s|x | |
# To prepare your dev environment | |
# | |
# sudo apt install python3-venv | |
# | |
# source prepare-devenv.sh x | |
# (x or s, depending on your device) | |
# To build/rebuild | |
# sh ./rebuild.sh | |
# If this process gets stuck or bugs out, | |
# just delete the 'dev-env' folder and run this script again. | |
# If you get `hidapi` errors, install the following: | |
# apt-get install libudev-dev libusb-1.0-0-dev -y > /dev/null | |
if [ $# -ne 1 ]; then | |
echo "Possible options: blue, s or x" | |
return | |
elif [[ $1 == "-h" ]]; then | |
echo "Possible options: blue, s or x" | |
return | |
elif [[ $1 != "blue" ]] && [[ $1 != "s" ]] && [[ $1 != "x" ]]; then | |
echo "Possible options: blue, s or x" | |
return | |
fi | |
if [[ $(dpkg-query -s python3-venv 2>&1) == *'is not installed'* ]]; then | |
printf "\nPackage python3-venv is missing.\nOn Debian-like distros, run:\n\napt install python3-venv\n\n" | |
return | |
fi | |
if [[ $(cat /etc/udev/rules.d/20-hw1.rules) == *'ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004"'* ]]; then | |
printf "\nMissing udev rules. Please refer to https://support.ledger.com/hc/en-us/articles/115005165269-Fix-connection-issues\n\n" | |
return | |
fi | |
if [ ! -d dev-env ]; then | |
mkdir dev-env | |
mkdir dev-env/SDK | |
mkdir dev-env/CC | |
mkdir dev-env/CC/others | |
mkdir dev-env/CC/nanox | |
mkdir temp | |
wget -q https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2 -O temp/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2 --show-progress | |
tar xjf temp/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2 --directory temp/ | |
ln -s /opt/bolos/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc | |
wget http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-16.10.tar.xz -O temp/clang+llvm.4.tar.xz --show-progress | |
tar xf temp/clang+llvm.4.tar.xz --directory temp/clang+llvm.4 | |
rm temp/clang+llvm.tar.xz | |
mv temp/clang+llvm.4* dev-env/CC/others/clang-arm-fropi | |
# wget http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz -O temp/clang+llvm.tar.xz | |
wget -q https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -O temp/clang+llvm.8.tar.xz --show-progress | |
tar xf temp/clang+llvm.8.tar.xz --directory temp/ | |
rm temp/clang+llvm.tar.xz | |
mv temp/clang+llvm* dev-env/CC/nanox/clang-arm-fropi | |
wget https://github.com/LedgerHQ/blue-secure-sdk/archive/blue-r21.1.tar.gz -O temp/blue-secure-sdk.tar.gz --show-progress | |
tar xf temp/blue-secure-sdk.tar.gz --directory temp/ | |
rm temp/blue-secure-sdk.tar.gz temp/ | |
mv temp/blue-secure-sdk* dev-env/SDK/blue-secure-sdk | |
wget https://github.com/LedgerHQ/nanos-secure-sdk/archive/nanos-1553.tar.gz -O temp/nanos-secure-sdk.tar.gz --show-progress | |
tar xf temp/nanos-secure-sdk.tar.gz --directory temp/ | |
rm temp/nanos-secure-sdk.tar.gz | |
mv temp/nanos-secure-sdk* dev-env/SDK/nanos-secure-sdk | |
python3 -m venv dev-env/ledger_py3 | |
source dev-env/ledger_py3/bin/activate | |
pip install wheel | |
pip install ledgerblue | |
fi | |
source dev-env/ledger_py3/bin/activate | |
if [[ $1 == "blue" ]]; then | |
export BOLOS_SDK=$(pwd)/dev-env/SDK/blue-secure-sdk | |
export BOLOS_ENV=$(pwd)/dev-env/CC/others | |
elif [[ $1 == "s" ]]; then | |
export BOLOS_SDK=$(pwd)/dev-env/SDK/nanos-secure-sdk | |
export BOLOS_ENV=$(pwd)/dev-env/CC/others | |
elif [[ $1 == "x" ]]; then | |
export BOLOS_SDK=$(pwd)/dev-env/SDK/nanox-secure-sdk | |
export BOLOS_ENV=$(pwd)/dev-env/CC/nanox | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment