LedgerHQ / rust-app-password-manager

Apache License 2.0
16 stars 7 forks source link

cargo build error #14

Closed monperrus closed 1 year ago

monperrus commented 1 year ago

I'm finally trying out rust-app-password-manager you demoed in Paris :)

but I hit this error.

$ cargo build
 error: -Zbuild-std requires --target
± cargo --version
cargo 1.71.0

thanks!

monperrus commented 1 year ago

ping @yhql

yhql commented 1 year ago

Hi, this error pops up because we haven't specified a default target. You should install this tool https://github.com/LedgerHQ/cargo-ledger which will enable you to do cargo ledger setup from the command line, and that will make the nanos, nanox and nanosplus targets available from anywhere. Then you'll be able to do cargo build --target nanosplus in the password-manager repo, or use cargo ledger build nanosplus --load to build+load directly on device.

If you hit build errors even after using the custom targets, there's probably a few more steps you need to check on your toolchain installation, which are listed here https://github.com/LedgerHQ/ledger-nanos-sdk#usage

monperrus commented 1 year ago

thanks, making progress with cargo ledger setup

the next error is

error: failed to run custom build command for `nanopass v1.2.1 (rust-app-password-manager)`

Caused by:
  process didn't exit successfully: `/home/martin/martin-no-backup/rust-app-password-manager/target/debug/build/nanopass-7627437efbf19800/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'failed: Os { code: 2, kind: NotFound, message: "No such file or directory" }', build.rs:25:10

build.rs:25 is

    let output = Command::new("arm-none-eabi-gcc")
        .arg("-print-sysroot")
        .output()
        .expect("failed");
monperrus commented 1 year ago

Installing gcc-arm-none-eabi from https://developer.arm.com/downloads/-/gnu-rm in a local directory

Verifying that the command works:

± ./gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc -print-sysroot
/home/martin/rust-app-password-manager/gcc-arm-none-eabi-10.3-2021.10/bin/../arm-none-eabi

Changing let output = Command::new("arm-none-eabi-gcc") to let output = Command::new("gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc")

Now I can compile!

± cargo build --target nanosplus
   Compiling nanopass v1.2.1 (/home/martin/martin-no-backup/rust-app-password-manager)
    Finished dev [unoptimized + debuginfo] target(s) in 2.94s

Thanks a lot!

monperrus commented 1 year ago

Now, I'm now trying to create the hex file

It fails as follows.

± cargo ledger build nanosplus
   Compiling heapless v0.7.16
   Compiling nanopass v1.2.1 (/home/martin/rust-app-password-manager)
    Finished release [optimized] target(s) in 1.01s
thread 'main' panicked at 'Objcopy failed: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/utils.rs:34:10

Any suggestion? Thanks!

monperrus commented 1 year ago

arm-none-eabi-objcopy was missing.

Fix is export PATH=gcc-arm-none-eabi-10.3-2021.10/bin/:$PATH

$ cargo ledger build nanosplus
    Finished release [optimized] target(s) in 0.06s
   text    data     bss     dec     hex filename
  25600   16896    1904   44400    ad70 /home/martin/martin-no-backup/rust-app-password-manager/target/nanosplus/release/nanopass
$ ls app_nanosplus.json
monperrus commented 1 year ago

Could build and run NanoPass.

https://github.com/LedgerHQ/rust-app-password-manager/pull/15 improves the documentation accordingly.

thanks @yhql .