Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Download and install custom target JSONs automatically #18

Merged
merged 4 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 149 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"

[dependencies]
cargo_metadata = "0.11.0"
clap = { version = "3.1.12", features = ["derive"] }
clap = { version = "4.1.8", features = ["derive"] }
goblin = "0.2.3"
serde = "1.0"
serde_derive = "1.0"
Expand Down
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

Builds a Nano App and outputs a JSON manifest file that can be used by [ledgerctl](https://github.com/LedgerHQ/ledgerctl) to install an application directly.

In order to build for Nano S, Nano X, and Nano S Plus, [custom target files](https://docs.rust-embedded.org/embedonomicon/custom-target.html) are used. They can be found at the root of the [Rust SDK](https://github.com/LedgerHQ/ledger-nanos-sdk/).
In order to build for Nano S, Nano X, and Nano S Plus, [custom target files](https://docs.rust-embedded.org/embedonomicon/custom-target.html) are used. They can be found at the root of the [Rust SDK](https://github.com/LedgerHQ/ledger-nanos-sdk/) and can be installed automatically with the command `setup`.

## Installation

Only `arm-none-eabi-objcopy` is needed.
This program requires:

- `arm-none-eabi-objcopy`
- [`ledgerctl`](https://github.com/LedgerHQ/ledgerctl)

Install this repo with:

Expand All @@ -23,28 +26,32 @@ cargo install --path .
Note that `cargo`'s dependency resolver may behave differently when installing, and you may end up with errors.
In order to fix those and force usage of the versions specified in the tagged `Cargo.lock`, append `--locked` to the above commands.

### Setting up custom targets

The preferred method is to have all custom target files (`nanos.json`, `nanox.json` and `nanosplus.json`) in a separate folder, and set an environment variable called `LEDGER_TARGETS` pointing to this folder.
## Usage

`cargo ledger` will check for this environment variable (or default to "" if it is empty) to fetch the current target specification.
General usage is displayed when invoking `cargo ledger`.

## Usage
### Setup

This will install custom target files from the SDK directly into your environment.

```
cargo ledger nanos
cargo ledger nanox
cargo ledger nanosplus
cargo ledger setup
```

Loading can optionally be performed by appending `--load` or `-l` to the command.
### Building

```
cargo ledger build nanos
cargo ledger build nanox
cargo ledger build nanosplus
```

By default, this program will attempt to build the current program with in `release` mode (full command: `cargo build -Zbuild-std -Zbuild-std-features=compiler-builtins-mem --release --target=nanos.json --message-format=json`)
Loading on device can optionally be performed by appending `--load` or `-l` to the command.

By default, this program will attempt to build the current program with in `release` mode (full command: `cargo build --release --target=nanos --message-format=json`)

Arguments can be passed to modify this behaviour after inserting a `--` like so:

```
cargo ledger nanos --load -- --features one -Z unstable-options --out-dir ./output/
cargo ledger build nanos --load -- --features one -Z unstable-options --out-dir ./output/
```
Loading