GithubHelp home page GithubHelp logo

isabella232 / rust-app-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ledgerhq/rust-app-demo

0.0 0.0 0.0 1.45 MB

(DEPRECATED) Proof of concept setup for a Rust App on Nano

License: Apache License 2.0

Rust 98.33% C 0.95% Assembly 0.30% Python 0.42%

rust-app-demo's Introduction

DEPRECATED: Now obsolete in favour of this new demo that uses an improved structure and a Rust UI.

Rust bindings to the SDK and app

Hybrid of Ledger's SDK that will allow incrementally replacing parts of the C SDK with safer Rust code.

This project allows you to develop an app for Nano S in Rust.

Installation

Installation requires adding a toolchain to your Rust installation, and both Clang and arm-none-eabi-gcc. The minimum required rustc version is 1.40.0.

Building

You can build on either Windows or Linux with a simple cargo build or cargo build --release

If you want to use a specific SDK (once you have generated the bindings), use: export BOLOS_SDK=/path/to/sdk/; cargo build

By default, the SDK available as a submodule in this project will be used if BOLOS_SDK is not specified.

Testing

One can for example use speculos

cargo run defaults to running speculos on the generated binary with the appropriate flags, if speculos.py is in your PATH.

On a real device, you can use the loading script load.py.

There is a small test script that sends some of the available commands in test/test_cmds.py

Generating the bindings

Pregenerated bindings to the sdk as a subrepo are already available for this project (in ./src/bindings.rs).

If you want to use another SDK, you can use bindgen:

cargo install bindgen

Those can be generated by copy-pasting wrapper.h in the root of this directory to the root of the SDK, and then using the following command :

TARGET=thumbv6m-none-eabi bindgen wrapper.h --use-core --no-prepend-enum-name --no-doc-comments --with-derive-default --no-derive-debug --ctypes-prefix=cty -- -fshort-enums -Ilib_ux/include -I. > bindings.rs

Then, copy bindings.rs into the src folder of this project.

Note that wrapper.h contains flag definitions that might not match with your expected app configuration. You can change those before generating the bindings.

What's next

The goal would be to reduce the C part as much as possible, and make every feature of the C SDK easily available in Rust. This means taking care of some macros that are not exported in the bindings.

There are some parts that could be simplified in build.rs also.

Lots of code could be reused from this great project: Rust BOLOS 3rd party SDK by @roosmaa which unfortunately does not seem to be functioning or maintained.

rust-app-demo's People

Contributors

kingofpayne avatar yhql avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.