sh Ledger Blue / NanoS / NanoX环境设置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Ledger Blue / NanoS / NanoX环境设置相关的知识,希望对你有一定的参考价值。
## 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
以上是关于sh Ledger Blue / NanoS / NanoX环境设置的主要内容,如果未能解决你的问题,请参考以下文章
Hyperledger Fabric 介绍几个关键配置文件(三)
将 java.sql.Timestamp 转换为 javax.xml.datatype.XMLGregorianCalendar 而不会丢失 nanos
在 Java 中获取 nanos unix 纪元时间的最快方法
使用 Instant/ChronoUnit 获取今天午夜的 nanos-since-epoch 时间比使用 GregorianCalendar/Date 提前 24 小时