Skip to content

Commit

Permalink
Merge pull request LedgerHQ#13 from obsidiansystems/develop
Browse files Browse the repository at this point in the history
Add Stax, Flex devices support, update SDK
  • Loading branch information
yogh333 authored Jan 8, 2025
2 parents da59b2d + c1d4099 commit e5b0d0e
Show file tree
Hide file tree
Showing 200 changed files with 1,771 additions and 2,396 deletions.
5 changes: 1 addition & 4 deletions .cargo/config → .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[unstable]
build-std = ["core"]
build-std = ["core", "alloc"]
build-std-features = ["compiler-builtins-mem"]

[target.nanosplus]
Expand All @@ -8,23 +8,20 @@ rustflags = [
"-C", "save-temps", # Fixes incremental builds by keeping .bc and .ll files
"-C", "embed-bitcode",
]
runner = "./speculos-wrapper -m nanosp "

[target.nanos]
rustflags = [
"-C", "codegen-units=1",
"-C", "save-temps", # Fixes incremental builds by keeping .bc and .ll files
"-C", "embed-bitcode",
]
runner = "./speculos-wrapper -m nanos "

[target.nanox]
rustflags = [
"-C", "codegen-units=1",
"-C", "save-temps", # Fixes incremental builds by keeping .bc and .ll files
"-C", "embed-bitcode",
]
runner = "./speculos-wrapper -m nanox "

[alias]
tt = "test --features extra_debug"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_and_functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
upload_app_binaries_artifact: "compiled_app_binaries"
builder: ledger-app-builder

functional_tests:
name: Run tests
ragger_tests:
name: Run ragger tests using the reusable workflow
needs: build_application
uses: ./.github/workflows/functional_tests.yml
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
with:
download_app_binaries_artifact: "compiled_app_binaries"
22 changes: 22 additions & 0 deletions .github/workflows/coding_style_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run coding style check

# This workflow will run linting checks to ensure a level of code quality among all Ledger applications.
#
# The presence of this workflow is mandatory as a minimal level of linting is required.

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
- develop-sync
pull_request:

jobs:
check_linting:
name: Check linting using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_lint.yml@v1
with:
source: './rust-app/src'
110 changes: 0 additions & 110 deletions .github/workflows/functional_tests.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/rust.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ Cargo.nix

result
result-*

__pycache__
snapshots-tmp
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ These dependencies are needed:

Additionally for testing these are needed:

- Node
- Yarn
- Python3
- [Speculos] the official Ledger emulator
- Ragger, a library to run tests on Speculos emulator

[Speculos]: https://github.com/ledgerHQ/speculos

Expand All @@ -27,12 +27,13 @@ The easiest way to get all these dependencies is with Nix:
```bash
nix-shell -A $DEVICE.rustShell
cd rust-app/
cargo ledger build -l $DEVICE
cargo build --release --target=$TARGET_JSON
````
where `DEVICE` is one of
- `nanos` for Nano S
- `nanox` for Nano X
- `nanosplus` for Nano S+
- `flex`, for Flex
- `stax`, for Stax

### Getting a development environment without Nix

Expand All @@ -54,12 +55,10 @@ in order to regenerate this file and keep it up to date.
## Running automated tests with Speculos
Using Nix, from the root level of this repo, run:
Using Nix, from the root level of this repo, run the following script to run tests for all devices
```bash
nix-shell -A $DEVICE.rustShell
cd rust-app/
cargo test --target=$TARGET_JSON
./run-ragger-tests.sh
```

## Deploying development builds to real hardware
Expand All @@ -70,7 +69,7 @@ Nix will always track the latest changes, freshly rebuilding components as neede
That said, it is also possible to use Cargo build.
This useful for the quickest "debug loop".

The [cargo-ledger](https://github.com/LedgerHQ/cargo-ledger.git) builds, outputs a `hex` file and a manifest file for `ledgerctl`, and loads it on a device in a single `cargo-ledger ledger -l nanos` command in the rust-app folder within app directory.
The [cargo-ledger](https://github.com/LedgerHQ/cargo-ledger.git) builds, outputs a `hex` file and a manifest file for `ledgerctl`, and loads it on a device in a single `cargo-ledger ledger -l nanosplus` command in the rust-app folder within app directory.

(You do not need to install `cargo-ledger` if you are using the nix-provided development shell, as it provides it.)

Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Written using [Alamgu](https://github.com/alamgu/).
## Device Compatability

This application is compatible with
- Ledger Nano S, running firmware 2.1.0 and above
- Ledger Nano S+, running firmware 1.1.0
- Ledger Nano S+
- Ledger Nano X
- Ledger Flex
- Ledger Stax

Note: Compatibility with Ledger Nano X is only possible to check on [Speculos](https://github.com/ledgerHQ/speculos/) emulator,
because the Nano X does not support side-loading apps under development.
Expand Down Expand Up @@ -74,9 +75,10 @@ Finally, run the following command to load the app on your device:
nix --extra-experimental-features nix-command run -f . $DEVICE.loadApp
```
where `DEVICE` is one of
- `nanos`, for Nano S
- `nanox`, for Nano X
- `nanosplus`, for Nano S+
- `flex`, for Flex
- `stax`, for Stax

The app will be downloaded (if you have our Nix cache enabled) and/or freshly built as needed.

Expand All @@ -97,9 +99,10 @@ To build one, run:
nix-build -A $DEVICE.tarball
```
where `DEVICE` is one of
- `nanos`, for Nano S
- `nanox`, for Nano X
- `nanosplus`, for Nano S+
- `flex`, for Flex
- `stax`, for Stax

The last line printed out will be the path of the tarball.

Expand Down Expand Up @@ -141,9 +144,10 @@ To use this tool using Nix, from the root level of this repo, run this command t
nix-shell -A $DEVICE.appShell
```
where `DEVICE` is one of
- `nanos`, for Nano S
- `nanox`, for Nano X
- `nanosplus`, for Nano S+
- `flex`, for Flex
- `stax`, for Stax

Then, one can use `generic-cli` like this:

Expand Down
2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ rec {
nanos = appForDevice "nanos";
nanosplus = appForDevice "nanosplus";
nanox = appForDevice "nanox";
flex = appForDevice "flex";
stax = appForDevice "stax";

cargoFmtCheck = pkgs.stdenv.mkDerivation {
pname = "cargo-fmt-${appName}";
Expand Down
4 changes: 2 additions & 2 deletions dep/alamgu/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"repo": "alamgu",
"branch": "develop",
"private": false,
"rev": "f41eb60cb2b5145b4948c51898062911c342db6b",
"sha256": "16n2b0irpkgjzp5mrl6vxza0bw7p5c6bmgbfmynbzbcyij5arhnh"
"rev": "7cb39c91dfc9af8c9bc499712df68efb49f694f3",
"sha256": "1b6ndhk24dj6vmyg3qvggfx4zyd90lfdda2qq4g4nf26wi85k6zn"
}
5 changes: 4 additions & 1 deletion dep/alamgu/thunk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
} else (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
}) {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
Expand Down
10 changes: 5 additions & 5 deletions dep/ledger-nanos-sdk/github.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"owner": "alamgu",
"repo": "ledger-nanos-sdk",
"branch": "alamgu-branch",
"owner": "LedgerHQ",
"repo": "ledger-device-rust-sdk",
"branch": "master",
"private": false,
"rev": "52edd548d7456a844b3919969b330e1e21b8e2fa",
"sha256": "1dnlav7883wi7y7m4lhjj9gx4nypa99iwa2acnbydq55pdd1mn6y"
"rev": "e9f89626ea509528f29df74ef775c1a989693450",
"sha256": "0n4v9ibwnkp22dmsdsiyz4hfd7jb83ccfjsv25vbmlcir4s5ppg0"
}
5 changes: 4 additions & 1 deletion dep/ledger-nanos-sdk/thunk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
} else (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
}) {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
Expand Down
6 changes: 3 additions & 3 deletions dep/ledger-secure-sdk-nanos/github.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"owner": "LedgerHQ",
"repo": "nanos-secure-sdk",
"repo": "ledger-secure-sdk",
"private": false,
"rev": "62dd047774b5e8a6b4e6158b493ee029453b5bae",
"sha256": "0y0czagzcrhjb5sfwzf6z2alk6227r3j3pgfc8aasg46zxisfrrz"
"rev": "36dd2110ad6349ab84da7bf9d33ecba5df9c4a19",
"sha256": "08icfqc82xxhzsy3r3zzbljas9v9fyjw6fcr3cgw7a8h7ybj2f4s"
}
4 changes: 2 additions & 2 deletions dep/ledger-secure-sdk-nanosplus/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"owner": "LedgerHQ",
"repo": "ledger-secure-sdk",
"private": false,
"rev": "48bb8d493548f840ddd261bbe60930f3f5966e7b",
"sha256": "1hgxygkp7qm46fpvd7mkiqzzaz82w510mfk7x4hmw3prkbvrlm3b"
"rev": "cfb10841a1044253190ac0c4f41d43414867fdad",
"sha256": "1kag9lchawp7ngl13wh077cbywm16p1qr9j5sdkv6y2f50wscx3g"
}
Loading

0 comments on commit e5b0d0e

Please sign in to comment.