Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.43 KB

app-dev.md

File metadata and controls

66 lines (46 loc) · 1.43 KB

How-To

Build a RISC-V app

Build the docker image to have a ready-to-use RISC-V toolchain:

docker build -t riscv -f riscv.Dockerfile .

Build the RISC-V C sdk using the docker.sh script:

$ ./docker.sh riscv
[root:/c-sdk] # cmake -Bbuild -H.
[root:/c-sdk] # make -C build/

Build the RISC-V VM and install it on the Nano device

Like any other Nano apps. Sources are in the vm/ directory.

cd vm/
make
make load

Run the app

Using speculos:

$ speculos.py --model nanox --sdk 2.0.2 vm/bin/app.elf &
$ ./host/stream.py --speculos --app ./app/build/app-swap/app-swap

Or using a real device:

$ ./host/stream.py --app ./app/build/app-swap/app-swap

Requests can then be entered in hexadecimal on stdin. Clients are also available, for instance for app-swap:

$ ./app/app-swap/swap.py --speculos --app ./app/build/app-swap/app-swap

Once the app is signed, the .zip can be passed as an argument:

$ ./app/app-swap/swap.py --speculos --app /tmp/app.zip

Sign the app

While everything is done transparently when passing an ELF file to stream.py, the following commands can be used to sign an app manually. The app is first signed by a (fake) Ledger HSM, then by the device:

$ python host/hsm.py --elf-path app/build/app-ethereum/app-ethereum --app-path /tmp/app.zip
$ python host/app.py --speculos --app-path /tmp/app.zip