Skip to content

Commit

Permalink
appflags should be set at device level
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed Dec 20, 2024
1 parent 52bec2a commit b65c669
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions cargo-ledger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cargo-ledger"
version = "1.5.1"
authors = ["yhql", "agrojean-ledger"]
version = "1.6.0"
authors = ["yhql", "agrojean-ledger", "y333"]
description = "Build and sideload Ledger devices apps"
categories = ["development-tools::cargo-plugins"]
repository = "https://github.com/LedgerHQ/cargo-ledger"
Expand Down
29 changes: 19 additions & 10 deletions cargo-ledger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ struct NanosMetadata {
struct LedgerMetadata {
curve: Vec<String>,
path: Vec<String>,
flags: String,
flags: Option<String>,
name: Option<String>,
}

#[derive(Debug, Deserialize)]
struct DeviceMetadata {
icon: String,
flags: Option<String>,
}

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -167,7 +168,7 @@ fn retrieve_metadata(
let ledger_metadata = LedgerMetadata {
curve: nanos_metadata.curve,
path: nanos_metadata.path,
flags: nanos_metadata.flags,
flags: Some(nanos_metadata.flags),
name: nanos_metadata.name,
};

Expand All @@ -176,6 +177,7 @@ fn retrieve_metadata(
Device::Nanos => nanos_metadata.icon,
_ => nanos_metadata.icon_small,
},
flags: None,
};

(this_pkg.clone(), ledger_metadata, device_metadata)
Expand Down Expand Up @@ -291,14 +293,21 @@ fn build_app(
// Retrieve real data size and SDK infos from ELF
let infos = retrieve_infos(&exe_path).unwrap();

// Modify flags to enable BLE if targeting Nano X
let flags = match device {
Device::Nanos | Device::Nanosplus => metadata_ledger.flags,
Device::Nanox | Device::Stax | Device::Flex => {
let base = u32::from_str_radix(metadata_ledger.flags.as_str(), 16)
.unwrap_or(0);
format!("0x{:x}", base | 0x200)
}
let flags = match metadata_device.flags {
Some(flags) => flags,
None => match metadata_ledger.flags {
Some(flags) => match device {
// Modify flags to enable BLE if targeting Nano X
Device::Nanos | Device::Nanosplus => flags,
Device::Nanox | Device::Stax | Device::Flex => {
let base =
u32::from_str_radix(flags.trim_start_matches("0x"), 16)
.unwrap_or(0);
format!("0x{:x}", base | 0x200)
}
},
None => String::from("0x00"),
},
};

// Target ID according to target, in case it
Expand Down

0 comments on commit b65c669

Please sign in to comment.