From 2bcc1d61d9348e2c37789c05ac62125ef66e93e8 Mon Sep 17 00:00:00 2001 From: Harrison Chin <2943043+harrychin@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:44:46 -0600 Subject: [PATCH 001/154] Make link-wrap.sh Linux and macOS cross-platform compatible Replace `stat -c %z` with `wc -c <` as the native stat command for macOS doesn't support that option. --- ledger_device_sdk/link_wrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_device_sdk/link_wrap.sh b/ledger_device_sdk/link_wrap.sh index 31f6cb7e..7decd9e3 100755 --- a/ledger_device_sdk/link_wrap.sh +++ b/ledger_device_sdk/link_wrap.sh @@ -28,7 +28,7 @@ llvm-objcopy --dump-section .rel.nvm_data=$OUT-nvm-reloc $OUT /dev/null || true cat $OUT-rodata-reloc $OUT-nvm-reloc $OUT-data-reloc > $OUT-relocs || true reloc_allocated_size="$((0x$(llvm-nm $OUT | grep _reloc_size | cut -d' ' -f1)))" -reloc_real_size="$(stat -c %s $OUT-relocs)" +reloc_real_size="$(wc -c < "$OUT-relocs")" # Check that our relocations _actually_ fit. if [ "$reloc_real_size" -gt "$reloc_allocated_size" ] then From 9d13e156825ba6c01eb5a89065fe5fd8643ebec4 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 17 Oct 2024 10:24:46 +0200 Subject: [PATCH 002/154] Passing arg0 to c_main makes the SDK start as lib --- ledger_secure_sdk_sys/src/c/src.c | 102 ++++++++++++++++-------------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index 5542e4d1..d0b2e140 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -14,7 +14,7 @@ bolos_ux_asynch_callback_t G_io_asynch_ux_callback; #endif -extern void sample_main(); +extern void sample_main(int arg0); extern void heap_init(); struct SectionSrc; @@ -258,7 +258,7 @@ void link_pass_nvram( uint8_t G_io_apdu_buffer[260]; #endif -int c_main(void) { +int c_main(int arg0) { __asm volatile("cpsie i"); // Update pointers for pic(), only issuing nvm_write() if we actually changed a pointer in the block. @@ -281,11 +281,13 @@ int c_main(void) { link_pass_ram(data_len, sidata_src, data); - size_t bss_len; - SYMBOL_ABSOLUTE_VALUE(bss_len, _bss_len); - struct SectionDst* bss; - SYMBOL_SBREL_ADDRESS(bss, _bss); - memset(bss, 0, bss_len); + if (arg0 == 0) { + size_t bss_len; + SYMBOL_ABSOLUTE_VALUE(bss_len, _bss_len); + struct SectionDst* bss; + SYMBOL_SBREL_ADDRESS(bss, _bss); + memset(bss, 0, bss_len); + } // formerly known as 'os_boot()' try_context_set(NULL); @@ -293,49 +295,51 @@ int c_main(void) { for(;;) { BEGIN_TRY { TRY { - // below is a 'manual' implementation of `io_seproxyhal_init` - #ifdef HAVE_MCU_PROTECT - unsigned char c[4]; - c[0] = SEPROXYHAL_TAG_MCU; - c[1] = 0; - c[2] = 1; - c[3] = SEPROXYHAL_TAG_MCU_TYPE_PROTECT; - io_seproxyhal_spi_send(c, 4); - #endif - - #ifdef HAVE_BLE - unsigned int plane = G_io_app.plane_mode; - #endif - - memset(&G_io_app, 0, sizeof(G_io_app)); - - #ifdef HAVE_BLE - G_io_app.plane_mode = plane; - #endif - G_io_app.apdu_state = APDU_IDLE; - G_io_app.apdu_length = 0; - G_io_app.apdu_media = IO_APDU_MEDIA_NONE; - - G_io_app.ms = 0; - io_usb_hid_init(); - - USB_power(0); - USB_power(1); - #ifdef HAVE_CCID - io_usb_ccid_set_card_inserted(1); - #endif - - #ifdef HAVE_BLE - memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback)); - BLE_power(1, NULL); - #endif - - #if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) - check_audited_app(); - #endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) - + if (arg0 == 0) { + // below is a 'manual' implementation of `io_seproxyhal_init` + #ifdef HAVE_MCU_PROTECT + unsigned char c[4]; + c[0] = SEPROXYHAL_TAG_MCU; + c[1] = 0; + c[2] = 1; + c[3] = SEPROXYHAL_TAG_MCU_TYPE_PROTECT; + io_seproxyhal_spi_send(c, 4); + #endif + + #ifdef HAVE_BLE + unsigned int plane = G_io_app.plane_mode; + #endif + + memset(&G_io_app, 0, sizeof(G_io_app)); + + #ifdef HAVE_BLE + G_io_app.plane_mode = plane; + #endif + G_io_app.apdu_state = APDU_IDLE; + G_io_app.apdu_length = 0; + G_io_app.apdu_media = IO_APDU_MEDIA_NONE; + + G_io_app.ms = 0; + io_usb_hid_init(); + + USB_power(0); + USB_power(1); + #ifdef HAVE_CCID + io_usb_ccid_set_card_inserted(1); + #endif + + #ifdef HAVE_BLE + memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback)); + BLE_power(1, NULL); + #endif + + #if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) + check_audited_app(); + #endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) + } + heap_init(); - sample_main(); + sample_main(arg0); } CATCH(EXCEPTION_IO_RESET) { continue; From 3721248896a2b7a9087916d55b6e7bb807f60874 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 18 Oct 2024 19:08:06 +0200 Subject: [PATCH 003/154] Swap: check_address cmd handler --- ledger_device_sdk/src/lib.rs | 1 + ledger_secure_sdk_sys/build.rs | 1 + ledger_secure_sdk_sys/src/c/src.c | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ledger_device_sdk/src/lib.rs b/ledger_device_sdk/src/lib.rs index 2c82630e..523a220c 100644 --- a/ledger_device_sdk/src/lib.rs +++ b/ledger_device_sdk/src/lib.rs @@ -16,6 +16,7 @@ pub mod ecc; pub mod hash; pub mod hmac; pub mod io; +pub mod libcall; pub mod nvm; pub mod random; pub mod screen; diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 55ef49d8..47c5cf0e 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -501,6 +501,7 @@ impl SDKBuilder { "include/ox.h", /* crypto-related syscalls */ "lib_stusb/STM32_USB_Device_Library/Core/Inc/usbd_def.h", "include/os_io_usb.h", + "lib_standard_app/swap_lib_calls.h", ], ); diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index d0b2e140..effa3788 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -336,9 +336,8 @@ int c_main(int arg0) { #if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) check_audited_app(); #endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) + heap_init(); } - - heap_init(); sample_main(arg0); } CATCH(EXCEPTION_IO_RESET) { From 7e3a6b2971c5dc42733e25625aa9dcedc3f030ee Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 22 Oct 2024 06:29:41 +0200 Subject: [PATCH 004/154] check_address parameters fixed cast --- ledger_device_sdk/src/libcall.rs | 170 ++++++++++++++++++++++ ledger_device_sdk/src/libcall/string.rs | 183 ++++++++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 ledger_device_sdk/src/libcall.rs create mode 100644 ledger_device_sdk/src/libcall/string.rs diff --git a/ledger_device_sdk/src/libcall.rs b/ledger_device_sdk/src/libcall.rs new file mode 100644 index 00000000..367ec82a --- /dev/null +++ b/ledger_device_sdk/src/libcall.rs @@ -0,0 +1,170 @@ +use crate::testing::debug_print; +use ledger_secure_sdk_sys::libargs_s__bindgen_ty_1; +use ledger_secure_sdk_sys::{ + check_address_parameters_t, create_transaction_parameters_t, get_printable_amount_parameters_t, + libargs_t, os_lib_end, CHECK_ADDRESS, GET_PRINTABLE_AMOUNT, SIGN_TRANSACTION, +}; + +mod string; +use string::CustomString; + +pub struct CheckAddressParams { + pub dpath: [u8; 64], + pub dpath_len: usize, + pub ref_address: [u8; 64], + pub ref_address_len: usize, +} + +impl Default for CheckAddressParams { + fn default() -> Self { + CheckAddressParams { + dpath: [0; 64], + dpath_len: 0, + ref_address: [0; 64], + ref_address_len: 0, + } + } +} + +pub enum LibCallCommand { + SignTransaction, + GetPrintableAmount, + CheckAddress, +} + +impl From for LibCallCommand { + fn from(command: u32) -> Self { + match command { + SIGN_TRANSACTION => LibCallCommand::SignTransaction, + GET_PRINTABLE_AMOUNT => LibCallCommand::GetPrintableAmount, + CHECK_ADDRESS => LibCallCommand::CheckAddress, + _ => panic!("Unknown command"), + } + } +} + +pub fn get_command(arg0: u32) -> LibCallCommand { + debug_print("GET_CMD\n"); + let mut libarg: libargs_t = libargs_t::default(); + + let arg = arg0 as *const u32; + + libarg.id = unsafe { *arg }; + libarg.command = unsafe { *arg.add(1) }; + libarg.unused = unsafe { *arg.add(2) }; + + debug_print("libarg content:\n"); + let id = CustomString::<8>::from(libarg.id); + debug_print(id.as_str()); + debug_print("\n"); + let cmd = CustomString::<8>::from(libarg.command); + debug_print(cmd.as_str()); + debug_print("\n"); + let unused = CustomString::<8>::from(libarg.unused); + debug_print(unused.as_str()); + debug_print("\n"); + + libarg.command.into() +} + +pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { + debug_print("GET_CHECK_ADDRESS_PARAMS\n"); + + let mut libarg: libargs_t = libargs_t::default(); + + let arg = arg0 as *const u32; + + libarg.id = unsafe { *arg }; + libarg.command = unsafe { *arg.add(1) }; + libarg.unused = unsafe { *arg.add(2) }; + + debug_print("libarg content:\n"); + let id = CustomString::<8>::from(libarg.id); + debug_print(id.as_str()); + debug_print("\n"); + let cmd = CustomString::<8>::from(libarg.command); + debug_print(cmd.as_str()); + debug_print("\n"); + let unused = CustomString::<8>::from(libarg.unused); + debug_print(unused.as_str()); + debug_print("\n"); + + libarg.__bindgen_anon_1 = unsafe { *(arg.add(3) as *const libargs_s__bindgen_ty_1) }; + + let params: check_address_parameters_t = + unsafe { *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t) }; + + let mut check_address_params: CheckAddressParams = Default::default(); + + unsafe { + debug_print("Display address_parameters\n"); + for i in 0..10 { + let s = CustomString::<2>::from(*((params.address_parameters as *const u8).add(i))); + debug_print(s.as_str()); + } + } + debug_print("\n"); + + unsafe { + debug_print("GET_DPATH_LENGTH\n"); + check_address_params.dpath_len = *params.address_parameters as usize; + + if check_address_params.dpath_len == 21 { + debug_print("dpath_len is 21\n"); + } + + debug_print("GET_DPATH \n"); + for i in 1..check_address_params.dpath_len * 4 { + check_address_params.dpath[i - 1] = *(params.address_parameters.add(i)); + } + + debug_print("GET_REF_ADDRESS\n"); + let mut address_length = 0usize; + while *(params.address_to_check.wrapping_add(address_length)) != '\0' as i8 { + address_length += 1; + } + + check_address_params.ref_address_len = address_length; + + for i in 0..address_length { + check_address_params.ref_address[i] = *(params.address_to_check.wrapping_add(i)) as u8; + } + } + + check_address_params +} + +// match libarg.command { +// SIGN_TRANSACTION => { +// debug_print("SIGN_TX\n"); +// let sign_tx_param: create_transaction_parameters_t = +// unsafe { *(arg.add(3) as *const create_transaction_parameters_t) }; +// } +// GET_PRINTABLE_AMOUNT => { +// debug_print("GET_PRINTABLE_AMOUNT\n"); +// let get_printable_amount_param: get_printable_amount_parameters_t = +// unsafe { *(arg.add(3) as *const get_printable_amount_parameters_t) }; +// } +// CHECK_ADDRESS => { +// let value = unsafe { *arg.add(3) as *mut check_address_parameters_t }; +// let params: &mut check_address_parameters_t = unsafe { &mut *value }; + +// let mut check_address_params: CheckAddressParams = Default::default(); + +// check_address_params.dpath_len = params.dpath_len; +// check_address_params +// .dpath +// .copy_from_slice(¶ms.dpath[..params.dpath_len]); + +// check_address_params.ref_address = params.address_to_check as *const u8; +// } +// _ => { +// debug_print("unknown command\n"); +// } +// } + +// debug_print("end of call app as a lib\n"); +// unsafe { +// os_lib_end(); +// } +// } diff --git a/ledger_device_sdk/src/libcall/string.rs b/ledger_device_sdk/src/libcall/string.rs new file mode 100644 index 00000000..f65665dd --- /dev/null +++ b/ledger_device_sdk/src/libcall/string.rs @@ -0,0 +1,183 @@ +#[derive(Debug, Copy, Clone)] +pub struct CustomString { + pub arr: [u8; N], + pub capacity: usize, + pub len: usize, +} + +impl Default for CustomString { + fn default() -> Self { + Self { + arr: [b'0'; N], + capacity: N, + len: 0, + } + } +} + +impl CustomString { + pub fn new() -> Self { + Self { + arr: [b'0'; N], + capacity: N, + len: 0, + } + } + + pub fn clear(&mut self) { + self.arr.fill(0); + self.len = 0; + } + + pub fn as_str(&self) -> &str { + core::str::from_utf8(&self.arr[..self.len]).unwrap() + } + + pub fn copy_from(&mut self, s: &CustomString) { + self.arr[..s.len].copy_from_slice(&s.arr[..s.len]); + self.len = s.len; + } +} + +impl From for CustomString<2> { + fn from(val: u8) -> Self { + let mut s = CustomString::<2>::new(); + let mut i: usize = 0; + for c in val.to_be_bytes().into_iter() { + let (c0, c1) = byte_to_hex(c); + s.arr[i] = c0 as u8; + s.arr[i + 1] = c1 as u8; + s.len += 2; + i += 2; + } + s + } +} + +impl From for CustomString<4> { + fn from(val: u16) -> Self { + let mut s = CustomString::<4>::new(); + let mut i: usize = 0; + for c in val.to_be_bytes().into_iter() { + let (c0, c1) = byte_to_hex(c); + s.arr[i] = c0 as u8; + s.arr[i + 1] = c1 as u8; + s.len += 2; + i += 2; + } + s + } +} + +impl From for CustomString<8> { + fn from(val: u32) -> Self { + let mut s = CustomString::<8>::new(); + let mut i: usize = 0; + for c in val.to_be_bytes().into_iter() { + let (c0, c1) = byte_to_hex(c); + s.arr[i] = c0 as u8; + s.arr[i + 1] = c1 as u8; + s.len += 2; + i += 2; + } + s + } +} + +impl From<[u8; 32]> for CustomString<64> { + fn from(arr: [u8; 32]) -> Self { + let mut s = CustomString::<64>::new(); + let mut i: usize = 0; + for c in arr.into_iter() { + let (c0, c1) = byte_to_hex(c); + s.arr[i] = c0 as u8; + s.arr[i + 1] = c1 as u8; + s.len += 2; + i += 2; + } + s + } +} + +impl TryFrom<&str> for CustomString { + type Error = &'static str; + fn try_from(st: &str) -> Result { + if N >= st.len() { + let mut s = CustomString::::new(); + s.arr[..st.len()].copy_from_slice(st.as_bytes()); + s.len = st.len(); + Ok(s) + } else { + Err("CustomString's capacity overflow!") + } + } +} + +/// Output an uint256 as an decimal CustomString +/// For instance: +/// +/// let val: [u8; 32] = token amount (32 bytes / 256 bits); +/// let s: CustomString<79> = uint256_to_integer(&val); // max number of decimal digits for Uint256 = 78 (+ 1 spare for '.') +/// testing::debug_print(s.print().unwrap()); +pub fn uint256_to_integer(value: &[u8; 32]) -> CustomString<79> { + let mut s: CustomString<79> = CustomString::new(); + + // Special case when value is 0 + if *value == [0u8; 32] { + s.arr[0] = b'0'; + s.len = 1; + return s; + } + + let mut n: [u16; 16] = [0u16; 16]; + for idx in 0..16 { + n[idx] = u16::from_be_bytes([value[2 * idx], value[2 * idx + 1]]); + } + + let mut pos: usize = s.capacity; + while n != [0u16; 16] { + if pos == 0 { + return s; + } + pos -= 1; + let mut carry = 0u32; + let mut rem: u32; + for i in 0..16 { + rem = ((carry << 16) | u32::from(n[i])) % 10; + n[i] = (((carry << 16) | u32::from(n[i])) / 10) as u16; + carry = rem; + } + s.arr[pos] = u8::try_from(char::from_digit(carry, 10).unwrap()).unwrap(); + } + s.arr.copy_within(pos.., 0); + s.len = s.capacity - pos; + s +} + +/// Output an uint256 as a float string +pub fn uint256_to_float(value: &[u8; 32], decimals: usize) -> CustomString<79> { + let mut s: CustomString<79> = uint256_to_integer(value); + + if decimals == 0 || s.arr[0] == b'0' { + return s; + } + + if s.len <= decimals { + s.arr.copy_within(0..s.len, 2 + decimals - s.len); + s.arr[0..2 + decimals - s.len].fill(b'0'); + s.arr[1] = b'.'; + s.len += 2 + decimals - s.len; + } else { + s.arr + .copy_within(s.len - decimals..s.len, s.len - decimals + 1); + s.arr[s.len - decimals] = b'.'; + s.len += 1; + } + s +} + +fn byte_to_hex(b: u8) -> (char, char) { + let c0 = char::from_digit((b >> 4).into(), 16).unwrap(); + let c1 = char::from_digit((b & 0xf).into(), 16).unwrap(); + (c0, c1) +} From 2d310f757ba3f1597831761db0be8916f63826fa Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 5 Dec 2024 10:29:36 +0100 Subject: [PATCH 005/154] Retrieve and provide app CHECK_ADDRESS parameters --- ledger_device_sdk/src/libcall.rs | 79 +++++++++++++++++++------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/ledger_device_sdk/src/libcall.rs b/ledger_device_sdk/src/libcall.rs index 367ec82a..e084a9bd 100644 --- a/ledger_device_sdk/src/libcall.rs +++ b/ledger_device_sdk/src/libcall.rs @@ -13,6 +13,7 @@ pub struct CheckAddressParams { pub dpath_len: usize, pub ref_address: [u8; 64], pub ref_address_len: usize, + pub result: *mut i32, } impl Default for CheckAddressParams { @@ -22,6 +23,7 @@ impl Default for CheckAddressParams { dpath_len: 0, ref_address: [0; 64], ref_address_len: 0, + result: core::ptr::null_mut(), } } } @@ -68,49 +70,47 @@ pub fn get_command(arg0: u32) -> LibCallCommand { } pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { - debug_print("GET_CHECK_ADDRESS_PARAMS\n"); + unsafe { + debug_print("GET_CHECK_ADDRESS_PARAMS\n"); - let mut libarg: libargs_t = libargs_t::default(); + let mut libarg: libargs_t = libargs_t::default(); - let arg = arg0 as *const u32; + let arg = arg0 as *const u32; - libarg.id = unsafe { *arg }; - libarg.command = unsafe { *arg.add(1) }; - libarg.unused = unsafe { *arg.add(2) }; + libarg.id = *arg; + libarg.command = *arg.add(1); + libarg.unused = *arg.add(2); - debug_print("libarg content:\n"); - let id = CustomString::<8>::from(libarg.id); - debug_print(id.as_str()); - debug_print("\n"); - let cmd = CustomString::<8>::from(libarg.command); - debug_print(cmd.as_str()); - debug_print("\n"); - let unused = CustomString::<8>::from(libarg.unused); - debug_print(unused.as_str()); - debug_print("\n"); + debug_print("libarg content:\n"); + let id = CustomString::<8>::from(libarg.id); + debug_print(id.as_str()); + debug_print("\n"); + let cmd = CustomString::<8>::from(libarg.command); + debug_print(cmd.as_str()); + debug_print("\n"); + let unused = CustomString::<8>::from(libarg.unused); + debug_print(unused.as_str()); + debug_print("\n"); - libarg.__bindgen_anon_1 = unsafe { *(arg.add(3) as *const libargs_s__bindgen_ty_1) }; + libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); - let params: check_address_parameters_t = - unsafe { *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t) }; + let params: check_address_parameters_t = + *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t); - let mut check_address_params: CheckAddressParams = Default::default(); + let mut check_address_params: CheckAddressParams = Default::default(); - unsafe { debug_print("Display address_parameters\n"); for i in 0..10 { let s = CustomString::<2>::from(*((params.address_parameters as *const u8).add(i))); debug_print(s.as_str()); } - } - debug_print("\n"); + debug_print("\n"); - unsafe { debug_print("GET_DPATH_LENGTH\n"); - check_address_params.dpath_len = *params.address_parameters as usize; + check_address_params.dpath_len = *(params.address_parameters as *const u8) as usize; - if check_address_params.dpath_len == 21 { - debug_print("dpath_len is 21\n"); + if check_address_params.dpath_len == 5 { + debug_print("dpath_len is 5\n"); } debug_print("GET_DPATH \n"); @@ -121,17 +121,30 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { debug_print("GET_REF_ADDRESS\n"); let mut address_length = 0usize; while *(params.address_to_check.wrapping_add(address_length)) != '\0' as i8 { + check_address_params.ref_address[address_length] = + *(params.address_to_check.wrapping_add(address_length)) as u8; address_length += 1; } - check_address_params.ref_address_len = address_length; - for i in 0..address_length { - check_address_params.ref_address[i] = *(params.address_to_check.wrapping_add(i)) as u8; - } - } + // "EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U" + debug_print("Display ref address\n"); - check_address_params + let mut s = CustomString::<44>::new(); + s.arr.copy_from_slice( + &check_address_params.ref_address[..check_address_params.ref_address_len], + ); + s.len = check_address_params.ref_address_len; + debug_print(s.as_str()); + debug_print("\n"); + + //(*(libarg.__bindgen_anon_1.check_address as *mut check_address_parameters_t)).result = 1; + check_address_params.result = (&(*(libarg.__bindgen_anon_1.check_address + as *mut check_address_parameters_t)) + .result as *const i32 as *mut i32); + + check_address_params + } } // match libarg.command { From f42efe0b01f21d2cdfa0c3cadf9967acc76f53b7 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 5 Dec 2024 17:04:37 +0100 Subject: [PATCH 006/154] Retrieve and provide app GET_PRINTABLE_AMOUNT parameters --- ledger_device_sdk/src/libcall.rs | 59 ++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/ledger_device_sdk/src/libcall.rs b/ledger_device_sdk/src/libcall.rs index e084a9bd..ee354cca 100644 --- a/ledger_device_sdk/src/libcall.rs +++ b/ledger_device_sdk/src/libcall.rs @@ -5,7 +5,7 @@ use ledger_secure_sdk_sys::{ libargs_t, os_lib_end, CHECK_ADDRESS, GET_PRINTABLE_AMOUNT, SIGN_TRANSACTION, }; -mod string; +pub mod string; use string::CustomString; pub struct CheckAddressParams { @@ -28,6 +28,22 @@ impl Default for CheckAddressParams { } } +pub struct PrintableAmountParams { + pub amount: [u8; 16], + pub amount_len: usize, + pub amount_str: *mut i8, +} + +impl Default for PrintableAmountParams { + fn default() -> Self { + PrintableAmountParams { + amount: [0; 16], + amount_len: 0, + amount_str: core::ptr::null_mut(), + } + } +} + pub enum LibCallCommand { SignTransaction, GetPrintableAmount, @@ -114,7 +130,7 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { } debug_print("GET_DPATH \n"); - for i in 1..check_address_params.dpath_len * 4 { + for i in 1..1 + check_address_params.dpath_len * 4 { check_address_params.dpath[i - 1] = *(params.address_parameters.add(i)); } @@ -147,6 +163,45 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { } } +pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { + unsafe { + debug_print("GET_PRINTABLE_AMOUNT_PARAMS\n"); + + let mut libarg: libargs_t = libargs_t::default(); + + let arg = arg0 as *const u32; + + libarg.id = *arg; + libarg.command = *arg.add(1); + libarg.unused = *arg.add(2); + + libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + + let params: get_printable_amount_parameters_t = + *(libarg.__bindgen_anon_1.get_printable_amount + as *const get_printable_amount_parameters_t); + + let mut printable_amount_params: PrintableAmountParams = Default::default(); + + debug_print("GET_AMOUNT_LENGTH\n"); + printable_amount_params.amount_len = params.amount_length as usize; + + debug_print("GET_AMOUNT\n"); + for i in 0..printable_amount_params.amount_len { + printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = + *(params.amount.add(i)); + } + + debug_print("GET_AMOUNT_STR\n"); + printable_amount_params.amount_str = (&(*(libarg.__bindgen_anon_1.get_printable_amount + as *mut get_printable_amount_parameters_t)) + .printable_amount as *const i8 + as *mut i8); + + printable_amount_params + } +} + // match libarg.command { // SIGN_TRANSACTION => { // debug_print("SIGN_TX\n"); From e35734b4e06891a493c728771274183967014866 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 5 Dec 2024 17:46:36 +0100 Subject: [PATCH 007/154] swap module (libcall use case) --- ledger_device_sdk/src/libcall.rs | 221 ++------------------------ ledger_device_sdk/src/libcall/swap.rs | 123 ++++++++++++++ 2 files changed, 132 insertions(+), 212 deletions(-) create mode 100644 ledger_device_sdk/src/libcall/swap.rs diff --git a/ledger_device_sdk/src/libcall.rs b/ledger_device_sdk/src/libcall.rs index ee354cca..b747b412 100644 --- a/ledger_device_sdk/src/libcall.rs +++ b/ledger_device_sdk/src/libcall.rs @@ -1,61 +1,22 @@ use crate::testing::debug_print; -use ledger_secure_sdk_sys::libargs_s__bindgen_ty_1; -use ledger_secure_sdk_sys::{ - check_address_parameters_t, create_transaction_parameters_t, get_printable_amount_parameters_t, - libargs_t, os_lib_end, CHECK_ADDRESS, GET_PRINTABLE_AMOUNT, SIGN_TRANSACTION, -}; -pub mod string; -use string::CustomString; - -pub struct CheckAddressParams { - pub dpath: [u8; 64], - pub dpath_len: usize, - pub ref_address: [u8; 64], - pub ref_address_len: usize, - pub result: *mut i32, -} - -impl Default for CheckAddressParams { - fn default() -> Self { - CheckAddressParams { - dpath: [0; 64], - dpath_len: 0, - ref_address: [0; 64], - ref_address_len: 0, - result: core::ptr::null_mut(), - } - } -} +use ledger_secure_sdk_sys::{libargs_t, CHECK_ADDRESS, GET_PRINTABLE_AMOUNT, SIGN_TRANSACTION}; -pub struct PrintableAmountParams { - pub amount: [u8; 16], - pub amount_len: usize, - pub amount_str: *mut i8, -} - -impl Default for PrintableAmountParams { - fn default() -> Self { - PrintableAmountParams { - amount: [0; 16], - amount_len: 0, - amount_str: core::ptr::null_mut(), - } - } -} +pub mod string; +pub mod swap; pub enum LibCallCommand { - SignTransaction, - GetPrintableAmount, - CheckAddress, + SwapSignTransaction, + SwapGetPrintableAmount, + SwapCheckAddress, } impl From for LibCallCommand { fn from(command: u32) -> Self { match command { - SIGN_TRANSACTION => LibCallCommand::SignTransaction, - GET_PRINTABLE_AMOUNT => LibCallCommand::GetPrintableAmount, - CHECK_ADDRESS => LibCallCommand::CheckAddress, + SIGN_TRANSACTION => LibCallCommand::SwapSignTransaction, + GET_PRINTABLE_AMOUNT => LibCallCommand::SwapGetPrintableAmount, + CHECK_ADDRESS => LibCallCommand::SwapCheckAddress, _ => panic!("Unknown command"), } } @@ -70,169 +31,5 @@ pub fn get_command(arg0: u32) -> LibCallCommand { libarg.id = unsafe { *arg }; libarg.command = unsafe { *arg.add(1) }; libarg.unused = unsafe { *arg.add(2) }; - - debug_print("libarg content:\n"); - let id = CustomString::<8>::from(libarg.id); - debug_print(id.as_str()); - debug_print("\n"); - let cmd = CustomString::<8>::from(libarg.command); - debug_print(cmd.as_str()); - debug_print("\n"); - let unused = CustomString::<8>::from(libarg.unused); - debug_print(unused.as_str()); - debug_print("\n"); - libarg.command.into() } - -pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { - unsafe { - debug_print("GET_CHECK_ADDRESS_PARAMS\n"); - - let mut libarg: libargs_t = libargs_t::default(); - - let arg = arg0 as *const u32; - - libarg.id = *arg; - libarg.command = *arg.add(1); - libarg.unused = *arg.add(2); - - debug_print("libarg content:\n"); - let id = CustomString::<8>::from(libarg.id); - debug_print(id.as_str()); - debug_print("\n"); - let cmd = CustomString::<8>::from(libarg.command); - debug_print(cmd.as_str()); - debug_print("\n"); - let unused = CustomString::<8>::from(libarg.unused); - debug_print(unused.as_str()); - debug_print("\n"); - - libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); - - let params: check_address_parameters_t = - *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t); - - let mut check_address_params: CheckAddressParams = Default::default(); - - debug_print("Display address_parameters\n"); - for i in 0..10 { - let s = CustomString::<2>::from(*((params.address_parameters as *const u8).add(i))); - debug_print(s.as_str()); - } - debug_print("\n"); - - debug_print("GET_DPATH_LENGTH\n"); - check_address_params.dpath_len = *(params.address_parameters as *const u8) as usize; - - if check_address_params.dpath_len == 5 { - debug_print("dpath_len is 5\n"); - } - - debug_print("GET_DPATH \n"); - for i in 1..1 + check_address_params.dpath_len * 4 { - check_address_params.dpath[i - 1] = *(params.address_parameters.add(i)); - } - - debug_print("GET_REF_ADDRESS\n"); - let mut address_length = 0usize; - while *(params.address_to_check.wrapping_add(address_length)) != '\0' as i8 { - check_address_params.ref_address[address_length] = - *(params.address_to_check.wrapping_add(address_length)) as u8; - address_length += 1; - } - check_address_params.ref_address_len = address_length; - - // "EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U" - debug_print("Display ref address\n"); - - let mut s = CustomString::<44>::new(); - s.arr.copy_from_slice( - &check_address_params.ref_address[..check_address_params.ref_address_len], - ); - s.len = check_address_params.ref_address_len; - debug_print(s.as_str()); - debug_print("\n"); - - //(*(libarg.__bindgen_anon_1.check_address as *mut check_address_parameters_t)).result = 1; - check_address_params.result = (&(*(libarg.__bindgen_anon_1.check_address - as *mut check_address_parameters_t)) - .result as *const i32 as *mut i32); - - check_address_params - } -} - -pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { - unsafe { - debug_print("GET_PRINTABLE_AMOUNT_PARAMS\n"); - - let mut libarg: libargs_t = libargs_t::default(); - - let arg = arg0 as *const u32; - - libarg.id = *arg; - libarg.command = *arg.add(1); - libarg.unused = *arg.add(2); - - libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); - - let params: get_printable_amount_parameters_t = - *(libarg.__bindgen_anon_1.get_printable_amount - as *const get_printable_amount_parameters_t); - - let mut printable_amount_params: PrintableAmountParams = Default::default(); - - debug_print("GET_AMOUNT_LENGTH\n"); - printable_amount_params.amount_len = params.amount_length as usize; - - debug_print("GET_AMOUNT\n"); - for i in 0..printable_amount_params.amount_len { - printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = - *(params.amount.add(i)); - } - - debug_print("GET_AMOUNT_STR\n"); - printable_amount_params.amount_str = (&(*(libarg.__bindgen_anon_1.get_printable_amount - as *mut get_printable_amount_parameters_t)) - .printable_amount as *const i8 - as *mut i8); - - printable_amount_params - } -} - -// match libarg.command { -// SIGN_TRANSACTION => { -// debug_print("SIGN_TX\n"); -// let sign_tx_param: create_transaction_parameters_t = -// unsafe { *(arg.add(3) as *const create_transaction_parameters_t) }; -// } -// GET_PRINTABLE_AMOUNT => { -// debug_print("GET_PRINTABLE_AMOUNT\n"); -// let get_printable_amount_param: get_printable_amount_parameters_t = -// unsafe { *(arg.add(3) as *const get_printable_amount_parameters_t) }; -// } -// CHECK_ADDRESS => { -// let value = unsafe { *arg.add(3) as *mut check_address_parameters_t }; -// let params: &mut check_address_parameters_t = unsafe { &mut *value }; - -// let mut check_address_params: CheckAddressParams = Default::default(); - -// check_address_params.dpath_len = params.dpath_len; -// check_address_params -// .dpath -// .copy_from_slice(¶ms.dpath[..params.dpath_len]); - -// check_address_params.ref_address = params.address_to_check as *const u8; -// } -// _ => { -// debug_print("unknown command\n"); -// } -// } - -// debug_print("end of call app as a lib\n"); -// unsafe { -// os_lib_end(); -// } -// } diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs new file mode 100644 index 00000000..ccad407b --- /dev/null +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -0,0 +1,123 @@ +use crate::testing::debug_print; +use ledger_secure_sdk_sys::{ + check_address_parameters_t, create_transaction_parameters_t, get_printable_amount_parameters_t, + libargs_s__bindgen_ty_1, libargs_t, +}; + +pub struct CheckAddressParams { + pub dpath: [u8; 64], + pub dpath_len: usize, + pub ref_address: [u8; 64], + pub ref_address_len: usize, + pub result: *mut i32, +} + +impl Default for CheckAddressParams { + fn default() -> Self { + CheckAddressParams { + dpath: [0; 64], + dpath_len: 0, + ref_address: [0; 64], + ref_address_len: 0, + result: core::ptr::null_mut(), + } + } +} + +pub struct PrintableAmountParams { + pub amount: [u8; 16], + pub amount_len: usize, + pub amount_str: *mut i8, +} + +impl Default for PrintableAmountParams { + fn default() -> Self { + PrintableAmountParams { + amount: [0; 16], + amount_len: 0, + amount_str: core::ptr::null_mut(), + } + } +} + +pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { + unsafe { + debug_print("GET_CHECK_ADDRESS_PARAMS\n"); + + let mut libarg: libargs_t = libargs_t::default(); + + let arg = arg0 as *const u32; + + libarg.id = *arg; + libarg.command = *arg.add(1); + libarg.unused = *arg.add(2); + + libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + + let params: check_address_parameters_t = + *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t); + + let mut check_address_params: CheckAddressParams = Default::default(); + + debug_print("GET_DPATH_LENGTH\n"); + check_address_params.dpath_len = *(params.address_parameters as *const u8) as usize; + + debug_print("GET_DPATH \n"); + for i in 1..1 + check_address_params.dpath_len * 4 { + check_address_params.dpath[i - 1] = *(params.address_parameters.add(i)); + } + + debug_print("GET_REF_ADDRESS\n"); + let mut address_length = 0usize; + while *(params.address_to_check.wrapping_add(address_length)) != '\0' as i8 { + check_address_params.ref_address[address_length] = + *(params.address_to_check.wrapping_add(address_length)) as u8; + address_length += 1; + } + check_address_params.ref_address_len = address_length; + + check_address_params.result = &(*(libarg.__bindgen_anon_1.check_address + as *mut check_address_parameters_t)) + .result as *const i32 as *mut i32; + + check_address_params + } +} + +pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { + unsafe { + debug_print("GET_PRINTABLE_AMOUNT_PARAMS\n"); + + let mut libarg: libargs_t = libargs_t::default(); + + let arg = arg0 as *const u32; + + libarg.id = *arg; + libarg.command = *arg.add(1); + libarg.unused = *arg.add(2); + + libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + + let params: get_printable_amount_parameters_t = + *(libarg.__bindgen_anon_1.get_printable_amount + as *const get_printable_amount_parameters_t); + + let mut printable_amount_params: PrintableAmountParams = Default::default(); + + debug_print("GET_AMOUNT_LENGTH\n"); + printable_amount_params.amount_len = params.amount_length as usize; + + debug_print("GET_AMOUNT\n"); + for i in 0..printable_amount_params.amount_len { + printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = + *(params.amount.add(i)); + } + + debug_print("GET_AMOUNT_STR\n"); + printable_amount_params.amount_str = &(*(libarg.__bindgen_anon_1.get_printable_amount + as *mut get_printable_amount_parameters_t)) + .printable_amount as *const i8 as *mut i8; + + printable_amount_params + } +} From ed340e8a37833b28d3b62a5dd904106d608b37bc Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 10 Dec 2024 11:29:16 +0100 Subject: [PATCH 008/154] Swap start signing tx usecase --- ledger_device_sdk/src/libcall/swap.rs | 89 +++++++++++++++++++++++++++ ledger_secure_sdk_sys/build.rs | 1 + ledger_secure_sdk_sys/src/c/src.c | 7 ++- 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index ccad407b..c5c5689f 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -4,6 +4,8 @@ use ledger_secure_sdk_sys::{ libargs_s__bindgen_ty_1, libargs_t, }; +use super::string::CustomString; + pub struct CheckAddressParams { pub dpath: [u8; 64], pub dpath_len: usize, @@ -40,6 +42,30 @@ impl Default for PrintableAmountParams { } } +pub struct CreateTxParams { + pub amount: [u8; 16], + pub amount_len: usize, + pub fee_amount: [u8; 16], + pub fee_amount_len: usize, + pub dest_address: [u8; 64], + pub dest_address_len: usize, + pub result: *mut u8, +} + +impl Default for CreateTxParams { + fn default() -> Self { + CreateTxParams { + amount: [0; 16], + amount_len: 0, + fee_amount: [0; 16], + fee_amount_len: 0, + dest_address: [0; 64], + dest_address_len: 0, + result: core::ptr::null_mut(), + } + } +} + pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { unsafe { debug_print("GET_CHECK_ADDRESS_PARAMS\n"); @@ -107,6 +133,11 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { debug_print("GET_AMOUNT_LENGTH\n"); printable_amount_params.amount_len = params.amount_length as usize; + let s = CustomString::<2>::from(printable_amount_params.amount_len as u8); + debug_print("AMOUNT LENGTH: \n"); + debug_print(s.as_str()); + debug_print("\n"); + debug_print("GET_AMOUNT\n"); for i in 0..printable_amount_params.amount_len { printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = @@ -121,3 +152,61 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { printable_amount_params } } + +pub fn sign_tx_params(arg0: u32) -> CreateTxParams { + unsafe { + debug_print("SIGN_TX_PARAMS\n"); + + let mut libarg: libargs_t = libargs_t::default(); + + let arg = arg0 as *const u32; + + libarg.id = *arg; + libarg.command = *arg.add(1); + libarg.unused = *arg.add(2); + + libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + + let params: create_transaction_parameters_t = + *(libarg.__bindgen_anon_1.create_transaction as *const create_transaction_parameters_t); + + let mut create_tx_params: CreateTxParams = Default::default(); + + debug_print("GET_AMOUNT_LENGTH\n"); + create_tx_params.amount_len = params.amount_length as usize; + + let s = CustomString::<2>::from(create_tx_params.amount_len as u8); + debug_print("AMOUNT LENGTH: \n"); + debug_print(s.as_str()); + debug_print("\n"); + + debug_print("GET_AMOUNT\n"); + for i in 0..create_tx_params.amount_len { + create_tx_params.amount[16 - create_tx_params.amount_len + i] = *(params.amount.add(i)); + } + + debug_print("GET_FEE_AMOUNT_LENGTH\n"); + create_tx_params.fee_amount_len = params.fee_amount_length as usize; + + debug_print("GET_FEE_AMOUNT\n"); + for i in 0..create_tx_params.fee_amount_len { + create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = + *(params.fee_amount.add(i)); + } + + debug_print("GET_DEST_ADDRESS\n"); + let mut dest_address_length = 0usize; + while *(params.destination_address.wrapping_add(dest_address_length)) != '\0' as i8 { + create_tx_params.dest_address[dest_address_length] = + *(params.destination_address.wrapping_add(dest_address_length)) as u8; + dest_address_length += 1; + } + create_tx_params.dest_address_len = dest_address_length; + + create_tx_params.result = &(*(libarg.__bindgen_anon_1.create_transaction + as *mut create_transaction_parameters_t)) + .result as *const u8 as *mut u8; + + create_tx_params + } +} diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 47c5cf0e..b7bbdfb2 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -426,6 +426,7 @@ impl SDKBuilder { .include(self.bolos_sdk.join("lib_cxng/include")) .include(self.bolos_sdk.join("lib_stusb")) .include(self.bolos_sdk.join("lib_stusb_impl")) + .include(self.bolos_sdk.join("lib_standard_app")) .include( self.bolos_sdk .join("lib_stusb/STM32_USB_Device_Library/Core/Inc"), diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index effa3788..875e108e 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -9,6 +9,7 @@ #include "os_nvm.h" #include "os_pic.h" #include "checks.h" +#include "swap_lib_calls.h" #ifdef HAVE_BLE #include "ledger_ble.h" bolos_ux_asynch_callback_t G_io_asynch_ux_callback; @@ -281,7 +282,9 @@ int c_main(int arg0) { link_pass_ram(data_len, sidata_src, data); - if (arg0 == 0) { + libargs_t *args = (libargs_t *) arg0; + + if (args == NULL || args->command == SIGN_TRANSACTION) { size_t bss_len; SYMBOL_ABSOLUTE_VALUE(bss_len, _bss_len); struct SectionDst* bss; @@ -295,7 +298,7 @@ int c_main(int arg0) { for(;;) { BEGIN_TRY { TRY { - if (arg0 == 0) { + if (args == NULL || args->command == SIGN_TRANSACTION) { // below is a 'manual' implementation of `io_seproxyhal_init` #ifdef HAVE_MCU_PROTECT unsigned char c[4]; From e51c879aa5d313039f8191cd2a35338a12b29cc9 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 12 Dec 2024 16:26:44 +0100 Subject: [PATCH 009/154] Manage lib vs std boot --- ledger_device_sdk/src/io.rs | 37 +++++++-- ledger_device_sdk/src/libcall/swap.rs | 22 ++--- ledger_secure_sdk_sys/build.rs | 1 - ledger_secure_sdk_sys/src/c/src.c | 111 +++++++++++++------------- 4 files changed, 99 insertions(+), 72 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index eebfded3..6a78e0bd 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -7,7 +7,7 @@ use ledger_secure_sdk_sys::*; #[cfg(feature = "ccid")] use crate::ccid; -use crate::seph; +use crate::{seph, testing}; use core::convert::{Infallible, TryFrom}; use core::ops::{Index, IndexMut}; @@ -170,7 +170,7 @@ impl Comm { /// Send the currently held APDU // This is private. Users should call reply to set the satus word and // transmit the response. - fn apdu_send(&mut self) { + fn apdu_send(&mut self, is_swap: bool) { if !sys_seph::is_status_sent() { sys_seph::send_general_status() } @@ -203,6 +203,13 @@ impl Comm { } _ => (), } + if is_swap { + if !sys_seph::is_status_sent() { + sys_seph::send_general_status() + } + sys_seph::seph_recv(&mut spi_buffer, 0); + seph::handle_event(&mut self.apdu_buffer, &spi_buffer); + } self.tx = 0; self.rx = 0; unsafe { @@ -506,7 +513,17 @@ impl Comm { self.apdu_buffer[self.tx + 1] = sw as u8; self.tx += 2; // Transmit the response - self.apdu_send(); + self.apdu_send(false); + } + + pub fn swap_reply>(&mut self, reply: T) { + let sw = reply.into().0; + // Append status word + self.apdu_buffer[self.tx] = (sw >> 8) as u8; + self.apdu_buffer[self.tx + 1] = sw as u8; + self.tx += 2; + // Transmit the response + self.apdu_send(true); } /// Set the Status Word of the response to `StatusWords::OK` (which is equal @@ -515,6 +532,10 @@ impl Comm { self.reply(StatusWords::Ok); } + pub fn swap_reply_ok(&mut self) { + self.swap_reply(StatusWords::Ok); + } + /// Return APDU Metadata pub fn get_apdu_metadata(&self) -> &ApduHeader { assert!(self.apdu_buffer.len() >= 4); @@ -552,10 +573,12 @@ impl Comm { } pub fn append(&mut self, m: &[u8]) { - for c in m.iter() { - self.apdu_buffer[self.tx] = *c; - self.tx += 1; - } + self.apdu_buffer[self.tx..self.tx + m.len()].copy_from_slice(m); + self.tx += m.len(); + // for c in m.iter() { + // self.apdu_buffer[self.tx] = *c; + // self.tx += 1; + // } } } diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index c5c5689f..36d3f8fd 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -1,3 +1,4 @@ +use crate::nbgl::NbglSpinner; use crate::testing::debug_print; use ledger_secure_sdk_sys::{ check_address_parameters_t, create_transaction_parameters_t, get_printable_amount_parameters_t, @@ -153,6 +154,11 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { } } +extern "C" { + fn c_reset_bss(); + fn c_boot_std(); +} + pub fn sign_tx_params(arg0: u32) -> CreateTxParams { unsafe { debug_print("SIGN_TX_PARAMS\n"); @@ -172,29 +178,19 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { let mut create_tx_params: CreateTxParams = Default::default(); - debug_print("GET_AMOUNT_LENGTH\n"); create_tx_params.amount_len = params.amount_length as usize; - let s = CustomString::<2>::from(create_tx_params.amount_len as u8); - debug_print("AMOUNT LENGTH: \n"); - debug_print(s.as_str()); - debug_print("\n"); - - debug_print("GET_AMOUNT\n"); for i in 0..create_tx_params.amount_len { create_tx_params.amount[16 - create_tx_params.amount_len + i] = *(params.amount.add(i)); } - debug_print("GET_FEE_AMOUNT_LENGTH\n"); create_tx_params.fee_amount_len = params.fee_amount_length as usize; - debug_print("GET_FEE_AMOUNT\n"); for i in 0..create_tx_params.fee_amount_len { create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = *(params.fee_amount.add(i)); } - debug_print("GET_DEST_ADDRESS\n"); let mut dest_address_length = 0usize; while *(params.destination_address.wrapping_add(dest_address_length)) != '\0' as i8 { create_tx_params.dest_address[dest_address_length] = @@ -207,6 +203,12 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { as *mut create_transaction_parameters_t)) .result as *const u8 as *mut u8; + /* Reset BSS and complete application boot */ + c_reset_bss(); + c_boot_std(); + + NbglSpinner::new().text("Signing").show(); + create_tx_params } } diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b7bbdfb2..47c5cf0e 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -426,7 +426,6 @@ impl SDKBuilder { .include(self.bolos_sdk.join("lib_cxng/include")) .include(self.bolos_sdk.join("lib_stusb")) .include(self.bolos_sdk.join("lib_stusb_impl")) - .include(self.bolos_sdk.join("lib_standard_app")) .include( self.bolos_sdk .join("lib_stusb/STM32_USB_Device_Library/Core/Inc"), diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index 875e108e..4716d0f5 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -9,7 +9,6 @@ #include "os_nvm.h" #include "os_pic.h" #include "checks.h" -#include "swap_lib_calls.h" #ifdef HAVE_BLE #include "ledger_ble.h" bolos_ux_asynch_callback_t G_io_asynch_ux_callback; @@ -259,6 +258,58 @@ void link_pass_nvram( uint8_t G_io_apdu_buffer[260]; #endif +void c_reset_bss() { + size_t bss_len; + SYMBOL_ABSOLUTE_VALUE(bss_len, _bss_len); + struct SectionDst* bss; + SYMBOL_SBREL_ADDRESS(bss, _bss); + memset(bss, 0, bss_len); +} + +void c_boot_std() { + // below is a 'manual' implementation of `io_seproxyhal_init` +#ifdef HAVE_MCU_PROTECT + unsigned char c[4]; + c[0] = SEPROXYHAL_TAG_MCU; + c[1] = 0; + c[2] = 1; + c[3] = SEPROXYHAL_TAG_MCU_TYPE_PROTECT; + io_seproxyhal_spi_send(c, 4); +#endif + +#ifdef HAVE_BLE + unsigned int plane = G_io_app.plane_mode; +#endif + + memset(&G_io_app, 0, sizeof(G_io_app)); + +#ifdef HAVE_BLE + G_io_app.plane_mode = plane; +#endif + G_io_app.apdu_state = APDU_IDLE; + G_io_app.apdu_length = 0; + G_io_app.apdu_media = IO_APDU_MEDIA_NONE; + + G_io_app.ms = 0; + io_usb_hid_init(); + + USB_power(0); + USB_power(1); +#ifdef HAVE_CCID + io_usb_ccid_set_card_inserted(1); +#endif + +#ifdef HAVE_BLE + memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback)); + BLE_power(1, NULL); +#endif + +#if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) + check_audited_app(); +#endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) + heap_init(); +} + int c_main(int arg0) { __asm volatile("cpsie i"); @@ -281,16 +332,9 @@ int c_main(int arg0) { __asm volatile("mov %[result],r9" : [result] "=r" (data)); link_pass_ram(data_len, sidata_src, data); - - libargs_t *args = (libargs_t *) arg0; - if (args == NULL || args->command == SIGN_TRANSACTION) { - size_t bss_len; - SYMBOL_ABSOLUTE_VALUE(bss_len, _bss_len); - struct SectionDst* bss; - SYMBOL_SBREL_ADDRESS(bss, _bss); - memset(bss, 0, bss_len); - } + if (arg0 == 0) + c_reset_bss(); // formerly known as 'os_boot()' try_context_set(NULL); @@ -298,49 +342,8 @@ int c_main(int arg0) { for(;;) { BEGIN_TRY { TRY { - if (args == NULL || args->command == SIGN_TRANSACTION) { - // below is a 'manual' implementation of `io_seproxyhal_init` - #ifdef HAVE_MCU_PROTECT - unsigned char c[4]; - c[0] = SEPROXYHAL_TAG_MCU; - c[1] = 0; - c[2] = 1; - c[3] = SEPROXYHAL_TAG_MCU_TYPE_PROTECT; - io_seproxyhal_spi_send(c, 4); - #endif - - #ifdef HAVE_BLE - unsigned int plane = G_io_app.plane_mode; - #endif - - memset(&G_io_app, 0, sizeof(G_io_app)); - - #ifdef HAVE_BLE - G_io_app.plane_mode = plane; - #endif - G_io_app.apdu_state = APDU_IDLE; - G_io_app.apdu_length = 0; - G_io_app.apdu_media = IO_APDU_MEDIA_NONE; - - G_io_app.ms = 0; - io_usb_hid_init(); - - USB_power(0); - USB_power(1); - #ifdef HAVE_CCID - io_usb_ccid_set_card_inserted(1); - #endif - - #ifdef HAVE_BLE - memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback)); - BLE_power(1, NULL); - #endif - - #if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) - check_audited_app(); - #endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN) - heap_init(); - } + if (arg0 == 0) + c_boot_std(); sample_main(arg0); } CATCH(EXCEPTION_IO_RESET) { @@ -355,4 +358,4 @@ int c_main(int arg0) { END_TRY; } return 0; -} +} \ No newline at end of file From dd96b2ab778d36e2ed69d3f7294e153e63b286ee Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 12 Dec 2024 17:07:07 +0100 Subject: [PATCH 010/154] Add debug feature to activate/deactivate traces --- ledger_device_sdk/Cargo.toml | 1 + ledger_device_sdk/src/io.rs | 2 +- ledger_device_sdk/src/libcall/swap.rs | 30 +++++++++++---------------- ledger_device_sdk/src/testing.rs | 7 ++++++- ledger_secure_sdk_sys/src/c/src.c | 2 ++ 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 40e04506..81b94c6b 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -24,6 +24,7 @@ const-zero = "0.1.1" ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.5.3" } [features] +debug = [] speculos = [] ccid = [] heap = [ "ledger_secure_sdk_sys/heap" ] diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 6a78e0bd..84ee9f5e 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -7,7 +7,7 @@ use ledger_secure_sdk_sys::*; #[cfg(feature = "ccid")] use crate::ccid; -use crate::{seph, testing}; +use crate::seph; use core::convert::{Infallible, TryFrom}; use core::ops::{Index, IndexMut}; diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 36d3f8fd..05e1d522 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -5,8 +5,6 @@ use ledger_secure_sdk_sys::{ libargs_s__bindgen_ty_1, libargs_t, }; -use super::string::CustomString; - pub struct CheckAddressParams { pub dpath: [u8; 64], pub dpath_len: usize, @@ -69,7 +67,7 @@ impl Default for CreateTxParams { pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { unsafe { - debug_print("GET_CHECK_ADDRESS_PARAMS\n"); + debug_print("=> get_check_address_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -86,15 +84,15 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { let mut check_address_params: CheckAddressParams = Default::default(); - debug_print("GET_DPATH_LENGTH\n"); + debug_print("==> GET_DPATH_LENGTH\n"); check_address_params.dpath_len = *(params.address_parameters as *const u8) as usize; - debug_print("GET_DPATH \n"); + debug_print("==> GET_DPATH \n"); for i in 1..1 + check_address_params.dpath_len * 4 { check_address_params.dpath[i - 1] = *(params.address_parameters.add(i)); } - debug_print("GET_REF_ADDRESS\n"); + debug_print("==> GET_REF_ADDRESS\n"); let mut address_length = 0usize; while *(params.address_to_check.wrapping_add(address_length)) != '\0' as i8 { check_address_params.ref_address[address_length] = @@ -113,7 +111,7 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { unsafe { - debug_print("GET_PRINTABLE_AMOUNT_PARAMS\n"); + debug_print("=> get_printable_amount_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -131,21 +129,16 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { let mut printable_amount_params: PrintableAmountParams = Default::default(); - debug_print("GET_AMOUNT_LENGTH\n"); + debug_print("==> GET_AMOUNT_LENGTH\n"); printable_amount_params.amount_len = params.amount_length as usize; - let s = CustomString::<2>::from(printable_amount_params.amount_len as u8); - debug_print("AMOUNT LENGTH: \n"); - debug_print(s.as_str()); - debug_print("\n"); - - debug_print("GET_AMOUNT\n"); + debug_print("==> GET_AMOUNT\n"); for i in 0..printable_amount_params.amount_len { printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = *(params.amount.add(i)); } - debug_print("GET_AMOUNT_STR\n"); + debug_print("==> GET_AMOUNT_STR\n"); printable_amount_params.amount_str = &(*(libarg.__bindgen_anon_1.get_printable_amount as *mut get_printable_amount_parameters_t)) .printable_amount as *const i8 as *mut i8; @@ -161,7 +154,7 @@ extern "C" { pub fn sign_tx_params(arg0: u32) -> CreateTxParams { unsafe { - debug_print("SIGN_TX_PARAMS\n"); + debug_print("=> sign_tx_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -178,19 +171,20 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { let mut create_tx_params: CreateTxParams = Default::default(); + debug_print("==> GET_AMOUNT\n"); create_tx_params.amount_len = params.amount_length as usize; - for i in 0..create_tx_params.amount_len { create_tx_params.amount[16 - create_tx_params.amount_len + i] = *(params.amount.add(i)); } + debug_print("==> GET_FEE\n"); create_tx_params.fee_amount_len = params.fee_amount_length as usize; - for i in 0..create_tx_params.fee_amount_len { create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = *(params.fee_amount.add(i)); } + debug_print("==> GET_DESTINATION_ADDRESS\n"); let mut dest_address_length = 0usize; while *(params.destination_address.wrapping_add(dest_address_length)) != '\0' as i8 { create_tx_params.dest_address[dest_address_length] = diff --git a/ledger_device_sdk/src/testing.rs b/ledger_device_sdk/src/testing.rs index 1cebb21c..e80e7f84 100644 --- a/ledger_device_sdk/src/testing.rs +++ b/ledger_device_sdk/src/testing.rs @@ -1,8 +1,11 @@ -use core::arch::asm; use core::panic::PanicInfo; +#[cfg(feature = "debug")] +use core::arch::asm; + /// Debug 'print' function that uses ARM semihosting /// Prints only strings with no formatting +#[cfg(feature = "debug")] pub fn debug_print(s: &str) { let p = s.as_bytes().as_ptr(); for i in 0..s.len() { @@ -16,6 +19,8 @@ pub fn debug_print(s: &str) { } } } +#[cfg(not(feature = "debug"))] +pub fn debug_print(_s: &str) {} pub fn to_hex(m: u32) -> [u8; 8] { let mut hex = [0u8; 8]; diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index 4716d0f5..0a751021 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -333,6 +333,7 @@ int c_main(int arg0) { link_pass_ram(data_len, sidata_src, data); + // if libcall, does not reset bss as it is shared with the calling app if (arg0 == 0) c_reset_bss(); @@ -342,6 +343,7 @@ int c_main(int arg0) { for(;;) { BEGIN_TRY { TRY { + // if libcall, does not start io and memory allocator if (arg0 == 0) c_boot_std(); sample_main(arg0); From b5cd3c9b4f14374faa7726dc9dacc850799056b9 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 13 Dec 2024 11:55:16 +0100 Subject: [PATCH 011/154] Add swap_return() function to wrap unsafe calls --- ledger_device_sdk/src/libcall/swap.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 05e1d522..76be11aa 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -206,3 +206,29 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { create_tx_params } } + +pub enum SwapResult<'a> { + CheckAddressResult(&'a mut CheckAddressParams, i32), + PrintableAmountResult(&'a mut PrintableAmountParams, &'a str), + CreateTxResult(&'a mut CreateTxParams, u8), +} + +pub fn swap_return(res: SwapResult) { + unsafe { + match res { + SwapResult::CheckAddressResult(&mut ref p, r) => { + *(p.result) = r; + } + SwapResult::PrintableAmountResult(&mut ref p, s) => { + for (i, c) in s.chars().enumerate() { + *(p.amount_str.add(i)) = c as i8; + } + *(p.amount_str.add(s.len())) = '\0' as i8; + } + SwapResult::CreateTxResult(&mut ref p, r) => { + *(p.result) = r; + } + } + ledger_secure_sdk_sys::os_lib_end(); + } +} From b4aa79f5b26a58b0b33f33ece91aaf5eb1750546 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 13 Dec 2024 16:25:13 +0100 Subject: [PATCH 012/154] Signing spinner only for Stax/Flex --- ledger_device_sdk/src/libcall/swap.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 76be11aa..25ee84bf 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -1,3 +1,4 @@ +#[cfg(any(target_os = "stax", target_os = "flex"))] use crate::nbgl::NbglSpinner; use crate::testing::debug_print; use ledger_secure_sdk_sys::{ @@ -201,6 +202,7 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { c_reset_bss(); c_boot_std(); + #[cfg(any(target_os = "stax", target_os = "flex"))] NbglSpinner::new().text("Signing").show(); create_tx_params From 993cec1c8aad79d65af6f768f8bd1522176184e2 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 13 Dec 2024 16:52:32 +0100 Subject: [PATCH 013/154] Bump new versions --- Cargo.lock | 6 +++--- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_device_sdk/src/io.rs | 4 ---- ledger_secure_sdk_sys/Cargo.toml | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29ba1cc9..da465e6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler" @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.18.4" +version = "1.19.0" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.5.3" +version = "1.6.0" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 81b94c6b..52e9d0d4 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.18.4" +version = "1.19.0" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.5.3" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.0" } [features] debug = [] diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 84ee9f5e..90ae542a 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -575,10 +575,6 @@ impl Comm { pub fn append(&mut self, m: &[u8]) { self.apdu_buffer[self.tx..self.tx + m.len()].copy_from_slice(m); self.tx += m.len(); - // for c in m.iter() { - // self.apdu_buffer[self.tx] = *c; - // self.tx += 1; - // } } } diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 98a4fd0b..f9bf21c4 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.5.3" -authors = ["yhql", "agrojean-ledger"] +version = "1.6.0" +authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true repository.workspace = true From 0c28f1c11d061952c0c42eb36718f40536a0bb48 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 13 Dec 2024 17:00:50 +0100 Subject: [PATCH 014/154] Force Cargo.lock version to 3 --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index da465e6f..f04b0d6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "adler" From b65c6691a50962d82244de08ca6a267de0997fde Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 20 Dec 2024 15:38:11 +0100 Subject: [PATCH 015/154] appflags should be set at device level --- Cargo.lock | 2 +- cargo-ledger/Cargo.toml | 4 ++-- cargo-ledger/src/main.rs | 29 +++++++++++++++++++---------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f04b0d6d..f71651fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,7 +127,7 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cargo-ledger" -version = "1.5.1" +version = "1.6.0" dependencies = [ "cargo_metadata", "clap", diff --git a/cargo-ledger/Cargo.toml b/cargo-ledger/Cargo.toml index 6ab648d0..60634adb 100644 --- a/cargo-ledger/Cargo.toml +++ b/cargo-ledger/Cargo.toml @@ -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" diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs index b6b97feb..95b0cc02 100644 --- a/cargo-ledger/src/main.rs +++ b/cargo-ledger/src/main.rs @@ -32,13 +32,14 @@ struct NanosMetadata { struct LedgerMetadata { curve: Vec, path: Vec, - flags: String, + flags: Option, name: Option, } #[derive(Debug, Deserialize)] struct DeviceMetadata { icon: String, + flags: Option, } #[derive(Parser, Debug)] @@ -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, }; @@ -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) @@ -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 From c1fe1ee6a4f9302ab8f3231abf255ddc0fb97ce0 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 20 Dec 2024 15:55:22 +0100 Subject: [PATCH 016/154] remove backward compatibility code --- cargo-ledger/src/main.rs | 44 +++++----------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs index 95b0cc02..723fae5f 100644 --- a/cargo-ledger/src/main.rs +++ b/cargo-ledger/src/main.rs @@ -16,18 +16,6 @@ use utils::*; mod setup; mod utils; -/// Structure for retrocompatibility, when the cargo manifest file -/// contains a single `[package.metadata.nanos]` section -#[derive(Debug, Deserialize)] -struct NanosMetadata { - curve: Vec, - path: Vec, - flags: String, - icon: String, - icon_small: String, - name: Option, -} - #[derive(Debug, Deserialize)] struct LedgerMetadata { curve: Vec, @@ -124,7 +112,7 @@ fn main() { fn retrieve_metadata( device: Device, manifest_path: Option<&str>, -) -> (Package, LedgerMetadata, DeviceMetadata) { +) -> Result<(Package, LedgerMetadata, DeviceMetadata), ()> { let mut cmd = cargo_metadata::MetadataCommand::new(); // Only used during tests @@ -155,32 +143,10 @@ fn retrieve_metadata( serde_json::from_value(metadata_device) .expect("Could not deserialize device medatada"); - (this_pkg.clone(), ledger_metadata, device_metadata) + Ok((this_pkg.clone(), ledger_metadata, device_metadata)) } else { - println!("WARNING: 'package.metadata.ledger' section is missing in Cargo.toml, trying 'package.metadata.nanos'"); - let nanos_section = this_pkg.metadata.get("nanos").expect( - "No appropriate [package.metadata.] section found.", - ); - - let nanos_metadata: NanosMetadata = - serde_json::from_value(nanos_section.clone()) - .expect("Could not deserialize medatada.nanos"); - let ledger_metadata = LedgerMetadata { - curve: nanos_metadata.curve, - path: nanos_metadata.path, - flags: Some(nanos_metadata.flags), - name: nanos_metadata.name, - }; - - let device_metadata = DeviceMetadata { - icon: match device { - Device::Nanos => nanos_metadata.icon, - _ => nanos_metadata.icon_small, - }, - flags: None, - }; - - (this_pkg.clone(), ledger_metadata, device_metadata) + println!("No metadata found for device: {}", device); + Err(()) } } @@ -265,7 +231,7 @@ fn build_app( }; let (this_pkg, metadata_ledger, metadata_device) = - retrieve_metadata(device, None); + retrieve_metadata(device, None).unwrap(); let package_path = this_pkg .manifest_path From 72c22a9c73edba8ce6106a3fefffcd22dbb5fdcb Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 20 Dec 2024 15:57:43 +0100 Subject: [PATCH 017/154] 0x000 is default appflags --- cargo-ledger/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs index 723fae5f..061319fd 100644 --- a/cargo-ledger/src/main.rs +++ b/cargo-ledger/src/main.rs @@ -272,7 +272,7 @@ fn build_app( format!("0x{:x}", base | 0x200) } }, - None => String::from("0x00"), + None => String::from("0x000"), }, }; From f5f6cbc9398f212d42593f2cb5be94eeb74f59d3 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 16 Dec 2024 10:43:53 +0100 Subject: [PATCH 018/154] Add customized cfgs --- ledger_device_sdk/Cargo.toml | 4 ++++ ledger_secure_sdk_sys/Cargo.toml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 52e9d0d4..2ba8c975 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -30,3 +30,7 @@ ccid = [] heap = [ "ledger_secure_sdk_sys/heap" ] default = [ "heap" ] + +[lints.rust.unexpected_cfgs] +level = "warn" +check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index f9bf21c4..690cd69f 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -18,3 +18,7 @@ critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] + +[lints.rust.unexpected_cfgs] +level = "warn" +check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] \ No newline at end of file From 69c011a9c1f564a4a7bee4afb933aed16bab9121 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 17 Dec 2024 12:03:34 +0100 Subject: [PATCH 019/154] Disallow references to static mut --- ledger_device_sdk/src/nbgl.rs | 2 +- .../src/nbgl/nbgl_home_and_settings.rs | 12 +++---- ledger_device_sdk/src/seph.rs | 36 ++++++++++--------- ledger_secure_sdk_sys/Cargo.toml | 1 + ledger_secure_sdk_sys/src/lib.rs | 2 +- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ledger_device_sdk/src/nbgl.rs b/ledger_device_sdk/src/nbgl.rs index 44451704..85bc4614 100644 --- a/ledger_device_sdk/src/nbgl.rs +++ b/ledger_device_sdk/src/nbgl.rs @@ -79,7 +79,7 @@ trait SyncNBGL: Sized { fn ux_sync_wait(&self, exit_on_apdu: bool) -> SyncNbgl { unsafe { - if let Some(comm) = COMM_REF.as_mut() { + if let Some(comm) = (*(&raw mut COMM_REF)).as_mut() { while !G_ENDED { let apdu_received = comm.next_event_ahead::(); if exit_on_apdu && apdu_received { diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index 623217f6..af9eb714 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -20,7 +20,7 @@ unsafe extern "C" fn settings_callback(token: c_int, _index: u8, _page: c_int) { _ => panic!("Invalid state."), } - if let Some(data) = NVM_REF.as_mut() { + if let Some(data) = (*(&raw mut NVM_REF)).as_mut() { let mut switch_values: [u8; SETTINGS_SIZE] = *data.get_ref(); if switch_values[setting_idx] == OFF_STATE { switch_values[setting_idx] = ON_STATE; @@ -166,7 +166,7 @@ impl<'a> NbglHomeAndSettings { for (i, setting) in self.setting_contents.iter().enumerate() { SWITCH_ARRAY[i].text = setting[0].as_ptr(); SWITCH_ARRAY[i].subText = setting[1].as_ptr(); - let state = if let Some(data) = NVM_REF.as_mut() { + let state = if let Some(data) = (*(&raw mut NVM_REF)).as_mut() { data.get_ref()[i] } else { OFF_STATE @@ -179,7 +179,7 @@ impl<'a> NbglHomeAndSettings { self.content = nbgl_content_t { content: nbgl_content_u { switchesList: nbgl_pageSwitchesList_s { - switches: &SWITCH_ARRAY as *const nbgl_contentSwitch_t, + switches: &raw const SWITCH_ARRAY as *const nbgl_contentSwitch_t, nbSwitches: self.nb_settings, }, }, @@ -211,7 +211,7 @@ impl<'a> NbglHomeAndSettings { ); match self.ux_sync_wait(true) { SyncNbgl::UxSyncRetApduReceived => { - if let Some(comm) = COMM_REF.as_mut() { + if let Some(comm) = (*(&raw mut COMM_REF)).as_mut() { if let Some(value) = comm.check_event() { return value; } @@ -250,7 +250,7 @@ impl<'a> NbglHomeAndSettings { for (i, setting) in self.setting_contents.iter().enumerate() { SWITCH_ARRAY[i].text = setting[0].as_ptr(); SWITCH_ARRAY[i].subText = setting[1].as_ptr(); - let state = if let Some(data) = NVM_REF.as_mut() { + let state = if let Some(data) = (*(&raw mut NVM_REF)).as_mut() { data.get_ref()[i] } else { OFF_STATE @@ -263,7 +263,7 @@ impl<'a> NbglHomeAndSettings { self.content = nbgl_content_t { content: nbgl_content_u { switchesList: nbgl_pageSwitchesList_s { - switches: &SWITCH_ARRAY as *const nbgl_contentSwitch_t, + switches: &raw const SWITCH_ARRAY as *const nbgl_contentSwitch_t, nbSwitches: self.nb_settings, }, }, diff --git a/ledger_device_sdk/src/seph.rs b/ledger_device_sdk/src/seph.rs index 666776c3..fe6258c2 100644 --- a/ledger_device_sdk/src/seph.rs +++ b/ledger_device_sdk/src/seph.rs @@ -112,8 +112,8 @@ pub fn handle_usb_event(event: u8) { match Events::from(event) { Events::USBEventReset => { unsafe { - USBD_LL_SetSpeed(&mut USBD_Device, 1 /*USBD_SPEED_FULL*/); - USBD_LL_Reset(&mut USBD_Device); + USBD_LL_SetSpeed(&raw mut USBD_Device, 1 /*USBD_SPEED_FULL*/); + USBD_LL_Reset(&raw mut USBD_Device); if G_io_app.apdu_media != IO_APDU_MEDIA_NONE { return; @@ -124,13 +124,13 @@ pub fn handle_usb_event(event: u8) { } } Events::USBEventSOF => unsafe { - USBD_LL_SOF(&mut USBD_Device); + USBD_LL_SOF(&raw mut USBD_Device); }, Events::USBEventSuspend => unsafe { - USBD_LL_Suspend(&mut USBD_Device); + USBD_LL_Suspend(&raw mut USBD_Device); }, Events::USBEventResume => unsafe { - USBD_LL_Resume(&mut USBD_Device); + USBD_LL_Resume(&raw mut USBD_Device); }, _ => (), } @@ -140,13 +140,13 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) { let endpoint = buffer[3] & 0x7f; match UsbEp::from(buffer[4]) { UsbEp::USBEpXFERSetup => unsafe { - USBD_LL_SetupStage(&mut USBD_Device, &buffer[6]); + USBD_LL_SetupStage(&raw mut USBD_Device, &buffer[6]); }, UsbEp::USBEpXFERIn => { if (endpoint as u32) < IO_USB_MAX_ENDPOINTS { unsafe { G_io_app.usb_ep_timeouts[endpoint as usize].timeout = 0; - USBD_LL_DataInStage(&mut USBD_Device, endpoint, &buffer[6]); + USBD_LL_DataInStage(&raw mut USBD_Device, endpoint, &buffer[6]); } } } @@ -158,7 +158,7 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) { buf: apdu_buffer.as_mut_ptr(), len: 260, }; - USBD_LL_DataOutStage(&mut USBD_Device, endpoint, &buffer[6], &mut apdu_buf); + USBD_LL_DataOutStage(&raw mut USBD_Device, endpoint, &buffer[6], &mut apdu_buf); } } } @@ -167,19 +167,21 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) { } pub fn handle_capdu_event(apdu_buffer: &mut [u8], buffer: &[u8]) { - let io_app = unsafe { &mut G_io_app }; - if io_app.apdu_state == APDU_IDLE { - let max = (apdu_buffer.len() - 3).min(buffer.len() - 3); - let size = u16::from_be_bytes([buffer[1], buffer[2]]) as usize; + let io_app = &raw mut G_io_app; + unsafe { + if (*io_app).apdu_state == APDU_IDLE { + let max = (apdu_buffer.len() - 3).min(buffer.len() - 3); + let size = u16::from_be_bytes([buffer[1], buffer[2]]) as usize; - io_app.apdu_media = IO_APDU_MEDIA_RAW; - io_app.apdu_state = APDU_RAW; + (*io_app).apdu_media = IO_APDU_MEDIA_RAW; + (*io_app).apdu_state = APDU_RAW; - let len = size.min(max); + let len = size.min(max); - io_app.apdu_length = len as u16; + (*io_app).apdu_length = len as u16; - apdu_buffer[..len].copy_from_slice(&buffer[3..len + 3]); + apdu_buffer[..len].copy_from_slice(&buffer[3..len + 3]); + } } } diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 690cd69f..ff5aefcd 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -18,6 +18,7 @@ critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] +ccid = [] [lints.rust.unexpected_cfgs] level = "warn" diff --git a/ledger_secure_sdk_sys/src/lib.rs b/ledger_secure_sdk_sys/src/lib.rs index 3039f88c..e05c3e8e 100644 --- a/ledger_secure_sdk_sys/src/lib.rs +++ b/ledger_secure_sdk_sys/src/lib.rs @@ -65,7 +65,7 @@ unsafe impl critical_section::Impl for CriticalSection { extern "C" fn heap_init() { // HEAP_SIZE comes from heap_size.rs, which is defined via env var and build.rs static mut HEAP_MEM: [MaybeUninit; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE]; - unsafe { HEAP.init(HEAP_MEM.as_ptr() as usize, HEAP_SIZE) } + unsafe { HEAP.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) } } #[no_mangle] From 857c6d3d067b1bc4131236c86059ae4571d73cdb Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 17 Dec 2024 14:54:58 +0100 Subject: [PATCH 020/154] Update API_LEVEL when cloning C SDK locally --- ledger_secure_sdk_sys/build.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 47c5cf0e..c7393a74 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -216,19 +216,19 @@ fn clone_sdk(device: &Device) -> PathBuf { ), Device::NanoX => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_5", + "API_LEVEL_22", ), Device::NanoSPlus => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_5", + "API_LEVEL_22", ), Device::Stax => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_21", + "API_LEVEL_22", ), Device::Flex => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_21", + "API_LEVEL_22", ), }; From 8ae0f4d556788b8da3431051aeb2bd57e74e12d2 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 17 Dec 2024 14:56:58 +0100 Subject: [PATCH 021/154] Remove workaround for managing both API_LEVEL_5 and API_LEVEL > 5 --- ledger_secure_sdk_sys/build.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index c7393a74..b2f2eb6d 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -408,13 +408,6 @@ impl SDKBuilder { // Let cc::Build determine CC from the environment variable } - // Test if the file lib_cxng/src/cx_exported_functions.c exists - // If it does, add it to the list of files to compile - let cxng_src = self.bolos_sdk.join("lib_cxng/src/cx_exported_functions.c"); - if cxng_src.exists() { - command.file(cxng_src); - } - command .files(&AUX_C_FILES) .files(str2path(&self.bolos_sdk, &SDK_C_FILES)) From 467b4903f3b7b59ddcf50686b5738b6b92a9bb54 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 17 Dec 2024 17:11:38 +0100 Subject: [PATCH 022/154] Add Near app --- .github/workflows/build_all_apps.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index a03f14dc..c9f50f6c 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -29,6 +29,8 @@ jobs: branch: 'develop' - repo: 'app-boilerplate-rust' branch: 'main' + - repo: 'app-near' + branch: 'y333_241015/add_swap_support' runs-on: ubuntu-latest container: From 42666d11480b2c745fc1bad37160cc1e92c8b324 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 17 Dec 2024 17:18:33 +0100 Subject: [PATCH 023/154] Fix Near app branch: use develop --- .github/workflows/build_all_apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index c9f50f6c..63073567 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -30,7 +30,7 @@ jobs: - repo: 'app-boilerplate-rust' branch: 'main' - repo: 'app-near' - branch: 'y333_241015/add_swap_support' + branch: 'develop' runs-on: ubuntu-latest container: From 5e7bd184e437c5fd85880588f6fa8c07f68d90f0 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 17 Dec 2024 17:20:40 +0100 Subject: [PATCH 024/154] Bump versions --- Cargo.lock | 6 +++--- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f71651fb..ecf9d80f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler" @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.0" +version = "1.19.1" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.0" +version = "1.6.1" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 2ba8c975..afe8fef4 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.0" +version = "1.19.1" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.0" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.1" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index ff5aefcd..378e37a8 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.0" +version = "1.6.1" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From 5a0fb4729c9fc901357f80219873561ae6da6d6d Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 14 Jan 2025 10:56:20 +0100 Subject: [PATCH 025/154] Increase SPI buffer size --- ledger_device_sdk/src/io.rs | 12 ++++++------ ledger_device_sdk/src/seph.rs | 4 ++-- ledger_device_sdk/src/uxapp.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 90ae542a..a187bc7e 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -174,7 +174,7 @@ impl Comm { if !sys_seph::is_status_sent() { sys_seph::send_general_status() } - let mut spi_buffer = [0u8; 128]; + let mut spi_buffer = [0u8; 256]; while sys_seph::is_status_sent() { sys_seph::seph_recv(&mut spi_buffer, 0); seph::handle_event(&mut self.apdu_buffer, &spi_buffer); @@ -260,7 +260,7 @@ impl Comm { T: TryFrom, Reply: From<>::Error>, { - let mut spi_buffer = [0u8; 128]; + let mut spi_buffer = [0u8; 256]; unsafe { G_io_app.apdu_state = APDU_IDLE; @@ -289,7 +289,7 @@ impl Comm { T: TryFrom, Reply: From<>::Error>, { - let mut spi_buffer = [0u8; 128]; + let mut spi_buffer = [0u8; 256]; // Signal end of command stream from SE to MCU // And prepare reception @@ -353,7 +353,7 @@ impl Comm { None } - pub fn process_event(&mut self, spi_buffer: &mut [u8; 128]) -> Option> + pub fn process_event(&mut self, spi_buffer: &mut [u8; 256]) -> Option> where T: TryFrom, Reply: From<>::Error>, @@ -422,7 +422,7 @@ impl Comm { None } - pub fn decode_event(&mut self, spi_buffer: &mut [u8; 128]) -> Option> + pub fn decode_event(&mut self, spi_buffer: &mut [u8; 256]) -> Option> where T: TryFrom, Reply: From<>::Error>, @@ -439,7 +439,7 @@ impl Comm { None } - fn detect_apdu(&mut self, spi_buffer: &mut [u8; 128]) -> bool + fn detect_apdu(&mut self, spi_buffer: &mut [u8; 256]) -> bool where T: TryFrom, Reply: From<>::Error>, diff --git a/ledger_device_sdk/src/seph.rs b/ledger_device_sdk/src/seph.rs index fe6258c2..b429a0ac 100644 --- a/ledger_device_sdk/src/seph.rs +++ b/ledger_device_sdk/src/seph.rs @@ -2,7 +2,7 @@ use ledger_secure_sdk_sys::*; -#[cfg(target_os = "nanox")] +#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] use crate::ble; #[repr(u8)] @@ -198,7 +198,7 @@ pub fn handle_event(apdu_buffer: &mut [u8], spi_buffer: &[u8]) { handle_usb_ep_xfer_event(apdu_buffer, spi_buffer); } } - #[cfg(target_os = "nanox")] + #[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] Events::BleReceive => ble::receive(apdu_buffer, spi_buffer), Events::CAPDUEvent => handle_capdu_event(apdu_buffer, spi_buffer), Events::TickerEvent => { /* unsafe{ G_io_app.ms += 100; } */ } diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 5354f27b..20762e05 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -78,7 +78,7 @@ impl UxEvent { if unsafe { os_sched_is_running(TASK_SUBTASKS_START as u32) } != BOLOS_TRUE.try_into().unwrap() { - let mut spi_buffer = [0u8; 128]; + let mut spi_buffer = [0u8; 256]; seph::send_general_status(); seph::seph_recv(&mut spi_buffer, 0); event = comm.decode_event(&mut spi_buffer); From e70e8be9b87de87e775dffaf312035d5f1f69990 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 14 Jan 2025 10:58:36 +0100 Subject: [PATCH 026/154] Bump version --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecf9d80f..68801fec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.1" +version = "1.19.2" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index afe8fef4..97f4f473 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.1" +version = "1.19.2" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 3641db616a3ab755e8d6c26cd466a1f6fce16c9c Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 14 Jan 2025 12:00:59 +0100 Subject: [PATCH 027/154] Update SPI buffer size (missed) --- ledger_device_sdk/src/uxapp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 20762e05..6b9f705e 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -55,7 +55,7 @@ impl UxEvent { if unsafe { os_sched_is_running(TASK_SUBTASKS_START as u32) } != BOLOS_TRUE.try_into().unwrap() { - let mut spi_buffer = [0u8; 128]; + let mut spi_buffer = [0u8; 256]; sys_seph::send_general_status(); sys_seph::seph_recv(&mut spi_buffer, 0); UxEvent::Event.request(); From 061c6740b533d968f0b5fd9603fe8549725463cb Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 14 Jan 2025 17:00:51 +0100 Subject: [PATCH 028/154] Add fees management in swap --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- ledger_device_sdk/src/libcall/swap.rs | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68801fec..5b87b184 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.2" +version = "1.19.3" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 97f4f473..02b061b6 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.2" +version = "1.19.3" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 25ee84bf..c0199643 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -30,6 +30,7 @@ pub struct PrintableAmountParams { pub amount: [u8; 16], pub amount_len: usize, pub amount_str: *mut i8, + pub is_fee: bool, } impl Default for PrintableAmountParams { @@ -38,6 +39,7 @@ impl Default for PrintableAmountParams { amount: [0; 16], amount_len: 0, amount_str: core::ptr::null_mut(), + is_fee: false, } } } @@ -130,6 +132,9 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { let mut printable_amount_params: PrintableAmountParams = Default::default(); + debug_print("==> GET_IS_FEE\n"); + printable_amount_params.is_fee = params.is_fee == true; + debug_print("==> GET_AMOUNT_LENGTH\n"); printable_amount_params.amount_len = params.amount_length as usize; From 7404ac603328f154664f89d15e088d2e3f85a86c Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 15 Jan 2025 10:18:28 +0100 Subject: [PATCH 029/154] Add buffer overflow checks --- ledger_device_sdk/src/libcall/swap.rs | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index c0199643..a89f58c8 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -3,7 +3,7 @@ use crate::nbgl::NbglSpinner; use crate::testing::debug_print; use ledger_secure_sdk_sys::{ check_address_parameters_t, create_transaction_parameters_t, get_printable_amount_parameters_t, - libargs_s__bindgen_ty_1, libargs_t, + libargs_s__bindgen_ty_1, libargs_t, MAX_PRINTABLE_AMOUNT_SIZE, }; pub struct CheckAddressParams { @@ -88,7 +88,8 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { let mut check_address_params: CheckAddressParams = Default::default(); debug_print("==> GET_DPATH_LENGTH\n"); - check_address_params.dpath_len = *(params.address_parameters as *const u8) as usize; + check_address_params.dpath_len = + 16usize.min(*(params.address_parameters as *const u8) as usize); debug_print("==> GET_DPATH \n"); for i in 1..1 + check_address_params.dpath_len * 4 { @@ -97,10 +98,11 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { debug_print("==> GET_REF_ADDRESS\n"); let mut address_length = 0usize; - while *(params.address_to_check.wrapping_add(address_length)) != '\0' as i8 { - check_address_params.ref_address[address_length] = - *(params.address_to_check.wrapping_add(address_length)) as u8; + let mut c = *(params.address_to_check.add(address_length)); + while c != '\0' as i8 && address_length < 64 { + check_address_params.ref_address[address_length] = c as u8; address_length += 1; + c = *(params.address_to_check.add(address_length)); } check_address_params.ref_address_len = address_length; @@ -136,7 +138,7 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { printable_amount_params.is_fee = params.is_fee == true; debug_print("==> GET_AMOUNT_LENGTH\n"); - printable_amount_params.amount_len = params.amount_length as usize; + printable_amount_params.amount_len = 16usize.min(params.amount_length as usize); debug_print("==> GET_AMOUNT\n"); for i in 0..printable_amount_params.amount_len { @@ -178,13 +180,13 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { let mut create_tx_params: CreateTxParams = Default::default(); debug_print("==> GET_AMOUNT\n"); - create_tx_params.amount_len = params.amount_length as usize; + create_tx_params.amount_len = 16usize.min(params.amount_length as usize); for i in 0..create_tx_params.amount_len { create_tx_params.amount[16 - create_tx_params.amount_len + i] = *(params.amount.add(i)); } debug_print("==> GET_FEE\n"); - create_tx_params.fee_amount_len = params.fee_amount_length as usize; + create_tx_params.fee_amount_len = 16usize.min(params.fee_amount_length as usize); for i in 0..create_tx_params.fee_amount_len { create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = *(params.fee_amount.add(i)); @@ -192,10 +194,11 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { debug_print("==> GET_DESTINATION_ADDRESS\n"); let mut dest_address_length = 0usize; - while *(params.destination_address.wrapping_add(dest_address_length)) != '\0' as i8 { - create_tx_params.dest_address[dest_address_length] = - *(params.destination_address.wrapping_add(dest_address_length)) as u8; + let mut c = *params.destination_address.add(dest_address_length); + while c != '\0' as i8 && dest_address_length < 64 { + create_tx_params.dest_address[dest_address_length] = c as u8; dest_address_length += 1; + c = *params.destination_address.add(dest_address_length); } create_tx_params.dest_address_len = dest_address_length; @@ -227,10 +230,12 @@ pub fn swap_return(res: SwapResult) { *(p.result) = r; } SwapResult::PrintableAmountResult(&mut ref p, s) => { - for (i, c) in s.chars().enumerate() { - *(p.amount_str.add(i)) = c as i8; + if s.len() < (MAX_PRINTABLE_AMOUNT_SIZE - 1).try_into().unwrap() { + for (i, c) in s.chars().enumerate() { + *(p.amount_str.add(i)) = c as i8; + } + *(p.amount_str.add(s.len())) = '\0' as i8; } - *(p.amount_str.add(s.len())) = '\0' as i8; } SwapResult::CreateTxResult(&mut ref p, r) => { *(p.result) = r; From 2c9cbc0b41c16865a6e4ca371e0ff1fd5f3bd9f5 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 15 Jan 2025 11:55:49 +0100 Subject: [PATCH 030/154] Move unsafe to each unsafe calls --- ledger_device_sdk/src/libcall/swap.rs | 225 +++++++++++++------------- 1 file changed, 112 insertions(+), 113 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index a89f58c8..6fba7750 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -69,90 +69,88 @@ impl Default for CreateTxParams { } pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { - unsafe { - debug_print("=> get_check_address_params\n"); + debug_print("=> get_check_address_params\n"); - let mut libarg: libargs_t = libargs_t::default(); + let mut libarg: libargs_t = libargs_t::default(); - let arg = arg0 as *const u32; + let arg = arg0 as *const u32; - libarg.id = *arg; - libarg.command = *arg.add(1); - libarg.unused = *arg.add(2); + libarg.id = unsafe { *arg }; + libarg.command = unsafe { *arg.add(1) }; + libarg.unused = unsafe { *arg.add(2) }; - libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + libarg.__bindgen_anon_1 = unsafe { *(arg.add(3) as *const libargs_s__bindgen_ty_1) }; - let params: check_address_parameters_t = - *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t); + let params: check_address_parameters_t = + unsafe { *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t) }; - let mut check_address_params: CheckAddressParams = Default::default(); + let mut check_address_params: CheckAddressParams = Default::default(); - debug_print("==> GET_DPATH_LENGTH\n"); - check_address_params.dpath_len = - 16usize.min(*(params.address_parameters as *const u8) as usize); + debug_print("==> GET_DPATH_LENGTH\n"); + check_address_params.dpath_len = + 16usize.min(unsafe { *(params.address_parameters as *const u8) as usize }); - debug_print("==> GET_DPATH \n"); - for i in 1..1 + check_address_params.dpath_len * 4 { - check_address_params.dpath[i - 1] = *(params.address_parameters.add(i)); - } + debug_print("==> GET_DPATH \n"); + for i in 1..1 + check_address_params.dpath_len * 4 { + check_address_params.dpath[i - 1] = unsafe { *(params.address_parameters.add(i)) }; + } - debug_print("==> GET_REF_ADDRESS\n"); - let mut address_length = 0usize; - let mut c = *(params.address_to_check.add(address_length)); - while c != '\0' as i8 && address_length < 64 { - check_address_params.ref_address[address_length] = c as u8; - address_length += 1; - c = *(params.address_to_check.add(address_length)); - } - check_address_params.ref_address_len = address_length; + debug_print("==> GET_REF_ADDRESS\n"); + let mut address_length = 0usize; + let mut c = unsafe { *(params.address_to_check.add(address_length)) }; + while c != '\0' as i8 && address_length < 64 { + check_address_params.ref_address[address_length] = c as u8; + address_length += 1; + c = unsafe { *(params.address_to_check.add(address_length)) }; + } + check_address_params.ref_address_len = address_length; - check_address_params.result = &(*(libarg.__bindgen_anon_1.check_address - as *mut check_address_parameters_t)) - .result as *const i32 as *mut i32; + check_address_params.result = unsafe { + &(*(libarg.__bindgen_anon_1.check_address as *mut check_address_parameters_t)).result + as *const i32 as *mut i32 + }; - check_address_params - } + check_address_params } pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { - unsafe { - debug_print("=> get_printable_amount_params\n"); + debug_print("=> get_printable_amount_params\n"); - let mut libarg: libargs_t = libargs_t::default(); + let mut libarg: libargs_t = libargs_t::default(); - let arg = arg0 as *const u32; + let arg = arg0 as *const u32; - libarg.id = *arg; - libarg.command = *arg.add(1); - libarg.unused = *arg.add(2); + libarg.id = unsafe { *arg }; + libarg.command = unsafe { *arg.add(1) }; + libarg.unused = unsafe { *arg.add(2) }; - libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + libarg.__bindgen_anon_1 = unsafe { *(arg.add(3) as *const libargs_s__bindgen_ty_1) }; - let params: get_printable_amount_parameters_t = - *(libarg.__bindgen_anon_1.get_printable_amount - as *const get_printable_amount_parameters_t); + let params: get_printable_amount_parameters_t = unsafe { + *(libarg.__bindgen_anon_1.get_printable_amount as *const get_printable_amount_parameters_t) + }; - let mut printable_amount_params: PrintableAmountParams = Default::default(); + let mut printable_amount_params: PrintableAmountParams = Default::default(); - debug_print("==> GET_IS_FEE\n"); - printable_amount_params.is_fee = params.is_fee == true; + debug_print("==> GET_IS_FEE\n"); + printable_amount_params.is_fee = params.is_fee == true; - debug_print("==> GET_AMOUNT_LENGTH\n"); - printable_amount_params.amount_len = 16usize.min(params.amount_length as usize); + debug_print("==> GET_AMOUNT_LENGTH\n"); + printable_amount_params.amount_len = 16usize.min(params.amount_length as usize); - debug_print("==> GET_AMOUNT\n"); - for i in 0..printable_amount_params.amount_len { - printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = - *(params.amount.add(i)); - } + debug_print("==> GET_AMOUNT\n"); + for i in 0..printable_amount_params.amount_len { + printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = + unsafe { *(params.amount.add(i)) }; + } - debug_print("==> GET_AMOUNT_STR\n"); - printable_amount_params.amount_str = &(*(libarg.__bindgen_anon_1.get_printable_amount - as *mut get_printable_amount_parameters_t)) - .printable_amount as *const i8 as *mut i8; + debug_print("==> GET_AMOUNT_STR\n"); + printable_amount_params.amount_str = unsafe { + &(*(libarg.__bindgen_anon_1.get_printable_amount as *mut get_printable_amount_parameters_t)) + .printable_amount as *const i8 as *mut i8 + }; - printable_amount_params - } + printable_amount_params } extern "C" { @@ -161,60 +159,63 @@ extern "C" { } pub fn sign_tx_params(arg0: u32) -> CreateTxParams { - unsafe { - debug_print("=> sign_tx_params\n"); + debug_print("=> sign_tx_params\n"); - let mut libarg: libargs_t = libargs_t::default(); + let mut libarg: libargs_t = libargs_t::default(); - let arg = arg0 as *const u32; + let arg = arg0 as *const u32; - libarg.id = *arg; - libarg.command = *arg.add(1); - libarg.unused = *arg.add(2); + libarg.id = unsafe { *arg }; + libarg.command = unsafe { *arg.add(1) }; + libarg.unused = unsafe { *arg.add(2) }; - libarg.__bindgen_anon_1 = *(arg.add(3) as *const libargs_s__bindgen_ty_1); + libarg.__bindgen_anon_1 = unsafe { *(arg.add(3) as *const libargs_s__bindgen_ty_1) }; - let params: create_transaction_parameters_t = - *(libarg.__bindgen_anon_1.create_transaction as *const create_transaction_parameters_t); + let params: create_transaction_parameters_t = unsafe { + *(libarg.__bindgen_anon_1.create_transaction as *const create_transaction_parameters_t) + }; - let mut create_tx_params: CreateTxParams = Default::default(); + let mut create_tx_params: CreateTxParams = Default::default(); - debug_print("==> GET_AMOUNT\n"); - create_tx_params.amount_len = 16usize.min(params.amount_length as usize); - for i in 0..create_tx_params.amount_len { - create_tx_params.amount[16 - create_tx_params.amount_len + i] = *(params.amount.add(i)); - } + debug_print("==> GET_AMOUNT\n"); + create_tx_params.amount_len = 16usize.min(params.amount_length as usize); + for i in 0..create_tx_params.amount_len { + create_tx_params.amount[16 - create_tx_params.amount_len + i] = + unsafe { *(params.amount.add(i)) }; + } - debug_print("==> GET_FEE\n"); - create_tx_params.fee_amount_len = 16usize.min(params.fee_amount_length as usize); - for i in 0..create_tx_params.fee_amount_len { - create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = - *(params.fee_amount.add(i)); - } + debug_print("==> GET_FEE\n"); + create_tx_params.fee_amount_len = 16usize.min(params.fee_amount_length as usize); + for i in 0..create_tx_params.fee_amount_len { + create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = + unsafe { *(params.fee_amount.add(i)) }; + } - debug_print("==> GET_DESTINATION_ADDRESS\n"); - let mut dest_address_length = 0usize; - let mut c = *params.destination_address.add(dest_address_length); - while c != '\0' as i8 && dest_address_length < 64 { - create_tx_params.dest_address[dest_address_length] = c as u8; - dest_address_length += 1; - c = *params.destination_address.add(dest_address_length); - } - create_tx_params.dest_address_len = dest_address_length; + debug_print("==> GET_DESTINATION_ADDRESS\n"); + let mut dest_address_length = 0usize; + let mut c = unsafe { *params.destination_address.add(dest_address_length) }; + while c != '\0' as i8 && dest_address_length < 64 { + create_tx_params.dest_address[dest_address_length] = c as u8; + dest_address_length += 1; + c = unsafe { *params.destination_address.add(dest_address_length) }; + } + create_tx_params.dest_address_len = dest_address_length; - create_tx_params.result = &(*(libarg.__bindgen_anon_1.create_transaction - as *mut create_transaction_parameters_t)) - .result as *const u8 as *mut u8; + create_tx_params.result = unsafe { + &(*(libarg.__bindgen_anon_1.create_transaction as *mut create_transaction_parameters_t)) + .result as *const u8 as *mut u8 + }; - /* Reset BSS and complete application boot */ + /* Reset BSS and complete application boot */ + unsafe { c_reset_bss(); c_boot_std(); + } - #[cfg(any(target_os = "stax", target_os = "flex"))] - NbglSpinner::new().text("Signing").show(); + #[cfg(any(target_os = "stax", target_os = "flex"))] + NbglSpinner::new().text("Signing").show(); - create_tx_params - } + create_tx_params } pub enum SwapResult<'a> { @@ -224,23 +225,21 @@ pub enum SwapResult<'a> { } pub fn swap_return(res: SwapResult) { - unsafe { - match res { - SwapResult::CheckAddressResult(&mut ref p, r) => { - *(p.result) = r; - } - SwapResult::PrintableAmountResult(&mut ref p, s) => { - if s.len() < (MAX_PRINTABLE_AMOUNT_SIZE - 1).try_into().unwrap() { - for (i, c) in s.chars().enumerate() { - *(p.amount_str.add(i)) = c as i8; - } - *(p.amount_str.add(s.len())) = '\0' as i8; + match res { + SwapResult::CheckAddressResult(&mut ref p, r) => { + unsafe { *(p.result) = r }; + } + SwapResult::PrintableAmountResult(&mut ref p, s) => { + if s.len() < (MAX_PRINTABLE_AMOUNT_SIZE - 1).try_into().unwrap() { + for (i, c) in s.chars().enumerate() { + unsafe { *(p.amount_str.add(i)) = c as i8 }; } + unsafe { *(p.amount_str.add(s.len())) = '\0' as i8 }; } - SwapResult::CreateTxResult(&mut ref p, r) => { - *(p.result) = r; - } } - ledger_secure_sdk_sys::os_lib_end(); + SwapResult::CreateTxResult(&mut ref p, r) => { + unsafe { *(p.result) = r }; + } } + unsafe { ledger_secure_sdk_sys::os_lib_end() }; } From 9af72fc90828ed583b609a4c572a350191d3e8db Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 15 Jan 2025 11:56:33 +0100 Subject: [PATCH 031/154] Bump version --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b87b184..1e65fdd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.3" +version = "1.19.4" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 02b061b6..328cd0e7 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.3" +version = "1.19.4" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 13fb0f38ca3cf013cf4d81ac48c5b354361cad03 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 15 Jan 2025 13:17:39 +0100 Subject: [PATCH 032/154] Swap: use constants for all buffer sizes --- ledger_device_sdk/src/libcall/swap.rs | 46 +++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 6fba7750..5a454944 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -6,10 +6,14 @@ use ledger_secure_sdk_sys::{ libargs_s__bindgen_ty_1, libargs_t, MAX_PRINTABLE_AMOUNT_SIZE, }; +const DPATH_STAGE_SIZE: usize = 16; +const ADDRESS_BUF_SIZE: usize = 64; +const AMOUNT_BUF_SIZE: usize = 16; + pub struct CheckAddressParams { - pub dpath: [u8; 64], + pub dpath: [u8; DPATH_STAGE_SIZE * 4], pub dpath_len: usize, - pub ref_address: [u8; 64], + pub ref_address: [u8; ADDRESS_BUF_SIZE], pub ref_address_len: usize, pub result: *mut i32, } @@ -17,9 +21,9 @@ pub struct CheckAddressParams { impl Default for CheckAddressParams { fn default() -> Self { CheckAddressParams { - dpath: [0; 64], + dpath: [0; DPATH_STAGE_SIZE * 4], dpath_len: 0, - ref_address: [0; 64], + ref_address: [0; ADDRESS_BUF_SIZE], ref_address_len: 0, result: core::ptr::null_mut(), } @@ -27,7 +31,7 @@ impl Default for CheckAddressParams { } pub struct PrintableAmountParams { - pub amount: [u8; 16], + pub amount: [u8; AMOUNT_BUF_SIZE], pub amount_len: usize, pub amount_str: *mut i8, pub is_fee: bool, @@ -36,7 +40,7 @@ pub struct PrintableAmountParams { impl Default for PrintableAmountParams { fn default() -> Self { PrintableAmountParams { - amount: [0; 16], + amount: [0; AMOUNT_BUF_SIZE], amount_len: 0, amount_str: core::ptr::null_mut(), is_fee: false, @@ -45,11 +49,11 @@ impl Default for PrintableAmountParams { } pub struct CreateTxParams { - pub amount: [u8; 16], + pub amount: [u8; AMOUNT_BUF_SIZE], pub amount_len: usize, - pub fee_amount: [u8; 16], + pub fee_amount: [u8; AMOUNT_BUF_SIZE], pub fee_amount_len: usize, - pub dest_address: [u8; 64], + pub dest_address: [u8; ADDRESS_BUF_SIZE], pub dest_address_len: usize, pub result: *mut u8, } @@ -57,11 +61,11 @@ pub struct CreateTxParams { impl Default for CreateTxParams { fn default() -> Self { CreateTxParams { - amount: [0; 16], + amount: [0; AMOUNT_BUF_SIZE], amount_len: 0, - fee_amount: [0; 16], + fee_amount: [0; AMOUNT_BUF_SIZE], fee_amount_len: 0, - dest_address: [0; 64], + dest_address: [0; ADDRESS_BUF_SIZE], dest_address_len: 0, result: core::ptr::null_mut(), } @@ -88,7 +92,7 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { debug_print("==> GET_DPATH_LENGTH\n"); check_address_params.dpath_len = - 16usize.min(unsafe { *(params.address_parameters as *const u8) as usize }); + DPATH_STAGE_SIZE.min(unsafe { *(params.address_parameters as *const u8) as usize }); debug_print("==> GET_DPATH \n"); for i in 1..1 + check_address_params.dpath_len * 4 { @@ -98,7 +102,7 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { debug_print("==> GET_REF_ADDRESS\n"); let mut address_length = 0usize; let mut c = unsafe { *(params.address_to_check.add(address_length)) }; - while c != '\0' as i8 && address_length < 64 { + while c != '\0' as i8 && address_length < ADDRESS_BUF_SIZE { check_address_params.ref_address[address_length] = c as u8; address_length += 1; c = unsafe { *(params.address_to_check.add(address_length)) }; @@ -136,11 +140,11 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { printable_amount_params.is_fee = params.is_fee == true; debug_print("==> GET_AMOUNT_LENGTH\n"); - printable_amount_params.amount_len = 16usize.min(params.amount_length as usize); + printable_amount_params.amount_len = AMOUNT_BUF_SIZE.min(params.amount_length as usize); debug_print("==> GET_AMOUNT\n"); for i in 0..printable_amount_params.amount_len { - printable_amount_params.amount[16 - printable_amount_params.amount_len + i] = + printable_amount_params.amount[AMOUNT_BUF_SIZE - printable_amount_params.amount_len + i] = unsafe { *(params.amount.add(i)) }; } @@ -178,23 +182,23 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { let mut create_tx_params: CreateTxParams = Default::default(); debug_print("==> GET_AMOUNT\n"); - create_tx_params.amount_len = 16usize.min(params.amount_length as usize); + create_tx_params.amount_len = AMOUNT_BUF_SIZE.min(params.amount_length as usize); for i in 0..create_tx_params.amount_len { - create_tx_params.amount[16 - create_tx_params.amount_len + i] = + create_tx_params.amount[AMOUNT_BUF_SIZE - create_tx_params.amount_len + i] = unsafe { *(params.amount.add(i)) }; } debug_print("==> GET_FEE\n"); - create_tx_params.fee_amount_len = 16usize.min(params.fee_amount_length as usize); + create_tx_params.fee_amount_len = AMOUNT_BUF_SIZE.min(params.fee_amount_length as usize); for i in 0..create_tx_params.fee_amount_len { - create_tx_params.fee_amount[16 - create_tx_params.fee_amount_len + i] = + create_tx_params.fee_amount[AMOUNT_BUF_SIZE - create_tx_params.fee_amount_len + i] = unsafe { *(params.fee_amount.add(i)) }; } debug_print("==> GET_DESTINATION_ADDRESS\n"); let mut dest_address_length = 0usize; let mut c = unsafe { *params.destination_address.add(dest_address_length) }; - while c != '\0' as i8 && dest_address_length < 64 { + while c != '\0' as i8 && dest_address_length < ADDRESS_BUF_SIZE { create_tx_params.dest_address[dest_address_length] = c as u8; dest_address_length += 1; c = unsafe { *params.destination_address.add(dest_address_length) }; From f44743d0214fd7a7dfbf9e7d304062d31f6df85a Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 16 Jan 2025 11:34:27 +0100 Subject: [PATCH 033/154] Return empty string if error --- ledger_device_sdk/src/libcall/swap.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 5a454944..dfd8e5f7 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -239,6 +239,8 @@ pub fn swap_return(res: SwapResult) { unsafe { *(p.amount_str.add(i)) = c as i8 }; } unsafe { *(p.amount_str.add(s.len())) = '\0' as i8 }; + } else { + unsafe { *(p.amount_str) = '\0' as i8 }; } } SwapResult::CreateTxResult(&mut ref p, r) => { From ebaae5f57bf8cbb02e0e05da93a8123487de8b40 Mon Sep 17 00:00:00 2001 From: Alexis Grojean Date: Wed, 21 Aug 2024 12:30:34 +0200 Subject: [PATCH 034/154] Add choice screen to ask user to confirm tx in generic review example. --- .../examples/nbgl_generic_review.rs | 38 ++++++++++++++---- .../icons/Important_Circle_64px.png | Bin 0 -> 6993 bytes 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100755 ledger_device_sdk/icons/Important_Circle_64px.png diff --git a/ledger_device_sdk/examples/nbgl_generic_review.rs b/ledger_device_sdk/examples/nbgl_generic_review.rs index 548f96a8..d10864ff 100644 --- a/ledger_device_sdk/examples/nbgl_generic_review.rs +++ b/ledger_device_sdk/examples/nbgl_generic_review.rs @@ -8,11 +8,13 @@ use include_gif::include_gif; use ledger_device_sdk::io::*; use ledger_device_sdk::nbgl::{ init_comm, CenteredInfo, CenteredInfoStyle, Field, InfoButton, InfoLongPress, InfosList, - NbglGenericReview, NbglGlyph, NbglPageContent, NbglStatus, TagValueConfirm, TagValueList, + NbglGenericReview, NbglGlyph, NbglPageContent, NbglStatus, NbglChoice, TagValueConfirm, TagValueList, TuneIndex, }; use ledger_secure_sdk_sys::*; +use core::ops::Not; + #[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { exit_app(1); @@ -87,11 +89,31 @@ extern "C" fn sample_main() { .add_content(NbglPageContent::TagValueConfirm(tag_value_confirm)) .add_content(NbglPageContent::InfosList(infos_list)); - let success = review.show("Reject Example"); - let status_text = if success { - "Example confirmed" - } else { - "Example rejected" - }; - NbglStatus::new().text(status_text).show(success); + const IMPORTANT: NbglGlyph = + NbglGlyph::from_include(include_gif!("icons/Important_Circle_64px.png", NBGL)); + + let mut show_tx = true; + let mut status_text = "Example rejected"; + while show_tx { + let confirm = review.show("Reject Example"); + if confirm { + status_text = "Example confirmed"; + show_tx = false; + } else { + show_tx = NbglChoice::new() + .glyph(&IMPORTANT) + .show( + "Reject transaction?", + "", + "Yes, reject", + "Go back to transaction", + ) + // not() is used to invert the boolean value returned + // by the choice (since we want to return to showing the + // transaction if the user selects "Go back to transaction" + // which returns false). + .not(); + } + } + NbglStatus::new().text(status_text).show(status_text == "Example confirmed"); } diff --git a/ledger_device_sdk/icons/Important_Circle_64px.png b/ledger_device_sdk/icons/Important_Circle_64px.png new file mode 100755 index 0000000000000000000000000000000000000000..40e9c22fe68023358b13da0cd8a88628de4536c2 GIT binary patch literal 6993 zcmV-X8?NMuP)000!`dQ@0+Qek%> zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3*tcI>cjg#U9DS%OH4q_`Y$Iww2G^79p_?(5-> zFR_o^cDKXvDnb>LG-`-_{LeV(nwqtLzvOW!+u|T1yMg|ym`I&9irzt z&+E-^@9gDzR)Rr3ZSVDZ93Ktz$;hw2+*j+r|N3J5a6j+IFSg8&jrilIANcfh; zOdQ`U3ZFml*_UtId4AR!*IIM$?mjaX%@3ju_p*-e;lhT=qurMIF8n0^F7{pdzK;9o zIA}e|*3XP{o7E%zUxI`)GTJmi!NFMe}pyy2R^_3h&Bz2EatjomdQjKmCz? zOkm+CAr$Yi#+ZXE;R>2t`0;jaNFfKk4L9M46mu;2rp6m* zoo50+<-EYqonksuN;#Euxm44gV?J}rIhQPwyGtx*NhOz3u2Rc=#p}G%m9KJLSH12U zYJ>w*&9&64)_UK;-Ar^d*3I=d@3hcjJ6meGm3Fn-?hbtV*;CKG^sCo?k1*nZCPp4* zT%(SAdN*N;dCoNREc2Rm-V3a)xXzVUUS(aYuKVq^$E)AI|G{hi@merX>ALdv8t=MN zUPE}%Ns`a-SU5c%FY*9@4)WP?`ST3&oP2iFKv1N>B9naMhL^{1;W>Rs%fEg1!*hS- zH}?m=bT*k|KT}@>%RN#Cte%MbKN|)qfjQRz{1e9VSI=>cx|CyQW0R|nFx$#kU+tV-*IhS;o5TL@ogiC$ zbT^-;Ycponja^qyky+W`nrRiAfB~)}P7D~hu+%n#FO{p-42Xta)`;EK<#J5@B!`!w ze~}a&V2r`g{Vc16xojmhu@F%|NxNw6P?V*?)qK$6UCJZQ7|W=|M(!u{oF~)tHreaS z=RL1{ua5gaCRFo_X*K!nq0<> z`7qT2*IL+IC+1EbeWc9KumAY9*c6WaO*n87r=v!#Bw=mrxwN7v7v-T1t{Y)fiU;&@ zv9h*;%vR@OhyeNfx;ieKJzzIBf{pNQY@Oe=fS$`nQZ8q#az$<|IGDF;w8=5X>~3iE zwXsynWR3>pbDVR{mip8(&NM^C#^#K04y|vUaWxGDurXs|paypM%mdb@ISI38|Eb0M zn5;p-$@u52`-MG3;fR?{*;f=a+Q2@I_ZgyoEFSkEDwRyid&5I4tpuQ*3(XpGs<)hy2L6BNv% ziEA$Gme6XI(O5ttWxByY7pAO)aki+gnf(hQgFuO^v_+7>oZ8`imQI-Y zuBc}PNdYtA(CN}NybMJFUYppdVbYMansMV?fWTIIDY_)BBav9+JRlxS)q{45@tleR zZYAj0G4u(6$y9%2I&4)(1NwQW=g!)FnJt$ztR z7gKE+>b!FYA#e?xB9>gWml-e#AY^uSr|^LQ*@xI6i4gkc&5UCm{MZZmti;*b?XhVL zb{No&IAkFHFR+Z|+rUoijr)RHX{WYUsckV*W^1KRV)66 z95S&aSkBNAbO!qvD_{tvY_0a33WHK?t&qkoUYKAfcw6LvNpjw90LE*_jkb3h?}=wz zguWIq#uHM%I0KWH3vN6#BO@fucy03-AJi-o0UmP0AmL$m??8@V;r(XXoB8kca8u&; zVzx1~Tsw+R?G7RkA24}mo7m04d`8rYC(LFvHP?=fm6@)j+d^cuPe};7iqMG|5OA*H zE{kJj4;E2MWg~b&8^?%^AUy#c`EUt^^VceabTp}M@SQSZ&xj1E6!QDbt3FW(sYI`w zuu~FZ#+N2|VP@Tf4YMN_;0q(oR&3R2uO!~%!2r}Uk7@oR1u3P8jx|o=%4{@rK3PQe z=uZwJPy+(0h-@JL(V$J1W_K0Rn8L^MmSR!igGE*X*%0wTQmp8Mn1xS(klHy0R>J)q z6ijy6(BIvRhv6}{Wa0-ixxY|r&nrq3<=G6csmxVi2CO)}nDcUQX};SqiPSMh^p7zF zV=&zwbKFvG>xJj~16@i#3(h7MGJFI0eyDPutpGcjZ{Gc&ZM>t<YwFqzF&91@~dD6#C^X1`nGCHo26coeW)cr740Ci(R2a~`K?XHVmZBoD*duY)D zOoBp9(nFr`mE(p)C*H}<t!Qm9mf7El-)X!#-;ACD6s<-R{@vM&~t>YirN zmTqy>^#k|r-vZ%N9Hcr;R4BT=+i2LteiftHv{S5VWSLWI)-Z&8Mc4yTN&C9ZNk~Xz zhUNMtec88|g3?Eu(-=LfwfR*}{aQ`Ak8%pMqXY?-L7JGSiBf`ru(!!Bge_+3#d8hD(dHIjNnvdzLj5-?i@TkX$=ry-3#77*jVbexZMxf)FRUL)mNV z`bWkpC3XJ+#I2>@V^gmT^ckVw09urDW$6_|lc9(HmqOa-V!v1T>|g9 zANThiXEC1Y=h;Qsbn^EVeOoH=&9=GAcqecAkSsWN+7xkImNOv&Q}BymaP2xIZ>Hbn zIMtfepRg*ZM%=WaD$b~eRRvjGAEm$Ub3cLW@1%cQDKV(fkxD?fZxcZNMm;4Nt*i8} z7FDfasWimEFgxT1O)h12z!4Whu&YXLQjj>g3?E%u;f9K(3b|KM=t^4na;QmxI#h9V z-$6)NdorQD1u{7?mHaCwSQda zH|6ZMbY2&EdYUbL6hFw8MOvVlEr&@k3%tja5#}O6;i3cQjp6X&@MFsZ%-4EVrqSvM zb4pmm6+SCf znEh7k$KmfMiuWP_{@9?eTj7vg#s5w13>F|Rut>HzRu#S@+5I$>fBCxV_L5vJC%v4F z`_~8Bfi{eIbinhX9=-R8d`wCtLFVmh-f8YlK0jUX->=v01rIg%Rx<5C`nOr)lHwM8 zLuM&lQLpEU_PU}xR~*^lYj$y!t)WF)K_QfO$F0bzqIdBftZux=HkZslLB@4iT}drc zA9bAxp;Z)>7dL_dGX9V>LbZE!+SapK^;^g#d`^b2&rje=bwuQscWC(dr_lISD7&A> z^1p|&`*|$?dnmhqeciM`ot<)$W2?D4bsK07FD1S4J#E$l_q^Js*K9;_|f{B zO@2H-rmfsmIXkrt)e)N__-yWpmZ%_yQ*b~mObb7Z)K!xi?W+`k_Su92kT`VRhleZ} zi?G&(vaT)+tuah=)xFcjh)?F6KqIp{;Bv< zTZCn^J2&&L=9}V;3DbOR^=btCIu3UfJ|XA+5Q}%LfFUg31^=zWP`Y`@9*m19*fi%@ z#FH?`V~}Q@wLH|eH-o4hstQ--sd^sc!g@KHFhke*+Emmey9alOJpC&XwyBn*kwQ7F z3#KN3QB zH-j-Rk?Xj@dcitrkg=^799~7Mx_1N)IEYR5$%i$XytkJ*A#S2SJdbp);jf;>;Ox)hL77R=MSWj3l+$HKc!zap%x8t>U~LCcPA+{ z@@_jY&$-(h6{!bQ(^UKWS0QX|&Y|E1SZ>xG@xj-ALydO zSHP&aLu@+1Fb=h_e6rdqjGb+*vWjsUOFt(k6nEKxJNl1a3Q+_XO4j7%gPHTG_I=#- z=~L}jt56Z|uL^axh&|?(8`l{P_09(Qs}4KvprEWoud1>l)u+?SoDE{`g|U16UnDYu z9pi&!>lp`J#(F^V=Q_VzD@s|nJ|~t6pk#-NAv_3oFNl9ac$$`UFR3l@`#g8gl&EBL z>E2ROo0~g$iM0<65lisD36JE*S(3N%TB}diQ(3#RcHP1sGk|DV%={O3djaoRucp7e zSF956#dJ0h1uXBzl>6G5`eS1%?BZ*v7-w6=iFzjp_Mu>+09Qn9F3RcJ+^5J`zWh~N z%6;xjsRapWoMdzzoa2`8H zD_ysFUAsw{Y>8mfQ5^K0f2=!cr#>oc~}q9mx%;ZfD)6D{{8PR`A! zV;@504g*-D@)mlnO-Ul6IL1liR8;m|I&ihM)rW{$3@N0~)XF|b+9~UNog*o8btJ3< z%yZb;ENgEj7@N&ko&!C#l@T(&ZJjH(wnOqmKS?KO@}A^TT)`=zyY5r-k0qT>+r&b39_)?}H7-(lbfjwmPak1u|aG zUg#vQ?XHQQiLkC6{^+^AlW>PbB{!9WgC0%U-Q_{nu%4(Rc_I-=!3#aeDR^hk%O9^n-Aq`|V%6(8dSUFx(A>vbRpM3T<9=SQzMpmik<}O@-VQQn;X>QriEF?9FvJHWf+Q+|Gj_im9(iTj*f%?^Z?p;x6!T=BIz zDpFfH7C6us_;UBuFfHu+Lx~t&wNcV_H}@jXzi1u5TgWn$`(NK0xYKGmAZY*q0flKp zLr_UWLm+T+Z)Rz1WdHzpoPCi!NW(xFhTo=2ORYFqLBt_Lb+RBT;;2<9LWNK(wCZ4T z=^r#{NLpMR1=oUuKZ{id7iV1^Tm?b!2gKRINzp}0{4Oc9i1Ci&9^U)jm%Hx(p;2a< z)in-ideuxN;$kMdDh6H=!~jAxdt_!AbCQ&V=lHsZkMDOep5RRSZ&0xHlTJAUv#_}yD8KRMwhh2uc?i*0|50D)bgS-0))W7}??0RCs-N^kos z4PfSz^m<#19szyZz{Pc2Q}%$%9boXukWJZ<{IrC89(X^aZ^{Dww?Jsk?OW>{rw>4y zdX>BZ4i16Q0%fmzygS(0w|{F|{rdq5fpUGqIDcLM000JJOGiWi{{a60|De66lK=n! z32;bRa{vGf6951U69E94oEQKA00(qQO+^Rj2o(wo5`3=mb^rhbTS-JgRA}DiTE9!f zP83h&3pyF46a<%wwp|p&*+mhu`4706f5D;uLcq~gr$%r~<^(6NgM%H4P+AM;AT*T1 zWxGuI4wZbb?~*h>t|sOCCgbVd``ml)-rakjitqcfT18PD$MIJzj^prWT}(_%QBGNi_AwZuEH5Q={Xf$_z`*ZdXh4Sm&~^PU z{XTg-XqvVhz+f=o)4N}g7={6q;nNNT0GubuNgVE)BJS;!QlJlS1PNR-!K$gQCBgxO zdIT`S!jtmlFH^)FUD4@1@6B}r*Go_6+ZCh* z%d$dT=%|mf7GQLpDz7{vw>)w(AMnUrM@BsX0;k6iFz{uQ&5oG~>`+;A;d4Um@ zHb_rR2?p0-Jn>VWjR-Mm6YH8V|hR&)cjS`^0>MBnYPb zM5TmujHNB2>{Nq1-2=W2vl6O7fFX+Pksn43cPhR?pPDbk$21EgE&GiSV%v5M`zSdb zBSnUfp~eJA=7cAVF^h*%N(gZr2O*^Edi*4cqNF+}Qd7=CIVGY*)3g;*&X&epPSvwL zKmM1rOP>9fjreL=R(|4C#TP{W_B?MgnT$rG@p$aI?r=B+)Z<#Mc5-r3uh*;9YQ0_; jMLiY Date: Mon, 20 Jan 2025 14:20:27 +0100 Subject: [PATCH 035/154] run cargo fmt --- ledger_device_sdk/examples/nbgl_generic_review.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ledger_device_sdk/examples/nbgl_generic_review.rs b/ledger_device_sdk/examples/nbgl_generic_review.rs index d10864ff..a0ecf8f6 100644 --- a/ledger_device_sdk/examples/nbgl_generic_review.rs +++ b/ledger_device_sdk/examples/nbgl_generic_review.rs @@ -8,8 +8,8 @@ use include_gif::include_gif; use ledger_device_sdk::io::*; use ledger_device_sdk::nbgl::{ init_comm, CenteredInfo, CenteredInfoStyle, Field, InfoButton, InfoLongPress, InfosList, - NbglGenericReview, NbglGlyph, NbglPageContent, NbglStatus, NbglChoice, TagValueConfirm, TagValueList, - TuneIndex, + NbglChoice, NbglGenericReview, NbglGlyph, NbglPageContent, NbglStatus, TagValueConfirm, + TagValueList, TuneIndex, }; use ledger_secure_sdk_sys::*; @@ -90,7 +90,7 @@ extern "C" fn sample_main() { .add_content(NbglPageContent::InfosList(infos_list)); const IMPORTANT: NbglGlyph = - NbglGlyph::from_include(include_gif!("icons/Important_Circle_64px.png", NBGL)); + NbglGlyph::from_include(include_gif!("icons/Important_Circle_64px.png", NBGL)); let mut show_tx = true; let mut status_text = "Example rejected"; @@ -115,5 +115,7 @@ extern "C" fn sample_main() { .not(); } } - NbglStatus::new().text(status_text).show(status_text == "Example confirmed"); + NbglStatus::new() + .text(status_text) + .show(status_text == "Example confirmed"); } From c51c49588b72fd7e25e1e504ec613114167a8652 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 8 Jan 2025 15:29:41 +0100 Subject: [PATCH 036/154] Pin code management: when device is locked, returned 0x5515 error --- ledger_device_sdk/src/io.rs | 8 ++++++++ ledger_device_sdk/src/ui/gadgets.rs | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index a187bc7e..63e1d368 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -432,6 +432,14 @@ impl Comm { } if unsafe { G_io_app.apdu_state } != APDU_IDLE && unsafe { G_io_app.apdu_length } > 0 { + unsafe { + if os_perso_is_pin_set() == BOLOS_TRUE.try_into().unwrap() + && os_global_pin_is_validated() != BOLOS_TRUE.try_into().unwrap() + { + self.reply(StatusWords::DeviceLocked); + return None; + } + } self.rx = unsafe { G_io_app.apdu_length as usize }; self.event_pending = true; return self.check_event(); diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index f2de19d7..236d2879 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -608,11 +608,7 @@ impl<'a> MultiPageMenu<'a> { io::Event::Ticker => { if UxEvent::Event.request() != BOLOS_UX_OK { // pin lock management - let (_res, ins) = UxEvent::block_and_get_event::(self.comm); - if let Some(_e) = ins { - self.comm - .reply::(io::StatusWords::DeviceLocked); - } + UxEvent::block_and_get_event::(self.comm); // notify Ticker event only when redisplay is required return EventOrPageIndex::Event(io::Event::Ticker); } From e85f931a0a7bb651eb6570020f98a28b774c0fe3 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 8 Jan 2025 16:40:05 +0100 Subject: [PATCH 037/154] Update build all apps workflow --- .github/workflows/build_all_apps.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index 63073567..87183174 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -91,6 +91,17 @@ jobs: echo "path=$path" >> $cargo_toml_path echo "Patch added to Cargo.toml" fi + # Patch include_gif + if grep -Fxq "[patch.crates-io.include_gif]" $cargo_toml_path; then + echo "The patch already exists in the file." + exit 1 + else + echo "" >> $cargo_toml_path + echo "[patch.crates-io.include_gif]" >> $cargo_toml_path + path=\"$GITHUB_WORKSPACE/sdk/include_gif\" + echo "path=$path" >> $cargo_toml_path + echo "Patch added to Cargo.toml" + fi - name: Build run: | @@ -100,8 +111,9 @@ jobs: cd $build_directory for device in $devices; do # Required as patch has a different version from what is locked in Cargo.lock - cargo +$RUST_NIGHTLY update ledger_device_sdk + cargo +$RUST_NIGHTLY update include_gif cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys + cargo +$RUST_NIGHTLY update ledger_device_sdk echo "Build for "$device cargo ledger build $device done From c8d5062e8571e026a8367637457a6ec7dfa2b263 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 8 Jan 2025 16:50:39 +0100 Subject: [PATCH 038/154] Remove nanos from CI tests --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afba35fe..7791c5e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanos", "nanox", "nanosplus", "stax", "flex"] + target: ["nanox", "nanosplus", "stax", "flex"] package: [include_gif, testmacro, ledger_secure_sdk_sys, ledger_device_sdk] steps: - name: Print Environment variables @@ -66,7 +66,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanos", "nanox", "nanosplus", "stax", "flex"] + target: ["nanox", "nanosplus", "stax", "flex"] steps: - name: Clone uses: actions/checkout@v4 @@ -95,7 +95,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanos", "nanox", "nanosplus", "stax", "flex"] + target: ["nanox", "nanosplus", "stax", "flex"] steps: - name: Clone uses: actions/checkout@v4 From 58b6c20cdfc29745a088ea7ba688d00016043eb6 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 8 Jan 2025 17:02:03 +0100 Subject: [PATCH 039/154] Exclude Nano S for pin management --- ledger_device_sdk/src/io.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 63e1d368..f689a7b4 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -432,6 +432,7 @@ impl Comm { } if unsafe { G_io_app.apdu_state } != APDU_IDLE && unsafe { G_io_app.apdu_length } > 0 { + #[cfg(not(any(target_os = "nanos")))] unsafe { if os_perso_is_pin_set() == BOLOS_TRUE.try_into().unwrap() && os_global_pin_is_validated() != BOLOS_TRUE.try_into().unwrap() From 83573d87ae6f7180d5cfd77ddb1c92ebb1dbbfb4 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 8 Jan 2025 17:09:47 +0100 Subject: [PATCH 040/154] Revert remove Nano S (should be done in another PR --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7791c5e7..afba35fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanox", "nanosplus", "stax", "flex"] + target: ["nanos", "nanox", "nanosplus", "stax", "flex"] package: [include_gif, testmacro, ledger_secure_sdk_sys, ledger_device_sdk] steps: - name: Print Environment variables @@ -66,7 +66,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanox", "nanosplus", "stax", "flex"] + target: ["nanos", "nanox", "nanosplus", "stax", "flex"] steps: - name: Clone uses: actions/checkout@v4 @@ -95,7 +95,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanox", "nanosplus", "stax", "flex"] + target: ["nanos", "nanox", "nanosplus", "stax", "flex"] steps: - name: Clone uses: actions/checkout@v4 From ec33697cf4e33a141dd9cc0cad0ec688f10cc5f5 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 9 Jan 2025 15:52:58 +0100 Subject: [PATCH 041/154] Implement heartbeat function in sys crate --- ledger_secure_sdk_sys/src/seph.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ledger_secure_sdk_sys/src/seph.rs b/ledger_secure_sdk_sys/src/seph.rs index b6ed8e75..0a83fcb1 100644 --- a/ledger_secure_sdk_sys/src/seph.rs +++ b/ledger_secure_sdk_sys/src/seph.rs @@ -34,6 +34,17 @@ pub fn send_general_status() { } } +/// Function to ensure a I/O channel is not timeouting waiting +/// for operations after a long time without SEPH packet exchanges +pub fn heartbeat() { + send_general_status(); + let mut spi_buffer = [0u8; 128]; + seph_recv(&mut spi_buffer, 0); + while is_status_sent() { + seph_recv(&mut spi_buffer, 0); + } +} + #[repr(u8)] pub enum SephTags { ScreenDisplayStatus = SEPROXYHAL_TAG_SCREEN_DISPLAY_STATUS as u8, From ba1211492e639b3067f358b2d38757992ddd4a45 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 22 Jan 2025 08:22:26 +0100 Subject: [PATCH 042/154] Bump versions --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 2 +- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e65fdd0..fe3de21f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.4" +version = "1.19.5" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.1" +version = "1.6.2" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 328cd0e7..508b09a2 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.4" +version = "1.19.5" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 378e37a8..29a673e8 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.1" +version = "1.6.2" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From f7f58c30a80c49ad071bb95a11ca130b30c3d00e Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 23 Jan 2025 17:01:07 +0100 Subject: [PATCH 043/154] Generate glyphs automatically when building sys crate --- Cargo.lock | 2 +- ledger_secure_sdk_sys/Cargo.toml | 2 +- ledger_secure_sdk_sys/build.rs | 76 +- .../src/c/glyphs_flex/glyphs.c | 813 ------------------ .../src/c/glyphs_flex/glyphs.h | 145 ---- .../src/c/glyphs_stax/glyphs.c | 784 ----------------- .../src/c/glyphs_stax/glyphs.h | 145 ---- 7 files changed, 72 insertions(+), 1895 deletions(-) delete mode 100644 ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.c delete mode 100644 ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.h delete mode 100644 ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.c delete mode 100644 ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.h diff --git a/Cargo.lock b/Cargo.lock index fe3de21f..96a15828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.2" +version = "1.6.3" dependencies = [ "bindgen", "cc", diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 29a673e8..71915aeb 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.2" +version = "1.6.3" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b2f2eb6d..b092a06d 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -400,6 +400,60 @@ impl SDKBuilder { self.cxdefines = cxdefines; } + pub fn generate_glyphs(&self) { + if self.device == Device::NanoS { + return; + } + + let icon2glyph = self.bolos_sdk.join("lib_nbgl/tools/icon2glyph.py"); + + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let dest_path = match self.device { + Device::Flex => out_path.join("glyphs_flex"), + Device::Stax => out_path.join("glyphs_stax"), + Device::NanoSPlus => out_path.join("glyphs_nanosplus"), + Device::NanoX => out_path.join("glyphs_nanox"), + Device::NanoS => panic!("Nano S does not support glyphs"), + }; + if !dest_path.exists() { + fs::create_dir_all(&dest_path).ok(); + } + + let mut glyph_folders: Vec = Vec::new(); + match self.device { + Device::Flex => { + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/40px")); + } + Device::Stax => { + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/32px")); + } + _ => { + glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/nano")); + } + } + + let mut png_list: Vec = Vec::new(); + for folder in glyph_folders.iter() { + for file in std::fs::read_dir(folder).unwrap() { + let path = file.unwrap().path(); + let path_str = path.to_str().unwrap().to_string(); + png_list.push(path_str); + } + } + + let _ = Command::new(icon2glyph.as_os_str()) + .arg("--glyphcheader") + .arg(dest_path.join("glyphs.h").as_os_str()) + .arg("--glyphcfile") + .arg(dest_path.join("glyphs.c").as_os_str()) + .args(png_list) + .output(); + } + pub fn build_c_sdk(&self) { let mut command = cc::Build::new(); if env::var_os("CC").is_none() { @@ -534,10 +588,17 @@ impl SDKBuilder { ) } Device::Stax | Device::Flex => { + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); if Device::Stax == self.device { - bindings = bindings.clang_args(["-I./src/c/glyphs_stax"]); + let glyphs = out_path.join("glyphs_stax"); + let include_path = glyphs.to_str().unwrap(); + let s = "-I".to_string() + include_path; + bindings = bindings.clang_args([s.as_str()]); } else { - bindings = bindings.clang_args(["-I./src/c/glyphs_flex"]); + let glyphs = out_path.join("glyphs_flex"); + let include_path = glyphs.to_str().unwrap(); + let s = "-I".to_string() + include_path; + bindings = bindings.clang_args([s.as_str()]); } bindings = bindings.clang_args([ @@ -618,6 +679,7 @@ fn main() { sdk_builder.device(); sdk_builder.bolos_sdk().unwrap(); sdk_builder.cxdefines(); + sdk_builder.generate_glyphs(); sdk_builder.build_c_sdk(); sdk_builder.generate_bindings(); sdk_builder.generate_heap_size(); @@ -721,6 +783,7 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command.define(define.as_str(), value.as_deref()); } + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs_stax"); command .target("thumbv8m.main-none-eabi") .file(bolos_sdk.join("src/ledger_protocol.c")) @@ -739,8 +802,8 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { .include(bolos_sdk.join("target/stax/include/")) .flag("-fropi") .flag("-frwpi") - .include("./src/c/glyphs_stax/") - .file("./src/c/glyphs_stax/glyphs.c"); + .include(&glyphs_path) + .file(glyphs_path.join("glyphs.c")); configure_lib_nbgl(command, bolos_sdk); } @@ -750,6 +813,7 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command.define(define.as_str(), value.as_deref()); } + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs_flex"); command .target("thumbv8m.main-none-eabi") .file(bolos_sdk.join("src/ledger_protocol.c")) @@ -768,8 +832,8 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { .include(bolos_sdk.join("target/flex/include/")) .flag("-fropi") .flag("-frwpi") - .include("./src/c/glyphs_flex/") - .file("./src/c/glyphs_flex/glyphs.c"); + .include(&glyphs_path) + .file(glyphs_path.join("glyphs.c")); configure_lib_nbgl(command, bolos_sdk); } diff --git a/ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.c b/ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.c deleted file mode 100644 index 1324f214..00000000 --- a/ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.c +++ /dev/null @@ -1,813 +0,0 @@ -/* Automatically generated by icon2glyph.py */ - -#include "glyphs.h" - -uint8_t const C_app_boilerplate_16px_bitmap[] = { - 0x10, 0x00, 0x10, 0x00, 0x02, 0x15, 0x00, 0x00, 0xf0, 0x71, 0xf1, 0xf2, 0x42, 0x83, 0x14, 0x87, - 0x78, 0x69, 0x79, 0x98, 0xa7, 0x93, 0x14, 0x82, 0x42, 0x81, 0xf1, 0xf0, 0xa0, -}; -const nbgl_icon_details_t C_app_boilerplate_16px = { 16, 16, NBGL_BPP_1, true, C_app_boilerplate_16px_bitmap }; - -uint8_t const C_app_boilerplate_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x01, 0xb3, 0x00, 0x00, 0xb1, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x75, 0xd1, 0xbb, 0x0d, 0x03, 0x21, 0x0c, 0x06, 0x60, 0x9f, 0x22, 0x85, - 0x92, 0x11, 0x6e, 0x85, 0x6c, 0x70, 0xa3, 0x1d, 0xa3, 0x79, 0x14, 0xa4, 0x14, 0x69, 0x29, 0x29, - 0x2c, 0x1c, 0x83, 0xff, 0x44, 0x04, 0xe5, 0xdc, 0x7c, 0x12, 0x0f, 0x1b, 0x1b, 0xa2, 0xab, 0xb8, - 0xc3, 0xf0, 0x31, 0x2d, 0x32, 0xcc, 0xb0, 0xc0, 0x3a, 0xf9, 0x30, 0x85, 0x68, 0xb3, 0xbd, 0xd0, - 0x88, 0xa2, 0x9d, 0x0d, 0x4a, 0x74, 0xf2, 0xf0, 0xa6, 0xc3, 0xb4, 0x6b, 0xea, 0xb2, 0x6a, 0xbf, - 0xa7, 0x2f, 0x6d, 0x43, 0xfd, 0x2a, 0xb0, 0xc2, 0x32, 0xb9, 0x9b, 0xfd, 0x09, 0x86, 0xa7, 0xb3, - 0xb0, 0x74, 0x47, 0xd7, 0x2a, 0xab, 0x1b, 0xd5, 0xd3, 0x8d, 0x65, 0x81, 0x15, 0xeb, 0x82, 0x73, - 0xbd, 0xdc, 0x01, 0xa3, 0xdf, 0xf3, 0x8d, 0x84, 0x0d, 0x46, 0xdd, 0xbc, 0x58, 0x96, 0xf7, 0xc9, - 0x8f, 0x4f, 0xf4, 0x91, 0x4f, 0xef, 0x8f, 0xa3, 0xf7, 0x9b, 0x36, 0x7f, 0xb0, 0xe5, 0xe6, 0x69, - 0x3e, 0x0d, 0xf3, 0x12, 0xcc, 0xaf, 0x2e, 0xf3, 0x2d, 0xcb, 0xdc, 0xf9, 0xe2, 0x7f, 0x96, 0x7f, - 0xfc, 0x1f, 0x6f, 0xe5, 0xd1, 0xa9, 0x21, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_app_boilerplate_64px = { 64, 64, NBGL_BPP_1, true, C_app_boilerplate_64px_bitmap }; - -uint8_t const C_pin_24_bitmap[] = { - 0x18, 0x00, 0x18, 0x00, 0x02, 0x29, 0x00, 0x00, 0x96, 0xfc, 0xbe, 0x9f, 0x01, 0x7f, 0x03, 0x5f, - 0x05, 0x3f, 0x07, 0x2f, 0x07, 0x2f, 0x07, 0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x09, 0x1f, 0x07, 0x2f, 0x07, 0x2f, 0x07, 0x3f, 0x05, 0x5f, 0x03, 0x7f, 0x01, 0x9e, 0xbc, 0xf6, - 0x90, -}; -const nbgl_icon_details_t C_pin_24 = { 24, 24, NBGL_BPP_1, true, C_pin_24_bitmap }; - -uint8_t const C_quarter_circle_bottom_left_32px_1bpp_bitmap[] = { - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, - 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x80, - 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x3e, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_circle_bottom_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_circle_bottom_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_bottom_left_40px_1bpp_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, - 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, - 0x03, 0xc0, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x00, 0xff, 0xe0, - 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_circle_bottom_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_circle_bottom_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_bottom_left_44px_1bpp_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, - 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, - 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, - 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_circle_bottom_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_circle_bottom_left_44px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_top_left_32px_1bpp_bitmap[] = { - 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, - 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, - 0x01, 0xc0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, - 0x00, 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0xf0, 0x00, - 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_circle_top_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_circle_top_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_top_left_40px_1bpp_bitmap[] = { - 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, - 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_circle_top_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_circle_top_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_top_left_44px_1bpp_bitmap[] = { - 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_circle_top_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_circle_top_left_44px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_bottom_left_32px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, - 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, - 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0x80, - 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xfc, 0x00, - 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xc0, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xfe, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_disc_bottom_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_disc_bottom_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_bottom_left_40px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, - 0xfc, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xf8, - 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, - 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, - 0xfe, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xf0, - 0x00, 0xff, 0xff, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0xff, 0xff, 0xff, 0x80, 0x00, - 0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x00, 0x00, 0xff, - 0xff, 0xc0, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xff, 0xe0, - 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_disc_bottom_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_disc_bottom_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_bottom_left_44px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, - 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, - 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xc0, 0x00, - 0xff, 0xff, 0xff, 0xf8, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xe0, 0x00, - 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, - 0x00, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, - 0x00, 0x0f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_disc_bottom_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_disc_bottom_left_44px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_top_left_32px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, - 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, - 0x1f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, - 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, - 0x01, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, - 0x00, 0x1f, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, - 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_disc_top_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_disc_top_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_top_left_40px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07, - 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, - 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x7f, 0xff, - 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, - 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xff, 0x00, - 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, - 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_disc_top_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_disc_top_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_top_left_44px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, - 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x1f, - 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x7f, 0xff, 0xff, 0xff, 0xf0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xf0, - 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xff, - 0x00, 0x01, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, - 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xff, - 0xff, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x1f, - 0xff, 0xf0, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_disc_top_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_disc_top_left_44px_1bpp_bitmap }; - -uint8_t const C_round_24px_bitmap[] = { - 0x18, 0x00, 0x18, 0x00, 0x02, 0x27, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x74, 0xf0, 0x38, - 0xec, 0xbe, 0xae, 0x9f, 0x01, 0x8f, 0x01, 0x7f, 0x03, 0x6f, 0x03, 0x6f, 0x03, 0x6f, 0x03, 0x7f, - 0x01, 0x8f, 0x01, 0x9e, 0xae, 0xbc, 0xe8, 0xf0, 0x34, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x70, -}; -const nbgl_icon_details_t C_round_24px = { 24, 24, NBGL_BPP_1, true, C_round_24px_bitmap }; - -uint8_t const C_switch_60_40_bitmap[] = { - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x00, - 0x3f, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0x80, 0x03, 0xff, - 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, - 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, - 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, - 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, - 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, - 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, - 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0x00, 0xff, 0xfc, 0x3f, 0xf8, 0x00, 0x1f, - 0xfc, 0x3f, 0xf0, 0x00, 0x0f, 0xfc, 0x3f, 0xc0, 0x00, 0x03, 0xfc, 0x3f, 0x80, 0x00, 0x01, 0xfc, - 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x3e, 0x00, 0x00, 0x00, 0x7c, 0x3c, - 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x3c, 0x38, 0x00, - 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, - 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, - 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 0x00, 0x38, - 0x1c, 0x00, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x00, 0x70, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x07, - 0x00, 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x01, 0xc0, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x01, 0xf0, - 0x00, 0x0f, 0x80, 0x00, 0xf8, 0x00, 0x1f, 0x00, 0x00, 0x3f, 0x00, 0xfc, 0x00, 0x00, 0x1f, 0xff, - 0xf8, 0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, -}; -const nbgl_icon_details_t C_switch_60_40 = { 60, 40, NBGL_BPP_1, false, C_switch_60_40_bitmap }; - -uint8_t const C_Check_Circle_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x33, 0x02, 0x00, 0x31, 0x02, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xad, 0x55, 0x39, 0x4e, 0x03, 0x31, 0x14, 0xfd, 0x24, 0x61, 0x5f, 0x4b, - 0x28, 0x80, 0x91, 0xa0, 0x01, 0x24, 0x88, 0xb8, 0x40, 0x46, 0x54, 0x20, 0x21, 0x41, 0x49, 0x39, - 0x2d, 0x15, 0xdc, 0x00, 0x90, 0xa0, 0x66, 0x11, 0xa2, 0x05, 0x71, 0x01, 0x10, 0x17, 0x48, 0x0a, - 0x6a, 0x02, 0x17, 0x60, 0xab, 0x41, 0x61, 0x89, 0x04, 0x24, 0x21, 0x9f, 0xef, 0x65, 0x66, 0xbe, - 0x3d, 0x0e, 0x8b, 0xc4, 0x14, 0x99, 0xb1, 0x9f, 0xfd, 0xfc, 0xfc, 0xfc, 0xf3, 0x8c, 0xf8, 0x7f, - 0x4f, 0xf5, 0x60, 0x1a, 0x60, 0x74, 0xa9, 0xd8, 0x00, 0xde, 0x04, 0xfd, 0xcc, 0x95, 0x1c, 0x68, - 0xcd, 0x87, 0xe8, 0xc9, 0x14, 0xbf, 0x85, 0x01, 0x52, 0x79, 0x0b, 0xae, 0x1b, 0x30, 0x40, 0x8b, - 0xb5, 0xc4, 0xae, 0x9c, 0xb5, 0x7c, 0x8d, 0xf8, 0x70, 0xe0, 0x89, 0xef, 0x71, 0x03, 0x7e, 0x13, - 0x5d, 0xfd, 0x7a, 0x4e, 0x7d, 0x4f, 0xb4, 0xd6, 0x38, 0x9e, 0xa5, 0x8e, 0xf9, 0xb8, 0x79, 0x4c, - 0xcd, 0x34, 0x5b, 0xe1, 0x9e, 0xda, 0x13, 0x7c, 0xbc, 0x18, 0x30, 0x19, 0x8b, 0xa3, 0x15, 0x5b, - 0x4d, 0xb9, 0x01, 0xa9, 0x89, 0x5a, 0xaf, 0x34, 0xfa, 0xd0, 0xd4, 0xfb, 0x41, 0x5d, 0xb9, 0xb0, - 0xb1, 0x0a, 0x30, 0x68, 0xfb, 0x71, 0x15, 0x53, 0x56, 0x00, 0x9a, 0x6e, 0x6c, 0xfc, 0xb3, 0x2f, - 0xe2, 0x24, 0x75, 0xdd, 0x49, 0xbf, 0x2f, 0x01, 0x86, 0xd4, 0x57, 0x10, 0x8e, 0xac, 0x5a, 0x0a, - 0x32, 0xaa, 0x97, 0xdc, 0x54, 0x5d, 0x47, 0x39, 0x3e, 0x80, 0x54, 0xc9, 0x63, 0x7a, 0x09, 0xb7, - 0x5a, 0x81, 0x34, 0xc7, 0xa9, 0x7f, 0x41, 0xbc, 0x0b, 0x00, 0x27, 0x6a, 0x3a, 0xdb, 0x92, 0xe2, - 0xed, 0x12, 0x6f, 0x3f, 0x74, 0x82, 0xb6, 0x64, 0x10, 0xf8, 0x52, 0x40, 0x1d, 0xa0, 0x23, 0xde, - 0x12, 0x27, 0x20, 0x62, 0xa5, 0x73, 0x0a, 0x9d, 0x04, 0xcf, 0x00, 0xdb, 0x88, 0xe5, 0xd8, 0x5b, - 0x8b, 0xe0, 0x5d, 0x0a, 0x7c, 0x02, 0x28, 0xa1, 0x93, 0x80, 0x56, 0xee, 0x15, 0xab, 0xa4, 0x0c, - 0x53, 0x19, 0x81, 0x07, 0x9d, 0x88, 0xeb, 0xa1, 0x3b, 0x49, 0x82, 0x00, 0xda, 0x11, 0x17, 0xc5, - 0x8f, 0x9b, 0x60, 0x47, 0x4c, 0xf5, 0x95, 0x0b, 0x2e, 0x82, 0x4b, 0xf1, 0xed, 0x41, 0x0f, 0x36, - 0x20, 0xb8, 0x15, 0xd2, 0xa4, 0x48, 0x37, 0xc1, 0x93, 0x30, 0xc8, 0xc2, 0x39, 0x81, 0x0b, 0xe7, - 0x04, 0x4e, 0x5c, 0x10, 0xac, 0x30, 0xdc, 0xd4, 0xa7, 0x08, 0x56, 0x98, 0xbe, 0xac, 0x5d, 0x7c, - 0x31, 0x5e, 0x10, 0x07, 0x1c, 0x70, 0x7f, 0x34, 0xff, 0x5a, 0xe8, 0x4f, 0xb3, 0x36, 0xc9, 0xad, - 0x2f, 0x80, 0x36, 0xc4, 0x53, 0x76, 0x3e, 0xd6, 0xfe, 0x3c, 0x61, 0x2d, 0x3f, 0x5f, 0x73, 0xba, - 0x3a, 0xdf, 0xb2, 0xac, 0x12, 0xd7, 0xf4, 0x0f, 0x59, 0x1f, 0x54, 0x25, 0xc3, 0x6e, 0x7b, 0x5f, - 0x54, 0x65, 0x01, 0x3b, 0x40, 0xe3, 0x78, 0x8e, 0xd4, 0xca, 0xbe, 0xfe, 0x1f, 0xe9, 0x92, 0x4c, - 0xb3, 0xf2, 0xc9, 0xe8, 0x32, 0xce, 0xb3, 0x92, 0x8c, 0xa6, 0x57, 0x34, 0x71, 0x39, 0x2e, 0x70, - 0xaa, 0xb6, 0x34, 0x0f, 0x1d, 0xd9, 0x5f, 0xe3, 0xe1, 0xf2, 0x9e, 0x63, 0xd5, 0xa7, 0x79, 0xfd, - 0x44, 0xba, 0xe8, 0xdd, 0x69, 0x63, 0xef, 0x1a, 0xe5, 0xc3, 0x64, 0x34, 0xd2, 0x9d, 0x2f, 0x27, - 0xbf, 0xcb, 0xa7, 0x1f, 0xf3, 0x8d, 0x9c, 0xb0, 0x03, 0x9b, 0x28, 0x53, 0x25, 0x23, 0x5f, 0x8d, - 0xc0, 0x3e, 0x33, 0xf2, 0x15, 0xeb, 0x59, 0x73, 0xc0, 0x39, 0x58, 0x51, 0x22, 0xf3, 0x7d, 0x2c, - 0xcc, 0xf7, 0x8d, 0x44, 0xbe, 0xcb, 0xc0, 0xa6, 0xfb, 0xe1, 0x02, 0xf1, 0x51, 0xdd, 0x0f, 0x03, - 0x98, 0x08, 0x6c, 0xfe, 0x64, 0xec, 0x2b, 0xac, 0xea, 0x19, 0x70, 0xf1, 0xaf, 0xf7, 0x1b, 0x2d, - 0xb1, 0x1f, 0xc2, 0xb3, 0x0d, 0x2e, 0xd0, 0xda, 0xd6, 0x0c, 0xc0, 0xc8, 0x72, 0xfe, 0x1f, 0xaf, - 0x6c, 0xfc, 0x02, 0x24, 0x14, 0x5a, 0xc5, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Check_Circle_64px = { 64, 64, NBGL_BPP_4, true, C_Check_Circle_64px_bitmap }; - -uint8_t const C_Denied_Circle_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x30, 0x02, 0x00, 0x2e, 0x02, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xad, 0x55, 0x4b, 0x2f, 0x04, 0x41, 0x10, 0x2e, 0x6b, 0xbd, 0x9f, 0x47, - 0x0e, 0xd8, 0x84, 0x48, 0x90, 0xac, 0x8d, 0x3f, 0x60, 0xe2, 0x44, 0x22, 0xe1, 0xe8, 0xb8, 0x71, - 0x73, 0xe2, 0x1f, 0x20, 0xe1, 0xec, 0x11, 0x71, 0x25, 0xfe, 0x00, 0xf1, 0x07, 0xd6, 0xc1, 0xd9, - 0xf2, 0x07, 0x3c, 0xe6, 0x4c, 0xd6, 0x63, 0xe3, 0xb9, 0xa6, 0x54, 0xf5, 0x63, 0xa6, 0xa7, 0x67, - 0x66, 0x97, 0x44, 0x1f, 0x76, 0xb6, 0xbb, 0xba, 0xaa, 0xbe, 0xfe, 0xea, 0xeb, 0x6a, 0xc4, 0xff, - 0x1b, 0x5f, 0xfb, 0x13, 0x00, 0x43, 0x0b, 0xc5, 0x04, 0xf3, 0x06, 0xa8, 0x31, 0x53, 0x8a, 0xb1, - 0x56, 0x1c, 0xf0, 0x47, 0xba, 0x58, 0xd5, 0x0c, 0x90, 0x2a, 0x58, 0x66, 0x2f, 0x64, 0x06, 0x68, - 0xb4, 0x52, 0xec, 0x08, 0xaf, 0xa5, 0x6b, 0xc4, 0xfb, 0xfd, 0x0c, 0xff, 0x1f, 0x0d, 0x99, 0xdf, - 0x78, 0xa9, 0x47, 0xf9, 0x78, 0xbb, 0x3c, 0x5b, 0x35, 0xed, 0x39, 0x5a, 0x98, 0x0d, 0xa6, 0x47, - 0x34, 0xad, 0x37, 0x32, 0xb8, 0x34, 0x1f, 0x33, 0xf7, 0xf3, 0x86, 0x6c, 0x00, 0x8e, 0x32, 0x36, - 0x85, 0xe1, 0xe6, 0x09, 0x8d, 0x3f, 0x7b, 0xa1, 0xdd, 0x07, 0x61, 0xbc, 0x1f, 0xb4, 0x34, 0xa9, - 0x27, 0x2b, 0x00, 0x7d, 0x36, 0x1f, 0x57, 0x41, 0xc8, 0x4f, 0x80, 0xba, 0x1b, 0xdb, 0xfe, 0xdd, - 0xed, 0xc7, 0x24, 0x74, 0x1d, 0x51, 0xbe, 0x2f, 0x01, 0xfa, 0xe5, 0xbf, 0x7c, 0x24, 0xbb, 0x42, - 0x90, 0x96, 0x55, 0x25, 0x36, 0xe3, 0xca, 0x49, 0xa8, 0x44, 0x99, 0x9e, 0xcd, 0xa3, 0x1a, 0x83, - 0xd6, 0xe7, 0xf8, 0x7b, 0x06, 0x70, 0x2c, 0x0f, 0x6d, 0xa9, 0x05, 0xa0, 0x9d, 0xbf, 0x8e, 0x66, - 0x62, 0x51, 0xf3, 0x3f, 0x2c, 0xbf, 0x8e, 0x00, 0xe0, 0x01, 0xb4, 0x8a, 0xe9, 0xab, 0x4e, 0xe3, - 0xc2, 0x32, 0xaa, 0xc0, 0x12, 0xe7, 0xb8, 0x3a, 0x46, 0xaa, 0xa4, 0xd8, 0x96, 0x78, 0x9f, 0x00, - 0xb6, 0x10, 0xcb, 0xfa, 0x74, 0x19, 0x85, 0x93, 0xe8, 0x90, 0x1b, 0xdf, 0x05, 0xc0, 0x47, 0x80, - 0x12, 0x1a, 0xeb, 0x9e, 0xde, 0xc7, 0x99, 0xbb, 0x38, 0x4b, 0x2a, 0xa8, 0x62, 0xd6, 0x70, 0xe7, - 0x88, 0x6d, 0x88, 0x6b, 0x3e, 0x3b, 0xc2, 0x12, 0xb8, 0x33, 0xa2, 0x16, 0xc4, 0x79, 0xfe, 0x09, - 0x02, 0x18, 0xee, 0xb8, 0xcd, 0xae, 0x8e, 0x64, 0x41, 0x07, 0x30, 0xdc, 0xa9, 0x44, 0xf5, 0x9c, - 0xa4, 0xd3, 0xd4, 0x91, 0xe1, 0x8e, 0xb7, 0x0c, 0x4d, 0x80, 0x34, 0x74, 0x68, 0x14, 0xe3, 0x91, - 0x09, 0x32, 0xed, 0x1c, 0x20, 0x70, 0xff, 0xbb, 0x3d, 0x2e, 0x7e, 0x2d, 0x7c, 0xb9, 0x40, 0x7c, - 0xf6, 0xf9, 0xce, 0xb8, 0xc0, 0xf9, 0x6a, 0xfc, 0x34, 0x28, 0x92, 0x92, 0xf8, 0x6d, 0x46, 0x3c, - 0xa9, 0x56, 0x9f, 0xf6, 0xda, 0xf5, 0x2d, 0x0b, 0x95, 0x18, 0xeb, 0xae, 0xbe, 0x9a, 0x1f, 0x42, - 0x1f, 0xa4, 0x92, 0x81, 0x78, 0x7d, 0x3d, 0x4b, 0x65, 0x29, 0x19, 0x47, 0xf5, 0x79, 0x28, 0x33, - 0x3b, 0xea, 0x1e, 0x45, 0xf4, 0x9d, 0x91, 0x06, 0x92, 0xb1, 0xd5, 0xcd, 0x4a, 0xfa, 0x5a, 0x8b, - 0xc0, 0x65, 0x2d, 0x70, 0x6b, 0xb8, 0x6a, 0xbd, 0x62, 0x37, 0x17, 0x9f, 0x1d, 0x15, 0xd7, 0x49, - 0xba, 0xdf, 0x8a, 0xd8, 0xbb, 0xa4, 0xfe, 0x90, 0xf5, 0x77, 0xc6, 0xf7, 0x97, 0xe3, 0xdf, 0xf5, - 0xa7, 0x9a, 0xfd, 0x8d, 0xaf, 0xa6, 0xd5, 0xb0, 0x57, 0x42, 0x42, 0x74, 0xed, 0x86, 0x7d, 0x1a, - 0xd2, 0x21, 0x7a, 0xb9, 0xf0, 0x86, 0x73, 0xee, 0xcf, 0x91, 0xfe, 0x3e, 0xa2, 0xf9, 0x5f, 0x8f, - 0xf4, 0x77, 0xd1, 0xb0, 0xe9, 0x7d, 0xb8, 0x40, 0x7c, 0x90, 0xef, 0x43, 0x2f, 0x46, 0x1a, 0xb6, - 0x39, 0xd2, 0xf6, 0x13, 0xf6, 0x95, 0x09, 0x99, 0x8b, 0x7f, 0x7d, 0xdf, 0x28, 0xc5, 0x9e, 0x36, - 0x4f, 0x27, 0x3c, 0xa0, 0x95, 0xcd, 0x29, 0x80, 0xc1, 0xa5, 0xc2, 0x3f, 0x3e, 0xd9, 0xf8, 0x03, - 0x70, 0xa7, 0x85, 0x84, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Denied_Circle_64px = { 64, 64, NBGL_BPP_4, true, C_Denied_Circle_64px_bitmap }; - -uint8_t const C_Important_Circle_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0xfa, 0x01, 0x00, 0xf8, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xb5, 0x55, 0xcd, 0x4e, 0xc2, 0x40, 0x10, 0x1e, 0xa1, 0xfe, 0xe3, 0xcf, - 0x51, 0x0f, 0x2a, 0x89, 0x5e, 0xd4, 0x04, 0x89, 0x2f, 0x60, 0xe3, 0x49, 0x13, 0x13, 0x3c, 0x7a, - 0xe4, 0xca, 0xcd, 0x37, 0x50, 0x13, 0x3d, 0xa3, 0xc6, 0x70, 0xd5, 0xf8, 0x02, 0x18, 0x5f, 0x00, - 0x0f, 0x9e, 0x05, 0x5f, 0xc0, 0x1f, 0xce, 0x1a, 0x10, 0x49, 0x54, 0xc0, 0x8e, 0xb3, 0xed, 0xb6, - 0x74, 0xdb, 0x59, 0xd0, 0x04, 0xe7, 0xd0, 0x76, 0xf6, 0xdb, 0xee, 0x7c, 0xfd, 0x76, 0xfa, 0x2d, - 0x62, 0xef, 0xa2, 0x99, 0x5b, 0x05, 0x58, 0xd8, 0x29, 0x6a, 0xe0, 0x43, 0x90, 0xb1, 0x59, 0x61, - 0xd0, 0x96, 0x09, 0x5e, 0x18, 0xc5, 0x8e, 0x30, 0x40, 0xa4, 0x10, 0x80, 0x2d, 0x05, 0x06, 0x18, - 0x08, 0x94, 0x38, 0xb1, 0xdf, 0xca, 0x3c, 0x20, 0xbe, 0xe4, 0xe2, 0xe2, 0x79, 0x49, 0x81, 0x3f, - 0xc4, 0xd0, 0x94, 0x7c, 0xc7, 0x3a, 0x15, 0xd9, 0x9e, 0x1f, 0x4f, 0xd2, 0xc0, 0x56, 0x3b, 0xbd, - 0xa4, 0x34, 0xea, 0xab, 0x50, 0xa6, 0x7c, 0xd9, 0x3f, 0x5f, 0x4c, 0x48, 0xb4, 0xc9, 0x51, 0xc5, - 0x41, 0x95, 0x6e, 0x9a, 0xd8, 0x78, 0xd9, 0x3b, 0xcd, 0x3e, 0x57, 0xf9, 0x7e, 0xd1, 0xd0, 0x9a, - 0x9b, 0xec, 0x02, 0xcc, 0x04, 0xf5, 0xb8, 0x6f, 0x2f, 0xd9, 0x00, 0xe8, 0x7b, 0x0c, 0xe2, 0xdf, - 0x93, 0xde, 0x9a, 0xc4, 0x6e, 0x2c, 0xac, 0x77, 0x09, 0x60, 0xd6, 0x79, 0x4a, 0x87, 0xaa, 0x4b, - 0x06, 0x86, 0xb3, 0xab, 0xa4, 0x26, 0xb7, 0x9d, 0xc4, 0xca, 0xde, 0xa6, 0x9a, 0xff, 0x53, 0x7d, - 0x41, 0xe3, 0x29, 0x71, 0xbf, 0x01, 0xc8, 0xb3, 0xdd, 0x02, 0x10, 0x13, 0x77, 0xd3, 0xa7, 0x84, - 0x12, 0xa6, 0x4d, 0xc0, 0x02, 0x18, 0xe1, 0x71, 0x5a, 0xd8, 0xe1, 0xb9, 0xc2, 0xe3, 0x6f, 0x00, - 0x59, 0xc4, 0x3a, 0xfb, 0x75, 0x22, 0x3e, 0x6d, 0x82, 0x55, 0x80, 0x0a, 0x8f, 0x53, 0xe5, 0x09, - 0x51, 0x25, 0xa2, 0xeb, 0xf7, 0x38, 0x8c, 0x22, 0xee, 0xf3, 0xea, 0x38, 0xc2, 0x0e, 0x23, 0x6e, - 0x8b, 0x0b, 0x1f, 0xc7, 0xe2, 0x55, 0xd3, 0x51, 0x81, 0x8b, 0x12, 0x44, 0x45, 0x91, 0x71, 0x3b, - 0x69, 0xf7, 0xb6, 0x20, 0x9e, 0x15, 0x43, 0x4f, 0x82, 0x9a, 0x4d, 0x92, 0xc7, 0xab, 0x42, 0xa0, - 0xff, 0xc6, 0xbb, 0xf1, 0x4b, 0x72, 0xcd, 0xe7, 0x6e, 0xa0, 0x21, 0x45, 0xd2, 0xe9, 0xd3, 0x2f, - 0x45, 0xd2, 0xe9, 0x3b, 0x84, 0x78, 0xd5, 0x69, 0x7f, 0x62, 0xdd, 0xf7, 0xb7, 0x2e, 0xc9, 0xb2, - 0x7f, 0x40, 0xca, 0xee, 0x92, 0x39, 0x1e, 0xaf, 0x39, 0x9d, 0x05, 0xba, 0x0d, 0xbc, 0x70, 0x2a, - 0x9b, 0xf2, 0x3f, 0x62, 0xe8, 0x19, 0xb2, 0x8d, 0x0b, 0x1c, 0xdc, 0x90, 0x0b, 0xd7, 0x35, 0x0d, - 0x5e, 0x96, 0xe3, 0xad, 0xa0, 0xb9, 0x78, 0xea, 0xc8, 0x75, 0x4d, 0xdd, 0xff, 0x2d, 0x85, 0x7d, - 0xd6, 0xf9, 0x43, 0xc2, 0x9b, 0xc9, 0xfb, 0x4b, 0xfe, 0x77, 0xfe, 0xd4, 0xd5, 0xdf, 0x48, 0x89, - 0xa0, 0x61, 0xd3, 0x92, 0x91, 0x8a, 0xe2, 0xaf, 0x8a, 0x61, 0x5f, 0x2b, 0xfe, 0x8a, 0x56, 0x52, - 0x9d, 0x70, 0x2b, 0xfc, 0x39, 0xe4, 0xef, 0x8b, 0xae, 0xbf, 0x1f, 0x84, 0xfc, 0xdd, 0x36, 0x6c, - 0x3a, 0x1f, 0xee, 0x10, 0x5f, 0x9d, 0xf3, 0x61, 0x1a, 0x43, 0x86, 0xed, 0x0f, 0x23, 0xd8, 0x53, - 0xcd, 0xb8, 0x02, 0x17, 0xff, 0x7a, 0xbe, 0x51, 0x89, 0x33, 0x17, 0xde, 0xd0, 0xf4, 0x73, 0xeb, - 0x68, 0x1d, 0x60, 0x3e, 0x53, 0xe8, 0xe1, 0x91, 0x8d, 0x3f, 0x0e, 0xc1, 0x39, 0xe4, 0x00, 0x08, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_Important_Circle_64px = { 64, 64, NBGL_BPP_4, true, C_Important_Circle_64px_bitmap }; - -uint8_t const C_Review_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0xd3, 0x00, 0x00, 0xd1, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xed, 0xd5, 0x3b, 0x0e, 0xc2, 0x30, 0x0c, 0x06, 0x60, 0xab, 0xea, 0x90, - 0x8d, 0x2b, 0xf4, 0x04, 0x39, 0x07, 0xc7, 0xe0, 0x28, 0x11, 0x62, 0xc8, 0x04, 0x77, 0x64, 0xea, - 0xd6, 0x95, 0xa9, 0xc1, 0x29, 0x24, 0xa6, 0xf8, 0x01, 0x43, 0x87, 0x0e, 0xf1, 0x52, 0xa1, 0xaf, - 0xb8, 0x4e, 0xa5, 0xfe, 0x4e, 0x69, 0x93, 0x9a, 0xa3, 0x50, 0x13, 0xf9, 0x1d, 0x84, 0xf2, 0xf4, - 0xf7, 0x41, 0xf2, 0xae, 0x36, 0x78, 0x00, 0x98, 0x0d, 0x14, 0xaf, 0x0d, 0xd0, 0x8f, 0x6c, 0xbc, - 0x81, 0x1a, 0xa0, 0xdf, 0xd8, 0x99, 0x70, 0x66, 0x87, 0x97, 0x11, 0x6f, 0xbd, 0x48, 0x8e, 0x43, - 0x3b, 0x1a, 0x9d, 0x7b, 0x0a, 0xd9, 0xcb, 0xc9, 0x35, 0x0f, 0xff, 0xfb, 0xf2, 0x1b, 0xe0, 0xf0, - 0xe5, 0x7d, 0x99, 0x4f, 0x71, 0x57, 0xce, 0xd7, 0xbc, 0x79, 0x73, 0xdd, 0x95, 0xef, 0x6f, 0x1f, - 0xce, 0xf2, 0xeb, 0xba, 0x76, 0x21, 0xfc, 0x6c, 0x07, 0x4f, 0x2e, 0xe6, 0x6f, 0x77, 0xaa, 0x2e, - 0xe7, 0x37, 0x90, 0xf3, 0xfc, 0x3f, 0xaf, 0x3c, 0x49, 0xe9, 0x69, 0xfa, 0xf2, 0x48, 0xcb, 0x73, - 0x03, 0xcb, 0xdf, 0xf9, 0xfd, 0xdb, 0xfb, 0x28, 0xd7, 0x6b, 0x3f, 0x04, 0xd0, 0x2b, 0xef, 0x17, - 0xcb, 0xbd, 0xfe, 0xe6, 0xea, 0x7a, 0x92, 0x57, 0xdf, 0xc7, 0x7a, 0x1b, 0xa3, 0x56, 0xd3, 0x06, - 0x8b, 0xfb, 0x09, 0xaa, 0x24, 0xa5, 0x2a, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Review_64px = { 64, 64, NBGL_BPP_4, true, C_Review_64px_bitmap }; - -uint8_t const C_SecurityShield_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x5a, 0x02, 0x00, 0x58, 0x02, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xad, 0x95, 0xbf, 0x53, 0x13, 0x41, 0x14, 0xc7, 0xbf, 0x97, 0x1c, 0xbf, - 0x14, 0xf1, 0x2a, 0x3a, 0xf0, 0x26, 0xb6, 0x8e, 0xc6, 0x86, 0x52, 0xd3, 0xd0, 0xd0, 0xc0, 0x7f, - 0x00, 0xa2, 0x85, 0x9d, 0x69, 0x1d, 0x2d, 0x62, 0xc1, 0x4c, 0xba, 0x60, 0x6d, 0x01, 0x63, 0x63, - 0xe3, 0x8c, 0xb4, 0x56, 0xde, 0x28, 0x43, 0xc3, 0x00, 0xf6, 0x16, 0x41, 0x0a, 0xad, 0x0c, 0xc2, - 0x80, 0x06, 0x48, 0x38, 0xf7, 0xed, 0xde, 0xed, 0xef, 0x8b, 0x33, 0x8e, 0xdb, 0x24, 0xbb, 0x9f, - 0xbd, 0xb7, 0xef, 0x7d, 0xdf, 0xbe, 0xb7, 0x69, 0xfa, 0x3f, 0x46, 0xef, 0xcd, 0xa3, 0x4a, 0xe5, - 0xe6, 0xec, 0xd3, 0x3d, 0x3f, 0x7e, 0x81, 0x7c, 0xcc, 0x7c, 0xf0, 0xe0, 0x4b, 0x68, 0x63, 0xce, - 0xe5, 0xa7, 0x3a, 0xc7, 0xf0, 0xa1, 0xcd, 0xd7, 0x0d, 0x8e, 0xd0, 0xf6, 0x22, 0x46, 0xf0, 0xf8, - 0x6d, 0xa7, 0xf3, 0x63, 0x7b, 0xa5, 0xea, 0xb3, 0x70, 0x0e, 0x5c, 0xc9, 0xff, 0x6f, 0xc5, 0xb4, - 0x61, 0xd4, 0xe0, 0xc7, 0xc0, 0xbc, 0x9c, 0xf4, 0x97, 0x69, 0xc3, 0x2d, 0xeb, 0x78, 0xdd, 0xe0, - 0x6b, 0xda, 0xd0, 0xd2, 0x16, 0x6a, 0x18, 0x32, 0xec, 0xd1, 0x86, 0xb2, 0xfa, 0xa2, 0x0f, 0x8c, - 0x9b, 0xfe, 0x36, 0xd8, 0x86, 0xdb, 0x72, 0xf6, 0x0b, 0xb8, 0x6f, 0xe9, 0x55, 0x03, 0x4a, 0x6d, - 0xcd, 0xbd, 0x77, 0x56, 0xc0, 0x5d, 0x66, 0x60, 0x2a, 0x9f, 0x6c, 0x20, 0x70, 0x14, 0xfd, 0x08, - 0x04, 0xb9, 0x81, 0x25, 0x0c, 0xbb, 0x19, 0x61, 0x32, 0x4c, 0x4b, 0xf5, 0xae, 0xba, 0x29, 0x39, - 0x60, 0x1e, 0x88, 0x10, 0x7a, 0xc0, 0x0d, 0x75, 0x2a, 0x72, 0xf9, 0xaa, 0xb9, 0x68, 0x67, 0xc0, - 0xa2, 0x0a, 0x4b, 0x8c, 0x16, 0x37, 0x30, 0xc2, 0x57, 0x4f, 0x80, 0x35, 0xc1, 0x55, 0x06, 0xaf, - 0x0b, 0x0f, 0x78, 0x1e, 0x8f, 0x80, 0xb6, 0x87, 0xa7, 0x09, 0x70, 0x87, 0x56, 0x3f, 0xcb, 0xf0, - 0x00, 0xf1, 0xfb, 0x93, 0xf3, 0xb3, 0xec, 0x80, 0x04, 0x21, 0xe5, 0xb8, 0xd9, 0x6c, 0x9a, 0x9c, - 0xa5, 0x85, 0x1b, 0x5e, 0xe5, 0xdb, 0x84, 0x6f, 0x06, 0xff, 0x2a, 0x22, 0xa8, 0x63, 0x8c, 0x5f, - 0x11, 0x87, 0x77, 0x45, 0xde, 0x6a, 0x24, 0x4f, 0xd7, 0xc3, 0x99, 0x70, 0x21, 0xe7, 0xe3, 0xc4, - 0x43, 0xe7, 0x7c, 0x96, 0x18, 0x8a, 0x30, 0xc6, 0x04, 0xf1, 0x51, 0xdb, 0x7f, 0xae, 0xcc, 0x93, - 0x34, 0x8d, 0x68, 0x96, 0xf3, 0xfe, 0x8e, 0xc6, 0xcf, 0xb9, 0xf2, 0xd0, 0xf9, 0x7a, 0x79, 0x47, - 0x71, 0xf6, 0xe9, 0x98, 0xc5, 0x1b, 0xe4, 0x92, 0xe4, 0x7c, 0x36, 0x80, 0xd7, 0x1d, 0x6e, 0xda, - 0x8f, 0xa9, 0x6e, 0x0c, 0xff, 0x7a, 0x96, 0x7f, 0x13, 0x7f, 0x8f, 0xaf, 0x8a, 0x6b, 0x05, 0xfa, - 0x24, 0x5c, 0x9f, 0x05, 0x3a, 0xc4, 0xab, 0x6f, 0x15, 0x25, 0x7e, 0x7d, 0x0b, 0xf2, 0x93, 0x95, - 0xf5, 0x2a, 0xbf, 0xde, 0x9e, 0xfc, 0x1e, 0x8b, 0x0b, 0xb4, 0x81, 0xb2, 0xff, 0x7e, 0xd4, 0x45, - 0x5d, 0xed, 0x17, 0xdc, 0xaf, 0x0b, 0x88, 0xba, 0x29, 0xba, 0x9f, 0x07, 0x59, 0x05, 0x9d, 0xfa, - 0xef, 0x37, 0x15, 0xc8, 0x5a, 0x56, 0x1f, 0xf3, 0x9e, 0xfa, 0x60, 0x55, 0x3f, 0x34, 0xa8, 0xbe, - 0x1a, 0xb2, 0x45, 0x44, 0x76, 0xfb, 0xc8, 0xf7, 0xb6, 0x8b, 0xeb, 0x9b, 0x2d, 0x92, 0x6c, 0x99, - 0xcc, 0x6e, 0x7f, 0x38, 0xd1, 0x5a, 0xd8, 0x91, 0x0c, 0x40, 0xb5, 0xac, 0x58, 0xeb, 0x91, 0xbf, - 0xf5, 0xf6, 0xa8, 0x22, 0x91, 0x1d, 0xb0, 0xe7, 0xf4, 0xb7, 0x4f, 0x50, 0xa7, 0xf3, 0x0a, 0x09, - 0x0d, 0xfc, 0x8d, 0xe1, 0x40, 0xeb, 0xe1, 0x49, 0xd6, 0x09, 0xb2, 0xf1, 0x3d, 0x62, 0xfc, 0x5e, - 0x51, 0x7f, 0x4e, 0x37, 0x49, 0xa1, 0x11, 0xab, 0xbf, 0x4b, 0x07, 0x2e, 0x1e, 0x10, 0x2e, 0xef, - 0x59, 0xef, 0x43, 0xe9, 0xd9, 0x2e, 0x75, 0xbd, 0xf7, 0x0f, 0xb9, 0xbe, 0x81, 0x15, 0x6f, 0xc2, - 0x57, 0x2b, 0x51, 0x26, 0x7f, 0xd0, 0xf2, 0xa8, 0xa5, 0x86, 0x83, 0xd3, 0xcb, 0x48, 0xc3, 0x93, - 0x9e, 0x37, 0xf2, 0xa5, 0xa4, 0xa5, 0xe7, 0xde, 0x07, 0xf4, 0xcb, 0xca, 0x5d, 0x82, 0x33, 0xaf, - 0x06, 0xbc, 0xc1, 0x9d, 0xc3, 0x7f, 0x79, 0xb9, 0xff, 0x00, 0xb6, 0x83, 0x9c, 0x31, 0x00, 0x08, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_SecurityShield_64px = { 64, 64, NBGL_BPP_4, true, C_SecurityShield_64px_bitmap }; - -uint8_t const C_Warning_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x5f, 0x01, 0x00, 0x5d, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x85, 0xd5, 0x31, 0x4e, 0xc3, 0x40, 0x10, 0x05, 0xd0, 0x8d, 0x85, 0x08, - 0x4a, 0x45, 0x49, 0x91, 0xc2, 0x25, 0xb2, 0x52, 0xe4, 0x08, 0x39, 0x40, 0xc4, 0x19, 0x72, 0x82, - 0x5c, 0x81, 0x84, 0x03, 0x80, 0xb8, 0x41, 0xc4, 0x05, 0x72, 0x04, 0x0a, 0xd2, 0xe7, 0x08, 0x69, - 0x02, 0xa2, 0x0b, 0xa5, 0x13, 0xa1, 0x1d, 0xec, 0x99, 0x5d, 0xb3, 0xf6, 0xee, 0x1f, 0x6f, 0xfb, - 0xc6, 0x96, 0xbc, 0xfe, 0x33, 0x43, 0x84, 0x4f, 0xb9, 0x27, 0xed, 0x5c, 0xf2, 0xeb, 0x93, 0xc2, - 0xbf, 0x53, 0x63, 0x26, 0x0a, 0xcf, 0x8c, 0x31, 0x23, 0x9d, 0xb1, 0x5b, 0x66, 0xe8, 0x76, 0x51, - 0xe1, 0x60, 0x06, 0x7d, 0x5d, 0x3f, 0xfc, 0xb8, 0x41, 0xce, 0xbc, 0x24, 0xe4, 0xcc, 0x73, 0x42, - 0xfe, 0xea, 0x18, 0xf8, 0x9b, 0xe7, 0xb4, 0xef, 0x6a, 0x96, 0x7b, 0x4b, 0x39, 0x73, 0x41, 0xc8, - 0x99, 0xef, 0x08, 0xf9, 0x31, 0xe4, 0xd8, 0xbf, 0x5a, 0x1c, 0x79, 0x79, 0x5b, 0xf1, 0x90, 0x90, - 0x33, 0x87, 0x91, 0x68, 0x3b, 0xf3, 0x55, 0x18, 0xa9, 0x96, 0x9f, 0x23, 0x6e, 0xf9, 0x25, 0x8f, - 0x38, 0x74, 0x8e, 0x4b, 0xd6, 0xc9, 0xeb, 0xbf, 0x0b, 0x6f, 0x09, 0x38, 0xf3, 0xe0, 0x85, 0x80, - 0xdb, 0x34, 0x7b, 0x97, 0xb0, 0xc5, 0xec, 0x5d, 0xc2, 0x46, 0xc8, 0x5d, 0xd8, 0x90, 0xaf, 0x9b, - 0xb8, 0x94, 0xc6, 0x9f, 0x1b, 0xfa, 0x31, 0x46, 0xdc, 0x36, 0x8c, 0x7d, 0x4e, 0xba, 0x17, 0x3d, - 0xae, 0xbd, 0x5f, 0xe2, 0xbc, 0xc4, 0x6e, 0x9f, 0xf4, 0xef, 0x93, 0xeb, 0x4b, 0x16, 0x84, 0xf7, - 0x9b, 0x2a, 0x68, 0xfe, 0x4f, 0x5d, 0x90, 0x3d, 0x43, 0x77, 0x05, 0x5b, 0xe8, 0x7d, 0xf9, 0x70, - 0xf1, 0xeb, 0x16, 0x44, 0xf9, 0xcc, 0xde, 0xa1, 0xbb, 0x00, 0x1f, 0xa0, 0xd3, 0x39, 0xef, 0xb4, - 0x4f, 0xb7, 0xbf, 0xbe, 0xf5, 0xfe, 0x72, 0xed, 0x1b, 0x14, 0xa4, 0xfb, 0x7b, 0x78, 0x82, 0x2e, - 0x05, 0xf7, 0xd8, 0xe9, 0x33, 0x18, 0x3f, 0xc9, 0xf9, 0xf4, 0xa1, 0xcf, 0x27, 0x97, 0x97, 0x02, - 0xbb, 0x14, 0x4c, 0xb0, 0x4b, 0xc1, 0x03, 0x76, 0xf2, 0x89, 0x43, 0x6e, 0x57, 0xfa, 0x7c, 0xf7, - 0x89, 0xdb, 0xe8, 0xfb, 0xc5, 0x4c, 0x95, 0xfd, 0xb4, 0x50, 0xf7, 0x93, 0x5f, 0x60, 0x23, 0x65, - 0x3f, 0xe6, 0xba, 0x73, 0xa0, 0xc6, 0x3d, 0xfb, 0x99, 0xf4, 0x05, 0x5e, 0xcd, 0xcb, 0x3f, 0xe4, - 0x2a, 0x7b, 0x24, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Warning_64px = { 64, 64, NBGL_BPP_4, true, C_Warning_64px_bitmap }; - -uint8_t const C_left_half_64px_bitmap[] = { - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, - 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, - 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, - 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_left_half_64px = { 24, 64, NBGL_BPP_1, false, C_left_half_64px_bitmap }; - -uint8_t const C_Back_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x8c, 0x00, 0x00, 0x8a, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xed, 0xd3, 0xcd, 0x09, 0xc0, 0x20, 0x0c, 0x80, 0xd1, 0xd0, 0x53, 0x0e, - 0x1d, 0xa2, 0xa3, 0x39, 0x4a, 0x36, 0x70, 0x95, 0x6e, 0xd2, 0x6d, 0xc4, 0x43, 0xc1, 0xe6, 0xc7, - 0xd6, 0xa8, 0xd0, 0x73, 0x0f, 0xf5, 0x10, 0xe1, 0xe3, 0x81, 0x10, 0xb0, 0x94, 0x97, 0x43, 0xf8, - 0xb7, 0xef, 0xb6, 0xc3, 0xb7, 0x53, 0x67, 0x46, 0xdf, 0x28, 0xca, 0xdc, 0x21, 0xb6, 0x96, 0x61, - 0x95, 0x2b, 0x01, 0xb6, 0x46, 0x06, 0x4a, 0xd0, 0x5b, 0x5b, 0x86, 0xfa, 0x92, 0x41, 0x6d, 0x37, - 0xab, 0x50, 0xda, 0xc3, 0x2a, 0x94, 0xd6, 0x98, 0x41, 0x6e, 0x8e, 0x19, 0xe4, 0xe6, 0x99, 0x42, - 0xc2, 0x8e, 0x29, 0x24, 0xec, 0x99, 0xc0, 0x6d, 0x81, 0x61, 0x33, 0x09, 0xf8, 0xc4, 0x61, 0x55, - 0x01, 0x60, 0x5a, 0x60, 0x9a, 0x19, 0x43, 0x7c, 0xfb, 0x01, 0xe5, 0x02, 0xe6, 0x04, 0x3a, 0xe4, - 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Back_40px = { 40, 40, NBGL_BPP_4, true, C_Back_40px_bitmap }; - -uint8_t const C_Check_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x01, 0x54, 0x00, 0x00, 0x52, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0xc0, 0x05, 0x78, 0x40, 0x84, 0x1c, 0x88, 0x90, 0x07, 0x13, - 0x0d, 0x40, 0x82, 0xff, 0x00, 0x90, 0x60, 0x7f, 0x00, 0x24, 0x98, 0x3f, 0x00, 0x09, 0xc6, 0x1f, - 0x20, 0x99, 0x3f, 0x20, 0xa2, 0x0e, 0x44, 0xd8, 0xe3, 0x57, 0x08, 0x26, 0x2a, 0x60, 0x2c, 0xb0, - 0x18, 0x58, 0x16, 0xac, 0x0e, 0xac, 0x03, 0xac, 0xd7, 0x1e, 0x6e, 0x5e, 0x0d, 0x5c, 0x83, 0x01, - 0x03, 0x01, 0x00, 0x00, 0x63, 0x83, 0xdc, 0x77, 0xc8, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Check_40px = { 40, 40, NBGL_BPP_1, true, C_Check_40px_bitmap }; - -uint8_t const C_Check_Circle_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x4b, 0x01, 0x00, 0x49, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x75, 0x53, 0x3b, 0x52, 0xc3, 0x30, 0x10, 0x7d, 0x16, 0x0d, 0x50, 0x04, - 0x57, 0x0c, 0x34, 0x58, 0x4d, 0x66, 0x20, 0x05, 0xd0, 0xd0, 0x86, 0x3b, 0xc0, 0x01, 0x18, 0x4e, - 0xc0, 0x15, 0x0c, 0x17, 0xe0, 0x53, 0xc3, 0x84, 0x49, 0xcf, 0xe4, 0x08, 0xa9, 0xa9, 0xa8, 0xa1, - 0x61, 0x12, 0x0e, 0x00, 0xe6, 0x37, 0xb6, 0x83, 0xb3, 0x48, 0x96, 0x56, 0x96, 0x32, 0xe3, 0x2d, - 0xa4, 0x9d, 0xe7, 0xb7, 0xbb, 0x4f, 0xbb, 0x6b, 0xa2, 0x56, 0x7b, 0x3c, 0x8a, 0xa3, 0x83, 0xbb, - 0x00, 0xba, 0x40, 0x6d, 0xbd, 0xf7, 0x06, 0x3a, 0x87, 0xb5, 0x6d, 0x07, 0xbd, 0x01, 0xeb, 0x0f, - 0x44, 0x2f, 0xa7, 0xc0, 0xae, 0x85, 0xca, 0x18, 0x3b, 0xc6, 0x1b, 0x22, 0x1a, 0x1b, 0xef, 0x1e, - 0x9b, 0x1c, 0x71, 0x8d, 0xd5, 0xfa, 0x9e, 0x41, 0xb8, 0xd4, 0x73, 0x89, 0x91, 0xbe, 0x27, 0xe8, - 0x93, 0x97, 0x7a, 0x4b, 0x5f, 0x52, 0x78, 0x0a, 0xe6, 0x72, 0x49, 0x9d, 0x39, 0x3a, 0xfa, 0xbc, - 0xb4, 0xe0, 0x04, 0xca, 0x9b, 0x62, 0xa0, 0xdc, 0x74, 0xd9, 0x62, 0x05, 0x12, 0x55, 0x55, 0x68, - 0x37, 0x05, 0x13, 0xa5, 0xfa, 0x2a, 0xeb, 0xea, 0x39, 0x98, 0x78, 0x25, 0xa8, 0xd2, 0x5c, 0x9f, - 0x98, 0xe1, 0xa9, 0xc0, 0x19, 0x05, 0xc4, 0x5f, 0x0c, 0x7e, 0x8c, 0xc8, 0x86, 0x58, 0xe2, 0xe4, - 0x0b, 0xaf, 0x14, 0x10, 0x2b, 0xec, 0x65, 0x60, 0xb9, 0x4c, 0x44, 0xf2, 0xe1, 0x30, 0x26, 0x62, - 0xad, 0xc1, 0x14, 0x71, 0x64, 0xb0, 0x26, 0x96, 0xbe, 0x4d, 0x30, 0x92, 0x4f, 0xae, 0xc1, 0xbc, - 0x0a, 0x87, 0x4e, 0x0b, 0xe7, 0x53, 0x5a, 0x58, 0xb3, 0xab, 0xab, 0x34, 0xff, 0xd9, 0xb7, 0xb9, - 0xb2, 0x99, 0x4a, 0x26, 0x57, 0x42, 0x79, 0xba, 0x4f, 0xa9, 0xb0, 0x98, 0x7d, 0xaf, 0xee, 0x53, - 0x56, 0xf7, 0xd4, 0x75, 0xba, 0xd0, 0x23, 0xce, 0xcd, 0x54, 0xc8, 0xef, 0x3d, 0xed, 0x87, 0x33, - 0x12, 0x6d, 0xb3, 0x2c, 0xc3, 0x99, 0x8f, 0xdb, 0x76, 0x83, 0x66, 0x31, 0x7a, 0xc6, 0xbb, 0x41, - 0xc4, 0x2f, 0x9d, 0x36, 0xbb, 0xd6, 0x5f, 0x5c, 0x53, 0x60, 0xc3, 0x53, 0x30, 0x5c, 0x5c, 0x53, - 0x6d, 0xcf, 0xc7, 0x71, 0xd4, 0xbd, 0x6d, 0xff, 0x07, 0xe8, 0x1f, 0xf5, 0xf4, 0xf5, 0xf3, 0x20, - 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Check_Circle_40px = { 40, 40, NBGL_BPP_4, true, C_Check_Circle_40px_bitmap }; - -uint8_t const C_Chevron_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x22, 0x5c, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xda, 0x1c, 0xe4, 0x03, 0x10, 0x03, 0xe2, 0x03, 0x30, 0x03, 0xe0, 0x03, 0x50, 0x03, 0xde, 0x03, - 0x20, 0x18, 0x20, 0x03, 0xdc, 0x03, 0x20, 0x08, 0xc1, 0x08, 0x20, 0x03, 0xda, 0x03, 0x20, 0x08, - 0xc3, 0x08, 0x20, 0x03, 0xd8, 0x03, 0x20, 0x08, 0xc5, 0x08, 0x20, 0x03, 0xd6, 0x03, 0x20, 0x08, - 0xc7, 0x08, 0x20, 0x03, 0xd4, 0x05, 0x20, 0x08, 0xc9, 0x08, 0x20, 0x05, 0xd3, 0x9e, 0x20, 0x80, - 0xcb, 0x98, 0x02, 0xe0, 0xd4, 0x0e, 0x09, 0xcd, 0x09, 0x0e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xe2, -}; -const nbgl_icon_details_t C_Chevron_40px = { 40, 40, NBGL_BPP_4, true, C_Chevron_40px_bitmap }; - -uint8_t const C_Chevron_Back_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x76, 0x00, 0x00, 0x74, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xed, 0xd2, 0xc1, 0x0d, 0x80, 0x30, 0x08, 0x05, 0x50, 0x8e, 0x3d, 0x38, - 0xa4, 0xa3, 0xb0, 0x41, 0x57, 0x71, 0x93, 0x6e, 0x63, 0x38, 0x98, 0xd4, 0x42, 0x10, 0x7e, 0xeb, - 0x06, 0x46, 0x0e, 0x34, 0xe5, 0xbf, 0x84, 0x0b, 0xbd, 0xff, 0x35, 0xaa, 0xe1, 0xe7, 0xb2, 0x2e, - 0x05, 0x67, 0x5c, 0xb5, 0x1f, 0x54, 0x73, 0x24, 0xb4, 0xe9, 0x73, 0x12, 0x40, 0x76, 0xb0, 0x27, - 0x94, 0x27, 0x07, 0xc8, 0x11, 0x07, 0x94, 0x4c, 0x03, 0x32, 0xac, 0x73, 0x28, 0xb8, 0xcd, 0x21, - 0x32, 0x87, 0x13, 0x73, 0x38, 0x33, 0x83, 0x0b, 0x33, 0xb8, 0x32, 0x85, 0x2b, 0x53, 0xf8, 0x62, - 0x03, 0x96, 0xcf, 0x1d, 0xc6, 0x0d, 0xf2, 0x8e, 0x43, 0x73, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Chevron_Back_40px = { 40, 40, NBGL_BPP_4, true, C_Chevron_Back_40px_bitmap }; - -uint8_t const C_Chevron_Next_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x71, 0x00, 0x00, 0x6f, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xed, 0xce, 0xbb, 0x0d, 0x80, 0x30, 0x0c, 0x45, 0x51, 0x57, 0x51, 0x0a, - 0x86, 0xcc, 0x06, 0xac, 0x90, 0x0d, 0x18, 0x09, 0xa6, 0x42, 0x48, 0x14, 0x8f, 0xc4, 0x44, 0x8e, - 0x3f, 0x1b, 0x20, 0x6e, 0xf9, 0x74, 0x64, 0x19, 0xf8, 0x58, 0x35, 0x87, 0xe9, 0x22, 0xda, 0x02, - 0x23, 0xca, 0x81, 0xa5, 0xe2, 0x61, 0xa5, 0xf5, 0x74, 0xb0, 0x31, 0xc0, 0xc1, 0xc6, 0x00, 0x0b, - 0x99, 0x39, 0xc8, 0xcc, 0xc2, 0xc1, 0x0c, 0x1c, 0x4c, 0x43, 0x61, 0x0a, 0x0a, 0x9b, 0x50, 0x31, - 0x81, 0xc7, 0x64, 0x1d, 0x2e, 0xec, 0x92, 0xfe, 0xbe, 0xbc, 0x07, 0x77, 0xbd, 0xdd, 0xf8, 0xeb, - 0x3d, 0x38, 0x09, 0xbe, 0x9b, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Chevron_Next_40px = { 40, 40, NBGL_BPP_4, true, C_Chevron_Next_40px_bitmap }; - -uint8_t const C_Close_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x85, 0x00, 0x00, 0x83, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x7f, 0xc0, 0xc0, 0xbf, 0xf9, 0x08, 0xf6, 0xcf, 0xf7, 0x10, - 0xfa, 0x11, 0x07, 0x42, 0xac, 0x41, 0x0f, 0x42, 0x4f, 0x60, 0xe8, 0x87, 0x09, 0xfd, 0x60, 0xe0, - 0x84, 0x31, 0xe0, 0x0a, 0x1b, 0xe0, 0xd2, 0x70, 0x16, 0x92, 0x2c, 0x9c, 0x89, 0x50, 0x06, 0x67, - 0x23, 0x29, 0x83, 0x73, 0x90, 0x95, 0x41, 0x79, 0x28, 0xca, 0xa0, 0x5c, 0x54, 0x65, 0x60, 0x3e, - 0x9a, 0x32, 0xb0, 0x42, 0x74, 0x65, 0x20, 0x85, 0xe8, 0xca, 0x40, 0x0a, 0x31, 0x94, 0x61, 0x15, - 0xc3, 0xa2, 0x17, 0x9b, 0x1d, 0x58, 0xdc, 0x82, 0xcd, 0xcd, 0x58, 0xfc, 0x86, 0x2d, 0x0c, 0xb0, - 0x84, 0x15, 0xb6, 0x30, 0xc5, 0x12, 0xf6, 0xd8, 0xe2, 0x08, 0x5b, 0x5c, 0x62, 0x8b, 0x73, 0x6c, - 0x69, 0x63, 0x40, 0x00, 0x00, 0xb4, 0x0b, 0xb4, 0x14, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Close_40px = { 40, 40, NBGL_BPP_4, true, C_Close_40px_bitmap }; - -uint8_t const C_Denied_Circle_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x3e, 0x01, 0x00, 0x3c, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x75, 0x53, 0x3b, 0x4e, 0x03, 0x31, 0x10, 0x7d, 0x6b, 0x9a, 0x90, 0x02, - 0xb6, 0x42, 0xd0, 0x24, 0x6e, 0x90, 0x20, 0x45, 0xa0, 0xa1, 0x0d, 0x77, 0x80, 0x03, 0x20, 0x4e, - 0xc0, 0x15, 0x16, 0x2e, 0x10, 0xa0, 0x06, 0x05, 0xa5, 0x47, 0x39, 0x42, 0x6a, 0x2a, 0x6a, 0x68, - 0xa2, 0x84, 0x03, 0x40, 0x40, 0xa0, 0xcd, 0x06, 0xf2, 0xf0, 0xac, 0x77, 0x13, 0xef, 0x6f, 0xa4, - 0xb5, 0xc7, 0xcf, 0xcf, 0x33, 0x6f, 0xc7, 0x63, 0xb2, 0xd2, 0x9e, 0x4e, 0x7c, 0xef, 0xe8, 0x3e, - 0x03, 0x5d, 0x21, 0xb6, 0xd6, 0xfb, 0x0a, 0xba, 0x44, 0x62, 0x7b, 0x4b, 0xe8, 0x0d, 0xd8, 0x7a, - 0x24, 0x5f, 0xcf, 0x81, 0x76, 0x02, 0x45, 0x3e, 0xf6, 0xad, 0xd7, 0x87, 0x37, 0xb4, 0xde, 0x03, - 0x76, 0xd2, 0x13, 0x37, 0xa8, 0xc7, 0xf3, 0x1c, 0x6a, 0x19, 0x7a, 0xa1, 0x31, 0x90, 0x79, 0x8c, - 0x0e, 0x9d, 0xd0, 0x0d, 0x99, 0xb4, 0x72, 0x14, 0x2c, 0xf4, 0x9a, 0x19, 0x43, 0x6c, 0xb8, 0x4a, - 0xc7, 0xe8, 0x92, 0x13, 0xf4, 0x5c, 0x6c, 0x86, 0xa6, 0xc9, 0xaa, 0x84, 0xdc, 0x65, 0x3a, 0xea, - 0x9a, 0xf9, 0x24, 0x7b, 0x50, 0x63, 0x3a, 0x5e, 0x2b, 0xfe, 0x09, 0x97, 0x81, 0x44, 0x09, 0x21, - 0xd8, 0x14, 0xcf, 0x33, 0x5c, 0x30, 0x59, 0xc6, 0x1b, 0xfc, 0x41, 0xef, 0xdb, 0x8a, 0x34, 0x6b, - 0x4b, 0x63, 0x84, 0xb3, 0x2f, 0x8c, 0x68, 0x89, 0x96, 0x66, 0x82, 0x1d, 0x4c, 0x61, 0x35, 0x04, - 0xb0, 0x34, 0x12, 0xcd, 0x8f, 0x04, 0x0b, 0x61, 0x69, 0x06, 0xdb, 0x2c, 0xc3, 0xca, 0xce, 0x7e, - 0x16, 0x73, 0x1c, 0x97, 0x69, 0x29, 0xd3, 0xfc, 0x5b, 0xfc, 0xb7, 0x11, 0xf5, 0x7a, 0xb6, 0x06, - 0x52, 0xa7, 0x20, 0x5f, 0xab, 0xba, 0x70, 0x73, 0x35, 0x6d, 0x4b, 0x94, 0x46, 0xa1, 0xf6, 0x3c, - 0xcc, 0xde, 0x91, 0xaa, 0xba, 0xcb, 0x28, 0x7b, 0xe7, 0xc3, 0xaa, 0xde, 0xe0, 0xdc, 0x47, 0xcb, - 0x7a, 0xb7, 0xf0, 0x06, 0xc9, 0xee, 0x64, 0xd5, 0x6b, 0x9d, 0x7c, 0x9b, 0x02, 0xdb, 0x8e, 0x82, - 0x7e, 0xbe, 0x4d, 0xc5, 0x5e, 0x4e, 0x7d, 0x6f, 0xf7, 0xae, 0xfa, 0x0d, 0xf0, 0x1f, 0x93, 0x8f, - 0x11, 0x3f, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Denied_Circle_40px = { 40, 40, NBGL_BPP_4, true, C_Denied_Circle_40px_bitmap }; - -uint8_t const C_Erase_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x01, 0x70, 0x00, 0x00, 0x6e, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0x80, 0x03, 0xfb, 0xff, 0x7f, 0x18, 0x18, 0xea, 0xff, 0xff, - 0xc3, 0x43, 0xd4, 0xfd, 0xaf, 0x63, 0x60, 0xa8, 0xa9, 0xb3, 0x03, 0xb2, 0x6c, 0x80, 0xac, 0x7a, - 0x09, 0x90, 0x44, 0x23, 0x88, 0x38, 0x0c, 0x27, 0xc0, 0x5c, 0x90, 0x04, 0x58, 0x09, 0x44, 0x31, - 0x48, 0x1b, 0x7e, 0x93, 0xc1, 0x04, 0xd8, 0x05, 0xf2, 0xff, 0x7f, 0x30, 0x30, 0xf0, 0xff, 0xff, - 0xc0, 0xc0, 0xc0, 0xfe, 0xff, 0x01, 0x03, 0x03, 0xf3, 0xff, 0x03, 0x0c, 0x0c, 0x8c, 0xff, 0x1b, - 0x80, 0x0e, 0xfc, 0x0f, 0x72, 0x65, 0x1d, 0x88, 0xb0, 0x01, 0x11, 0x12, 0x0c, 0x48, 0x00, 0x00, - 0xd0, 0xf4, 0xce, 0x34, 0xc8, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Erase_40px = { 40, 40, NBGL_BPP_1, true, C_Erase_40px_bitmap }; - -uint8_t const C_Info_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x31, 0x00, 0x00, 0x2f, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x7f, 0x14, 0xd0, 0x0b, 0x30, 0xf0, 0xff, 0x67, 0x80, 0x01, - 0x7e, 0x2a, 0x89, 0x71, 0x60, 0x5a, 0xd3, 0x80, 0x45, 0xec, 0x57, 0xcf, 0x68, 0xf0, 0x93, 0x05, - 0x00, 0xd9, 0x9e, 0xc9, 0x19, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Info_40px = { 40, 40, NBGL_BPP_4, true, C_Info_40px_bitmap }; - -uint8_t const C_Maj_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x01, 0x51, 0x00, 0x00, 0x4f, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0x20, 0x09, 0x58, 0x80, 0x88, 0x0a, 0x10, 0xf1, 0x03, 0x88, - 0x19, 0x41, 0x04, 0x33, 0x88, 0x60, 0x07, 0x11, 0xfc, 0xff, 0xff, 0x33, 0x30, 0xc8, 0xff, 0xff, - 0xdf, 0xc0, 0x60, 0x0f, 0x22, 0xea, 0x41, 0xc4, 0x7f, 0x38, 0x51, 0x0f, 0x97, 0x00, 0x2b, 0x01, - 0x2b, 0x66, 0x87, 0x1b, 0x00, 0x36, 0x0a, 0x6c, 0x28, 0xc4, 0x78, 0x0b, 0xd2, 0xdc, 0xc5, 0x00, - 0x00, 0x96, 0xe8, 0xea, 0xc6, 0xc8, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Maj_40px = { 40, 40, NBGL_BPP_1, true, C_Maj_40px_bitmap }; - -uint8_t const C_Maj_Lock_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x01, 0x4d, 0x00, 0x00, 0x4b, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0x20, 0x09, 0x3c, 0x00, 0x62, 0x46, 0x10, 0xc1, 0x0c, 0x22, - 0xd8, 0x41, 0x04, 0x3f, 0x88, 0x90, 0x07, 0x11, 0xf6, 0xff, 0x7f, 0x3c, 0x60, 0xa8, 0x07, 0x11, - 0xff, 0x81, 0x04, 0x23, 0x88, 0x60, 0x86, 0x13, 0x60, 0x2e, 0x58, 0x02, 0xa2, 0x04, 0xac, 0x58, - 0x1e, 0x6e, 0x00, 0x3b, 0xdc, 0x50, 0xb0, 0xf1, 0x60, 0x8b, 0x48, 0x01, 0x00, 0xac, 0x36, 0x99, - 0x6b, 0xc8, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Maj_Lock_40px = { 40, 40, NBGL_BPP_1, true, C_Maj_Lock_40px_bitmap }; - -uint8_t const C_Mini_Push_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0xce, 0x00, 0x00, 0xcc, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x6d, 0x93, 0xcd, 0x0d, 0xc2, 0x30, 0x0c, 0x46, 0x23, 0x21, 0xa4, 0x4e, - 0x83, 0xba, 0x01, 0x2b, 0x30, 0x52, 0x37, 0x60, 0x04, 0x46, 0x62, 0x07, 0x06, 0xb0, 0x0f, 0x5c, - 0x40, 0x42, 0x36, 0x49, 0x9c, 0x2f, 0xbf, 0xf6, 0xa5, 0xc9, 0xd3, 0xb3, 0x13, 0x39, 0xae, 0xaa, - 0x85, 0x10, 0xb1, 0x0e, 0x11, 0x49, 0x0a, 0x1e, 0x10, 0x77, 0x9f, 0x82, 0xb0, 0x6a, 0x90, 0x5a, - 0x06, 0x96, 0xc2, 0x3a, 0xa7, 0x08, 0xf5, 0xa7, 0xd1, 0xa2, 0x61, 0x47, 0xe3, 0xb5, 0x68, 0xd1, - 0x6c, 0x2f, 0x3a, 0x05, 0x2f, 0xa9, 0x19, 0xf0, 0xcc, 0xa4, 0x95, 0xfb, 0x3d, 0x6b, 0xc1, 0xca, - 0xf6, 0x53, 0x63, 0x65, 0xf5, 0x0e, 0xe1, 0x8a, 0x43, 0xc0, 0xf6, 0x10, 0x20, 0x32, 0x41, 0xdb, - 0x0e, 0x88, 0x44, 0xd0, 0xee, 0x1f, 0x88, 0x85, 0x45, 0x4d, 0x15, 0x62, 0x61, 0x51, 0x53, 0x85, - 0x68, 0x2c, 0x6b, 0x55, 0x34, 0x76, 0x4b, 0x5a, 0x12, 0xcf, 0x99, 0xe5, 0xbb, 0xbc, 0x36, 0xab, - 0x7e, 0x5c, 0xda, 0xfd, 0xe4, 0x61, 0xec, 0xcb, 0xc6, 0xd6, 0x1e, 0xb8, 0xcc, 0xeb, 0x95, 0xdb, - 0x53, 0xaf, 0xf7, 0xde, 0x1b, 0x79, 0x6f, 0xe9, 0xbe, 0xf9, 0x28, 0x96, 0xc9, 0xea, 0x47, 0xb1, - 0x26, 0x39, 0xb3, 0xe6, 0xce, 0xa4, 0x37, 0xbb, 0xee, 0x8c, 0x4f, 0xff, 0xc2, 0x1f, 0x64, 0x87, - 0x98, 0x9d, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Mini_Push_40px = { 40, 40, NBGL_BPP_4, true, C_Mini_Push_40px_bitmap }; - -uint8_t const C_Next_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x86, 0x00, 0x00, 0x84, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xed, 0xd0, 0x31, 0x0e, 0x80, 0x30, 0x08, 0x40, 0x51, 0x5c, 0x1a, 0x06, - 0x07, 0x8f, 0xe8, 0x0d, 0xbc, 0x02, 0x37, 0xf0, 0x48, 0x7a, 0xaa, 0xa6, 0x89, 0x43, 0x2d, 0x50, - 0x95, 0x4a, 0xa2, 0xab, 0x83, 0x8c, 0x3f, 0x2f, 0x0d, 0x25, 0xe7, 0x87, 0x21, 0x74, 0x29, 0x01, - 0xcc, 0x8e, 0x01, 0xa0, 0x67, 0x0e, 0x12, 0x0c, 0xdd, 0x0d, 0x26, 0x08, 0x84, 0x63, 0x0b, 0x09, - 0x26, 0xc2, 0xd8, 0xc0, 0xc2, 0x78, 0x97, 0x06, 0x16, 0xc6, 0xcd, 0x42, 0x66, 0xb2, 0xb3, 0x81, - 0xcc, 0xa4, 0x5d, 0x50, 0x98, 0xfe, 0xed, 0x84, 0xc2, 0xb4, 0x1d, 0x50, 0x59, 0xbd, 0x41, 0x85, - 0xab, 0xb0, 0xda, 0x22, 0xf4, 0xe2, 0x82, 0xbd, 0xd5, 0xa8, 0x0f, 0x2e, 0xb6, 0x6d, 0x2f, 0x37, - 0xfd, 0xdb, 0xc7, 0x9a, 0x99, 0x1d, 0xa6, 0xf9, 0xc2, 0x38, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Next_40px = { 40, 40, NBGL_BPP_4, true, C_Next_40px_bitmap }; - -uint8_t const C_Plus_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x36, 0x00, 0x00, 0x34, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x9f, 0x46, 0xa0, 0x81, 0x63, 0x54, 0x0c, 0x45, 0xac, 0x03, - 0x02, 0x1c, 0x58, 0xa0, 0x0c, 0x90, 0x18, 0x03, 0x1a, 0xc0, 0x25, 0x86, 0x4d, 0xef, 0x68, 0x98, - 0xe2, 0x15, 0xa3, 0x12, 0x00, 0x00, 0x63, 0x2f, 0x8b, 0x12, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Plus_40px = { 40, 40, NBGL_BPP_4, true, C_Plus_40px_bitmap }; - -uint8_t const C_QRCode_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x99, 0x00, 0x00, 0x97, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x9f, 0xda, 0xe0, 0x11, 0x03, 0x08, 0x30, 0xbd, 0xff, 0x00, - 0xa2, 0xfe, 0x7f, 0x60, 0x00, 0x89, 0x29, 0x80, 0xc5, 0x18, 0xf4, 0x91, 0xc5, 0x20, 0x42, 0x0c, - 0xfc, 0x28, 0x62, 0xfc, 0x30, 0x12, 0xc2, 0xc2, 0x2d, 0xf6, 0xa7, 0xa3, 0x07, 0x43, 0xec, 0x07, - 0x03, 0x07, 0x84, 0xff, 0x01, 0x61, 0x1e, 0xb1, 0x62, 0x10, 0xf3, 0xc0, 0x3c, 0x90, 0x73, 0x90, - 0xec, 0x25, 0x28, 0x86, 0xf0, 0x07, 0x3f, 0xcc, 0x39, 0x48, 0xfe, 0x85, 0x8b, 0x21, 0x85, 0x0b, - 0x3f, 0x92, 0xb3, 0x49, 0x0a, 0xd3, 0x7f, 0x10, 0x83, 0xf5, 0x90, 0xed, 0xf8, 0x04, 0xa1, 0x99, - 0x30, 0xc2, 0x14, 0x9b, 0x9b, 0xd1, 0xc2, 0x19, 0x55, 0x0c, 0x1e, 0x06, 0x27, 0x3a, 0xce, 0xa3, - 0x86, 0x15, 0x90, 0xd7, 0xc0, 0xd0, 0x4f, 0xaa, 0x18, 0x36, 0xf3, 0x88, 0x74, 0x0b, 0x16, 0x7f, - 0x60, 0xf3, 0x2f, 0xb6, 0x70, 0xa1, 0x2e, 0x00, 0x00, 0x5b, 0xb2, 0x1e, 0xfb, 0x20, 0x03, 0x00, - 0x00, -}; -const nbgl_icon_details_t C_QRCode_40px = { 40, 40, NBGL_BPP_4, true, C_QRCode_40px_bitmap }; - -uint8_t const C_Settings_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0x93, 0x01, 0x00, 0x91, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x75, 0x52, 0xb1, 0x52, 0xc2, 0x40, 0x10, 0x7d, 0xc9, 0x88, 0x41, 0x98, - 0x91, 0x8c, 0x56, 0x8e, 0xce, 0x10, 0x87, 0x5e, 0x46, 0x3e, 0x40, 0xec, 0xb0, 0x93, 0x8e, 0x4e, - 0xfd, 0x03, 0x53, 0x40, 0x0d, 0x85, 0x95, 0x16, 0x62, 0x9d, 0x42, 0x4a, 0x3b, 0xb0, 0x93, 0x8a, - 0xf1, 0x0b, 0xfc, 0x04, 0x1c, 0x1c, 0xeb, 0x40, 0x02, 0xa2, 0x20, 0x39, 0x77, 0x2f, 0x38, 0x17, - 0x18, 0xd8, 0x62, 0x6f, 0xef, 0xe5, 0xf2, 0xee, 0xed, 0xbb, 0x15, 0x62, 0x7d, 0x8c, 0x4d, 0xad, - 0xba, 0x8c, 0xd5, 0x81, 0xad, 0x25, 0x28, 0x80, 0x61, 0x6b, 0xdd, 0x45, 0xac, 0x87, 0xac, 0x8f, - 0xac, 0xda, 0x4f, 0x76, 0x0b, 0x4e, 0x51, 0x77, 0x03, 0x33, 0xd6, 0xae, 0x1c, 0x76, 0x42, 0xac, - 0x01, 0x8a, 0x84, 0x10, 0xad, 0xf9, 0x4a, 0x31, 0xe5, 0x12, 0xf7, 0x74, 0xb5, 0x2c, 0x9a, 0x8c, - 0x0d, 0x30, 0x6b, 0x97, 0x73, 0x5c, 0xe5, 0x4a, 0x8e, 0x8b, 0x34, 0x57, 0x1e, 0x5c, 0xc5, 0x3d, - 0x43, 0x9e, 0x97, 0x11, 0x3a, 0x0a, 0x9b, 0xe2, 0x5c, 0x76, 0x80, 0x47, 0x85, 0xfd, 0xa0, 0x1a, - 0x59, 0x9e, 0xee, 0x5c, 0x75, 0x60, 0x8a, 0x4b, 0xca, 0x57, 0xc0, 0x26, 0x81, 0xc3, 0x90, 0x68, - 0xc4, 0xfa, 0x7b, 0x2c, 0xe3, 0x48, 0x08, 0x1f, 0x17, 0x7c, 0x93, 0x45, 0x57, 0x05, 0x16, 0x0a, - 0x37, 0xd0, 0x59, 0x84, 0x4e, 0xa7, 0x1f, 0x60, 0x08, 0xf1, 0x85, 0x03, 0x21, 0x9e, 0x71, 0x2d, - 0x44, 0x8d, 0xec, 0x19, 0x43, 0x23, 0x86, 0x77, 0xa6, 0xf9, 0x45, 0x8a, 0x9a, 0xb7, 0x50, 0x1d, - 0xe0, 0x84, 0x08, 0x5a, 0x1b, 0xcc, 0x7c, 0x9a, 0x90, 0x0e, 0xa5, 0xfb, 0x06, 0xef, 0x6a, 0x71, - 0xce, 0x76, 0x98, 0x53, 0x73, 0x2c, 0xfa, 0x25, 0x35, 0x60, 0x05, 0xa2, 0x11, 0xfe, 0x9b, 0xa4, - 0xf4, 0x81, 0xf4, 0x18, 0x3a, 0xb9, 0xd3, 0xc7, 0x1b, 0x8b, 0xdf, 0xa6, 0x64, 0x52, 0x5b, 0x75, - 0xc4, 0x59, 0xcb, 0xbe, 0x10, 0xaf, 0xac, 0xc5, 0xc6, 0x9e, 0x60, 0xb9, 0xd4, 0x87, 0x85, 0xb3, - 0x32, 0xcb, 0xf5, 0xa1, 0xf3, 0x4b, 0x7d, 0xb2, 0x65, 0xff, 0xbd, 0x79, 0xb2, 0xf9, 0xd0, 0xb2, - 0x80, 0x3d, 0x50, 0x66, 0x86, 0x5e, 0x05, 0x2f, 0xb7, 0x11, 0x33, 0x57, 0x79, 0x3a, 0x5c, 0xf4, - 0x5e, 0xf2, 0xf9, 0xe8, 0x46, 0x67, 0x24, 0x1b, 0xbe, 0x65, 0xd0, 0xae, 0x64, 0xb8, 0xca, 0x14, - 0x9c, 0x6e, 0xf8, 0x96, 0x13, 0xf9, 0xd4, 0x44, 0xf3, 0x2d, 0x8b, 0x8e, 0x9a, 0x8d, 0xa4, 0x9a, - 0x11, 0xc9, 0xbb, 0x53, 0x72, 0x8a, 0x9a, 0x1b, 0x58, 0xb1, 0x76, 0xf9, 0xb8, 0xa9, 0xb8, 0x3d, - 0xe4, 0x3d, 0xe9, 0x50, 0x24, 0x66, 0xa6, 0x61, 0x47, 0x67, 0x64, 0xdd, 0xec, 0xae, 0x9c, 0xf1, - 0x68, 0xfc, 0x01, 0x47, 0x1a, 0xf5, 0x7f, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Settings_40px = { 40, 40, NBGL_BPP_4, true, C_Settings_40px_bitmap }; - -uint8_t const C_Space_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x01, 0x24, 0x00, 0x00, 0x22, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0xe0, 0xff, 0xc0, 0xc0, 0x80, 0x44, 0x30, 0x14, 0x0c, 0x15, - 0x02, 0xc5, 0xe1, 0x00, 0xfa, 0x92, 0x85, 0x5f, 0xc8, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Space_40px = { 40, 40, NBGL_BPP_1, true, C_Space_40px_bitmap }; - -uint8_t const C_Warning_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0xe7, 0x00, 0x00, 0xe5, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x6d, 0xd3, 0xb1, 0x0d, 0xc2, 0x40, 0x0c, 0x85, 0xe1, 0x47, 0x84, 0x22, - 0x3a, 0x28, 0x11, 0xd5, 0xd5, 0x88, 0x82, 0x11, 0x32, 0x00, 0x62, 0x86, 0x4c, 0x90, 0x15, 0x08, - 0x13, 0x30, 0x03, 0x2c, 0xc0, 0x0e, 0x88, 0x9e, 0x25, 0x10, 0x6d, 0x52, 0x50, 0x84, 0x10, 0x9d, - 0xb9, 0x73, 0x42, 0x88, 0x7d, 0xb8, 0xfc, 0xaa, 0x5f, 0x67, 0x1f, 0x91, 0x1c, 0x4b, 0xc1, 0x34, - 0x26, 0x0b, 0x28, 0xc1, 0x44, 0x5b, 0x8a, 0xc0, 0xf6, 0xc0, 0x5a, 0xd9, 0x11, 0xd8, 0xe6, 0xd2, - 0xae, 0xc0, 0x86, 0xa4, 0xdd, 0x81, 0x05, 0x49, 0xab, 0x80, 0x39, 0x49, 0xab, 0x66, 0x88, 0x49, - 0x5a, 0x63, 0x30, 0xbe, 0x49, 0x73, 0xad, 0x11, 0xd3, 0xc0, 0x52, 0x8c, 0x0e, 0x24, 0xcd, 0xb5, - 0x76, 0xd4, 0x9b, 0x6f, 0x25, 0x69, 0xdc, 0x2a, 0xad, 0x6d, 0x15, 0xd6, 0xb5, 0x0e, 0xed, 0xc5, - 0xad, 0x25, 0xfc, 0x4c, 0x4b, 0xb0, 0x3d, 0xb9, 0x35, 0xb0, 0x42, 0xdb, 0xdb, 0x20, 0x2e, 0x94, - 0xd1, 0x43, 0x3e, 0x77, 0xdb, 0xe2, 0x70, 0xa9, 0x8d, 0x2e, 0xc0, 0x4a, 0x1b, 0x9d, 0x80, 0x4c, - 0x1b, 0xe5, 0x3f, 0xec, 0xcd, 0xa6, 0x88, 0xce, 0xca, 0xc8, 0x26, 0x5f, 0x1c, 0xbc, 0x7d, 0x6d, - 0xb8, 0x5d, 0xee, 0xa8, 0xe6, 0x76, 0xb5, 0xcb, 0xae, 0x5d, 0xee, 0xbc, 0x6d, 0x57, 0xb7, 0xc1, - 0xed, 0xca, 0xb8, 0x5d, 0x9b, 0x6f, 0x37, 0xda, 0xec, 0x9f, 0x9b, 0xf4, 0xed, 0x81, 0xb9, 0xcc, - 0x5d, 0x78, 0xf8, 0xfe, 0x2f, 0x7c, 0x00, 0x13, 0xd8, 0xb8, 0x06, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Warning_40px = { 40, 40, NBGL_BPP_4, true, C_Warning_40px_bitmap }; - -uint8_t const C_radio_active_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x22, 0x1f, 0x01, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x9c, 0x73, 0x10, 0x10, - 0x91, 0x47, 0xc0, 0xdb, 0x0a, 0x02, 0x70, 0x10, 0x02, 0x0a, 0xd7, 0x0e, 0x03, 0x70, 0x50, 0x02, - 0x0e, 0xd4, 0x0a, 0x01, 0x70, 0x70, 0x01, 0x0b, 0xd2, 0x0b, 0x40, 0x91, 0x7b, 0xe0, 0xc1, 0x8d, - 0xb6, 0x50, 0x0a, 0xd0, 0x0e, 0x01, 0x30, 0x05, 0xc8, 0x0e, 0x06, 0x30, 0x01, 0x0e, 0xcf, 0x02, - 0x30, 0x09, 0xcb, 0x08, 0x30, 0x03, 0xce, 0x0a, 0x30, 0x08, 0xcd, 0x09, 0x30, 0x0a, 0xcd, 0x02, - 0x20, 0x06, 0xc4, 0x08, 0x04, 0x10, 0x03, 0x0a, 0xc4, 0x05, 0x20, 0x02, 0xcc, 0x0c, 0x30, 0x0e, - 0xc2, 0x0e, 0x02, 0x50, 0x02, 0x0e, 0xc3, 0x01, 0x20, 0x0c, 0xcb, 0x07, 0x20, 0x06, 0xc3, 0x02, - 0x70, 0x02, 0xc3, 0x07, 0x20, 0x07, 0xcb, 0x04, 0x20, 0x0b, 0xc2, 0x0a, 0x70, 0x10, 0x08, 0xc2, - 0x0b, 0x20, 0x03, 0xcb, 0x01, 0x20, 0x0d, 0xc2, 0x03, 0x70, 0x10, 0x04, 0xc2, 0x0e, 0x20, 0x01, - 0xcb, 0x30, 0xc3, 0x70, 0x30, 0xc3, 0x30, 0xcb, 0x30, 0xc3, 0x70, 0x30, 0xc3, 0x30, 0xcb, 0x01, - 0x20, 0x0e, 0xc2, 0x04, 0x70, 0x10, 0x03, 0xc2, 0x0d, 0x20, 0x01, 0xcb, 0x03, 0x20, 0x0b, 0xc2, - 0x08, 0x70, 0x10, 0x0a, 0xc2, 0x0b, 0x20, 0x04, 0xcb, 0x07, 0x20, 0x07, 0xc3, 0x02, 0x70, 0x02, - 0xc3, 0x06, 0x20, 0x07, 0xcb, 0x0c, 0x20, 0x01, 0xc3, 0x0e, 0x02, 0x50, 0x02, 0x0e, 0xc2, 0x0e, - 0x30, 0x0c, 0xcc, 0x02, 0x20, 0x05, 0xc4, 0x0a, 0x03, 0x10, 0x04, 0x08, 0xc4, 0x06, 0x20, 0x02, - 0xcd, 0x0a, 0x30, 0x09, 0xcd, 0x08, 0x30, 0x0a, 0xce, 0x03, 0x30, 0x08, 0xcb, 0x09, 0x30, 0x02, - 0xcf, 0x0e, 0x01, 0x30, 0x06, 0x0e, 0xc8, 0x05, 0x30, 0x01, 0x0e, 0xd0, 0x0a, 0x50, 0x86, 0xbd, - 0xc1, 0x9e, 0xb7, 0x10, 0x40, 0x0b, 0xd2, 0x0b, 0x01, 0x70, 0x70, 0x01, 0x0a, 0xd4, 0x0e, 0x02, - 0x70, 0x50, 0x03, 0x0e, 0xd7, 0x0a, 0x02, 0x70, 0x10, 0x02, 0x0a, 0xdb, 0x9c, 0x74, 0x10, 0x10, - 0x91, 0x37, 0xc0, 0xff, 0xff, 0xff, 0xfe, -}; -const nbgl_icon_details_t C_radio_active_40px = { 40, 40, NBGL_BPP_4, true, C_radio_active_40px_bitmap }; - -uint8_t const C_radio_inactive_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0xc5, 0x00, 0x00, 0xc3, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xc5, 0x52, 0xbb, 0x0e, 0xc2, 0x30, 0x10, 0xfb, 0xff, 0x4f, 0x70, 0xc2, - 0x63, 0xce, 0x00, 0x9d, 0x2b, 0x21, 0x31, 0x23, 0x24, 0x98, 0x99, 0x32, 0x17, 0x21, 0x65, 0xa6, - 0xb4, 0x84, 0x6b, 0x93, 0xeb, 0x5d, 0x51, 0x10, 0x1b, 0x78, 0xe9, 0xc9, 0xaa, 0x6b, 0x9f, 0xaf, - 0x31, 0xfe, 0x15, 0xcf, 0xa3, 0x33, 0xbb, 0x30, 0xa7, 0x1c, 0x08, 0x66, 0x46, 0xd6, 0x18, 0x61, - 0x14, 0x75, 0x45, 0xc6, 0x56, 0x94, 0xf4, 0xc6, 0x29, 0xc6, 0x1b, 0x91, 0x9e, 0xb9, 0x16, 0xd8, - 0x0f, 0xcf, 0x0e, 0xa8, 0x98, 0x73, 0x58, 0xa6, 0xe1, 0x02, 0x2b, 0xd2, 0x2c, 0xe9, 0x81, 0xc0, - 0xd2, 0x85, 0xf8, 0x67, 0x71, 0x83, 0xb5, 0x7c, 0x79, 0x95, 0x86, 0x03, 0xce, 0xcc, 0x75, 0x2c, - 0xa9, 0x11, 0x24, 0x95, 0x65, 0x5b, 0x49, 0xcf, 0xab, 0x40, 0x73, 0xf8, 0xcc, 0x95, 0xb4, 0x25, - 0x8f, 0x52, 0x96, 0x46, 0x36, 0xbf, 0x73, 0xe6, 0x76, 0xda, 0x9c, 0x24, 0xd5, 0xb4, 0xb9, 0x7f, - 0x9f, 0xc8, 0x64, 0xea, 0xca, 0xa8, 0x4e, 0x47, 0x97, 0x87, 0xea, 0x94, 0x0a, 0xc4, 0xd0, 0xbd, - 0x83, 0xa4, 0x92, 0x1b, 0x6d, 0xd4, 0xe1, 0x5c, 0xa2, 0xac, 0xbe, 0x6f, 0x9f, 0x6e, 0xee, 0xbf, - 0xfd, 0x1b, 0xbf, 0xc7, 0x0b, 0x8b, 0x9c, 0x75, 0x0e, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_radio_inactive_40px = { 40, 40, NBGL_BPP_4, true, C_radio_inactive_40px_bitmap }; - -uint8_t const C_app_boilerplate_40px_bitmap[] = { - 0x28, 0x00, 0x28, 0x00, 0x21, 0xe4, 0x00, 0x00, 0xe2, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x9d, 0x92, 0xbd, 0x0d, 0x83, 0x30, 0x10, 0x85, 0xcf, 0x72, 0x81, 0xe4, - 0x26, 0x66, 0x00, 0x94, 0x15, 0x88, 0x32, 0x00, 0x33, 0x21, 0x06, 0xc8, 0x2c, 0x51, 0x3a, 0x1a, - 0x86, 0xa1, 0x40, 0x4a, 0x93, 0x31, 0x2c, 0x59, 0x3a, 0x5d, 0x62, 0x88, 0xed, 0xb3, 0x4d, 0x41, - 0x72, 0x05, 0x32, 0x8f, 0xc7, 0x7d, 0xf7, 0x63, 0xa2, 0x5f, 0x02, 0x5f, 0xa5, 0x66, 0x9a, 0x52, - 0xb3, 0x72, 0xc7, 0x07, 0xd3, 0x8e, 0xa6, 0xca, 0x7f, 0x01, 0x3c, 0xc5, 0x4e, 0xc1, 0x07, 0xdd, - 0x76, 0x1a, 0xeb, 0x5b, 0xd4, 0x56, 0x0a, 0x0e, 0xba, 0x8a, 0xf9, 0xc0, 0x51, 0x96, 0x56, 0xe8, - 0x86, 0x6b, 0xca, 0xde, 0x35, 0x80, 0x08, 0xd5, 0x1b, 0xf7, 0xd6, 0x7e, 0x3e, 0x40, 0x45, 0xdc, - 0x07, 0xda, 0x3d, 0x3a, 0x5e, 0xcb, 0x16, 0x22, 0x8e, 0xa0, 0xf7, 0x5a, 0x28, 0x7d, 0x69, 0xbd, - 0xe4, 0x5b, 0x5c, 0x71, 0xdf, 0xa8, 0x0a, 0x53, 0x20, 0x70, 0xc9, 0x13, 0x6c, 0x2f, 0x20, 0x4f, - 0x47, 0x38, 0x47, 0xed, 0x1c, 0x4a, 0x19, 0x03, 0x84, 0x8d, 0x1b, 0x87, 0x0c, 0x92, 0xf4, 0xa1, - 0x28, 0xed, 0x37, 0xa1, 0x30, 0x1f, 0x9c, 0x12, 0x9f, 0x7c, 0x5e, 0x74, 0x3e, 0x2b, 0x45, 0xf8, - 0xa8, 0x41, 0x74, 0x7c, 0xa6, 0x2e, 0x93, 0xe9, 0x23, 0xc5, 0x08, 0xb1, 0x9d, 0xf1, 0x1a, 0x96, - 0x1a, 0x77, 0x49, 0x73, 0xdc, 0xa5, 0xdc, 0xb9, 0x07, 0xea, 0xd8, 0x1d, 0x92, 0xc7, 0xee, 0x24, - 0xd2, 0x3f, 0xf1, 0x06, 0x29, 0x24, 0x97, 0x3f, 0x20, 0x03, 0x00, 0x00, -}; -const nbgl_icon_details_t C_app_boilerplate_40px = { 40, 40, NBGL_BPP_4, true, C_app_boilerplate_40px_bitmap }; - diff --git a/ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.h b/ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.h deleted file mode 100644 index 7fe841f1..00000000 --- a/ledger_secure_sdk_sys/src/c/glyphs_flex/glyphs.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Automatically generated by icon2glyph.py */ - -#pragma once - -#include "app_config.h" -#include "nbgl_types.h" - -extern uint8_t const C_app_boilerplate_16px_bitmap[29]; -extern const nbgl_icon_details_t C_app_boilerplate_16px; - -extern uint8_t const C_app_boilerplate_64px_bitmap[187]; -extern const nbgl_icon_details_t C_app_boilerplate_64px; - -extern uint8_t const C_pin_24_bitmap[49]; -extern const nbgl_icon_details_t C_pin_24; - -extern uint8_t const C_quarter_circle_bottom_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_circle_bottom_left_32px_1bpp; - -extern uint8_t const C_quarter_circle_bottom_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_circle_bottom_left_40px_1bpp; - -extern uint8_t const C_quarter_circle_bottom_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_circle_bottom_left_44px_1bpp; - -extern uint8_t const C_quarter_circle_top_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_circle_top_left_32px_1bpp; - -extern uint8_t const C_quarter_circle_top_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_circle_top_left_40px_1bpp; - -extern uint8_t const C_quarter_circle_top_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_circle_top_left_44px_1bpp; - -extern uint8_t const C_quarter_disc_bottom_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_disc_bottom_left_32px_1bpp; - -extern uint8_t const C_quarter_disc_bottom_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_disc_bottom_left_40px_1bpp; - -extern uint8_t const C_quarter_disc_bottom_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_disc_bottom_left_44px_1bpp; - -extern uint8_t const C_quarter_disc_top_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_disc_top_left_32px_1bpp; - -extern uint8_t const C_quarter_disc_top_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_disc_top_left_40px_1bpp; - -extern uint8_t const C_quarter_disc_top_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_disc_top_left_44px_1bpp; - -extern uint8_t const C_round_24px_bitmap[47]; -extern const nbgl_icon_details_t C_round_24px; - -extern uint8_t const C_switch_60_40_bitmap[300]; -extern const nbgl_icon_details_t C_switch_60_40; - -extern uint8_t const C_Check_Circle_64px_bitmap[571]; -extern const nbgl_icon_details_t C_Check_Circle_64px; - -extern uint8_t const C_Denied_Circle_64px_bitmap[568]; -extern const nbgl_icon_details_t C_Denied_Circle_64px; - -extern uint8_t const C_Important_Circle_64px_bitmap[514]; -extern const nbgl_icon_details_t C_Important_Circle_64px; - -extern uint8_t const C_Review_64px_bitmap[219]; -extern const nbgl_icon_details_t C_Review_64px; - -extern uint8_t const C_SecurityShield_64px_bitmap[610]; -extern const nbgl_icon_details_t C_SecurityShield_64px; - -extern uint8_t const C_Warning_64px_bitmap[359]; -extern const nbgl_icon_details_t C_Warning_64px; - -extern uint8_t const C_left_half_64px_bitmap[192]; -extern const nbgl_icon_details_t C_left_half_64px; - -extern uint8_t const C_Back_40px_bitmap[148]; -extern const nbgl_icon_details_t C_Back_40px; - -extern uint8_t const C_Check_40px_bitmap[92]; -extern const nbgl_icon_details_t C_Check_40px; - -extern uint8_t const C_Check_Circle_40px_bitmap[339]; -extern const nbgl_icon_details_t C_Check_Circle_40px; - -extern uint8_t const C_Chevron_40px_bitmap[100]; -extern const nbgl_icon_details_t C_Chevron_40px; - -extern uint8_t const C_Chevron_Back_40px_bitmap[126]; -extern const nbgl_icon_details_t C_Chevron_Back_40px; - -extern uint8_t const C_Chevron_Next_40px_bitmap[121]; -extern const nbgl_icon_details_t C_Chevron_Next_40px; - -extern uint8_t const C_Close_40px_bitmap[141]; -extern const nbgl_icon_details_t C_Close_40px; - -extern uint8_t const C_Denied_Circle_40px_bitmap[326]; -extern const nbgl_icon_details_t C_Denied_Circle_40px; - -extern uint8_t const C_Erase_40px_bitmap[120]; -extern const nbgl_icon_details_t C_Erase_40px; - -extern uint8_t const C_Info_40px_bitmap[57]; -extern const nbgl_icon_details_t C_Info_40px; - -extern uint8_t const C_Maj_40px_bitmap[89]; -extern const nbgl_icon_details_t C_Maj_40px; - -extern uint8_t const C_Maj_Lock_40px_bitmap[85]; -extern const nbgl_icon_details_t C_Maj_Lock_40px; - -extern uint8_t const C_Mini_Push_40px_bitmap[214]; -extern const nbgl_icon_details_t C_Mini_Push_40px; - -extern uint8_t const C_Next_40px_bitmap[142]; -extern const nbgl_icon_details_t C_Next_40px; - -extern uint8_t const C_Plus_40px_bitmap[62]; -extern const nbgl_icon_details_t C_Plus_40px; - -extern uint8_t const C_QRCode_40px_bitmap[161]; -extern const nbgl_icon_details_t C_QRCode_40px; - -extern uint8_t const C_Settings_40px_bitmap[411]; -extern const nbgl_icon_details_t C_Settings_40px; - -extern uint8_t const C_Space_40px_bitmap[44]; -extern const nbgl_icon_details_t C_Space_40px; - -extern uint8_t const C_Warning_40px_bitmap[239]; -extern const nbgl_icon_details_t C_Warning_40px; - -extern uint8_t const C_radio_active_40px_bitmap[295]; -extern const nbgl_icon_details_t C_radio_active_40px; - -extern uint8_t const C_radio_inactive_40px_bitmap[205]; -extern const nbgl_icon_details_t C_radio_inactive_40px; - -extern uint8_t const C_app_boilerplate_40px_bitmap[236]; -extern const nbgl_icon_details_t C_app_boilerplate_40px; - diff --git a/ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.c b/ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.c deleted file mode 100644 index 2e99cac2..00000000 --- a/ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.c +++ /dev/null @@ -1,784 +0,0 @@ -/* Automatically generated by icon2glyph.py */ - -#include "glyphs.h" - -uint8_t const C_app_boilerplate_16px_bitmap[] = { - 0x10, 0x00, 0x10, 0x00, 0x02, 0x15, 0x00, 0x00, 0xf0, 0x71, 0xf1, 0xf2, 0x42, 0x83, 0x14, 0x87, - 0x78, 0x69, 0x79, 0x98, 0xa7, 0x93, 0x14, 0x82, 0x42, 0x81, 0xf1, 0xf0, 0xa0, -}; -const nbgl_icon_details_t C_app_boilerplate_16px = { 16, 16, NBGL_BPP_1, true, C_app_boilerplate_16px_bitmap }; - -uint8_t const C_app_boilerplate_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x01, 0xb3, 0x00, 0x00, 0xb1, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x75, 0xd1, 0xbb, 0x0d, 0x03, 0x21, 0x0c, 0x06, 0x60, 0x9f, 0x22, 0x85, - 0x92, 0x11, 0x6e, 0x85, 0x6c, 0x70, 0xa3, 0x1d, 0xa3, 0x79, 0x14, 0xa4, 0x14, 0x69, 0x29, 0x29, - 0x2c, 0x1c, 0x83, 0xff, 0x44, 0x04, 0xe5, 0xdc, 0x7c, 0x12, 0x0f, 0x1b, 0x1b, 0xa2, 0xab, 0xb8, - 0xc3, 0xf0, 0x31, 0x2d, 0x32, 0xcc, 0xb0, 0xc0, 0x3a, 0xf9, 0x30, 0x85, 0x68, 0xb3, 0xbd, 0xd0, - 0x88, 0xa2, 0x9d, 0x0d, 0x4a, 0x74, 0xf2, 0xf0, 0xa6, 0xc3, 0xb4, 0x6b, 0xea, 0xb2, 0x6a, 0xbf, - 0xa7, 0x2f, 0x6d, 0x43, 0xfd, 0x2a, 0xb0, 0xc2, 0x32, 0xb9, 0x9b, 0xfd, 0x09, 0x86, 0xa7, 0xb3, - 0xb0, 0x74, 0x47, 0xd7, 0x2a, 0xab, 0x1b, 0xd5, 0xd3, 0x8d, 0x65, 0x81, 0x15, 0xeb, 0x82, 0x73, - 0xbd, 0xdc, 0x01, 0xa3, 0xdf, 0xf3, 0x8d, 0x84, 0x0d, 0x46, 0xdd, 0xbc, 0x58, 0x96, 0xf7, 0xc9, - 0x8f, 0x4f, 0xf4, 0x91, 0x4f, 0xef, 0x8f, 0xa3, 0xf7, 0x9b, 0x36, 0x7f, 0xb0, 0xe5, 0xe6, 0x69, - 0x3e, 0x0d, 0xf3, 0x12, 0xcc, 0xaf, 0x2e, 0xf3, 0x2d, 0xcb, 0xdc, 0xf9, 0xe2, 0x7f, 0x96, 0x7f, - 0xfc, 0x1f, 0x6f, 0xe5, 0xd1, 0xa9, 0x21, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_app_boilerplate_64px = { 64, 64, NBGL_BPP_1, true, C_app_boilerplate_64px_bitmap }; - -uint8_t const C_pin_24_bitmap[] = { - 0x18, 0x00, 0x18, 0x00, 0x02, 0x29, 0x00, 0x00, 0x96, 0xfc, 0xbe, 0x9f, 0x01, 0x7f, 0x03, 0x5f, - 0x05, 0x3f, 0x07, 0x2f, 0x07, 0x2f, 0x07, 0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x09, 0x1f, 0x07, 0x2f, 0x07, 0x2f, 0x07, 0x3f, 0x05, 0x5f, 0x03, 0x7f, 0x01, 0x9e, 0xbc, 0xf6, - 0x90, -}; -const nbgl_icon_details_t C_pin_24 = { 24, 24, NBGL_BPP_1, true, C_pin_24_bitmap }; - -uint8_t const C_quarter_circle_bottom_left_32px_1bpp_bitmap[] = { - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, - 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x80, - 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x3e, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_circle_bottom_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_circle_bottom_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_bottom_left_40px_1bpp_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, - 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, - 0x03, 0xc0, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x00, 0xff, 0xe0, - 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_circle_bottom_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_circle_bottom_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_bottom_left_44px_1bpp_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, - 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, - 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, - 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_circle_bottom_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_circle_bottom_left_44px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_top_left_32px_1bpp_bitmap[] = { - 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, - 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, - 0x01, 0xc0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, - 0x00, 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0xf0, 0x00, - 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_circle_top_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_circle_top_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_top_left_40px_1bpp_bitmap[] = { - 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, - 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_circle_top_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_circle_top_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_circle_top_left_44px_1bpp_bitmap[] = { - 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, - 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_circle_top_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_circle_top_left_44px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_bottom_left_32px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, - 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, - 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0x80, - 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xfc, 0x00, - 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xc0, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xfe, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_disc_bottom_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_disc_bottom_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_bottom_left_40px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, - 0xfc, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xf8, - 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, - 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, - 0xfe, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xf0, - 0x00, 0xff, 0xff, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0xff, 0xff, 0xff, 0x80, 0x00, - 0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x00, 0x00, 0xff, - 0xff, 0xc0, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xff, 0xe0, - 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_disc_bottom_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_disc_bottom_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_bottom_left_44px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, - 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, - 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xc0, 0x00, - 0xff, 0xff, 0xff, 0xf8, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xe0, 0x00, - 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, - 0x00, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, - 0x00, 0x0f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_quarter_disc_bottom_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_disc_bottom_left_44px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_top_left_32px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, - 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, - 0x1f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, - 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, - 0x01, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, - 0x00, 0x1f, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, - 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_disc_top_left_32px_1bpp = { 32, 32, NBGL_BPP_1, false, C_quarter_disc_top_left_32px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_top_left_40px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07, - 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, - 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x7f, 0xff, - 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, - 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x7f, 0xff, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xff, 0x00, - 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, - 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_disc_top_left_40px_1bpp = { 40, 40, NBGL_BPP_1, false, C_quarter_disc_top_left_40px_1bpp_bitmap }; - -uint8_t const C_quarter_disc_top_left_44px_1bpp_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, - 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x1f, - 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x7f, 0xff, 0xff, 0xff, 0xf0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xf0, - 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xff, - 0x00, 0x01, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, - 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xff, - 0xff, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x1f, - 0xff, 0xf0, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x3f, -}; -const nbgl_icon_details_t C_quarter_disc_top_left_44px_1bpp = { 44, 44, NBGL_BPP_1, false, C_quarter_disc_top_left_44px_1bpp_bitmap }; - -uint8_t const C_round_24px_bitmap[] = { - 0x18, 0x00, 0x18, 0x00, 0x02, 0x27, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x74, 0xf0, 0x38, - 0xec, 0xbe, 0xae, 0x9f, 0x01, 0x8f, 0x01, 0x7f, 0x03, 0x6f, 0x03, 0x6f, 0x03, 0x6f, 0x03, 0x7f, - 0x01, 0x8f, 0x01, 0x9e, 0xae, 0xbc, 0xe8, 0xf0, 0x34, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x70, -}; -const nbgl_icon_details_t C_round_24px = { 24, 24, NBGL_BPP_1, true, C_round_24px_bitmap }; - -uint8_t const C_switch_60_40_bitmap[] = { - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x00, - 0x3f, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0x80, 0x03, 0xff, - 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, - 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, - 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, - 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, - 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, - 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, - 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0x00, 0xff, 0xfc, 0x3f, 0xf8, 0x00, 0x1f, - 0xfc, 0x3f, 0xf0, 0x00, 0x0f, 0xfc, 0x3f, 0xc0, 0x00, 0x03, 0xfc, 0x3f, 0x80, 0x00, 0x01, 0xfc, - 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x3e, 0x00, 0x00, 0x00, 0x7c, 0x3c, - 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x3c, 0x38, 0x00, - 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, - 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, - 0x1c, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 0x00, 0x38, - 0x1c, 0x00, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x00, 0x70, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x07, - 0x00, 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x01, 0xc0, 0x03, 0xc0, 0x00, 0x03, 0xc0, 0x01, 0xf0, - 0x00, 0x0f, 0x80, 0x00, 0xf8, 0x00, 0x1f, 0x00, 0x00, 0x3f, 0x00, 0xfc, 0x00, 0x00, 0x1f, 0xff, - 0xf8, 0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, -}; -const nbgl_icon_details_t C_switch_60_40 = { 60, 40, NBGL_BPP_1, false, C_switch_60_40_bitmap }; - -uint8_t const C_Check_Circle_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x33, 0x02, 0x00, 0x31, 0x02, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xad, 0x55, 0x39, 0x4e, 0x03, 0x31, 0x14, 0xfd, 0x24, 0x61, 0x5f, 0x4b, - 0x28, 0x80, 0x91, 0xa0, 0x01, 0x24, 0x88, 0xb8, 0x40, 0x46, 0x54, 0x20, 0x21, 0x41, 0x49, 0x39, - 0x2d, 0x15, 0xdc, 0x00, 0x90, 0xa0, 0x66, 0x11, 0xa2, 0x05, 0x71, 0x01, 0x10, 0x17, 0x48, 0x0a, - 0x6a, 0x02, 0x17, 0x60, 0xab, 0x41, 0x61, 0x89, 0x04, 0x24, 0x21, 0x9f, 0xef, 0x65, 0x66, 0xbe, - 0x3d, 0x0e, 0x8b, 0xc4, 0x14, 0x99, 0xb1, 0x9f, 0xfd, 0xfc, 0xfc, 0xfc, 0xf3, 0x8c, 0xf8, 0x7f, - 0x4f, 0xf5, 0x60, 0x1a, 0x60, 0x74, 0xa9, 0xd8, 0x00, 0xde, 0x04, 0xfd, 0xcc, 0x95, 0x1c, 0x68, - 0xcd, 0x87, 0xe8, 0xc9, 0x14, 0xbf, 0x85, 0x01, 0x52, 0x79, 0x0b, 0xae, 0x1b, 0x30, 0x40, 0x8b, - 0xb5, 0xc4, 0xae, 0x9c, 0xb5, 0x7c, 0x8d, 0xf8, 0x70, 0xe0, 0x89, 0xef, 0x71, 0x03, 0x7e, 0x13, - 0x5d, 0xfd, 0x7a, 0x4e, 0x7d, 0x4f, 0xb4, 0xd6, 0x38, 0x9e, 0xa5, 0x8e, 0xf9, 0xb8, 0x79, 0x4c, - 0xcd, 0x34, 0x5b, 0xe1, 0x9e, 0xda, 0x13, 0x7c, 0xbc, 0x18, 0x30, 0x19, 0x8b, 0xa3, 0x15, 0x5b, - 0x4d, 0xb9, 0x01, 0xa9, 0x89, 0x5a, 0xaf, 0x34, 0xfa, 0xd0, 0xd4, 0xfb, 0x41, 0x5d, 0xb9, 0xb0, - 0xb1, 0x0a, 0x30, 0x68, 0xfb, 0x71, 0x15, 0x53, 0x56, 0x00, 0x9a, 0x6e, 0x6c, 0xfc, 0xb3, 0x2f, - 0xe2, 0x24, 0x75, 0xdd, 0x49, 0xbf, 0x2f, 0x01, 0x86, 0xd4, 0x57, 0x10, 0x8e, 0xac, 0x5a, 0x0a, - 0x32, 0xaa, 0x97, 0xdc, 0x54, 0x5d, 0x47, 0x39, 0x3e, 0x80, 0x54, 0xc9, 0x63, 0x7a, 0x09, 0xb7, - 0x5a, 0x81, 0x34, 0xc7, 0xa9, 0x7f, 0x41, 0xbc, 0x0b, 0x00, 0x27, 0x6a, 0x3a, 0xdb, 0x92, 0xe2, - 0xed, 0x12, 0x6f, 0x3f, 0x74, 0x82, 0xb6, 0x64, 0x10, 0xf8, 0x52, 0x40, 0x1d, 0xa0, 0x23, 0xde, - 0x12, 0x27, 0x20, 0x62, 0xa5, 0x73, 0x0a, 0x9d, 0x04, 0xcf, 0x00, 0xdb, 0x88, 0xe5, 0xd8, 0x5b, - 0x8b, 0xe0, 0x5d, 0x0a, 0x7c, 0x02, 0x28, 0xa1, 0x93, 0x80, 0x56, 0xee, 0x15, 0xab, 0xa4, 0x0c, - 0x53, 0x19, 0x81, 0x07, 0x9d, 0x88, 0xeb, 0xa1, 0x3b, 0x49, 0x82, 0x00, 0xda, 0x11, 0x17, 0xc5, - 0x8f, 0x9b, 0x60, 0x47, 0x4c, 0xf5, 0x95, 0x0b, 0x2e, 0x82, 0x4b, 0xf1, 0xed, 0x41, 0x0f, 0x36, - 0x20, 0xb8, 0x15, 0xd2, 0xa4, 0x48, 0x37, 0xc1, 0x93, 0x30, 0xc8, 0xc2, 0x39, 0x81, 0x0b, 0xe7, - 0x04, 0x4e, 0x5c, 0x10, 0xac, 0x30, 0xdc, 0xd4, 0xa7, 0x08, 0x56, 0x98, 0xbe, 0xac, 0x5d, 0x7c, - 0x31, 0x5e, 0x10, 0x07, 0x1c, 0x70, 0x7f, 0x34, 0xff, 0x5a, 0xe8, 0x4f, 0xb3, 0x36, 0xc9, 0xad, - 0x2f, 0x80, 0x36, 0xc4, 0x53, 0x76, 0x3e, 0xd6, 0xfe, 0x3c, 0x61, 0x2d, 0x3f, 0x5f, 0x73, 0xba, - 0x3a, 0xdf, 0xb2, 0xac, 0x12, 0xd7, 0xf4, 0x0f, 0x59, 0x1f, 0x54, 0x25, 0xc3, 0x6e, 0x7b, 0x5f, - 0x54, 0x65, 0x01, 0x3b, 0x40, 0xe3, 0x78, 0x8e, 0xd4, 0xca, 0xbe, 0xfe, 0x1f, 0xe9, 0x92, 0x4c, - 0xb3, 0xf2, 0xc9, 0xe8, 0x32, 0xce, 0xb3, 0x92, 0x8c, 0xa6, 0x57, 0x34, 0x71, 0x39, 0x2e, 0x70, - 0xaa, 0xb6, 0x34, 0x0f, 0x1d, 0xd9, 0x5f, 0xe3, 0xe1, 0xf2, 0x9e, 0x63, 0xd5, 0xa7, 0x79, 0xfd, - 0x44, 0xba, 0xe8, 0xdd, 0x69, 0x63, 0xef, 0x1a, 0xe5, 0xc3, 0x64, 0x34, 0xd2, 0x9d, 0x2f, 0x27, - 0xbf, 0xcb, 0xa7, 0x1f, 0xf3, 0x8d, 0x9c, 0xb0, 0x03, 0x9b, 0x28, 0x53, 0x25, 0x23, 0x5f, 0x8d, - 0xc0, 0x3e, 0x33, 0xf2, 0x15, 0xeb, 0x59, 0x73, 0xc0, 0x39, 0x58, 0x51, 0x22, 0xf3, 0x7d, 0x2c, - 0xcc, 0xf7, 0x8d, 0x44, 0xbe, 0xcb, 0xc0, 0xa6, 0xfb, 0xe1, 0x02, 0xf1, 0x51, 0xdd, 0x0f, 0x03, - 0x98, 0x08, 0x6c, 0xfe, 0x64, 0xec, 0x2b, 0xac, 0xea, 0x19, 0x70, 0xf1, 0xaf, 0xf7, 0x1b, 0x2d, - 0xb1, 0x1f, 0xc2, 0xb3, 0x0d, 0x2e, 0xd0, 0xda, 0xd6, 0x0c, 0xc0, 0xc8, 0x72, 0xfe, 0x1f, 0xaf, - 0x6c, 0xfc, 0x02, 0x24, 0x14, 0x5a, 0xc5, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Check_Circle_64px = { 64, 64, NBGL_BPP_4, true, C_Check_Circle_64px_bitmap }; - -uint8_t const C_Denied_Circle_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x30, 0x02, 0x00, 0x2e, 0x02, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xad, 0x55, 0x4b, 0x2f, 0x04, 0x41, 0x10, 0x2e, 0x6b, 0xbd, 0x9f, 0x47, - 0x0e, 0xd8, 0x84, 0x48, 0x90, 0xac, 0x8d, 0x3f, 0x60, 0xe2, 0x44, 0x22, 0xe1, 0xe8, 0xb8, 0x71, - 0x73, 0xe2, 0x1f, 0x20, 0xe1, 0xec, 0x11, 0x71, 0x25, 0xfe, 0x00, 0xf1, 0x07, 0xd6, 0xc1, 0xd9, - 0xf2, 0x07, 0x3c, 0xe6, 0x4c, 0xd6, 0x63, 0xe3, 0xb9, 0xa6, 0x54, 0xf5, 0x63, 0xa6, 0xa7, 0x67, - 0x66, 0x97, 0x44, 0x1f, 0x76, 0xb6, 0xbb, 0xba, 0xaa, 0xbe, 0xfe, 0xea, 0xeb, 0x6a, 0xc4, 0xff, - 0x1b, 0x5f, 0xfb, 0x13, 0x00, 0x43, 0x0b, 0xc5, 0x04, 0xf3, 0x06, 0xa8, 0x31, 0x53, 0x8a, 0xb1, - 0x56, 0x1c, 0xf0, 0x47, 0xba, 0x58, 0xd5, 0x0c, 0x90, 0x2a, 0x58, 0x66, 0x2f, 0x64, 0x06, 0x68, - 0xb4, 0x52, 0xec, 0x08, 0xaf, 0xa5, 0x6b, 0xc4, 0xfb, 0xfd, 0x0c, 0xff, 0x1f, 0x0d, 0x99, 0xdf, - 0x78, 0xa9, 0x47, 0xf9, 0x78, 0xbb, 0x3c, 0x5b, 0x35, 0xed, 0x39, 0x5a, 0x98, 0x0d, 0xa6, 0x47, - 0x34, 0xad, 0x37, 0x32, 0xb8, 0x34, 0x1f, 0x33, 0xf7, 0xf3, 0x86, 0x6c, 0x00, 0x8e, 0x32, 0x36, - 0x85, 0xe1, 0xe6, 0x09, 0x8d, 0x3f, 0x7b, 0xa1, 0xdd, 0x07, 0x61, 0xbc, 0x1f, 0xb4, 0x34, 0xa9, - 0x27, 0x2b, 0x00, 0x7d, 0x36, 0x1f, 0x57, 0x41, 0xc8, 0x4f, 0x80, 0xba, 0x1b, 0xdb, 0xfe, 0xdd, - 0xed, 0xc7, 0x24, 0x74, 0x1d, 0x51, 0xbe, 0x2f, 0x01, 0xfa, 0xe5, 0xbf, 0x7c, 0x24, 0xbb, 0x42, - 0x90, 0x96, 0x55, 0x25, 0x36, 0xe3, 0xca, 0x49, 0xa8, 0x44, 0x99, 0x9e, 0xcd, 0xa3, 0x1a, 0x83, - 0xd6, 0xe7, 0xf8, 0x7b, 0x06, 0x70, 0x2c, 0x0f, 0x6d, 0xa9, 0x05, 0xa0, 0x9d, 0xbf, 0x8e, 0x66, - 0x62, 0x51, 0xf3, 0x3f, 0x2c, 0xbf, 0x8e, 0x00, 0xe0, 0x01, 0xb4, 0x8a, 0xe9, 0xab, 0x4e, 0xe3, - 0xc2, 0x32, 0xaa, 0xc0, 0x12, 0xe7, 0xb8, 0x3a, 0x46, 0xaa, 0xa4, 0xd8, 0x96, 0x78, 0x9f, 0x00, - 0xb6, 0x10, 0xcb, 0xfa, 0x74, 0x19, 0x85, 0x93, 0xe8, 0x90, 0x1b, 0xdf, 0x05, 0xc0, 0x47, 0x80, - 0x12, 0x1a, 0xeb, 0x9e, 0xde, 0xc7, 0x99, 0xbb, 0x38, 0x4b, 0x2a, 0xa8, 0x62, 0xd6, 0x70, 0xe7, - 0x88, 0x6d, 0x88, 0x6b, 0x3e, 0x3b, 0xc2, 0x12, 0xb8, 0x33, 0xa2, 0x16, 0xc4, 0x79, 0xfe, 0x09, - 0x02, 0x18, 0xee, 0xb8, 0xcd, 0xae, 0x8e, 0x64, 0x41, 0x07, 0x30, 0xdc, 0xa9, 0x44, 0xf5, 0x9c, - 0xa4, 0xd3, 0xd4, 0x91, 0xe1, 0x8e, 0xb7, 0x0c, 0x4d, 0x80, 0x34, 0x74, 0x68, 0x14, 0xe3, 0x91, - 0x09, 0x32, 0xed, 0x1c, 0x20, 0x70, 0xff, 0xbb, 0x3d, 0x2e, 0x7e, 0x2d, 0x7c, 0xb9, 0x40, 0x7c, - 0xf6, 0xf9, 0xce, 0xb8, 0xc0, 0xf9, 0x6a, 0xfc, 0x34, 0x28, 0x92, 0x92, 0xf8, 0x6d, 0x46, 0x3c, - 0xa9, 0x56, 0x9f, 0xf6, 0xda, 0xf5, 0x2d, 0x0b, 0x95, 0x18, 0xeb, 0xae, 0xbe, 0x9a, 0x1f, 0x42, - 0x1f, 0xa4, 0x92, 0x81, 0x78, 0x7d, 0x3d, 0x4b, 0x65, 0x29, 0x19, 0x47, 0xf5, 0x79, 0x28, 0x33, - 0x3b, 0xea, 0x1e, 0x45, 0xf4, 0x9d, 0x91, 0x06, 0x92, 0xb1, 0xd5, 0xcd, 0x4a, 0xfa, 0x5a, 0x8b, - 0xc0, 0x65, 0x2d, 0x70, 0x6b, 0xb8, 0x6a, 0xbd, 0x62, 0x37, 0x17, 0x9f, 0x1d, 0x15, 0xd7, 0x49, - 0xba, 0xdf, 0x8a, 0xd8, 0xbb, 0xa4, 0xfe, 0x90, 0xf5, 0x77, 0xc6, 0xf7, 0x97, 0xe3, 0xdf, 0xf5, - 0xa7, 0x9a, 0xfd, 0x8d, 0xaf, 0xa6, 0xd5, 0xb0, 0x57, 0x42, 0x42, 0x74, 0xed, 0x86, 0x7d, 0x1a, - 0xd2, 0x21, 0x7a, 0xb9, 0xf0, 0x86, 0x73, 0xee, 0xcf, 0x91, 0xfe, 0x3e, 0xa2, 0xf9, 0x5f, 0x8f, - 0xf4, 0x77, 0xd1, 0xb0, 0xe9, 0x7d, 0xb8, 0x40, 0x7c, 0x90, 0xef, 0x43, 0x2f, 0x46, 0x1a, 0xb6, - 0x39, 0xd2, 0xf6, 0x13, 0xf6, 0x95, 0x09, 0x99, 0x8b, 0x7f, 0x7d, 0xdf, 0x28, 0xc5, 0x9e, 0x36, - 0x4f, 0x27, 0x3c, 0xa0, 0x95, 0xcd, 0x29, 0x80, 0xc1, 0xa5, 0xc2, 0x3f, 0x3e, 0xd9, 0xf8, 0x03, - 0x70, 0xa7, 0x85, 0x84, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Denied_Circle_64px = { 64, 64, NBGL_BPP_4, true, C_Denied_Circle_64px_bitmap }; - -uint8_t const C_Important_Circle_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0xfa, 0x01, 0x00, 0xf8, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xb5, 0x55, 0xcd, 0x4e, 0xc2, 0x40, 0x10, 0x1e, 0xa1, 0xfe, 0xe3, 0xcf, - 0x51, 0x0f, 0x2a, 0x89, 0x5e, 0xd4, 0x04, 0x89, 0x2f, 0x60, 0xe3, 0x49, 0x13, 0x13, 0x3c, 0x7a, - 0xe4, 0xca, 0xcd, 0x37, 0x50, 0x13, 0x3d, 0xa3, 0xc6, 0x70, 0xd5, 0xf8, 0x02, 0x18, 0x5f, 0x00, - 0x0f, 0x9e, 0x05, 0x5f, 0xc0, 0x1f, 0xce, 0x1a, 0x10, 0x49, 0x54, 0xc0, 0x8e, 0xb3, 0xed, 0xb6, - 0x74, 0xdb, 0x59, 0xd0, 0x04, 0xe7, 0xd0, 0x76, 0xf6, 0xdb, 0xee, 0x7c, 0xfd, 0x76, 0xfa, 0x2d, - 0x62, 0xef, 0xa2, 0x99, 0x5b, 0x05, 0x58, 0xd8, 0x29, 0x6a, 0xe0, 0x43, 0x90, 0xb1, 0x59, 0x61, - 0xd0, 0x96, 0x09, 0x5e, 0x18, 0xc5, 0x8e, 0x30, 0x40, 0xa4, 0x10, 0x80, 0x2d, 0x05, 0x06, 0x18, - 0x08, 0x94, 0x38, 0xb1, 0xdf, 0xca, 0x3c, 0x20, 0xbe, 0xe4, 0xe2, 0xe2, 0x79, 0x49, 0x81, 0x3f, - 0xc4, 0xd0, 0x94, 0x7c, 0xc7, 0x3a, 0x15, 0xd9, 0x9e, 0x1f, 0x4f, 0xd2, 0xc0, 0x56, 0x3b, 0xbd, - 0xa4, 0x34, 0xea, 0xab, 0x50, 0xa6, 0x7c, 0xd9, 0x3f, 0x5f, 0x4c, 0x48, 0xb4, 0xc9, 0x51, 0xc5, - 0x41, 0x95, 0x6e, 0x9a, 0xd8, 0x78, 0xd9, 0x3b, 0xcd, 0x3e, 0x57, 0xf9, 0x7e, 0xd1, 0xd0, 0x9a, - 0x9b, 0xec, 0x02, 0xcc, 0x04, 0xf5, 0xb8, 0x6f, 0x2f, 0xd9, 0x00, 0xe8, 0x7b, 0x0c, 0xe2, 0xdf, - 0x93, 0xde, 0x9a, 0xc4, 0x6e, 0x2c, 0xac, 0x77, 0x09, 0x60, 0xd6, 0x79, 0x4a, 0x87, 0xaa, 0x4b, - 0x06, 0x86, 0xb3, 0xab, 0xa4, 0x26, 0xb7, 0x9d, 0xc4, 0xca, 0xde, 0xa6, 0x9a, 0xff, 0x53, 0x7d, - 0x41, 0xe3, 0x29, 0x71, 0xbf, 0x01, 0xc8, 0xb3, 0xdd, 0x02, 0x10, 0x13, 0x77, 0xd3, 0xa7, 0x84, - 0x12, 0xa6, 0x4d, 0xc0, 0x02, 0x18, 0xe1, 0x71, 0x5a, 0xd8, 0xe1, 0xb9, 0xc2, 0xe3, 0x6f, 0x00, - 0x59, 0xc4, 0x3a, 0xfb, 0x75, 0x22, 0x3e, 0x6d, 0x82, 0x55, 0x80, 0x0a, 0x8f, 0x53, 0xe5, 0x09, - 0x51, 0x25, 0xa2, 0xeb, 0xf7, 0x38, 0x8c, 0x22, 0xee, 0xf3, 0xea, 0x38, 0xc2, 0x0e, 0x23, 0x6e, - 0x8b, 0x0b, 0x1f, 0xc7, 0xe2, 0x55, 0xd3, 0x51, 0x81, 0x8b, 0x12, 0x44, 0x45, 0x91, 0x71, 0x3b, - 0x69, 0xf7, 0xb6, 0x20, 0x9e, 0x15, 0x43, 0x4f, 0x82, 0x9a, 0x4d, 0x92, 0xc7, 0xab, 0x42, 0xa0, - 0xff, 0xc6, 0xbb, 0xf1, 0x4b, 0x72, 0xcd, 0xe7, 0x6e, 0xa0, 0x21, 0x45, 0xd2, 0xe9, 0xd3, 0x2f, - 0x45, 0xd2, 0xe9, 0x3b, 0x84, 0x78, 0xd5, 0x69, 0x7f, 0x62, 0xdd, 0xf7, 0xb7, 0x2e, 0xc9, 0xb2, - 0x7f, 0x40, 0xca, 0xee, 0x92, 0x39, 0x1e, 0xaf, 0x39, 0x9d, 0x05, 0xba, 0x0d, 0xbc, 0x70, 0x2a, - 0x9b, 0xf2, 0x3f, 0x62, 0xe8, 0x19, 0xb2, 0x8d, 0x0b, 0x1c, 0xdc, 0x90, 0x0b, 0xd7, 0x35, 0x0d, - 0x5e, 0x96, 0xe3, 0xad, 0xa0, 0xb9, 0x78, 0xea, 0xc8, 0x75, 0x4d, 0xdd, 0xff, 0x2d, 0x85, 0x7d, - 0xd6, 0xf9, 0x43, 0xc2, 0x9b, 0xc9, 0xfb, 0x4b, 0xfe, 0x77, 0xfe, 0xd4, 0xd5, 0xdf, 0x48, 0x89, - 0xa0, 0x61, 0xd3, 0x92, 0x91, 0x8a, 0xe2, 0xaf, 0x8a, 0x61, 0x5f, 0x2b, 0xfe, 0x8a, 0x56, 0x52, - 0x9d, 0x70, 0x2b, 0xfc, 0x39, 0xe4, 0xef, 0x8b, 0xae, 0xbf, 0x1f, 0x84, 0xfc, 0xdd, 0x36, 0x6c, - 0x3a, 0x1f, 0xee, 0x10, 0x5f, 0x9d, 0xf3, 0x61, 0x1a, 0x43, 0x86, 0xed, 0x0f, 0x23, 0xd8, 0x53, - 0xcd, 0xb8, 0x02, 0x17, 0xff, 0x7a, 0xbe, 0x51, 0x89, 0x33, 0x17, 0xde, 0xd0, 0xf4, 0x73, 0xeb, - 0x68, 0x1d, 0x60, 0x3e, 0x53, 0xe8, 0xe1, 0x91, 0x8d, 0x3f, 0x0e, 0xc1, 0x39, 0xe4, 0x00, 0x08, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_Important_Circle_64px = { 64, 64, NBGL_BPP_4, true, C_Important_Circle_64px_bitmap }; - -uint8_t const C_Review_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0xd3, 0x00, 0x00, 0xd1, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xed, 0xd5, 0x3b, 0x0e, 0xc2, 0x30, 0x0c, 0x06, 0x60, 0xab, 0xea, 0x90, - 0x8d, 0x2b, 0xf4, 0x04, 0x39, 0x07, 0xc7, 0xe0, 0x28, 0x11, 0x62, 0xc8, 0x04, 0x77, 0x64, 0xea, - 0xd6, 0x95, 0xa9, 0xc1, 0x29, 0x24, 0xa6, 0xf8, 0x01, 0x43, 0x87, 0x0e, 0xf1, 0x52, 0xa1, 0xaf, - 0xb8, 0x4e, 0xa5, 0xfe, 0x4e, 0x69, 0x93, 0x9a, 0xa3, 0x50, 0x13, 0xf9, 0x1d, 0x84, 0xf2, 0xf4, - 0xf7, 0x41, 0xf2, 0xae, 0x36, 0x78, 0x00, 0x98, 0x0d, 0x14, 0xaf, 0x0d, 0xd0, 0x8f, 0x6c, 0xbc, - 0x81, 0x1a, 0xa0, 0xdf, 0xd8, 0x99, 0x70, 0x66, 0x87, 0x97, 0x11, 0x6f, 0xbd, 0x48, 0x8e, 0x43, - 0x3b, 0x1a, 0x9d, 0x7b, 0x0a, 0xd9, 0xcb, 0xc9, 0x35, 0x0f, 0xff, 0xfb, 0xf2, 0x1b, 0xe0, 0xf0, - 0xe5, 0x7d, 0x99, 0x4f, 0x71, 0x57, 0xce, 0xd7, 0xbc, 0x79, 0x73, 0xdd, 0x95, 0xef, 0x6f, 0x1f, - 0xce, 0xf2, 0xeb, 0xba, 0x76, 0x21, 0xfc, 0x6c, 0x07, 0x4f, 0x2e, 0xe6, 0x6f, 0x77, 0xaa, 0x2e, - 0xe7, 0x37, 0x90, 0xf3, 0xfc, 0x3f, 0xaf, 0x3c, 0x49, 0xe9, 0x69, 0xfa, 0xf2, 0x48, 0xcb, 0x73, - 0x03, 0xcb, 0xdf, 0xf9, 0xfd, 0xdb, 0xfb, 0x28, 0xd7, 0x6b, 0x3f, 0x04, 0xd0, 0x2b, 0xef, 0x17, - 0xcb, 0xbd, 0xfe, 0xe6, 0xea, 0x7a, 0x92, 0x57, 0xdf, 0xc7, 0x7a, 0x1b, 0xa3, 0x56, 0xd3, 0x06, - 0x8b, 0xfb, 0x09, 0xaa, 0x24, 0xa5, 0x2a, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Review_64px = { 64, 64, NBGL_BPP_4, true, C_Review_64px_bitmap }; - -uint8_t const C_SecurityShield_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x5a, 0x02, 0x00, 0x58, 0x02, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xad, 0x95, 0xbf, 0x53, 0x13, 0x41, 0x14, 0xc7, 0xbf, 0x97, 0x1c, 0xbf, - 0x14, 0xf1, 0x2a, 0x3a, 0xf0, 0x26, 0xb6, 0x8e, 0xc6, 0x86, 0x52, 0xd3, 0xd0, 0xd0, 0xc0, 0x7f, - 0x00, 0xa2, 0x85, 0x9d, 0x69, 0x1d, 0x2d, 0x62, 0xc1, 0x4c, 0xba, 0x60, 0x6d, 0x01, 0x63, 0x63, - 0xe3, 0x8c, 0xb4, 0x56, 0xde, 0x28, 0x43, 0xc3, 0x00, 0xf6, 0x16, 0x41, 0x0a, 0xad, 0x0c, 0xc2, - 0x80, 0x06, 0x48, 0x38, 0xf7, 0xed, 0xde, 0xed, 0xef, 0x8b, 0x33, 0x8e, 0xdb, 0x24, 0xbb, 0x9f, - 0xbd, 0xb7, 0xef, 0x7d, 0xdf, 0xbe, 0xb7, 0x69, 0xfa, 0x3f, 0x46, 0xef, 0xcd, 0xa3, 0x4a, 0xe5, - 0xe6, 0xec, 0xd3, 0x3d, 0x3f, 0x7e, 0x81, 0x7c, 0xcc, 0x7c, 0xf0, 0xe0, 0x4b, 0x68, 0x63, 0xce, - 0xe5, 0xa7, 0x3a, 0xc7, 0xf0, 0xa1, 0xcd, 0xd7, 0x0d, 0x8e, 0xd0, 0xf6, 0x22, 0x46, 0xf0, 0xf8, - 0x6d, 0xa7, 0xf3, 0x63, 0x7b, 0xa5, 0xea, 0xb3, 0x70, 0x0e, 0x5c, 0xc9, 0xff, 0x6f, 0xc5, 0xb4, - 0x61, 0xd4, 0xe0, 0xc7, 0xc0, 0xbc, 0x9c, 0xf4, 0x97, 0x69, 0xc3, 0x2d, 0xeb, 0x78, 0xdd, 0xe0, - 0x6b, 0xda, 0xd0, 0xd2, 0x16, 0x6a, 0x18, 0x32, 0xec, 0xd1, 0x86, 0xb2, 0xfa, 0xa2, 0x0f, 0x8c, - 0x9b, 0xfe, 0x36, 0xd8, 0x86, 0xdb, 0x72, 0xf6, 0x0b, 0xb8, 0x6f, 0xe9, 0x55, 0x03, 0x4a, 0x6d, - 0xcd, 0xbd, 0x77, 0x56, 0xc0, 0x5d, 0x66, 0x60, 0x2a, 0x9f, 0x6c, 0x20, 0x70, 0x14, 0xfd, 0x08, - 0x04, 0xb9, 0x81, 0x25, 0x0c, 0xbb, 0x19, 0x61, 0x32, 0x4c, 0x4b, 0xf5, 0xae, 0xba, 0x29, 0x39, - 0x60, 0x1e, 0x88, 0x10, 0x7a, 0xc0, 0x0d, 0x75, 0x2a, 0x72, 0xf9, 0xaa, 0xb9, 0x68, 0x67, 0xc0, - 0xa2, 0x0a, 0x4b, 0x8c, 0x16, 0x37, 0x30, 0xc2, 0x57, 0x4f, 0x80, 0x35, 0xc1, 0x55, 0x06, 0xaf, - 0x0b, 0x0f, 0x78, 0x1e, 0x8f, 0x80, 0xb6, 0x87, 0xa7, 0x09, 0x70, 0x87, 0x56, 0x3f, 0xcb, 0xf0, - 0x00, 0xf1, 0xfb, 0x93, 0xf3, 0xb3, 0xec, 0x80, 0x04, 0x21, 0xe5, 0xb8, 0xd9, 0x6c, 0x9a, 0x9c, - 0xa5, 0x85, 0x1b, 0x5e, 0xe5, 0xdb, 0x84, 0x6f, 0x06, 0xff, 0x2a, 0x22, 0xa8, 0x63, 0x8c, 0x5f, - 0x11, 0x87, 0x77, 0x45, 0xde, 0x6a, 0x24, 0x4f, 0xd7, 0xc3, 0x99, 0x70, 0x21, 0xe7, 0xe3, 0xc4, - 0x43, 0xe7, 0x7c, 0x96, 0x18, 0x8a, 0x30, 0xc6, 0x04, 0xf1, 0x51, 0xdb, 0x7f, 0xae, 0xcc, 0x93, - 0x34, 0x8d, 0x68, 0x96, 0xf3, 0xfe, 0x8e, 0xc6, 0xcf, 0xb9, 0xf2, 0xd0, 0xf9, 0x7a, 0x79, 0x47, - 0x71, 0xf6, 0xe9, 0x98, 0xc5, 0x1b, 0xe4, 0x92, 0xe4, 0x7c, 0x36, 0x80, 0xd7, 0x1d, 0x6e, 0xda, - 0x8f, 0xa9, 0x6e, 0x0c, 0xff, 0x7a, 0x96, 0x7f, 0x13, 0x7f, 0x8f, 0xaf, 0x8a, 0x6b, 0x05, 0xfa, - 0x24, 0x5c, 0x9f, 0x05, 0x3a, 0xc4, 0xab, 0x6f, 0x15, 0x25, 0x7e, 0x7d, 0x0b, 0xf2, 0x93, 0x95, - 0xf5, 0x2a, 0xbf, 0xde, 0x9e, 0xfc, 0x1e, 0x8b, 0x0b, 0xb4, 0x81, 0xb2, 0xff, 0x7e, 0xd4, 0x45, - 0x5d, 0xed, 0x17, 0xdc, 0xaf, 0x0b, 0x88, 0xba, 0x29, 0xba, 0x9f, 0x07, 0x59, 0x05, 0x9d, 0xfa, - 0xef, 0x37, 0x15, 0xc8, 0x5a, 0x56, 0x1f, 0xf3, 0x9e, 0xfa, 0x60, 0x55, 0x3f, 0x34, 0xa8, 0xbe, - 0x1a, 0xb2, 0x45, 0x44, 0x76, 0xfb, 0xc8, 0xf7, 0xb6, 0x8b, 0xeb, 0x9b, 0x2d, 0x92, 0x6c, 0x99, - 0xcc, 0x6e, 0x7f, 0x38, 0xd1, 0x5a, 0xd8, 0x91, 0x0c, 0x40, 0xb5, 0xac, 0x58, 0xeb, 0x91, 0xbf, - 0xf5, 0xf6, 0xa8, 0x22, 0x91, 0x1d, 0xb0, 0xe7, 0xf4, 0xb7, 0x4f, 0x50, 0xa7, 0xf3, 0x0a, 0x09, - 0x0d, 0xfc, 0x8d, 0xe1, 0x40, 0xeb, 0xe1, 0x49, 0xd6, 0x09, 0xb2, 0xf1, 0x3d, 0x62, 0xfc, 0x5e, - 0x51, 0x7f, 0x4e, 0x37, 0x49, 0xa1, 0x11, 0xab, 0xbf, 0x4b, 0x07, 0x2e, 0x1e, 0x10, 0x2e, 0xef, - 0x59, 0xef, 0x43, 0xe9, 0xd9, 0x2e, 0x75, 0xbd, 0xf7, 0x0f, 0xb9, 0xbe, 0x81, 0x15, 0x6f, 0xc2, - 0x57, 0x2b, 0x51, 0x26, 0x7f, 0xd0, 0xf2, 0xa8, 0xa5, 0x86, 0x83, 0xd3, 0xcb, 0x48, 0xc3, 0x93, - 0x9e, 0x37, 0xf2, 0xa5, 0xa4, 0xa5, 0xe7, 0xde, 0x07, 0xf4, 0xcb, 0xca, 0x5d, 0x82, 0x33, 0xaf, - 0x06, 0xbc, 0xc1, 0x9d, 0xc3, 0x7f, 0x79, 0xb9, 0xff, 0x00, 0xb6, 0x83, 0x9c, 0x31, 0x00, 0x08, - 0x00, 0x00, -}; -const nbgl_icon_details_t C_SecurityShield_64px = { 64, 64, NBGL_BPP_4, true, C_SecurityShield_64px_bitmap }; - -uint8_t const C_Warning_64px_bitmap[] = { - 0x40, 0x00, 0x40, 0x00, 0x21, 0x5f, 0x01, 0x00, 0x5d, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x85, 0xd5, 0x31, 0x4e, 0xc3, 0x40, 0x10, 0x05, 0xd0, 0x8d, 0x85, 0x08, - 0x4a, 0x45, 0x49, 0x91, 0xc2, 0x25, 0xb2, 0x52, 0xe4, 0x08, 0x39, 0x40, 0xc4, 0x19, 0x72, 0x82, - 0x5c, 0x81, 0x84, 0x03, 0x80, 0xb8, 0x41, 0xc4, 0x05, 0x72, 0x04, 0x0a, 0xd2, 0xe7, 0x08, 0x69, - 0x02, 0xa2, 0x0b, 0xa5, 0x13, 0xa1, 0x1d, 0xec, 0x99, 0x5d, 0xb3, 0xf6, 0xee, 0x1f, 0x6f, 0xfb, - 0xc6, 0x96, 0xbc, 0xfe, 0x33, 0x43, 0x84, 0x4f, 0xb9, 0x27, 0xed, 0x5c, 0xf2, 0xeb, 0x93, 0xc2, - 0xbf, 0x53, 0x63, 0x26, 0x0a, 0xcf, 0x8c, 0x31, 0x23, 0x9d, 0xb1, 0x5b, 0x66, 0xe8, 0x76, 0x51, - 0xe1, 0x60, 0x06, 0x7d, 0x5d, 0x3f, 0xfc, 0xb8, 0x41, 0xce, 0xbc, 0x24, 0xe4, 0xcc, 0x73, 0x42, - 0xfe, 0xea, 0x18, 0xf8, 0x9b, 0xe7, 0xb4, 0xef, 0x6a, 0x96, 0x7b, 0x4b, 0x39, 0x73, 0x41, 0xc8, - 0x99, 0xef, 0x08, 0xf9, 0x31, 0xe4, 0xd8, 0xbf, 0x5a, 0x1c, 0x79, 0x79, 0x5b, 0xf1, 0x90, 0x90, - 0x33, 0x87, 0x91, 0x68, 0x3b, 0xf3, 0x55, 0x18, 0xa9, 0x96, 0x9f, 0x23, 0x6e, 0xf9, 0x25, 0x8f, - 0x38, 0x74, 0x8e, 0x4b, 0xd6, 0xc9, 0xeb, 0xbf, 0x0b, 0x6f, 0x09, 0x38, 0xf3, 0xe0, 0x85, 0x80, - 0xdb, 0x34, 0x7b, 0x97, 0xb0, 0xc5, 0xec, 0x5d, 0xc2, 0x46, 0xc8, 0x5d, 0xd8, 0x90, 0xaf, 0x9b, - 0xb8, 0x94, 0xc6, 0x9f, 0x1b, 0xfa, 0x31, 0x46, 0xdc, 0x36, 0x8c, 0x7d, 0x4e, 0xba, 0x17, 0x3d, - 0xae, 0xbd, 0x5f, 0xe2, 0xbc, 0xc4, 0x6e, 0x9f, 0xf4, 0xef, 0x93, 0xeb, 0x4b, 0x16, 0x84, 0xf7, - 0x9b, 0x2a, 0x68, 0xfe, 0x4f, 0x5d, 0x90, 0x3d, 0x43, 0x77, 0x05, 0x5b, 0xe8, 0x7d, 0xf9, 0x70, - 0xf1, 0xeb, 0x16, 0x44, 0xf9, 0xcc, 0xde, 0xa1, 0xbb, 0x00, 0x1f, 0xa0, 0xd3, 0x39, 0xef, 0xb4, - 0x4f, 0xb7, 0xbf, 0xbe, 0xf5, 0xfe, 0x72, 0xed, 0x1b, 0x14, 0xa4, 0xfb, 0x7b, 0x78, 0x82, 0x2e, - 0x05, 0xf7, 0xd8, 0xe9, 0x33, 0x18, 0x3f, 0xc9, 0xf9, 0xf4, 0xa1, 0xcf, 0x27, 0x97, 0x97, 0x02, - 0xbb, 0x14, 0x4c, 0xb0, 0x4b, 0xc1, 0x03, 0x76, 0xf2, 0x89, 0x43, 0x6e, 0x57, 0xfa, 0x7c, 0xf7, - 0x89, 0xdb, 0xe8, 0xfb, 0xc5, 0x4c, 0x95, 0xfd, 0xb4, 0x50, 0xf7, 0x93, 0x5f, 0x60, 0x23, 0x65, - 0x3f, 0xe6, 0xba, 0x73, 0xa0, 0xc6, 0x3d, 0xfb, 0x99, 0xf4, 0x05, 0x5e, 0xcd, 0xcb, 0x3f, 0xe4, - 0x2a, 0x7b, 0x24, 0x00, 0x08, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Warning_64px = { 64, 64, NBGL_BPP_4, true, C_Warning_64px_bitmap }; - -uint8_t const C_left_half_64px_bitmap[] = { - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, - 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, - 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, - 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, - 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, - 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_left_half_64px = { 24, 64, NBGL_BPP_1, false, C_left_half_64px_bitmap }; - -uint8_t const C_Back_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x85, 0x00, 0x00, 0x83, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x1f, 0x0c, 0xde, 0x9c, 0xfb, 0x8f, 0x02, 0x1a, 0x38, 0x46, - 0xf9, 0x50, 0xb0, 0xf0, 0x3e, 0x8c, 0xff, 0x57, 0x0a, 0x48, 0xfc, 0x66, 0x90, 0x85, 0xf1, 0x2f, - 0x32, 0xac, 0xff, 0xff, 0xff, 0x9f, 0x02, 0xe3, 0x7d, 0x08, 0xff, 0xaf, 0x00, 0xd3, 0x7b, 0xa0, - 0xe8, 0x23, 0x90, 0x02, 0x10, 0xff, 0x22, 0x83, 0x1e, 0x48, 0x3f, 0x58, 0x01, 0x90, 0x0f, 0x95, - 0x86, 0x28, 0x00, 0xf2, 0xa1, 0xd2, 0x10, 0x05, 0x0d, 0x1c, 0x70, 0x69, 0xb0, 0x82, 0x06, 0x0e, - 0xb8, 0x34, 0x58, 0x41, 0x00, 0x2b, 0x42, 0x1a, 0xa4, 0x00, 0x08, 0xf4, 0x10, 0xae, 0xfd, 0xa7, - 0xc0, 0xc0, 0x80, 0x24, 0x0d, 0x56, 0xa0, 0x87, 0xec, 0x9d, 0x7f, 0x0a, 0x28, 0xd2, 0xff, 0xff, - 0xbf, 0xe8, 0x83, 0x32, 0x00, 0x80, 0x9b, 0xa4, 0x4d, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Back_32px = { 32, 32, NBGL_BPP_4, true, C_Back_32px_bitmap }; - -uint8_t const C_Check_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x02, 0x42, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0x32, 0xf0, 0xe4, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, - 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc6, 0xf0, 0xc5, 0xf0, 0xc5, 0xf0, 0xb6, - 0xf0, 0xa6, 0xf0, 0xa6, 0xf0, 0xa6, 0xf0, 0xa6, 0xf0, 0xa6, 0xf0, 0xb5, 0xf0, 0xd3, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xa0, -}; -const nbgl_icon_details_t C_Check_32px = { 32, 32, NBGL_BPP_1, true, C_Check_32px_bitmap }; - -uint8_t const C_Check_Circle_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x16, 0x01, 0x00, 0x14, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x6d, 0x91, 0x3d, 0x4e, 0xc3, 0x40, 0x10, 0x85, 0xdf, 0x2e, 0x48, 0x44, - 0x16, 0x52, 0xf6, 0x06, 0xf6, 0x09, 0x48, 0x3a, 0xca, 0x94, 0x94, 0x70, 0x13, 0x90, 0xa0, 0x44, - 0x0a, 0x15, 0x55, 0x94, 0x1c, 0x21, 0xb9, 0x41, 0x8e, 0x60, 0x3a, 0xe8, 0x7c, 0x07, 0x2a, 0xba, - 0x60, 0x12, 0xc5, 0x26, 0xb1, 0x32, 0xcc, 0xcf, 0xda, 0x42, 0x4a, 0xb6, 0x59, 0x7d, 0x33, 0x6f, - 0xe7, 0xe7, 0x2d, 0xd1, 0x89, 0xd3, 0x3c, 0x06, 0x77, 0x93, 0x77, 0x58, 0x07, 0xf0, 0xf1, 0xd3, - 0x88, 0xbf, 0x8a, 0x1c, 0x58, 0x1a, 0x3f, 0xc0, 0x4d, 0x56, 0xf4, 0x9e, 0xe1, 0x42, 0x71, 0x0b, - 0x5f, 0xc8, 0xbd, 0xcb, 0x70, 0x6f, 0xe9, 0xb1, 0xe9, 0x2a, 0x15, 0xec, 0xd0, 0x6b, 0xeb, 0xbe, - 0x60, 0x4e, 0xf4, 0x29, 0xe9, 0xd7, 0x28, 0x48, 0x39, 0xe8, 0xb9, 0xa1, 0xbd, 0xa4, 0x8c, 0xa5, - 0x59, 0x22, 0x7c, 0xae, 0xfc, 0xe6, 0x68, 0x8f, 0x81, 0xbe, 0x1c, 0x09, 0x97, 0x28, 0x2a, 0xad, - 0x5e, 0xe3, 0x4c, 0x07, 0xc5, 0x78, 0x83, 0x82, 0x3a, 0x41, 0x83, 0x51, 0x09, 0x5b, 0x41, 0x05, - 0x07, 0xa4, 0xdf, 0x68, 0x7b, 0x8b, 0x00, 0xfd, 0x96, 0x6b, 0x1d, 0x0b, 0xfd, 0x12, 0x2b, 0x0b, - 0x04, 0xe5, 0x74, 0x6d, 0xf5, 0x68, 0x8d, 0x44, 0xea, 0xdd, 0x56, 0x98, 0x29, 0x0f, 0xe5, 0xe6, - 0xe6, 0x8d, 0xcc, 0x2c, 0x69, 0x91, 0xff, 0x20, 0xa7, 0x70, 0x29, 0x7c, 0xa7, 0xb2, 0x85, 0xb7, - 0x7d, 0x38, 0x9f, 0xb4, 0xfb, 0x94, 0x66, 0x47, 0xae, 0xfb, 0x5e, 0xb1, 0x9b, 0xff, 0xfd, 0x58, - 0x1e, 0xfb, 0x25, 0x7e, 0xaa, 0xd1, 0x4d, 0xf4, 0x93, 0x05, 0xfe, 0x99, 0x0e, 0x1f, 0x21, 0xfa, - 0x2d, 0x46, 0xeb, 0x71, 0xf3, 0x58, 0xe7, 0x4b, 0x03, 0x6e, 0xd6, 0x7d, 0xe0, 0xfe, 0x29, 0xb8, - 0xeb, 0xe2, 0xd4, 0x4f, 0xd3, 0x1f, 0x10, 0xc6, 0xaf, 0x18, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Check_Circle_32px = { 32, 32, NBGL_BPP_4, true, C_Check_Circle_32px_bitmap }; - -uint8_t const C_Chevron_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x22, 0x50, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcd, 0x0a, 0x14, - 0x0a, 0xda, 0x0a, 0x30, 0x0a, 0xd8, 0x0a, 0x50, 0x0a, 0xd6, 0x0a, 0x20, 0x12, 0x20, 0x0a, 0xd4, - 0x0a, 0x20, 0x02, 0x1e, 0x02, 0x20, 0x0a, 0xd2, 0x0a, 0x20, 0x02, 0x0e, 0xc1, 0x0e, 0x02, 0x20, - 0x0a, 0xd0, 0x0a, 0x20, 0x02, 0x0e, 0xc3, 0x0e, 0x02, 0x20, 0x0a, 0xcf, 0x02, 0x10, 0x02, 0x0e, - 0xc5, 0x0e, 0x02, 0x10, 0x02, 0xcf, 0x0e, 0x12, 0x0e, 0xc7, 0x0e, 0x12, 0x0e, 0xd0, 0x1e, 0xc9, - 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc8, -}; -const nbgl_icon_details_t C_Chevron_32px = { 32, 32, NBGL_BPP_4, true, C_Chevron_32px_bitmap }; - -uint8_t const C_Chevron_Back_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x69, 0x00, 0x00, 0x67, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x7f, 0xb0, 0x83, 0x27, 0xef, 0x61, 0xac, 0x7f, 0x7e, 0x20, - 0x42, 0x41, 0x0f, 0xc6, 0x7f, 0xc4, 0x04, 0x94, 0xfa, 0x2b, 0xc0, 0x04, 0x55, 0xf0, 0x4f, 0x81, - 0xf1, 0x3e, 0x90, 0xba, 0xc8, 0x00, 0x55, 0xf0, 0x88, 0x41, 0x16, 0x44, 0xc1, 0x14, 0x40, 0xa5, - 0xe1, 0x0a, 0xa0, 0xd2, 0x30, 0x05, 0x70, 0x69, 0xa8, 0x02, 0xb8, 0x34, 0x44, 0x01, 0x92, 0x34, - 0x58, 0x01, 0x92, 0x34, 0x58, 0x01, 0xb2, 0x34, 0x48, 0x01, 0xb2, 0x34, 0x48, 0x01, 0x8a, 0xf4, - 0xff, 0xff, 0xd7, 0x72, 0x07, 0x49, 0xe8, 0x02, 0x00, 0x69, 0xf0, 0x4c, 0x8b, 0x00, 0x02, 0x00, - 0x00, -}; -const nbgl_icon_details_t C_Chevron_Back_32px = { 32, 32, NBGL_BPP_4, true, C_Chevron_Back_32px_bitmap }; - -uint8_t const C_Chevron_Next_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x69, 0x00, 0x00, 0x67, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x7f, 0x50, 0x80, 0x6b, 0xb9, 0x28, 0xdc, 0xbf, 0x02, 0x8c, - 0xf7, 0x91, 0xf9, 0x17, 0x19, 0x18, 0x64, 0x51, 0xa4, 0x99, 0x14, 0x90, 0x15, 0x5c, 0x64, 0xd0, - 0x7b, 0x84, 0xa4, 0x00, 0x28, 0xfd, 0xfe, 0x1f, 0x92, 0x02, 0xa0, 0xf4, 0xff, 0xff, 0x08, 0x05, - 0x20, 0xe9, 0xff, 0xff, 0x11, 0x0a, 0xc0, 0xd2, 0x08, 0x05, 0x10, 0x69, 0x84, 0x02, 0xa8, 0x34, - 0x4c, 0x01, 0x4c, 0x1a, 0xa6, 0xe0, 0x9f, 0x82, 0x1e, 0xcc, 0x9e, 0x47, 0x60, 0x99, 0x27, 0xef, - 0x61, 0xfc, 0x7f, 0x7e, 0xff, 0x07, 0x3d, 0x00, 0x00, 0xb4, 0x0a, 0xa5, 0xcb, 0x00, 0x02, 0x00, - 0x00, -}; -const nbgl_icon_details_t C_Chevron_Next_32px = { 32, 32, NBGL_BPP_4, true, C_Chevron_Next_32px_bitmap }; - -uint8_t const C_Close_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x68, 0x00, 0x00, 0x66, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x9f, 0xea, 0x60, 0x05, 0x8c, 0xd1, 0x05, 0x26, 0x7f, 0x31, - 0xf4, 0x43, 0xb8, 0x3f, 0x18, 0xd6, 0x43, 0x28, 0x0e, 0x08, 0xbf, 0x01, 0x2a, 0x01, 0xa5, 0xe1, - 0xe2, 0x50, 0x06, 0x4c, 0x1a, 0xca, 0x82, 0x4b, 0x43, 0x99, 0x08, 0x69, 0x30, 0x1b, 0x49, 0x1a, - 0xac, 0x00, 0x59, 0x1a, 0xa4, 0x00, 0x59, 0x1a, 0xa4, 0x00, 0x45, 0x1a, 0x83, 0x8f, 0xa6, 0x1e, - 0xdd, 0x3c, 0x34, 0xfb, 0xd0, 0xdd, 0x83, 0xe6, 0x5e, 0x74, 0xff, 0xa0, 0xf9, 0x17, 0x3d, 0x3c, - 0xd0, 0xc3, 0x0b, 0x3d, 0x3c, 0xa9, 0x0b, 0x00, 0x26, 0xb1, 0x3a, 0x4e, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Close_32px = { 32, 32, NBGL_BPP_4, true, C_Close_32px_bitmap }; - -uint8_t const C_Denied_Circle_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x10, 0x01, 0x00, 0x0e, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x6d, 0x51, 0x31, 0x4e, 0xc3, 0x40, 0x10, 0x9c, 0x3b, 0x0a, 0x22, 0x14, - 0x89, 0xfb, 0x81, 0xfd, 0x02, 0xa0, 0xa3, 0x4c, 0x49, 0xc9, 0x53, 0x40, 0x82, 0x12, 0x29, 0x79, - 0x00, 0xc2, 0x4f, 0x30, 0x3f, 0xf0, 0x13, 0x42, 0x07, 0x9d, 0xff, 0x40, 0x45, 0x17, 0x0c, 0x08, - 0x3b, 0x8e, 0x95, 0x61, 0xf7, 0xd6, 0x4e, 0x08, 0xe4, 0x9a, 0xd5, 0xec, 0xce, 0xce, 0xee, 0xce, - 0x91, 0x7b, 0x5e, 0x77, 0x13, 0xdc, 0xc5, 0x7c, 0x03, 0x9b, 0x00, 0x79, 0xfe, 0xa1, 0x87, 0xcb, - 0x08, 0x25, 0x51, 0x18, 0xbe, 0x86, 0xbb, 0x5f, 0xf0, 0x39, 0xc5, 0x61, 0x84, 0xdf, 0xf0, 0xa5, - 0xc6, 0x36, 0xc5, 0x95, 0x95, 0xa7, 0xc6, 0xab, 0x23, 0xa1, 0xc5, 0x68, 0xd0, 0x9d, 0x21, 0x27, - 0x5f, 0x87, 0xb2, 0x12, 0x12, 0x49, 0x7a, 0x99, 0xa0, 0x48, 0xd4, 0x53, 0xa1, 0xa6, 0x47, 0xe4, - 0x59, 0x26, 0x4b, 0x1c, 0x90, 0x4f, 0x8e, 0x2b, 0x9c, 0x9a, 0x84, 0x36, 0x57, 0x28, 0x6b, 0x6d, - 0x9f, 0x21, 0x6b, 0x34, 0xd7, 0x60, 0xfa, 0x85, 0x52, 0xe3, 0x48, 0x52, 0x72, 0x07, 0x26, 0x15, - 0x6c, 0x52, 0x9c, 0xba, 0x46, 0xf2, 0x1e, 0x71, 0x03, 0x2d, 0x93, 0x38, 0xfe, 0x8b, 0x2b, 0x2c, - 0xb6, 0x7c, 0x22, 0xf9, 0xdc, 0xd5, 0xbb, 0xac, 0x35, 0x0e, 0xf3, 0x64, 0x78, 0x27, 0x3b, 0x2f, - 0x6d, 0x9f, 0x82, 0x1f, 0x98, 0x33, 0x8c, 0xb7, 0xfb, 0x3e, 0x7a, 0xbb, 0xa7, 0x55, 0xad, 0xdc, - 0xee, 0xa9, 0x7e, 0xdf, 0x7b, 0x42, 0x6b, 0x1e, 0xfc, 0x28, 0xfe, 0xfb, 0xa5, 0x7e, 0x46, 0xa3, - 0xbb, 0xde, 0x4f, 0x21, 0xf8, 0x3b, 0xae, 0x5f, 0x42, 0xef, 0xb7, 0x1a, 0x1d, 0x9f, 0xcb, 0x7b, - 0x9d, 0xb7, 0x98, 0x70, 0xd9, 0xe6, 0x03, 0x57, 0xb7, 0xc1, 0x9d, 0x97, 0xfb, 0x7e, 0x9a, 0x3f, - 0xba, 0x87, 0x04, 0xa2, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Denied_Circle_32px = { 32, 32, NBGL_BPP_4, true, C_Denied_Circle_32px_bitmap }; - -uint8_t const C_Erase_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x02, 0x48, 0x00, 0x00, 0xf0, 0xf0, 0xaf, 0x01, 0xff, 0x03, 0xef, 0x03, - 0xef, 0x03, 0xef, 0x03, 0xef, 0x03, 0xe5, 0x16, 0x15, 0xe4, 0x34, 0x34, 0xe5, 0x32, 0x35, 0xe6, - 0x66, 0xe7, 0x47, 0xe7, 0x47, 0xe6, 0x66, 0xe5, 0x32, 0x35, 0xe4, 0x34, 0x34, 0xe5, 0x16, 0x15, - 0xef, 0x03, 0xef, 0x03, 0xef, 0x03, 0xef, 0x03, 0xef, 0x03, 0xef, 0x03, 0xff, 0x01, 0xf0, 0x2e, - 0xf0, 0x4c, 0xf0, 0x6a, 0xf0, 0x88, 0xf0, 0xa6, 0xf0, 0xc4, 0xf0, 0xe2, 0xf0, 0xf0, 0xf0, 0x20, -}; -const nbgl_icon_details_t C_Erase_32px = { 32, 32, NBGL_BPP_1, true, C_Erase_32px_bitmap }; - -uint8_t const C_Important_Circle_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0xf9, 0x00, 0x00, 0xf7, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x6d, 0x91, 0x3f, 0x12, 0xc1, 0x40, 0x14, 0xc6, 0xbf, 0xdd, 0x86, 0x31, - 0x66, 0xec, 0x0d, 0x92, 0x13, 0x50, 0x2a, 0x95, 0x4a, 0xb7, 0xd0, 0x32, 0x43, 0x69, 0x86, 0x52, - 0x61, 0xe4, 0x08, 0xdc, 0xc0, 0x11, 0xa2, 0xa3, 0xcb, 0x1d, 0x54, 0x3a, 0x82, 0x11, 0x24, 0xe3, - 0x79, 0xbb, 0x49, 0x6c, 0xfc, 0xf9, 0x9a, 0xcc, 0xef, 0xed, 0xb7, 0x2f, 0xef, 0x7d, 0x4b, 0xf4, - 0x47, 0xc9, 0x40, 0x89, 0xb6, 0xff, 0xc6, 0x9b, 0x02, 0x4b, 0xce, 0x33, 0xbc, 0x1b, 0xe4, 0xc2, - 0x2a, 0xe5, 0x3e, 0xc4, 0xec, 0x40, 0x1b, 0x17, 0x25, 0x83, 0x57, 0xc8, 0x40, 0x7f, 0x1f, 0x2e, - 0x7a, 0xe9, 0xf1, 0x38, 0xf5, 0x45, 0xc6, 0xf0, 0x40, 0x39, 0xef, 0x3b, 0xc1, 0x82, 0x68, 0x97, - 0x1f, 0x6b, 0x83, 0xc3, 0x45, 0x69, 0xe7, 0x70, 0xd9, 0xea, 0x56, 0x2c, 0xaf, 0x05, 0xc5, 0x68, - 0x58, 0x0e, 0x11, 0x44, 0xf6, 0x3a, 0x0f, 0x8a, 0xf1, 0x05, 0x41, 0x61, 0x0f, 0xb4, 0x42, 0x10, - 0xc5, 0x5d, 0x96, 0x3f, 0xf5, 0xe8, 0x09, 0xe7, 0x08, 0x6d, 0x63, 0x79, 0xa8, 0x11, 0xa1, 0xf6, - 0xcd, 0x21, 0x0e, 0xd6, 0x4f, 0x70, 0xce, 0x9f, 0xfd, 0x3a, 0x11, 0x3c, 0xcb, 0xfc, 0xf3, 0x44, - 0xcf, 0x9c, 0xeb, 0x04, 0x9f, 0x54, 0xd5, 0xf2, 0x52, 0xfe, 0xee, 0x13, 0x16, 0xf7, 0xad, 0x73, - 0x9a, 0xc5, 0x3c, 0x56, 0xbf, 0x79, 0xe9, 0x3c, 0x4d, 0xd0, 0x49, 0x96, 0x27, 0x1b, 0xe4, 0x88, - 0x9e, 0x5b, 0x95, 0xe5, 0xad, 0x83, 0x36, 0x12, 0x8b, 0xac, 0xcf, 0xde, 0x14, 0x84, 0x1d, 0x34, - 0x1e, 0x2a, 0xd1, 0x0c, 0xfe, 0xbd, 0x34, 0xbd, 0x00, 0xf4, 0xd3, 0x6c, 0x41, 0x00, 0x02, 0x00, - 0x00, -}; -const nbgl_icon_details_t C_Important_Circle_32px = { 32, 32, NBGL_BPP_4, true, C_Important_Circle_32px_bitmap }; - -uint8_t const C_Info_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x22, 0x2d, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc5, - 0x20, 0xc1, 0x70, 0x60, 0x0a, 0xca, 0x20, 0xc1, 0x70, 0x60, 0x0a, 0xca, 0x20, 0xc1, 0x70, 0x60, - 0x0a, 0xca, 0x20, 0xc1, 0x70, 0x60, 0x0a, 0xcf, 0x08, 0x10, 0x08, 0xdc, 0x8a, 0x8c, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xd0, -}; -const nbgl_icon_details_t C_Info_32px = { 32, 32, NBGL_BPP_4, true, C_Info_32px_bitmap }; - -uint8_t const C_Maj_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x01, 0x43, 0x00, 0x00, 0x41, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0xc0, 0x03, 0x98, 0x1b, 0x18, 0x18, 0xd8, 0x81, 0x98, 0x1f, - 0x88, 0xe5, 0x81, 0xd8, 0x1e, 0x88, 0xeb, 0xff, 0x1f, 0x60, 0xf8, 0xff, 0xff, 0x01, 0x23, 0x10, - 0x33, 0x43, 0x31, 0x88, 0x0d, 0x12, 0x03, 0xcb, 0xd9, 0x43, 0xd5, 0xf2, 0x43, 0xf5, 0x82, 0xcc, - 0xc0, 0x03, 0x00, 0x1d, 0xbe, 0x6b, 0xd4, 0x80, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Maj_32px = { 32, 32, NBGL_BPP_1, true, C_Maj_32px_bitmap }; - -uint8_t const C_Maj_Lock_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x01, 0x3f, 0x00, 0x00, 0x3d, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0xc0, 0x03, 0xd8, 0x80, 0x98, 0x1f, 0x88, 0xe5, 0x81, 0xd8, - 0x1e, 0x88, 0xeb, 0x81, 0xf8, 0xff, 0xff, 0x02, 0x46, 0x20, 0x66, 0x06, 0x62, 0x76, 0x28, 0x66, - 0x86, 0x8a, 0x81, 0xe4, 0xc0, 0x6a, 0xec, 0xa1, 0x7a, 0xf8, 0xa1, 0x66, 0xe0, 0x01, 0x00, 0x80, - 0xa1, 0x95, 0x6d, 0x80, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Maj_Lock_32px = { 32, 32, NBGL_BPP_1, true, C_Maj_Lock_32px_bitmap }; - -uint8_t const C_Mini_Push_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x22, 0xb4, 0x00, 0x00, 0xcc, 0x5e, 0xd6, 0x2e, 0xc5, 0x2e, 0xd1, 0x1e, - 0xcb, 0x1e, 0xcd, 0x2e, 0xce, 0x1e, 0xca, 0x1e, 0xd1, 0x1e, 0xc8, 0x1e, 0xd4, 0x0e, 0xc6, 0x1e, - 0xd5, 0x1e, 0xc5, 0x0e, 0xd7, 0x1e, 0xc3, 0x0e, 0xd9, 0x0e, 0xc3, 0x0e, 0xd9, 0x0e, 0xc2, 0x0e, - 0xcc, 0x1d, 0xcc, 0x0e, 0xc1, 0x0e, 0xcb, 0x99, 0x10, 0x60, 0xcb, 0x0e, 0xc1, 0x0e, 0xca, 0x0a, - 0x01, 0x10, 0x01, 0x07, 0xca, 0x0e, 0xc1, 0x0e, 0xc9, 0xb9, 0x10, 0x34, 0x00, 0x01, 0x07, 0xca, - 0x2e, 0xc8, 0xb8, 0x10, 0x3c, 0xe0, 0x95, 0x01, 0x60, 0xc9, 0x2e, 0xc7, 0xa9, 0x10, 0x2c, 0xc1, - 0x0e, 0x04, 0x10, 0x06, 0xc8, 0x2e, 0xc6, 0xaa, 0x10, 0x2b, 0xc3, 0xad, 0x40, 0x17, 0xc7, 0x2e, - 0xc5, 0xaa, 0x10, 0x3c, 0xc5, 0xad, 0x40, 0x18, 0xc6, 0x8e, 0xfe, 0xc5, 0x9c, 0x13, 0xc0, 0xc7, - 0x9e, 0x51, 0x90, 0xc6, 0x8e, 0xfe, 0xc6, 0x0d, 0x0c, 0xc9, 0x0e, 0x0b, 0xc6, 0x0e, 0xc1, 0x0e, - 0xdb, 0x0e, 0xc1, 0x0e, 0xdb, 0x0e, 0xc2, 0x0e, 0xd9, 0x0e, 0xc3, 0x1e, 0xd8, 0x0e, 0xc4, 0x0e, - 0xd7, 0x0e, 0xc6, 0x0e, 0xd5, 0x1e, 0xc6, 0x1e, 0xd3, 0x1e, 0xc8, 0x1e, 0xd1, 0x1e, 0xcb, 0x0e, - 0xcf, 0x1e, 0xcd, 0x1e, 0xcb, 0x1e, 0xd1, 0x7e, 0x3e, 0xd7, 0x4e, 0xcc, -}; -const nbgl_icon_details_t C_Mini_Push_32px = { 32, 32, NBGL_BPP_4, true, C_Mini_Push_32px_bitmap }; - -uint8_t const C_Next_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x81, 0x00, 0x00, 0x7f, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xe5, 0x8e, 0xbb, 0x0d, 0x80, 0x30, 0x0c, 0x05, 0x2d, 0x68, 0xa2, 0x4c, - 0xc1, 0x04, 0x88, 0x11, 0x33, 0x0a, 0x13, 0x90, 0x11, 0xd8, 0x80, 0x21, 0x28, 0x11, 0x12, 0x7d, - 0x0a, 0x1e, 0xb6, 0xf3, 0xc1, 0xcc, 0x80, 0x8b, 0xc8, 0xa7, 0x3b, 0x59, 0x01, 0x74, 0x8e, 0x05, - 0x76, 0xee, 0xa1, 0xbb, 0x2c, 0xef, 0x44, 0xe3, 0x47, 0x13, 0xd9, 0x80, 0xb5, 0x0d, 0x58, 0x4f, - 0xbd, 0x09, 0x76, 0xf2, 0xc1, 0xcd, 0x2d, 0x60, 0x1d, 0x83, 0x4b, 0x2d, 0x60, 0x8d, 0xe0, 0x50, - 0x03, 0xd1, 0xc2, 0x35, 0x10, 0x2d, 0x5c, 0x02, 0xd5, 0xca, 0x39, 0x48, 0xa2, 0x95, 0x39, 0x58, - 0xe5, 0x8d, 0x95, 0x93, 0xd7, 0x7b, 0xa8, 0x8c, 0xf7, 0xcb, 0x99, 0xf1, 0x5b, 0x3e, 0xb7, 0xb2, - 0x3c, 0xa9, 0x70, 0x9b, 0xe5, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Next_32px = { 32, 32, NBGL_BPP_4, true, C_Next_32px_bitmap }; - -uint8_t const C_QRCode_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x87, 0x00, 0x00, 0x85, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x95, 0x8f, 0xc1, 0x0d, 0x80, 0x20, 0x0c, 0x45, 0x7f, 0x5c, 0x80, 0x15, - 0xdc, 0xc0, 0x35, 0xbd, 0x39, 0x9a, 0xa3, 0x40, 0x3c, 0x79, 0x30, 0x96, 0x02, 0x05, 0x4b, 0xb9, - 0x48, 0x43, 0x52, 0x1e, 0xa1, 0xbf, 0xff, 0x13, 0x4d, 0xd6, 0xbb, 0x02, 0x58, 0x7c, 0x00, 0x1c, - 0xf1, 0xa1, 0x0b, 0xa9, 0xb6, 0xc6, 0x21, 0xb3, 0x53, 0xcc, 0x43, 0xe9, 0xc2, 0xaf, 0x69, 0x3e, - 0xe0, 0xd9, 0xcf, 0x8e, 0x6f, 0x1c, 0x23, 0xf3, 0x58, 0x96, 0xa8, 0xff, 0x15, 0x67, 0x3d, 0xc5, - 0x75, 0x9f, 0x37, 0x7e, 0x0a, 0x7f, 0x7e, 0x0b, 0xff, 0xcc, 0x27, 0xad, 0xe9, 0x49, 0xd3, 0xfb, - 0x60, 0xfc, 0x10, 0x75, 0x7e, 0x25, 0x66, 0xcb, 0x23, 0x31, 0x47, 0xb6, 0xff, 0xad, 0x5e, 0xbf, - 0xcf, 0xfa, 0xb1, 0x7e, 0x27, 0x2b, 0x02, 0x01, 0x38, 0xc0, 0x97, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_QRCode_32px = { 32, 32, NBGL_BPP_4, true, C_QRCode_32px_bitmap }; - -uint8_t const C_Settings_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x11, 0x01, 0x00, 0x0f, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0xfb, 0xff, 0x1f, 0x0c, 0xde, 0x9e, 0xfb, 0x8f, 0x0c, 0x7e, 0x31, 0x30, - 0xac, 0x47, 0xe6, 0x3f, 0x64, 0x60, 0x90, 0x43, 0xe6, 0x2b, 0x30, 0x29, 0x30, 0xc1, 0xd8, 0xff, - 0x14, 0x5d, 0xdb, 0x18, 0xe4, 0x1e, 0x32, 0x64, 0x24, 0x2b, 0xbd, 0x07, 0xf1, 0x1f, 0x31, 0x00, - 0xc1, 0xfc, 0x9f, 0x20, 0x52, 0x0f, 0xac, 0x16, 0xc8, 0x60, 0xff, 0xff, 0xbf, 0x00, 0x48, 0x81, - 0xf5, 0x28, 0xf0, 0x9c, 0x2c, 0xf5, 0xff, 0xff, 0xff, 0x4b, 0xfa, 0xea, 0x03, 0x8c, 0x20, 0xbe, - 0x01, 0x37, 0xcc, 0xa4, 0x03, 0x2c, 0x20, 0x32, 0x81, 0x0b, 0xc6, 0x9f, 0xc0, 0x0a, 0x22, 0x1b, - 0x80, 0x9a, 0xff, 0x9f, 0xe8, 0x01, 0x12, 0x05, 0x1c, 0x60, 0x79, 0xb6, 0xff, 0xff, 0x0f, 0x31, - 0x30, 0xe8, 0xfc, 0xff, 0x1f, 0xc0, 0x06, 0xb6, 0x8e, 0xe5, 0xff, 0x1f, 0x90, 0x65, 0xe7, 0xff, - 0x3b, 0x00, 0x2d, 0xfc, 0x25, 0xc0, 0x50, 0xff, 0xff, 0x13, 0x83, 0x78, 0x11, 0x83, 0xfe, 0xff, - 0xef, 0x0c, 0x8c, 0xeb, 0x1f, 0x30, 0x48, 0x02, 0x0d, 0x66, 0x7a, 0xff, 0x4f, 0x80, 0xe7, 0xff, - 0xff, 0x89, 0x0c, 0x7c, 0x40, 0x26, 0xc4, 0x48, 0x90, 0x61, 0xff, 0x14, 0x78, 0x2f, 0xa0, 0xf2, - 0x79, 0x20, 0xea, 0x19, 0xdf, 0x03, 0x99, 0x60, 0xf5, 0x50, 0xf3, 0xd4, 0x0b, 0xa1, 0xe6, 0xa1, - 0xdb, 0x07, 0x74, 0x0f, 0x2b, 0xcc, 0x3d, 0x20, 0x97, 0x61, 0xba, 0x37, 0x80, 0x13, 0xe6, 0x9f, - 0x05, 0x60, 0x79, 0x07, 0x1e, 0x18, 0x7f, 0x03, 0x33, 0x88, 0x14, 0xe0, 0xd9, 0x55, 0x06, 0x0a, - 0x8f, 0xf0, 0x39, 0x07, 0x98, 0xb0, 0x85, 0x17, 0x7a, 0x78, 0xfe, 0x53, 0x32, 0x83, 0x84, 0x77, - 0x88, 0xd0, 0x7b, 0x6c, 0xf1, 0x81, 0x2d, 0xbe, 0xd0, 0xe3, 0xf3, 0xff, 0x9b, 0x7b, 0x50, 0x06, - 0x00, 0x17, 0x13, 0x23, 0x7a, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Settings_32px = { 32, 32, NBGL_BPP_4, true, C_Settings_32px_bitmap }; - -uint8_t const C_Space_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x01, 0x21, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x63, 0x60, 0xf8, 0xc7, 0xc0, 0x00, 0xc7, 0x7c, 0x74, 0xc2, 0x08, 0x3b, - 0x01, 0xfa, 0xbb, 0x7f, 0xea, 0x80, 0x00, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Space_32px = { 32, 32, NBGL_BPP_1, true, C_Space_32px_bitmap }; - -uint8_t const C_Warning_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0xc1, 0x00, 0x00, 0xbf, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x65, 0xd1, 0xbd, 0x0a, 0xc2, 0x30, 0x14, 0x05, 0xe0, 0x83, 0x96, 0x1a, - 0x9c, 0x3a, 0x0a, 0x2e, 0x1d, 0x7d, 0x2c, 0x27, 0x67, 0x1f, 0xa1, 0xa3, 0x83, 0xe0, 0xe6, 0x03, - 0x08, 0xce, 0x82, 0x2f, 0x20, 0x88, 0x7b, 0xdf, 0x42, 0xbb, 0x65, 0x71, 0x88, 0x54, 0x38, 0x26, - 0x2d, 0x69, 0xee, 0xb5, 0xd9, 0xbe, 0x43, 0x48, 0xee, 0x0f, 0x29, 0xcf, 0xd1, 0x2a, 0x9e, 0x30, - 0x97, 0xbc, 0x02, 0x46, 0xf0, 0x01, 0x65, 0xcf, 0xc5, 0xd6, 0x28, 0xb2, 0x32, 0x8a, 0xc9, 0x9e, - 0x33, 0x26, 0x3f, 0x81, 0xdc, 0x26, 0x7b, 0x66, 0x5d, 0x25, 0xbd, 0x5d, 0x81, 0xac, 0xe6, 0xe0, - 0xc4, 0xce, 0x82, 0xc1, 0x92, 0xde, 0x9f, 0x02, 0xd3, 0xfa, 0xbb, 0xf3, 0x67, 0xdf, 0x6e, 0x6e, - 0x95, 0x79, 0x63, 0x72, 0xa1, 0x43, 0x28, 0xdd, 0xe1, 0x30, 0x76, 0x5b, 0xfa, 0x40, 0xdc, 0xa7, - 0x0b, 0x41, 0x7a, 0x8f, 0x6c, 0x4a, 0xf5, 0x1f, 0xf9, 0x8a, 0xd5, 0xc6, 0x7a, 0x63, 0x37, 0xb2, - 0x9f, 0x5c, 0xf4, 0x33, 0xea, 0x77, 0x08, 0xd2, 0xbc, 0xfa, 0xa0, 0xd2, 0xf3, 0xb4, 0xc2, 0xbc, - 0x03, 0xab, 0xb5, 0x51, 0xdb, 0xd2, 0xfb, 0x09, 0x81, 0xf9, 0xdb, 0xe7, 0x52, 0x99, 0x67, 0xfb, - 0x03, 0xe2, 0x51, 0xe0, 0xb9, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_Warning_32px = { 32, 32, NBGL_BPP_4, true, C_Warning_32px_bitmap }; - -uint8_t const C_radio_active_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0x18, 0x01, 0x00, 0x16, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x8d, 0x51, 0x3b, 0x4e, 0x03, 0x31, 0x14, 0x9c, 0xfd, 0x90, 0x10, 0x84, - 0x90, 0xeb, 0x20, 0xc1, 0xde, 0x20, 0xdb, 0xd1, 0xa6, 0xa3, 0xe5, 0x06, 0xd0, 0x23, 0x01, 0x12, - 0x74, 0x14, 0xe4, 0x06, 0xe1, 0x06, 0xc0, 0x09, 0x50, 0x1a, 0x28, 0xc9, 0x0d, 0x72, 0x84, 0x40, - 0x43, 0xbb, 0x22, 0x12, 0x10, 0x3e, 0xd9, 0x61, 0x9e, 0xed, 0x45, 0x42, 0xa2, 0xc8, 0x48, 0xd6, - 0xf3, 0x58, 0x7e, 0x33, 0xef, 0x43, 0x2e, 0x81, 0xef, 0x53, 0x97, 0xec, 0x4e, 0x7e, 0xe9, 0x67, - 0x01, 0x21, 0xbd, 0x8d, 0xb4, 0x2e, 0xe1, 0x91, 0x56, 0x81, 0xdf, 0x20, 0x62, 0xd3, 0xd3, 0x2f, - 0x20, 0x39, 0xaf, 0x16, 0x77, 0x7a, 0xf0, 0x19, 0x4f, 0xc0, 0xbe, 0xc5, 0x67, 0x60, 0xcb, 0x62, - 0x81, 0x4e, 0xc8, 0x1b, 0x20, 0x33, 0x71, 0x60, 0x18, 0xf8, 0x87, 0x4f, 0x98, 0xa1, 0x45, 0xce, - 0xfb, 0x99, 0xae, 0x7b, 0xe8, 0x91, 0x63, 0x6c, 0xb0, 0x2e, 0xbc, 0xdb, 0x0b, 0xd6, 0xc9, 0x13, - 0x1c, 0xeb, 0x8f, 0xd0, 0xe3, 0x3b, 0xda, 0x64, 0x1f, 0x0f, 0xbc, 0x36, 0xbe, 0x2a, 0x67, 0x09, - 0x3a, 0x4c, 0xe9, 0x0b, 0xcc, 0x59, 0x23, 0x21, 0x01, 0x3b, 0x86, 0xe6, 0xfe, 0x97, 0x3b, 0x54, - 0xd2, 0x10, 0x32, 0x2e, 0xec, 0x7f, 0x29, 0xbd, 0x81, 0xf1, 0x35, 0xe9, 0xe5, 0xe6, 0x77, 0xd1, - 0xf8, 0xbd, 0x99, 0xdf, 0x18, 0xdb, 0x4d, 0x3d, 0x8f, 0x56, 0xcf, 0x0c, 0x2b, 0x6a, 0xa2, 0xcc, - 0xd5, 0xc4, 0x81, 0xd5, 0xab, 0x7e, 0xae, 0x42, 0x3f, 0xf3, 0x30, 0x80, 0x52, 0x95, 0x79, 0x5c, - 0x22, 0x8d, 0xf3, 0x38, 0xb2, 0xf8, 0x1a, 0xe7, 0xa1, 0x04, 0x1c, 0x4e, 0xeb, 0x7b, 0x07, 0x39, - 0x1b, 0x46, 0xcd, 0x3c, 0xbb, 0x71, 0xde, 0x45, 0xa0, 0x59, 0xf5, 0xff, 0x3e, 0xb4, 0xaf, 0x33, - 0x97, 0xec, 0x4c, 0x96, 0xd9, 0x2c, 0x7f, 0x00, 0xda, 0xde, 0xe9, 0x38, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_radio_active_32px = { 32, 32, NBGL_BPP_4, true, C_radio_active_32px_bitmap }; - -uint8_t const C_radio_inactive_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x21, 0xc1, 0x00, 0x00, 0xbf, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xff, 0x8d, 0x51, 0xbb, 0x0e, 0xc2, 0x30, 0x0c, 0xfc, 0xff, 0x4f, 0xb8, 0xf0, - 0x9a, 0x33, 0x00, 0x73, 0x25, 0x24, 0xe6, 0x0a, 0x09, 0x66, 0xa6, 0xcc, 0x45, 0x48, 0x9d, 0x09, - 0x4d, 0xdd, 0x38, 0x76, 0x93, 0x2a, 0x08, 0xc4, 0x2d, 0xd1, 0x39, 0x17, 0xdb, 0x77, 0x21, 0xfa, - 0x03, 0xe3, 0xc5, 0x9a, 0x53, 0x5f, 0xa8, 0x45, 0x84, 0xc9, 0x85, 0x06, 0x09, 0x46, 0xe9, 0x03, - 0x8a, 0x83, 0xa8, 0xe3, 0xcd, 0x95, 0xe8, 0x19, 0x0b, 0x8e, 0xb9, 0x07, 0xce, 0x7c, 0x0e, 0xc0, - 0x91, 0x4f, 0x8b, 0x8d, 0xbc, 0xbb, 0x63, 0x25, 0x72, 0x27, 0x3c, 0x00, 0x3d, 0xcb, 0xd7, 0x65, - 0x4e, 0x7c, 0xd0, 0x61, 0x37, 0x73, 0x8f, 0x2d, 0x51, 0x8b, 0xdb, 0xcc, 0x07, 0x96, 0x36, 0xc8, - 0x7b, 0x8d, 0xdc, 0xd0, 0xa2, 0xf8, 0xe0, 0x15, 0xb1, 0xe4, 0xf8, 0xe4, 0xb5, 0xbe, 0xee, 0x57, - 0xcf, 0xeb, 0xc4, 0x05, 0xe3, 0xc5, 0xfb, 0xf8, 0xe4, 0x22, 0xa1, 0xe5, 0xab, 0xb0, 0xf4, 0xe3, - 0x92, 0x8b, 0xec, 0xd7, 0x68, 0x1e, 0xa9, 0xe3, 0x5b, 0xf3, 0x88, 0x01, 0x80, 0xf3, 0xb2, 0xd0, - 0xc9, 0x39, 0xcf, 0xbd, 0xf6, 0xb5, 0x42, 0xf3, 0x9c, 0x20, 0xff, 0xe1, 0xbe, 0xfd, 0xd7, 0x2f, - 0x4c, 0x5a, 0x1c, 0xe5, 0x46, 0x00, 0x02, 0x00, 0x00, -}; -const nbgl_icon_details_t C_radio_inactive_32px = { 32, 32, NBGL_BPP_4, true, C_radio_inactive_32px_bitmap }; - -uint8_t const C_app_boilerplate_32px_bitmap[] = { - 0x20, 0x00, 0x20, 0x00, 0x02, 0x45, 0x00, 0x00, 0xf0, 0xf0, 0xd1, 0xf0, 0xf0, 0x12, 0xf0, 0xf3, - 0xf0, 0xe3, 0xf0, 0xe4, 0xf0, 0xd5, 0xc2, 0xd6, 0x84, 0xe6, 0x56, 0xf7, 0x19, 0xff, 0x01, 0xf0, - 0x1f, 0xff, 0x01, 0xdf, 0x04, 0xaf, 0x06, 0x9f, 0x07, 0xaf, 0x07, 0xcf, 0x06, 0xef, 0x04, 0xf0, - 0x1f, 0x02, 0xf0, 0x2f, 0xf0, 0x2f, 0x01, 0xf0, 0x17, 0x19, 0xf6, 0x57, 0xe5, 0x94, 0xe5, 0xc2, - 0xd4, 0xf0, 0xd3, 0xf0, 0xe2, 0xf0, 0xf2, 0xf0, 0xf1, 0xf0, 0xf0, 0xf0, 0x70, -}; -const nbgl_icon_details_t C_app_boilerplate_32px = { 32, 32, NBGL_BPP_1, true, C_app_boilerplate_32px_bitmap }; - diff --git a/ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.h b/ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.h deleted file mode 100644 index 50e28aaa..00000000 --- a/ledger_secure_sdk_sys/src/c/glyphs_stax/glyphs.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Automatically generated by icon2glyph.py */ - -#pragma once - -#include "app_config.h" -#include "nbgl_types.h" - -extern uint8_t const C_app_boilerplate_16px_bitmap[29]; -extern const nbgl_icon_details_t C_app_boilerplate_16px; - -extern uint8_t const C_app_boilerplate_64px_bitmap[187]; -extern const nbgl_icon_details_t C_app_boilerplate_64px; - -extern uint8_t const C_pin_24_bitmap[49]; -extern const nbgl_icon_details_t C_pin_24; - -extern uint8_t const C_quarter_circle_bottom_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_circle_bottom_left_32px_1bpp; - -extern uint8_t const C_quarter_circle_bottom_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_circle_bottom_left_40px_1bpp; - -extern uint8_t const C_quarter_circle_bottom_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_circle_bottom_left_44px_1bpp; - -extern uint8_t const C_quarter_circle_top_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_circle_top_left_32px_1bpp; - -extern uint8_t const C_quarter_circle_top_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_circle_top_left_40px_1bpp; - -extern uint8_t const C_quarter_circle_top_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_circle_top_left_44px_1bpp; - -extern uint8_t const C_quarter_disc_bottom_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_disc_bottom_left_32px_1bpp; - -extern uint8_t const C_quarter_disc_bottom_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_disc_bottom_left_40px_1bpp; - -extern uint8_t const C_quarter_disc_bottom_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_disc_bottom_left_44px_1bpp; - -extern uint8_t const C_quarter_disc_top_left_32px_1bpp_bitmap[128]; -extern const nbgl_icon_details_t C_quarter_disc_top_left_32px_1bpp; - -extern uint8_t const C_quarter_disc_top_left_40px_1bpp_bitmap[200]; -extern const nbgl_icon_details_t C_quarter_disc_top_left_40px_1bpp; - -extern uint8_t const C_quarter_disc_top_left_44px_1bpp_bitmap[242]; -extern const nbgl_icon_details_t C_quarter_disc_top_left_44px_1bpp; - -extern uint8_t const C_round_24px_bitmap[47]; -extern const nbgl_icon_details_t C_round_24px; - -extern uint8_t const C_switch_60_40_bitmap[300]; -extern const nbgl_icon_details_t C_switch_60_40; - -extern uint8_t const C_Check_Circle_64px_bitmap[571]; -extern const nbgl_icon_details_t C_Check_Circle_64px; - -extern uint8_t const C_Denied_Circle_64px_bitmap[568]; -extern const nbgl_icon_details_t C_Denied_Circle_64px; - -extern uint8_t const C_Important_Circle_64px_bitmap[514]; -extern const nbgl_icon_details_t C_Important_Circle_64px; - -extern uint8_t const C_Review_64px_bitmap[219]; -extern const nbgl_icon_details_t C_Review_64px; - -extern uint8_t const C_SecurityShield_64px_bitmap[610]; -extern const nbgl_icon_details_t C_SecurityShield_64px; - -extern uint8_t const C_Warning_64px_bitmap[359]; -extern const nbgl_icon_details_t C_Warning_64px; - -extern uint8_t const C_left_half_64px_bitmap[192]; -extern const nbgl_icon_details_t C_left_half_64px; - -extern uint8_t const C_Back_32px_bitmap[141]; -extern const nbgl_icon_details_t C_Back_32px; - -extern uint8_t const C_Check_32px_bitmap[74]; -extern const nbgl_icon_details_t C_Check_32px; - -extern uint8_t const C_Check_Circle_32px_bitmap[286]; -extern const nbgl_icon_details_t C_Check_Circle_32px; - -extern uint8_t const C_Chevron_32px_bitmap[88]; -extern const nbgl_icon_details_t C_Chevron_32px; - -extern uint8_t const C_Chevron_Back_32px_bitmap[113]; -extern const nbgl_icon_details_t C_Chevron_Back_32px; - -extern uint8_t const C_Chevron_Next_32px_bitmap[113]; -extern const nbgl_icon_details_t C_Chevron_Next_32px; - -extern uint8_t const C_Close_32px_bitmap[112]; -extern const nbgl_icon_details_t C_Close_32px; - -extern uint8_t const C_Denied_Circle_32px_bitmap[280]; -extern const nbgl_icon_details_t C_Denied_Circle_32px; - -extern uint8_t const C_Erase_32px_bitmap[80]; -extern const nbgl_icon_details_t C_Erase_32px; - -extern uint8_t const C_Important_Circle_32px_bitmap[257]; -extern const nbgl_icon_details_t C_Important_Circle_32px; - -extern uint8_t const C_Info_32px_bitmap[53]; -extern const nbgl_icon_details_t C_Info_32px; - -extern uint8_t const C_Maj_32px_bitmap[75]; -extern const nbgl_icon_details_t C_Maj_32px; - -extern uint8_t const C_Maj_Lock_32px_bitmap[71]; -extern const nbgl_icon_details_t C_Maj_Lock_32px; - -extern uint8_t const C_Mini_Push_32px_bitmap[188]; -extern const nbgl_icon_details_t C_Mini_Push_32px; - -extern uint8_t const C_Next_32px_bitmap[137]; -extern const nbgl_icon_details_t C_Next_32px; - -extern uint8_t const C_QRCode_32px_bitmap[143]; -extern const nbgl_icon_details_t C_QRCode_32px; - -extern uint8_t const C_Settings_32px_bitmap[281]; -extern const nbgl_icon_details_t C_Settings_32px; - -extern uint8_t const C_Space_32px_bitmap[41]; -extern const nbgl_icon_details_t C_Space_32px; - -extern uint8_t const C_Warning_32px_bitmap[201]; -extern const nbgl_icon_details_t C_Warning_32px; - -extern uint8_t const C_radio_active_32px_bitmap[288]; -extern const nbgl_icon_details_t C_radio_active_32px; - -extern uint8_t const C_radio_inactive_32px_bitmap[201]; -extern const nbgl_icon_details_t C_radio_inactive_32px; - -extern uint8_t const C_app_boilerplate_32px_bitmap[77]; -extern const nbgl_icon_details_t C_app_boilerplate_32px; - From c9ed92194b8450ae42af8de06c548c57e88b31e0 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 24 Jan 2025 09:20:06 +0100 Subject: [PATCH 044/154] Bump SDK version --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96a15828..dcb44c4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.5" +version = "1.19.6" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 508b09a2..1e93ced6 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.5" +version = "1.19.6" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.1" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.3" } [features] debug = [] From 4c93f64bb89d91ba6ba8394fb34856770efcef23 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 24 Jan 2025 09:52:27 +0100 Subject: [PATCH 045/154] Improved code readability --- ledger_secure_sdk_sys/build.rs | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b092a06d..16007495 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -436,22 +436,21 @@ impl SDKBuilder { } } - let mut png_list: Vec = Vec::new(); + let mut cmd = Command::new(icon2glyph.as_os_str()); + cmd.arg("--glyphcheader") + .arg(dest_path.join("glyphs.h").as_os_str()) + .arg("--glyphcfile") + .arg(dest_path.join("glyphs.c").as_os_str()); + for folder in glyph_folders.iter() { for file in std::fs::read_dir(folder).unwrap() { let path = file.unwrap().path(); let path_str = path.to_str().unwrap().to_string(); - png_list.push(path_str); + cmd.arg(path_str); } } - let _ = Command::new(icon2glyph.as_os_str()) - .arg("--glyphcheader") - .arg(dest_path.join("glyphs.h").as_os_str()) - .arg("--glyphcfile") - .arg(dest_path.join("glyphs.c").as_os_str()) - .args(png_list) - .output(); + let _ = cmd.output(); } pub fn build_c_sdk(&self) { @@ -589,17 +588,14 @@ impl SDKBuilder { } Device::Stax | Device::Flex => { let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - if Device::Stax == self.device { - let glyphs = out_path.join("glyphs_stax"); - let include_path = glyphs.to_str().unwrap(); - let s = "-I".to_string() + include_path; - bindings = bindings.clang_args([s.as_str()]); - } else { - let glyphs = out_path.join("glyphs_flex"); - let include_path = glyphs.to_str().unwrap(); - let s = "-I".to_string() + include_path; - bindings = bindings.clang_args([s.as_str()]); - } + let mut include_path = "-I".to_string(); + let glyphs = match self.device { + Device::Stax => out_path.join("glyphs_stax"), + Device::Flex => out_path.join("glyphs_flex"), + _ => panic!("Invalid device"), + }; + include_path += glyphs.to_str().unwrap(); + bindings = bindings.clang_args([include_path.as_str()]); bindings = bindings.clang_args([ format!("-I{bsdk}/lib_nbgl/include/").as_str(), From c4768479d165c8a934b3fedb19aaa4cd132e0bdf Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 29 Jan 2025 15:58:27 +0100 Subject: [PATCH 046/154] Update NBGL spinner: previous and new strings shall be stored to enable recurrent calls --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- ledger_device_sdk/examples/nbgl_spinner.rs | 2 +- ledger_device_sdk/src/libcall/swap.rs | 2 +- ledger_device_sdk/src/nbgl/nbgl_spinner.rs | 28 ++++++++++++++-------- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dcb44c4c..3904549f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.19.6" +version = "1.20.0" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 1e93ced6..a30f9f1e 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.19.6" +version = "1.20.0" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true diff --git a/ledger_device_sdk/examples/nbgl_spinner.rs b/ledger_device_sdk/examples/nbgl_spinner.rs index d711d77d..568dc180 100644 --- a/ledger_device_sdk/examples/nbgl_spinner.rs +++ b/ledger_device_sdk/examples/nbgl_spinner.rs @@ -49,7 +49,7 @@ extern "C" fn sample_main() { .glyph(&FERRIS) .show(&my_field); - NbglSpinner::new().text("Please wait...").show(); + NbglSpinner::new().show("Please wait..."); // Simulate an idle state of the app where it just // waits for some event to happen (such as APDU reception), going through diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index dfd8e5f7..41a06978 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -217,7 +217,7 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { } #[cfg(any(target_os = "stax", target_os = "flex"))] - NbglSpinner::new().text("Signing").show(); + NbglSpinner::new().show("Signing"); create_tx_params } diff --git a/ledger_device_sdk/src/nbgl/nbgl_spinner.rs b/ledger_device_sdk/src/nbgl/nbgl_spinner.rs index 83c99368..628c54c0 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_spinner.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_spinner.rs @@ -1,28 +1,36 @@ use super::*; +extern crate alloc; +use alloc::ffi::CString; /// A wrapper around the asynchronous NBGL nbgl_useCaseSpinner C API binding. /// Draws a spinner page with the given parameters. The spinner will "turn" automatically every /// 800 ms, provided the IO event loop is running to process TickerEvents. +#[derive(Debug, Default)] pub struct NbglSpinner { - text: CString, + text: [Option; 2], + write_idx: usize, + read_idx: usize, } impl NbglSpinner { pub fn new() -> NbglSpinner { NbglSpinner { - text: CString::new("").unwrap(), + text: [None, None], + write_idx: 0, + read_idx: 0, } } - pub fn text(self, text: &str) -> NbglSpinner { - NbglSpinner { - text: CString::new(text).unwrap(), - } - } - - pub fn show(&self) { + /// Shows the spinner with the current text. + /// Every call make the spinner "turn" to the next text. + pub fn show(&mut self, text: &str) { + self.text[self.write_idx] = Some(CString::new(text).unwrap()); + self.read_idx = self.write_idx; + self.write_idx = (self.write_idx + 1) % 2; unsafe { - nbgl_useCaseSpinner(self.text.as_ptr() as *const c_char); + nbgl_useCaseSpinner( + self.text[self.read_idx].as_ref().unwrap().as_ptr() as *const c_char + ); } } } From d8b1037c602a0de45d2d7765f43b8c35b2b99867 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 29 Jan 2025 16:04:46 +0100 Subject: [PATCH 047/154] Update NBGL spinner --- ledger_device_sdk/src/nbgl/nbgl_spinner.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_spinner.rs b/ledger_device_sdk/src/nbgl/nbgl_spinner.rs index 628c54c0..b13ff56b 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_spinner.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_spinner.rs @@ -7,7 +7,7 @@ use alloc::ffi::CString; /// 800 ms, provided the IO event loop is running to process TickerEvents. #[derive(Debug, Default)] pub struct NbglSpinner { - text: [Option; 2], + text: [CString; 2], write_idx: usize, read_idx: usize, } @@ -15,7 +15,7 @@ pub struct NbglSpinner { impl NbglSpinner { pub fn new() -> NbglSpinner { NbglSpinner { - text: [None, None], + text: [CString::default(), CString::default()], write_idx: 0, read_idx: 0, } @@ -24,13 +24,11 @@ impl NbglSpinner { /// Shows the spinner with the current text. /// Every call make the spinner "turn" to the next text. pub fn show(&mut self, text: &str) { - self.text[self.write_idx] = Some(CString::new(text).unwrap()); + self.text[self.write_idx] = CString::new(text).unwrap(); self.read_idx = self.write_idx; self.write_idx = (self.write_idx + 1) % 2; unsafe { - nbgl_useCaseSpinner( - self.text[self.read_idx].as_ref().unwrap().as_ptr() as *const c_char - ); + nbgl_useCaseSpinner(self.text[self.read_idx].as_ptr() as *const c_char); } } } From f1ee5411116a640d5f6103fdb3ca76250172d044 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 31 Jan 2025 14:53:08 +0100 Subject: [PATCH 048/154] Remove C SDK NBGL UX sync dep --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- ledger_secure_sdk_sys/build.rs | 9 --------- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3904549f..523bf603 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.20.0" +version = "1.20.1" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.3" +version = "1.6.4" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index a30f9f1e..f8e594a0 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.20.0" +version = "1.20.1" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.3" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.4" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 71915aeb..f32728f2 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.3" +version = "1.6.4" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 16007495..56a19683 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -599,7 +599,6 @@ impl SDKBuilder { bindings = bindings.clang_args([ format!("-I{bsdk}/lib_nbgl/include/").as_str(), - format!("-I{bsdk}/lib_ux_sync/include/").as_str(), format!("-I{bsdk}/lib_ux_nbgl/").as_str(), ]); bindings = bindings @@ -609,12 +608,6 @@ impl SDKBuilder { .to_str() .unwrap(), ) - .header( - self.bolos_sdk - .join("lib_ux_sync/include/ux_sync.h") - .to_str() - .unwrap(), - ) .header( self.bolos_sdk .join("lib_ux_nbgl/ux_nbgl.h") @@ -839,12 +832,10 @@ fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) { .flag("-fms-extensions") .include(bolos_sdk.join("lib_nbgl/include/")) .include(bolos_sdk.join("lib_nbgl/include/fonts/")) - .include(bolos_sdk.join("lib_ux_sync/include/")) .include(bolos_sdk.join("lib_ux_nbgl/")) .include(bolos_sdk.join("qrcode/include/")) .include(bolos_sdk.join("lib_bagl/include/")) .file(bolos_sdk.join("lib_ux_nbgl/ux.c")) - .file(bolos_sdk.join("lib_ux_sync/src/ux_sync.c")) .file(bolos_sdk.join("lib_bagl/src/bagl_fonts.c")) .file(bolos_sdk.join("src/os_printf.c")) .file(bolos_sdk.join("qrcode/src/qrcodegen.c")) From d81bc7e6e8f338f30cb868eb6fee5b0460653c52 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Tue, 4 Feb 2025 11:16:55 +0100 Subject: [PATCH 049/154] Fix sysroot fallback --- ledger_secure_sdk_sys/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 56a19683..26616baa 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -319,7 +319,8 @@ impl SDKBuilder { .trim(); let gcc_toolchain = if sysroot.is_empty() { - String::from("/usr") + // path for Debian-based systems + String::from("/usr/lib/arm-none-eabi") } else { format!("{sysroot}") }; From 0196fabedbfb295509347b50792ca80a254bb150 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Tue, 4 Feb 2025 11:43:25 +0100 Subject: [PATCH 050/154] Version bump --- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index f8e594a0..48e4fdbd 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.20.1" +version = "1.20.2" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.4" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.5" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index f32728f2..3e47ac04 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.4" +version = "1.6.5" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true @@ -22,4 +22,4 @@ ccid = [] [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] \ No newline at end of file +check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] From 5db6239eb4969ef3716d17111ba39a1eb29cbe6e Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Feb 2025 14:41:30 +0100 Subject: [PATCH 051/154] Use libc from C SDK for each device --- Cargo.lock | 4 ++-- ledger_secure_sdk_sys/build.rs | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 523bf603..acff7ef2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.20.1" +version = "1.20.2" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.4" +version = "1.6.5" dependencies = [ "bindgen", "cc", diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 26616baa..dfcd4f94 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -518,9 +518,20 @@ impl SDKBuilder { command.compile("ledger-secure-sdk"); /* Link with libc for unresolved symbols */ - let gcc_tc = self.gcc_toolchain.display().to_string(); + let mut path = self.bolos_sdk.display().to_string(); + match self.device { + Device::NanoS => { + path = self.gcc_toolchain.display().to_string().push_str("/lib"); + } + Device::NanoX => { + path.push_str("/arch/st33/lib"); + } + Device::NanoSPlus | Device::Flex | Device::Stax => { + path.push_str("/arch/st33k1/lib"); + } + }; println!("cargo:rustc-link-lib=c"); - println!("cargo:rustc-link-search={gcc_tc}/lib"); + println!("cargo:rustc-link-search={path}"); } fn generate_bindings(&self) { From 8ea8bf493480f54c1bcc4f2893edbd2315f59182 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Feb 2025 14:45:52 +0100 Subject: [PATCH 052/154] defautl path for Nano S --- ledger_secure_sdk_sys/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index dfcd4f94..18f3d23e 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -521,7 +521,8 @@ impl SDKBuilder { let mut path = self.bolos_sdk.display().to_string(); match self.device { Device::NanoS => { - path = self.gcc_toolchain.display().to_string().push_str("/lib"); + path = self.gcc_toolchain.display().to_string(); + path.push_str("/lib"); } Device::NanoX => { path.push_str("/arch/st33/lib"); From 3cb435d5fb9b2d113f52722dede588db771891aa Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Feb 2025 14:54:41 +0100 Subject: [PATCH 053/154] Bump version --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index acff7ef2..d0c16979 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.20.2" +version = "1.20.3" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.5" +version = "1.6.6" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 48e4fdbd..998546d9 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.20.2" +version = "1.20.3" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.5" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.6" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 3e47ac04..790fe30c 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.5" +version = "1.6.6" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From d5c423e88a088bb6c31b2e256c1fe4751e64973f Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 4 Feb 2025 12:14:47 +0100 Subject: [PATCH 054/154] Fix pin lock issue during io reset --- ledger_device_sdk/src/nbgl.rs | 3 --- ledger_secure_sdk_sys/src/c/src.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ledger_device_sdk/src/nbgl.rs b/ledger_device_sdk/src/nbgl.rs index 85bc4614..2ad72609 100644 --- a/ledger_device_sdk/src/nbgl.rs +++ b/ledger_device_sdk/src/nbgl.rs @@ -8,9 +8,6 @@ use core::ffi::{c_char, c_int}; use core::mem::transmute; use ledger_secure_sdk_sys::*; -#[no_mangle] -static mut G_ux_params: bolos_ux_params_t = unsafe { const_zero!(bolos_ux_params_t) }; - pub mod nbgl_address_review; pub mod nbgl_choice; pub mod nbgl_generic_review; diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index 0a751021..f1da0190 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -266,6 +266,8 @@ void c_reset_bss() { memset(bss, 0, bss_len); } +bolos_ux_params_t G_ux_params; + void c_boot_std() { // below is a 'manual' implementation of `io_seproxyhal_init` #ifdef HAVE_MCU_PROTECT @@ -277,6 +279,19 @@ void c_boot_std() { io_seproxyhal_spi_send(c, 4); #endif + // Warn UX layer of io reset to avoid unwanted pin lock + memset(&G_ux_params, 0, sizeof(G_ux_params)); + G_ux_params.ux_id = BOLOS_UX_IO_RESET; + + // If the app has just been booted from the UX, multiple os_ux calls may be necessary + // to ensure UX layer has take the BOLOS_UX_IO_RESET instruction into account. + for (uint8_t i = 0; i < 2; i++) { + os_ux(&G_ux_params); + if (os_sched_last_status(TASK_BOLOS_UX) == BOLOS_UX_OK) { + break; + } + } + #ifdef HAVE_BLE unsigned int plane = G_io_app.plane_mode; #endif From ceb82de1f1d2b231a6db20e3c934e3231181577d Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 4 Feb 2025 14:49:05 +0100 Subject: [PATCH 055/154] Exclude Nano S --- ledger_secure_sdk_sys/src/c/src.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index f1da0190..74cbadab 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -279,6 +279,7 @@ void c_boot_std() { io_seproxyhal_spi_send(c, 4); #endif +#ifndef TARGET_NANOS // Warn UX layer of io reset to avoid unwanted pin lock memset(&G_ux_params, 0, sizeof(G_ux_params)); G_ux_params.ux_id = BOLOS_UX_IO_RESET; @@ -291,6 +292,7 @@ void c_boot_std() { break; } } +#endif #ifdef HAVE_BLE unsigned int plane = G_io_app.plane_mode; From 42efbd7d450a1f4b14bd9626fd5f889fe40c7b2e Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 5 Feb 2025 09:27:09 +0100 Subject: [PATCH 056/154] Fix SRAM sizes for S+ and X --- ledger_device_sdk/nanosplus_layout.ld | 2 +- ledger_device_sdk/nanox_layout.ld | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ledger_device_sdk/nanosplus_layout.ld b/ledger_device_sdk/nanosplus_layout.ld index 8456e07d..9418ef65 100644 --- a/ledger_device_sdk/nanosplus_layout.ld +++ b/ledger_device_sdk/nanosplus_layout.ld @@ -2,7 +2,7 @@ MEMORY { FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 30K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K } PAGE_SIZE = 512; diff --git a/ledger_device_sdk/nanox_layout.ld b/ledger_device_sdk/nanox_layout.ld index 88856e92..c708fdf8 100644 --- a/ledger_device_sdk/nanox_layout.ld +++ b/ledger_device_sdk/nanox_layout.ld @@ -2,7 +2,7 @@ MEMORY { FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 30K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 28K } PAGE_SIZE = 256; From 07fd458016c79ad5a6c7219eb4237352717c1d7e Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 12 Feb 2025 18:08:59 +0100 Subject: [PATCH 057/154] Bump versions --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0c16979..1f58c2f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.20.3" +version = "1.20.4" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.6" +version = "1.6.7" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 998546d9..f0d9a880 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.20.3" +version = "1.20.4" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.6" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.7" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 790fe30c..b4f5c604 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.6" +version = "1.6.7" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From 6136cd1e4baea11a7d172bfd320b88659a96ef08 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 5 Feb 2025 17:00:27 +0100 Subject: [PATCH 058/154] Move custom target files into cargo-ledger crate --- cargo-ledger/custom_targets/flex.json | 29 ++++++++++++++++++++ cargo-ledger/custom_targets/nanos.json | 32 ++++++++++++++++++++++ cargo-ledger/custom_targets/nanosplus.json | 29 ++++++++++++++++++++ cargo-ledger/custom_targets/nanox.json | 29 ++++++++++++++++++++ cargo-ledger/custom_targets/stax.json | 29 ++++++++++++++++++++ cargo-ledger/src/setup.rs | 2 +- 6 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 cargo-ledger/custom_targets/flex.json create mode 100644 cargo-ledger/custom_targets/nanos.json create mode 100644 cargo-ledger/custom_targets/nanosplus.json create mode 100644 cargo-ledger/custom_targets/nanox.json create mode 100644 cargo-ledger/custom_targets/stax.json diff --git a/cargo-ledger/custom_targets/flex.json b/cargo-ledger/custom_targets/flex.json new file mode 100644 index 00000000..af01a46e --- /dev/null +++ b/cargo-ledger/custom_targets/flex.json @@ -0,0 +1,29 @@ +{ + "abi": "eabi", + "arch": "arm", + "c-enum-min-bits": 8, + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "executables": true, + "frame-pointer": "always", + "linker": "link_wrap.sh", + "linker-flavor": "ld.lld", + "llvm-target": "thumbv8m.main-none-eabi", + "max-atomic-width": 32, + "panic-strategy": "abort", + "pre-link-args": { + "ld.lld": [ + "-Tstax_flex_layout.ld", + "-Tlink.ld" + ], + "ld": [ + "-Tstax_flex_layout.ld", + "-Tlink.ld" + ] + }, + "relocation-model": "ropi-rwpi", + "singlethread": true, + "target-pointer-width": "32", + "os": "flex", + "target-family": [ "bolos" ] +} diff --git a/cargo-ledger/custom_targets/nanos.json b/cargo-ledger/custom_targets/nanos.json new file mode 100644 index 00000000..4d893faf --- /dev/null +++ b/cargo-ledger/custom_targets/nanos.json @@ -0,0 +1,32 @@ +{ + "abi": "eabi", + "arch": "arm", + "atomic-cas": false, + "c-enum-min-bits": 8, + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "executables": true, + "features": "+strict-align", + "frame-pointer": "always", + "linker": "link_wrap.sh", + "linker-flavor": "ld.lld", + "llvm-target": "thumbv6m-none-eabi", + "panic-strategy": "abort", + "pre-link-args": { + "ld.lld": [ + "-Tnanos_layout.ld", + "-Tlink.ld", + "--emit-relocs" + ], + "ld": [ + "-Tnanos_layout.ld", + "-Tlink.ld", + "--emit-relocs" + ] + }, + "relocation-model": "ropi", + "singlethread": true, + "target-pointer-width": "32", + "os": "nanos", + "target-family": [ "bolos" ] +} diff --git a/cargo-ledger/custom_targets/nanosplus.json b/cargo-ledger/custom_targets/nanosplus.json new file mode 100644 index 00000000..5f3d2030 --- /dev/null +++ b/cargo-ledger/custom_targets/nanosplus.json @@ -0,0 +1,29 @@ +{ + "abi": "eabi", + "arch": "arm", + "c-enum-min-bits": 8, + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "executables": true, + "frame-pointer": "always", + "linker": "link_wrap.sh", + "linker-flavor": "ld.lld", + "llvm-target": "thumbv8m.main-none-eabi", + "max-atomic-width": 32, + "panic-strategy": "abort", + "pre-link-args": { + "ld.lld": [ + "-Tnanosplus_layout.ld", + "-Tlink.ld" + ], + "ld": [ + "-Tnanosplus_layout.ld", + "-Tlink.ld" + ] + }, + "relocation-model": "ropi-rwpi", + "singlethread": true, + "target-pointer-width": "32", + "os": "nanosplus", + "target-family": [ "bolos" ] +} diff --git a/cargo-ledger/custom_targets/nanox.json b/cargo-ledger/custom_targets/nanox.json new file mode 100644 index 00000000..245672ec --- /dev/null +++ b/cargo-ledger/custom_targets/nanox.json @@ -0,0 +1,29 @@ +{ + "abi": "eabi", + "arch": "arm", + "atomic-cas": false, + "c-enum-min-bits": 8, + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "executables": true, + "frame-pointer": "always", + "linker": "link_wrap.sh", + "linker-flavor": "ld.lld", + "llvm-target": "thumbv6m-none-eabi", + "panic-strategy": "abort", + "pre-link-args": { + "ld.lld": [ + "-Tnanox_layout.ld", + "-Tlink.ld" + ], + "ld": [ + "-Tnanox_layout.ld", + "-Tlink.ld" + ] + }, + "relocation-model": "ropi-rwpi", + "singlethread": true, + "target-pointer-width": "32", + "os": "nanox", + "target-family": [ "bolos" ] +} diff --git a/cargo-ledger/custom_targets/stax.json b/cargo-ledger/custom_targets/stax.json new file mode 100644 index 00000000..c39cd3d0 --- /dev/null +++ b/cargo-ledger/custom_targets/stax.json @@ -0,0 +1,29 @@ +{ + "abi": "eabi", + "arch": "arm", + "c-enum-min-bits": 8, + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "executables": true, + "frame-pointer": "always", + "linker": "link_wrap.sh", + "linker-flavor": "ld.lld", + "llvm-target": "thumbv8m.main-none-eabi", + "max-atomic-width": 32, + "panic-strategy": "abort", + "pre-link-args": { + "ld.lld": [ + "-Tstax_flex_layout.ld", + "-Tlink.ld" + ], + "ld": [ + "-Tstax_flex_layout.ld", + "-Tlink.ld" + ] + }, + "relocation-model": "ropi-rwpi", + "singlethread": true, + "target-pointer-width": "32", + "os": "stax", + "target-family": [ "bolos" ] +} diff --git a/cargo-ledger/src/setup.rs b/cargo-ledger/src/setup.rs index 822f26d4..68254db0 100644 --- a/cargo-ledger/src/setup.rs +++ b/cargo-ledger/src/setup.rs @@ -13,7 +13,7 @@ pub fn install_targets() { let sysroot_cmd = std::str::from_utf8(&sysroot_cmd).unwrap().trim(); let target_files_url = Path::new( - "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/a7fb841160df34b8de268b136704c8b2ed8f9973/ledger_device_sdk/" + "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/y333/nbgl_support_for_nanos/cargo-ledger/" ); let sysroot = Path::new(sysroot_cmd).join("lib").join("rustlib"); From 2dfc857e7aa9fc4ef1bac08fd634b96e739abbe8 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 5 Feb 2025 18:36:31 +0100 Subject: [PATCH 059/154] Update cargo ledger setup --- .../flex.json | 0 .../custom_files}/link_wrap.sh | 0 .../nanos.json | 0 .../nanosplus.json | 0 .../nanox.json | 0 .../stax.json | 0 cargo-ledger/src/setup.rs | 2 +- ledger_device_sdk/flex.json | 29 ----------------- ledger_device_sdk/nanos.json | 32 ------------------- ledger_device_sdk/nanosplus.json | 29 ----------------- ledger_device_sdk/nanox.json | 29 ----------------- ledger_device_sdk/stax.json | 29 ----------------- 12 files changed, 1 insertion(+), 149 deletions(-) rename cargo-ledger/{custom_targets => custom_files}/flex.json (100%) rename {ledger_device_sdk => cargo-ledger/custom_files}/link_wrap.sh (100%) rename cargo-ledger/{custom_targets => custom_files}/nanos.json (100%) rename cargo-ledger/{custom_targets => custom_files}/nanosplus.json (100%) rename cargo-ledger/{custom_targets => custom_files}/nanox.json (100%) rename cargo-ledger/{custom_targets => custom_files}/stax.json (100%) delete mode 100644 ledger_device_sdk/flex.json delete mode 100644 ledger_device_sdk/nanos.json delete mode 100644 ledger_device_sdk/nanosplus.json delete mode 100644 ledger_device_sdk/nanox.json delete mode 100644 ledger_device_sdk/stax.json diff --git a/cargo-ledger/custom_targets/flex.json b/cargo-ledger/custom_files/flex.json similarity index 100% rename from cargo-ledger/custom_targets/flex.json rename to cargo-ledger/custom_files/flex.json diff --git a/ledger_device_sdk/link_wrap.sh b/cargo-ledger/custom_files/link_wrap.sh similarity index 100% rename from ledger_device_sdk/link_wrap.sh rename to cargo-ledger/custom_files/link_wrap.sh diff --git a/cargo-ledger/custom_targets/nanos.json b/cargo-ledger/custom_files/nanos.json similarity index 100% rename from cargo-ledger/custom_targets/nanos.json rename to cargo-ledger/custom_files/nanos.json diff --git a/cargo-ledger/custom_targets/nanosplus.json b/cargo-ledger/custom_files/nanosplus.json similarity index 100% rename from cargo-ledger/custom_targets/nanosplus.json rename to cargo-ledger/custom_files/nanosplus.json diff --git a/cargo-ledger/custom_targets/nanox.json b/cargo-ledger/custom_files/nanox.json similarity index 100% rename from cargo-ledger/custom_targets/nanox.json rename to cargo-ledger/custom_files/nanox.json diff --git a/cargo-ledger/custom_targets/stax.json b/cargo-ledger/custom_files/stax.json similarity index 100% rename from cargo-ledger/custom_targets/stax.json rename to cargo-ledger/custom_files/stax.json diff --git a/cargo-ledger/src/setup.rs b/cargo-ledger/src/setup.rs index 68254db0..416dd707 100644 --- a/cargo-ledger/src/setup.rs +++ b/cargo-ledger/src/setup.rs @@ -13,7 +13,7 @@ pub fn install_targets() { let sysroot_cmd = std::str::from_utf8(&sysroot_cmd).unwrap().trim(); let target_files_url = Path::new( - "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/y333/nbgl_support_for_nanos/cargo-ledger/" + "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/y333/nbgl_support_for_nanos/cargo-ledger/custom_files" ); let sysroot = Path::new(sysroot_cmd).join("lib").join("rustlib"); diff --git a/ledger_device_sdk/flex.json b/ledger_device_sdk/flex.json deleted file mode 100644 index af01a46e..00000000 --- a/ledger_device_sdk/flex.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "abi": "eabi", - "arch": "arm", - "c-enum-min-bits": 8, - "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "emit-debug-gdb-scripts": false, - "executables": true, - "frame-pointer": "always", - "linker": "link_wrap.sh", - "linker-flavor": "ld.lld", - "llvm-target": "thumbv8m.main-none-eabi", - "max-atomic-width": 32, - "panic-strategy": "abort", - "pre-link-args": { - "ld.lld": [ - "-Tstax_flex_layout.ld", - "-Tlink.ld" - ], - "ld": [ - "-Tstax_flex_layout.ld", - "-Tlink.ld" - ] - }, - "relocation-model": "ropi-rwpi", - "singlethread": true, - "target-pointer-width": "32", - "os": "flex", - "target-family": [ "bolos" ] -} diff --git a/ledger_device_sdk/nanos.json b/ledger_device_sdk/nanos.json deleted file mode 100644 index 4d893faf..00000000 --- a/ledger_device_sdk/nanos.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "abi": "eabi", - "arch": "arm", - "atomic-cas": false, - "c-enum-min-bits": 8, - "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "emit-debug-gdb-scripts": false, - "executables": true, - "features": "+strict-align", - "frame-pointer": "always", - "linker": "link_wrap.sh", - "linker-flavor": "ld.lld", - "llvm-target": "thumbv6m-none-eabi", - "panic-strategy": "abort", - "pre-link-args": { - "ld.lld": [ - "-Tnanos_layout.ld", - "-Tlink.ld", - "--emit-relocs" - ], - "ld": [ - "-Tnanos_layout.ld", - "-Tlink.ld", - "--emit-relocs" - ] - }, - "relocation-model": "ropi", - "singlethread": true, - "target-pointer-width": "32", - "os": "nanos", - "target-family": [ "bolos" ] -} diff --git a/ledger_device_sdk/nanosplus.json b/ledger_device_sdk/nanosplus.json deleted file mode 100644 index 5f3d2030..00000000 --- a/ledger_device_sdk/nanosplus.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "abi": "eabi", - "arch": "arm", - "c-enum-min-bits": 8, - "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "emit-debug-gdb-scripts": false, - "executables": true, - "frame-pointer": "always", - "linker": "link_wrap.sh", - "linker-flavor": "ld.lld", - "llvm-target": "thumbv8m.main-none-eabi", - "max-atomic-width": 32, - "panic-strategy": "abort", - "pre-link-args": { - "ld.lld": [ - "-Tnanosplus_layout.ld", - "-Tlink.ld" - ], - "ld": [ - "-Tnanosplus_layout.ld", - "-Tlink.ld" - ] - }, - "relocation-model": "ropi-rwpi", - "singlethread": true, - "target-pointer-width": "32", - "os": "nanosplus", - "target-family": [ "bolos" ] -} diff --git a/ledger_device_sdk/nanox.json b/ledger_device_sdk/nanox.json deleted file mode 100644 index 245672ec..00000000 --- a/ledger_device_sdk/nanox.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "abi": "eabi", - "arch": "arm", - "atomic-cas": false, - "c-enum-min-bits": 8, - "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "emit-debug-gdb-scripts": false, - "executables": true, - "frame-pointer": "always", - "linker": "link_wrap.sh", - "linker-flavor": "ld.lld", - "llvm-target": "thumbv6m-none-eabi", - "panic-strategy": "abort", - "pre-link-args": { - "ld.lld": [ - "-Tnanox_layout.ld", - "-Tlink.ld" - ], - "ld": [ - "-Tnanox_layout.ld", - "-Tlink.ld" - ] - }, - "relocation-model": "ropi-rwpi", - "singlethread": true, - "target-pointer-width": "32", - "os": "nanox", - "target-family": [ "bolos" ] -} diff --git a/ledger_device_sdk/stax.json b/ledger_device_sdk/stax.json deleted file mode 100644 index c39cd3d0..00000000 --- a/ledger_device_sdk/stax.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "abi": "eabi", - "arch": "arm", - "c-enum-min-bits": 8, - "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "emit-debug-gdb-scripts": false, - "executables": true, - "frame-pointer": "always", - "linker": "link_wrap.sh", - "linker-flavor": "ld.lld", - "llvm-target": "thumbv8m.main-none-eabi", - "max-atomic-width": 32, - "panic-strategy": "abort", - "pre-link-args": { - "ld.lld": [ - "-Tstax_flex_layout.ld", - "-Tlink.ld" - ], - "ld": [ - "-Tstax_flex_layout.ld", - "-Tlink.ld" - ] - }, - "relocation-model": "ropi-rwpi", - "singlethread": true, - "target-pointer-width": "32", - "os": "stax", - "target-family": [ "bolos" ] -} From 4b01fd87a580cee6f55cb318828cd5f7bfc26f9f Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Feb 2025 10:07:50 +0100 Subject: [PATCH 060/154] Manage unknown device --- ledger_secure_sdk_sys/build.rs | 85 ++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 18f3d23e..fc9ee054 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -51,6 +51,20 @@ enum Device { NanoX, Stax, Flex, + Unknown, +} + +impl From<&str> for Device { + fn from(s: &str) -> Self { + match s { + "nanos" => Device::NanoS, + "nanosplus" => Device::NanoSPlus, + "nanox" => Device::NanoX, + "stax" => Device::Stax, + "flex" => Device::Flex, + _s => Device::Unknown, + } + } } impl std::fmt::Display for Device { @@ -61,13 +75,13 @@ impl std::fmt::Display for Device { Device::NanoX => write!(f, "nanox"), Device::Stax => write!(f, "stax"), Device::Flex => write!(f, "flex"), + Device::Unknown => write!(f, "unknown"), } } } #[derive(Default)] -struct SDKInfo { - pub bolos_sdk: PathBuf, +struct CSDKInfo { pub api_level: Option, pub target_id: String, pub target_name: String, @@ -76,20 +90,18 @@ struct SDKInfo { pub c_sdk_version: String, } -impl SDKInfo { +impl CSDKInfo { pub fn new() -> Self { - SDKInfo::default() + CSDKInfo::default() } } -fn retrieve_sdk_info(device: &Device, path: &Path) -> Result { - let mut sdk_info = SDKInfo::new(); - sdk_info.bolos_sdk = path.to_path_buf(); - (sdk_info.api_level, sdk_info.c_sdk_name) = retrieve_makefile_infos(&sdk_info.bolos_sdk)?; - (sdk_info.target_id, sdk_info.target_name) = - retrieve_target_file_infos(device, &sdk_info.bolos_sdk)?; - (sdk_info.c_sdk_hash, sdk_info.c_sdk_version) = retrieve_sdk_git_info(&sdk_info.bolos_sdk); - Ok(sdk_info) +fn retrieve_sdk_info(device: &Device, path: &PathBuf) -> Result { + let mut csdk_info = CSDKInfo::new(); + (csdk_info.api_level, csdk_info.c_sdk_name) = retrieve_makefile_infos(path)?; + (csdk_info.target_id, csdk_info.target_name) = retrieve_target_file_infos(device, path)?; + (csdk_info.c_sdk_hash, csdk_info.c_sdk_version) = retrieve_sdk_git_info(path); + Ok(csdk_info) } fn retrieve_sdk_git_info(bolos_sdk: &Path) -> (String, String) { @@ -230,6 +242,7 @@ fn clone_sdk(device: &Device) -> PathBuf { Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", ), + Device::Unknown => panic!("Unknown device"), }; let out_dir = env::var("OUT_DIR").unwrap(); @@ -249,6 +262,7 @@ fn clone_sdk(device: &Device) -> PathBuf { #[derive(Debug)] enum SDKBuildError { + UnknownDevice, InvalidAPILevel, MissingSDKName, TargetFileNotFound, @@ -306,7 +320,7 @@ impl SDKBuilder { } } - pub fn gcc_toolchain(&mut self) { + pub fn gcc_toolchain(&mut self) -> Result<(), SDKBuildError> { // Find out where the arm toolchain is located let output = Command::new("arm-none-eabi-gcc") .arg("-print-sysroot") @@ -325,36 +339,35 @@ impl SDKBuilder { format!("{sysroot}") }; self.gcc_toolchain = PathBuf::from(gcc_toolchain); + Ok(()) } - pub fn device(&mut self) { + pub fn device(&mut self) -> Result<(), SDKBuildError> { // determine device - let device = match env::var_os("CARGO_CFG_TARGET_OS").unwrap().to_str().unwrap() { - "nanos" => Device::NanoS, - "nanosplus" => Device::NanoSPlus, - "nanox" => Device::NanoX, - "stax" => Device::Stax, - "flex" => Device::Flex, - target_name => panic!( - "invalid target `{target_name}`, expected one of `nanos`, `nanox`, `nanosplus`. Run with `-Z build-std=core --target=./.json`" - ), - }; - self.device = device; - // export TARGET into env for 'infos.rs' - println!("cargo:rustc-env=TARGET={}", self.device); - println!("cargo:warning=Device is {:?}", self.device); + self.device = env::var_os("CARGO_CFG_TARGET_OS") + .unwrap() + .to_str() + .unwrap() + .into(); + + if self.device == Device::Unknown { + return Err(SDKBuildError::UnknownDevice); + } else { + // export TARGET into env for 'infos.rs' + println!("cargo:rustc-env=TARGET={}", self.device); + println!("cargo:warning=Device is {:?}", self.device); + Ok(()) + } } pub fn bolos_sdk(&mut self) -> Result<(), SDKBuildError> { println!("cargo:rerun-if-env-changed=LEDGER_SDK_PATH"); - let sdk_path = match env::var("LEDGER_SDK_PATH") { + self.bolos_sdk = match env::var("LEDGER_SDK_PATH") { Err(_) => clone_sdk(&self.device), Ok(path) => PathBuf::from(path), }; - let sdk_info = retrieve_sdk_info(&self.device, &sdk_path)?; - - self.bolos_sdk = sdk_info.bolos_sdk; + let sdk_info = retrieve_sdk_info(&self.device, &self.bolos_sdk)?; match sdk_info.api_level { Some(api_level) => { @@ -415,6 +428,7 @@ impl SDKBuilder { Device::NanoSPlus => out_path.join("glyphs_nanosplus"), Device::NanoX => out_path.join("glyphs_nanox"), Device::NanoS => panic!("Nano S does not support glyphs"), + Device::Unknown => panic!("Unknown device"), }; if !dest_path.exists() { fs::create_dir_all(&dest_path).ok(); @@ -508,6 +522,7 @@ impl SDKBuilder { Device::NanoSPlus => finalize_nanosplus_configuration(&mut command, &self.bolos_sdk), Device::Stax => finalize_stax_configuration(&mut command, &self.bolos_sdk), Device::Flex => finalize_flex_configuration(&mut command, &self.bolos_sdk), + Device::Unknown => panic!("Unknown device"), }; // Add the defines found in the Makefile.conf.cx to our build command. @@ -578,6 +593,7 @@ impl SDKBuilder { Device::NanoSPlus => ("nanos2", "sdk_nanosp.h"), Device::Stax => ("stax", "sdk_stax.h"), Device::Flex => ("flex", "sdk_flex.h"), + Device::Unknown => panic!("Unknown device"), }; bindings = bindings.clang_arg(format!("-I{bsdk}/target/{include_path}/include/")); bindings = bindings.header(header); @@ -677,11 +693,12 @@ impl SDKBuilder { fn main() { let mut sdk_builder = SDKBuilder::new(); - sdk_builder.gcc_toolchain(); - sdk_builder.device(); + sdk_builder.gcc_toolchain().unwrap(); + sdk_builder.device().unwrap(); sdk_builder.bolos_sdk().unwrap(); sdk_builder.cxdefines(); sdk_builder.generate_glyphs(); + sdk_builder.build_c_sdk(); sdk_builder.generate_bindings(); sdk_builder.generate_heap_size(); From 7c47bb9cdbec19e0b3d0a4742bb833a36cab6431 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Feb 2025 18:37:34 +0100 Subject: [PATCH 061/154] Move custom targets and link files into sys crate --- {cargo-ledger/custom_files => ledger_secure_sdk_sys}/flex.json | 0 {cargo-ledger/custom_files => ledger_secure_sdk_sys}/link_wrap.sh | 0 {cargo-ledger/custom_files => ledger_secure_sdk_sys}/nanos.json | 0 .../custom_files => ledger_secure_sdk_sys}/nanosplus.json | 0 {cargo-ledger/custom_files => ledger_secure_sdk_sys}/nanox.json | 0 {cargo-ledger/custom_files => ledger_secure_sdk_sys}/stax.json | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {cargo-ledger/custom_files => ledger_secure_sdk_sys}/flex.json (100%) rename {cargo-ledger/custom_files => ledger_secure_sdk_sys}/link_wrap.sh (100%) rename {cargo-ledger/custom_files => ledger_secure_sdk_sys}/nanos.json (100%) rename {cargo-ledger/custom_files => ledger_secure_sdk_sys}/nanosplus.json (100%) rename {cargo-ledger/custom_files => ledger_secure_sdk_sys}/nanox.json (100%) rename {cargo-ledger/custom_files => ledger_secure_sdk_sys}/stax.json (100%) diff --git a/cargo-ledger/custom_files/flex.json b/ledger_secure_sdk_sys/flex.json similarity index 100% rename from cargo-ledger/custom_files/flex.json rename to ledger_secure_sdk_sys/flex.json diff --git a/cargo-ledger/custom_files/link_wrap.sh b/ledger_secure_sdk_sys/link_wrap.sh similarity index 100% rename from cargo-ledger/custom_files/link_wrap.sh rename to ledger_secure_sdk_sys/link_wrap.sh diff --git a/cargo-ledger/custom_files/nanos.json b/ledger_secure_sdk_sys/nanos.json similarity index 100% rename from cargo-ledger/custom_files/nanos.json rename to ledger_secure_sdk_sys/nanos.json diff --git a/cargo-ledger/custom_files/nanosplus.json b/ledger_secure_sdk_sys/nanosplus.json similarity index 100% rename from cargo-ledger/custom_files/nanosplus.json rename to ledger_secure_sdk_sys/nanosplus.json diff --git a/cargo-ledger/custom_files/nanox.json b/ledger_secure_sdk_sys/nanox.json similarity index 100% rename from cargo-ledger/custom_files/nanox.json rename to ledger_secure_sdk_sys/nanox.json diff --git a/cargo-ledger/custom_files/stax.json b/ledger_secure_sdk_sys/stax.json similarity index 100% rename from cargo-ledger/custom_files/stax.json rename to ledger_secure_sdk_sys/stax.json From 19bf4b168134b6fe34ceb1201b04cebd23d3272c Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Feb 2025 18:49:26 +0100 Subject: [PATCH 062/154] Use RUST_NIGHTLY env variable for setup target files --- cargo-ledger/src/setup.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/cargo-ledger/src/setup.rs b/cargo-ledger/src/setup.rs index 416dd707..d6705b9b 100644 --- a/cargo-ledger/src/setup.rs +++ b/cargo-ledger/src/setup.rs @@ -1,19 +1,39 @@ use std::path::Path; use std::process::Command; +use std::str::from_utf8; pub fn install_targets() { - println!("[ ] Checking for installed custom targets..."); + println!("[ ] Install custom targets..."); // Check if target files are installed + let mut args: Vec = vec![]; + match std::env::var("RUST_NIGHTLY") { + Ok(version) => { + println!( + "Install custom targets for nightly toolchain: {}", + version + ); + args.push(format!("+{}", version)); + } + Err(_) => { + let rustup_cmd = + Command::new("rustup").arg("default").output().unwrap(); + println!( + "Install custom targets for default toolchain {}", + from_utf8(rustup_cmd.stdout.as_slice()).unwrap() + ); + } + } + args.push(String::from("--print")); + args.push(String::from("sysroot")); let sysroot_cmd = Command::new("rustc") - .arg("--print") - .arg("sysroot") + .args(&args) .output() .expect("failed to call rustc") .stdout; let sysroot_cmd = std::str::from_utf8(&sysroot_cmd).unwrap().trim(); let target_files_url = Path::new( - "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/y333/nbgl_support_for_nanos/cargo-ledger/custom_files" + "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/y333/nbgl_support_for_nanos/ledger_secure_sdk_sys" ); let sysroot = Path::new(sysroot_cmd).join("lib").join("rustlib"); From b1e46a140e85674c265bd19b1dfafde3161a3b59 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Feb 2025 11:39:04 +0100 Subject: [PATCH 063/154] Fix C SDK info --- ledger_secure_sdk_sys/build.rs | 89 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index fc9ee054..78fadb79 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -51,20 +51,6 @@ enum Device { NanoX, Stax, Flex, - Unknown, -} - -impl From<&str> for Device { - fn from(s: &str) -> Self { - match s { - "nanos" => Device::NanoS, - "nanosplus" => Device::NanoSPlus, - "nanox" => Device::NanoX, - "stax" => Device::Stax, - "flex" => Device::Flex, - _s => Device::Unknown, - } - } } impl std::fmt::Display for Device { @@ -75,7 +61,6 @@ impl std::fmt::Display for Device { Device::NanoX => write!(f, "nanox"), Device::Stax => write!(f, "stax"), Device::Flex => write!(f, "flex"), - Device::Unknown => write!(f, "unknown"), } } } @@ -96,15 +81,15 @@ impl CSDKInfo { } } -fn retrieve_sdk_info(device: &Device, path: &PathBuf) -> Result { +fn retrieve_csdk_info(device: &Device, path: &PathBuf) -> Result { let mut csdk_info = CSDKInfo::new(); (csdk_info.api_level, csdk_info.c_sdk_name) = retrieve_makefile_infos(path)?; (csdk_info.target_id, csdk_info.target_name) = retrieve_target_file_infos(device, path)?; - (csdk_info.c_sdk_hash, csdk_info.c_sdk_version) = retrieve_sdk_git_info(path); + (csdk_info.c_sdk_hash, csdk_info.c_sdk_version) = retrieve_csdk_git_info(path); Ok(csdk_info) } -fn retrieve_sdk_git_info(bolos_sdk: &Path) -> (String, String) { +fn retrieve_csdk_git_info(bolos_sdk: &Path) -> (String, String) { let c_sdk_hash = match Command::new("git") .arg("-C") .arg(bolos_sdk) @@ -132,7 +117,6 @@ fn retrieve_sdk_git_info(bolos_sdk: &Path) -> (String, String) { .arg(bolos_sdk) .arg("describe") .arg("--tags") - .arg("--exact-match") .arg("--match") .arg("v[0-9]*") .arg("--dirty") @@ -140,10 +124,10 @@ fn retrieve_sdk_git_info(bolos_sdk: &Path) -> (String, String) { .ok() { Some(output) => { - if output.stdout.is_empty() { - "None".to_string() - } else { + if output.status.success() { String::from_utf8(output.stdout).unwrap_or("None".to_string()) + } else { + String::from_utf8(output.stderr).unwrap_or("None".to_string()) } } None => "None".to_string(), @@ -152,24 +136,35 @@ fn retrieve_sdk_git_info(bolos_sdk: &Path) -> (String, String) { } fn retrieve_makefile_infos(bolos_sdk: &Path) -> Result<(Option, String), SDKBuildError> { - let makefile_defines = + let makefile = File::open(bolos_sdk.join("Makefile.defines")).expect("Could not find Makefile.defines"); let mut api_level: Option = None; - let mut sdk_name: Option = None; - for line in BufReader::new(makefile_defines).lines().flatten() { + for line in BufReader::new(makefile).lines().flatten() { if let Some(value) = line.split(":=").nth(1).map(str::trim) { if line.contains("API_LEVEL") && api_level.is_none() { api_level = Some(value.parse().map_err(|_| SDKBuildError::InvalidAPILevel)?); - } else if line.contains("SDK_NAME") && sdk_name.is_none() { + } + } + if api_level.is_some() { + // Key found, break out of the loop + break; + } + } + let makefile = + File::open(bolos_sdk.join("Makefile.target")).expect("Could not find Makefile.defines"); + let mut sdk_name: Option = None; + for line in BufReader::new(makefile).lines().flatten() { + if let Some(value) = line.split(":=").nth(1).map(str::trim) { + if line.contains("SDK_NAME") && sdk_name.is_none() { sdk_name = Some(value.to_string().replace('\"', "")); } } - - if api_level.is_some() && sdk_name.is_some() { - // Both keys found, break out of the loop + if sdk_name.is_some() { + // Key found, break out of the loop break; } } + let sdk_name = sdk_name.ok_or(SDKBuildError::MissingSDKName)?; Ok((api_level, sdk_name)) } @@ -198,7 +193,10 @@ fn retrieve_target_file_infos( .map_err(|_| SDKBuildError::MissingTargetId)? .to_string(), ); - } else if target_name.is_none() && line.contains("TARGET_") { + } else if target_name.is_none() + && line.contains("#define TARGET_") + && !line.contains("#define TARGET_ID") + { target_name = Some( line.split_whitespace() .nth(1) @@ -242,7 +240,6 @@ fn clone_sdk(device: &Device) -> PathBuf { Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", ), - Device::Unknown => panic!("Unknown device"), }; let out_dir = env::var("OUT_DIR").unwrap(); @@ -344,20 +341,25 @@ impl SDKBuilder { pub fn device(&mut self) -> Result<(), SDKBuildError> { // determine device - self.device = env::var_os("CARGO_CFG_TARGET_OS") + self.device = match env::var_os("CARGO_CFG_TARGET_OS") .unwrap() .to_str() .unwrap() - .into(); + { + "nanos" => Device::NanoS, + "nanosplus" => Device::NanoSPlus, + "nanox" => Device::NanoX, + "stax" => Device::Stax, + "flex" => Device::Flex, + _ => { + return Err(SDKBuildError::UnknownDevice); + } + }; - if self.device == Device::Unknown { - return Err(SDKBuildError::UnknownDevice); - } else { - // export TARGET into env for 'infos.rs' - println!("cargo:rustc-env=TARGET={}", self.device); - println!("cargo:warning=Device is {:?}", self.device); - Ok(()) - } + // export TARGET into env for 'infos.rs' + println!("cargo:rustc-env=TARGET={}", self.device); + println!("cargo:warning=Device is {:?}", self.device); + Ok(()) } pub fn bolos_sdk(&mut self) -> Result<(), SDKBuildError> { @@ -367,7 +369,7 @@ impl SDKBuilder { Ok(path) => PathBuf::from(path), }; - let sdk_info = retrieve_sdk_info(&self.device, &self.bolos_sdk)?; + let sdk_info = retrieve_csdk_info(&self.device, &self.bolos_sdk)?; match sdk_info.api_level { Some(api_level) => { @@ -428,7 +430,6 @@ impl SDKBuilder { Device::NanoSPlus => out_path.join("glyphs_nanosplus"), Device::NanoX => out_path.join("glyphs_nanox"), Device::NanoS => panic!("Nano S does not support glyphs"), - Device::Unknown => panic!("Unknown device"), }; if !dest_path.exists() { fs::create_dir_all(&dest_path).ok(); @@ -522,7 +523,6 @@ impl SDKBuilder { Device::NanoSPlus => finalize_nanosplus_configuration(&mut command, &self.bolos_sdk), Device::Stax => finalize_stax_configuration(&mut command, &self.bolos_sdk), Device::Flex => finalize_flex_configuration(&mut command, &self.bolos_sdk), - Device::Unknown => panic!("Unknown device"), }; // Add the defines found in the Makefile.conf.cx to our build command. @@ -593,7 +593,6 @@ impl SDKBuilder { Device::NanoSPlus => ("nanos2", "sdk_nanosp.h"), Device::Stax => ("stax", "sdk_stax.h"), Device::Flex => ("flex", "sdk_flex.h"), - Device::Unknown => panic!("Unknown device"), }; bindings = bindings.clang_arg(format!("-I{bsdk}/target/{include_path}/include/")); bindings = bindings.header(header); From 28ef844dc0e883b91863860d844779694f9bf236 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 10 Feb 2025 10:31:05 +0100 Subject: [PATCH 064/154] Use single file for glyphs --- ledger_secure_sdk_sys/build.rs | 84 +++++++++++++++++----------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 78fadb79..237aa0a0 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -259,7 +259,7 @@ fn clone_sdk(device: &Device) -> PathBuf { #[derive(Debug)] enum SDKBuildError { - UnknownDevice, + UnsupportedDevice, InvalidAPILevel, MissingSDKName, TargetFileNotFound, @@ -303,6 +303,7 @@ struct SDKBuilder { api_level: u32, gcc_toolchain: PathBuf, device: Device, + glyphs_folders: Vec, cxdefines: Vec, } @@ -313,6 +314,7 @@ impl SDKBuilder { api_level: 0, gcc_toolchain: PathBuf::new(), device: Device::NanoS, + glyphs_folders: Vec::new(), cxdefines: Vec::new(), } } @@ -352,7 +354,7 @@ impl SDKBuilder { "stax" => Device::Stax, "flex" => Device::Flex, _ => { - return Err(SDKBuildError::UnknownDevice); + return Err(SDKBuildError::UnsupportedDevice); } }; @@ -370,7 +372,6 @@ impl SDKBuilder { }; let sdk_info = retrieve_csdk_info(&self.device, &self.bolos_sdk)?; - match sdk_info.api_level { Some(api_level) => { self.api_level = api_level; @@ -384,6 +385,31 @@ impl SDKBuilder { } } } + + // set glyphs folders + match self.device { + Device::Flex => { + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/40px")); + } + Device::Stax => { + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/32px")); + } + _ => { + self.glyphs_folders + .push(self.bolos_sdk.join("lib_nbgl/glyphs/nano")); + } + } + // Export other SDK infos into env for 'infos.rs' println!("cargo:rustc-env=TARGET_ID={}", sdk_info.target_id); println!("cargo:warning=TARGET_ID is {}", sdk_info.target_id); @@ -398,7 +424,7 @@ impl SDKBuilder { Ok(()) } - fn cxdefines(&mut self) { + fn cxdefines(&mut self) -> Result<(), SDKBuildError> { let mut makefile = File::open(self.bolos_sdk.join("Makefile.conf.cx")) .expect("Could not find Makefile.conf.cx"); let mut content = String::new(); @@ -414,51 +440,29 @@ impl SDKBuilder { cxdefines.push("NATIVE_LITTLE_ENDIAN".to_string()); self.cxdefines = cxdefines; + Ok(()) } - pub fn generate_glyphs(&self) { + pub fn generate_glyphs(&self) -> Result<(), SDKBuildError> { if self.device == Device::NanoS { - return; + return Err(SDKBuildError::UnsupportedDevice); } let icon2glyph = self.bolos_sdk.join("lib_nbgl/tools/icon2glyph.py"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - let dest_path = match self.device { - Device::Flex => out_path.join("glyphs_flex"), - Device::Stax => out_path.join("glyphs_stax"), - Device::NanoSPlus => out_path.join("glyphs_nanosplus"), - Device::NanoX => out_path.join("glyphs_nanox"), - Device::NanoS => panic!("Nano S does not support glyphs"), - }; + let dest_path = out_path.join("glyphs"); if !dest_path.exists() { fs::create_dir_all(&dest_path).ok(); } - let mut glyph_folders: Vec = Vec::new(); - match self.device { - Device::Flex => { - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/40px")); - } - Device::Stax => { - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/32px")); - } - _ => { - glyph_folders.push(self.bolos_sdk.join("lib_nbgl/glyphs/nano")); - } - } - let mut cmd = Command::new(icon2glyph.as_os_str()); cmd.arg("--glyphcheader") .arg(dest_path.join("glyphs.h").as_os_str()) .arg("--glyphcfile") .arg(dest_path.join("glyphs.c").as_os_str()); - for folder in glyph_folders.iter() { + for folder in self.glyphs_folders.iter() { for file in std::fs::read_dir(folder).unwrap() { let path = file.unwrap().path(); let path_str = path.to_str().unwrap().to_string(); @@ -467,6 +471,7 @@ impl SDKBuilder { } let _ = cmd.output(); + Ok(()) } pub fn build_c_sdk(&self) { @@ -617,11 +622,7 @@ impl SDKBuilder { Device::Stax | Device::Flex => { let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let mut include_path = "-I".to_string(); - let glyphs = match self.device { - Device::Stax => out_path.join("glyphs_stax"), - Device::Flex => out_path.join("glyphs_flex"), - _ => panic!("Invalid device"), - }; + let glyphs = out_path.join("glyphs"); include_path += glyphs.to_str().unwrap(); bindings = bindings.clang_args([include_path.as_str()]); @@ -695,9 +696,8 @@ fn main() { sdk_builder.gcc_toolchain().unwrap(); sdk_builder.device().unwrap(); sdk_builder.bolos_sdk().unwrap(); - sdk_builder.cxdefines(); - sdk_builder.generate_glyphs(); - + sdk_builder.cxdefines().unwrap(); + sdk_builder.generate_glyphs().unwrap(); sdk_builder.build_c_sdk(); sdk_builder.generate_bindings(); sdk_builder.generate_heap_size(); @@ -768,7 +768,9 @@ fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { } fn configure_lib_bagl(command: &mut cc::Build, bolos_sdk: &Path) { + println!("cargo:warning=TEST if LIB_BAGL is built"); if env::var_os("CARGO_FEATURE_LIB_BAGL").is_some() { + println!("cargo:warning=LIB_BAGL is built"); command .define("HAVE_BAGL", None) // Just include all the fonts for now; we can shrink the X and S+ images later. @@ -801,7 +803,7 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command.define(define.as_str(), value.as_deref()); } - let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs_stax"); + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command .target("thumbv8m.main-none-eabi") .file(bolos_sdk.join("src/ledger_protocol.c")) @@ -831,7 +833,7 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command.define(define.as_str(), value.as_deref()); } - let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs_flex"); + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command .target("thumbv8m.main-none-eabi") .file(bolos_sdk.join("src/ledger_protocol.c")) From 4386359ebfd904e7f5746d15a755240b04c78184 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 10 Feb 2025 17:26:29 +0100 Subject: [PATCH 065/154] Enable NBGL for Nano S+ and Nano X --- ledger_secure_sdk_sys/Cargo.toml | 1 + ledger_secure_sdk_sys/build.rs | 151 ++++++++++++++--------------- ledger_secure_sdk_sys/sdk_flex.h | 43 ++++++-- ledger_secure_sdk_sys/sdk_nanosp.h | 43 +++++--- ledger_secure_sdk_sys/sdk_nanox.h | 46 +++++++-- ledger_secure_sdk_sys/sdk_stax.h | 44 +++++++-- 6 files changed, 209 insertions(+), 119 deletions(-) diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index b4f5c604..ba09348c 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -19,6 +19,7 @@ critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] ccid = [] +nbgl = [] [lints.rust.unexpected_cfgs] level = "warn" diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 237aa0a0..b13a86b6 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -504,13 +504,20 @@ impl SDKBuilder { .debug(true) .flag("-Oz") .flag("-fomit-frame-pointer") + .flag("-momit-leaf-frame-pointer") .flag("-fno-common") + .flag("-mlittle-endian") + .flag("-std=gnu99") .flag("-fdata-sections") .flag("-ffunction-sections") - .flag("-mthumb") - .flag("-fno-jump-tables") + .flag("-funsigned-char") .flag("-fshort-enums") .flag("-mno-unaligned-access") + .flag("-fropi") + .flag("-mthumb") + .flag("-fno-jump-tables") + .flag("-nostdlib") + .flag("-nodefaultlibs") .flag("-Wno-unused-command-line-argument") .clone(); @@ -607,11 +614,47 @@ impl SDKBuilder { bindings = bindings.header(header); } + // BAGL or NBGL bindings match self.device { Device::NanoS => { bindings = bindings.header(self.bolos_sdk.join("include/bagl.h").to_str().unwrap()) } - Device::NanoX => { + Device::NanoSPlus | Device::NanoX | Device::Stax | Device::Flex => { + if ((self.device == Device::NanoX || self.device == Device::NanoSPlus) + && env::var_os("CARGO_FEATURE_NBGL").is_some()) + || self.device == Device::Stax + || self.device == Device::Flex + { + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let mut include_path = "-I".to_string(); + let glyphs = out_path.join("glyphs"); + include_path += glyphs.to_str().unwrap(); + bindings = bindings.clang_args([include_path.as_str()]); + + bindings = bindings.clang_args([ + format!("-I{bsdk}/lib_nbgl/include/").as_str(), + format!("-I{bsdk}/lib_ux_nbgl/").as_str(), + ]); + bindings = bindings + .header( + self.bolos_sdk + .join("lib_nbgl/include/nbgl_use_case.h") + .to_str() + .unwrap(), + ) + .header( + self.bolos_sdk + .join("lib_ux_nbgl/ux_nbgl.h") + .to_str() + .unwrap(), + ); + } + } + } + + // BLE bindings + match self.device { + Device::NanoX | Device::Flex | Device::Stax => { bindings = bindings.header( self.bolos_sdk .join("lib_blewbxx_impl/include/ledger_ble.h") @@ -619,37 +662,6 @@ impl SDKBuilder { .unwrap(), ) } - Device::Stax | Device::Flex => { - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - let mut include_path = "-I".to_string(); - let glyphs = out_path.join("glyphs"); - include_path += glyphs.to_str().unwrap(); - bindings = bindings.clang_args([include_path.as_str()]); - - bindings = bindings.clang_args([ - format!("-I{bsdk}/lib_nbgl/include/").as_str(), - format!("-I{bsdk}/lib_ux_nbgl/").as_str(), - ]); - bindings = bindings - .header( - self.bolos_sdk - .join("lib_nbgl/include/nbgl_use_case.h") - .to_str() - .unwrap(), - ) - .header( - self.bolos_sdk - .join("lib_ux_nbgl/ux_nbgl.h") - .to_str() - .unwrap(), - ) - .header( - self.bolos_sdk - .join("lib_blewbxx_impl/include/ledger_ble.h") - .to_str() - .unwrap(), - ) - } _ => (), } @@ -712,8 +724,6 @@ fn finalize_nanos_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command .target("thumbv6m-none-eabi") .define("ST31", None) - .define("BAGL_HEIGHT", Some("32")) - .define("BAGL_WIDTH", Some("128")) .include(bolos_sdk.join("target/nanos/include")) .flag("-fropi"); } @@ -727,8 +737,6 @@ fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command .target("thumbv6m-none-eabi") .define("ST33", None) - .define("BAGL_HEIGHT", Some("64")) - .define("BAGL_WIDTH", Some("128")) .file(bolos_sdk.join("src/ledger_protocol.c")) .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) @@ -747,7 +755,17 @@ fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &Path) { .flag("-ffixed-r9") .flag("-fropi") .flag("-frwpi"); - configure_lib_bagl(command, bolos_sdk); + + if env::var_os("CARGO_FEATURE_NBGL").is_some() { + println!("cargo:warning=NBGL is built"); + command.define("HAVE_NBGL", None); + command.define("NBGL_STEP", None); + command.define("NBGL_USE_CASE", None); + configure_lib_nbgl(command, bolos_sdk); + } else { + println!("cargo:warning=BAGL is built"); + command.define("HAVE_BAGL", None); + } } fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { @@ -759,41 +777,19 @@ fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command .target("thumbv8m.main-none-eabi") .define("ST33K1M5", None) - .define("BAGL_HEIGHT", Some("64")) - .define("BAGL_WIDTH", Some("128")) .include(bolos_sdk.join("target/nanos2/include")) .flag("-fropi") .flag("-frwpi"); - configure_lib_bagl(command, bolos_sdk); -} -fn configure_lib_bagl(command: &mut cc::Build, bolos_sdk: &Path) { - println!("cargo:warning=TEST if LIB_BAGL is built"); - if env::var_os("CARGO_FEATURE_LIB_BAGL").is_some() { - println!("cargo:warning=LIB_BAGL is built"); - command - .define("HAVE_BAGL", None) - // Just include all the fonts for now; we can shrink the X and S+ images later. - .define("HAVE_BAGL_FONT_LUCIDA_CONSOLE_8PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16_22PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_REGULAR_8_11PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_REGULAR_10_13PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11_14PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_REGULAR_13_18PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_REGULAR_22_30PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_SEMIBOLD_8_11PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_SEMIBOLD_10_13PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_SEMIBOLD_11_16PX", None) - .define("HAVE_BAGL_FONT_OPEN_SANS_SEMIBOLD_13_18PX", None) - .define("HAVE_BAGL_FONT_SYMBOLS_0", None) - .define("HAVE_BAGL_FONT_SYMBOLS_1", None) - .include(bolos_sdk.join("lib_bagl/src/")) - .file(bolos_sdk.join("lib_bagl/src/bagl.c")) - .file(bolos_sdk.join("lib_bagl/src/bagl_fonts.c")) - .file(bolos_sdk.join("lib_bagl/src/bagl_glyphs.c")); + if env::var_os("CARGO_FEATURE_NBGL").is_some() { + println!("cargo:warning=NBGL is built"); + command.define("HAVE_NBGL", None); + command.define("NBGL_STEP", None); + command.define("NBGL_USE_CASE", None); + configure_lib_nbgl(command, bolos_sdk); + } else { + println!("cargo:warning=BAGL is built"); + command.define("HAVE_BAGL", None); } } @@ -803,7 +799,6 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command.define(define.as_str(), value.as_deref()); } - let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command .target("thumbv8m.main-none-eabi") .file(bolos_sdk.join("src/ledger_protocol.c")) @@ -821,9 +816,7 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { .include(bolos_sdk.join("lib_blewbxx_impl/include")) .include(bolos_sdk.join("target/stax/include/")) .flag("-fropi") - .flag("-frwpi") - .include(&glyphs_path) - .file(glyphs_path.join("glyphs.c")); + .flag("-frwpi"); configure_lib_nbgl(command, bolos_sdk); } @@ -833,7 +826,6 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command.define(define.as_str(), value.as_deref()); } - let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command .target("thumbv8m.main-none-eabi") .file(bolos_sdk.join("src/ledger_protocol.c")) @@ -851,13 +843,12 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { .include(bolos_sdk.join("lib_blewbxx_impl/include")) .include(bolos_sdk.join("target/flex/include/")) .flag("-fropi") - .flag("-frwpi") - .include(&glyphs_path) - .file(glyphs_path.join("glyphs.c")); + .flag("-frwpi"); configure_lib_nbgl(command, bolos_sdk); } fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) { + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command .flag("-Wno-microsoft-anon-tag") .flag("-fms-extensions") @@ -875,5 +866,7 @@ fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) { .unwrap() .map(|x| x.unwrap()) .collect::>(), - ); + ) + .include(&glyphs_path) + .file(glyphs_path.join("glyphs.c")); } diff --git a/ledger_secure_sdk_sys/sdk_flex.h b/ledger_secure_sdk_sys/sdk_flex.h index b3350ab9..7b4d1556 100644 --- a/ledger_secure_sdk_sys/sdk_flex.h +++ b/ledger_secure_sdk_sys/sdk_flex.h @@ -1,19 +1,19 @@ -#define HAVE_SPRINTF -#define HAVE_LOCAL_APDU_BUFFER +// Standard Defines #define IO_HID_EP_LENGTH 64 -#define USB_SEGMENT_SIZE 64 -#define OS_IO_SEPROXYHAL +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U #define HAVE_IO_USB #define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU -#define __IO volatile -#define IO_USB_MAX_ENDPOINTS 6 +#define USB_SEGMENT_SIZE 64 +#define OS_IO_SEPROXYHAL +#define HAVE_LOCAL_APDU_BUFFER #define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +#define __IO volatile #define main _start -#define NBGL_QRCODE - -// from Makefile.defines +// NBGL #define HAVE_BAGL_FONT_INTER_REGULAR_28PX #define HAVE_BAGL_FONT_INTER_SEMIBOLD_28PX #define HAVE_BAGL_FONT_INTER_MEDIUM_36PX @@ -27,7 +27,30 @@ #define SCREEN_SIZE_WALLET #define HAVE_FAST_HOLD_TO_APPROVE +// WEB USB +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL + +// BLE SUPPORT #define HAVE_BLE #define HAVE_BLE_APDU #define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 \ No newline at end of file +#define BLE_SEGMENT_SIZE 32 +#define HAVE_INAPP_BLE_PAIRING + +// NFC SUPPORT +//#define HAVE_NFC +//#define HAVE_NFC_READER + +// APP STORAGE +//#define HAVE_APP_STORAGE + +// NBGL QRCODE +#define NBGL_QRCODE + +// NBGL KEYBOARD +//#define NBGL_KEYBOARD + +// NBGL KEYPAD +//#define NBGL_KEYPAD diff --git a/ledger_secure_sdk_sys/sdk_nanosp.h b/ledger_secure_sdk_sys/sdk_nanosp.h index ce099221..29792604 100644 --- a/ledger_secure_sdk_sys/sdk_nanosp.h +++ b/ledger_secure_sdk_sys/sdk_nanosp.h @@ -1,19 +1,40 @@ -#define HAVE_LOCAL_APDU_BUFFER +// Standard Defines #define IO_HID_EP_LENGTH 64 -#define USB_SEGMENT_SIZE 64 -#define OS_IO_SEPROXYHAL +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U #define HAVE_IO_USB #define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define OS_IO_SEPROXYHAL +#define HAVE_LOCAL_APDU_BUFFER +#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 #define __IO volatile -#define IO_USB_MAX_ENDPOINTS 6 -#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 #define main _start -#define HAVE_SEPROXYHAL_MCU -#define HAVE_MCU_PROTECT -#define HAVE_MCU_SEPROXYHAL -#define HAVE_MCU_SERIAL_STORAGE #define HAVE_SE_BUTTON -#define HAVE_BAGL -#define HAVE_SE_SCREEN \ No newline at end of file +#define HAVE_SE_SCREEN +#define HAVE_FONTS + +#define BAGL_HEIGHT 64 +#define BAGL_WIDTH 128 +#define HAVE_BAGL_ELLIPSIS +#define HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX +#define SCREEN_SIZE_NANO + +// WEB USB +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL + +// APP STORAGE +//#define HAVE_APP_STORAGE + +// NBGL KEYBOARD +//#define NBGL_KEYBOARD + +// NBGL KEYPAD +//#define NBGL_KEYPAD \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_nanox.h b/ledger_secure_sdk_sys/sdk_nanox.h index aa4c956a..7c04b35e 100644 --- a/ledger_secure_sdk_sys/sdk_nanox.h +++ b/ledger_secure_sdk_sys/sdk_nanox.h @@ -1,22 +1,50 @@ -#define HAVE_LOCAL_APDU_BUFFER +// Standard Defines #define IO_HID_EP_LENGTH 64 -#define USB_SEGMENT_SIZE 64 -#define OS_IO_SEPROXYHAL +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U #define HAVE_IO_USB #define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define OS_IO_SEPROXYHAL +#define HAVE_LOCAL_APDU_BUFFER +#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 #define __IO volatile -#define IO_USB_MAX_ENDPOINTS 6 -#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 #define main _start #define HAVE_SEPROXYHAL_MCU #define HAVE_MCU_PROTECT -#define HAVE_MCU_SEPROXYHAL -#define HAVE_MCU_SERIAL_STORAGE + #define HAVE_SE_BUTTON -#define HAVE_BAGL #define HAVE_SE_SCREEN +#define HAVE_FONTS + +#define BAGL_HEIGHT 64 +#define BAGL_WIDTH 128 +#define HAVE_BAGL_ELLIPSIS +#define HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX +#define SCREEN_SIZE_NANO + +// WEB USB +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL +// BLE SUPPORT #define HAVE_BLE -#define HAVE_BLE_APDU \ No newline at end of file +#define HAVE_BLE_APDU +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define BLE_SEGMENT_SIZE 32 +#define HAVE_INAPP_BLE_PAIRING + +// APP STORAGE +//#define HAVE_APP_STORAGE + +// NBGL KEYBOARD +//#define NBGL_KEYBOARD + +// NBGL KEYPAD +//#define NBGL_KEYPAD \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_stax.h b/ledger_secure_sdk_sys/sdk_stax.h index ace4a4b5..40cb016b 100644 --- a/ledger_secure_sdk_sys/sdk_stax.h +++ b/ledger_secure_sdk_sys/sdk_stax.h @@ -1,19 +1,19 @@ -#define HAVE_SPRINTF -#define HAVE_LOCAL_APDU_BUFFER +// Standard Defines #define IO_HID_EP_LENGTH 64 -#define USB_SEGMENT_SIZE 64 -#define OS_IO_SEPROXYHAL +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U #define HAVE_IO_USB #define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU -#define __IO volatile -#define IO_USB_MAX_ENDPOINTS 6 +#define USB_SEGMENT_SIZE 64 +#define OS_IO_SEPROXYHAL +#define HAVE_LOCAL_APDU_BUFFER #define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +#define __IO volatile #define main _start -#define NBGL_QRCODE - -// from Makefile.defines +// NBGL #define HAVE_BAGL_FONT_INTER_REGULAR_24PX #define HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX #define HAVE_BAGL_FONT_INTER_MEDIUM_32PX @@ -26,7 +26,31 @@ #define NBGL_USE_CASE #define SCREEN_SIZE_WALLET +// WEB USB +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL + +// BLE SUPPORT #define HAVE_BLE #define HAVE_BLE_APDU #define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 \ No newline at end of file +#define BLE_SEGMENT_SIZE 32 +#define HAVE_INAPP_BLE_PAIRING + +// NFC SUPPORT +//#define HAVE_NFC +//#define HAVE_NFC_READER + +// APP STORAGE +//#define HAVE_APP_STORAGE + +// NBGL QRCODE +#define NBGL_QRCODE + +// NBGL KEYBOARD +//#define NBGL_KEYBOARD + +// NBGL KEYPAD +//#define NBGL_KEYPAD + From 4524cbb24994369fea4a20772693e9febe26f04a Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Feb 2025 11:59:37 +0100 Subject: [PATCH 066/154] Cleanup header files --- ledger_secure_sdk_sys/build.rs | 3 --- ledger_secure_sdk_sys/sdk_flex.h | 22 +++++++++++----------- ledger_secure_sdk_sys/sdk_nanosp.h | 8 ++++---- ledger_secure_sdk_sys/sdk_nanox.h | 20 ++++++++++---------- ledger_secure_sdk_sys/sdk_stax.h | 23 +++++++++++------------ 5 files changed, 36 insertions(+), 40 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b13a86b6..dc1e6e04 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -574,7 +574,6 @@ impl SDKBuilder { format!("-I{bsdk}/lib_stusb/STM32_USB_Device_Library/Core/Inc/"), format!("-I{bsdk}/lib_stusb/"), ]; - let headers = str2path( &self.bolos_sdk, &[ @@ -736,7 +735,6 @@ fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command .target("thumbv6m-none-eabi") - .define("ST33", None) .file(bolos_sdk.join("src/ledger_protocol.c")) .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) @@ -776,7 +774,6 @@ fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { command .target("thumbv8m.main-none-eabi") - .define("ST33K1M5", None) .include(bolos_sdk.join("target/nanos2/include")) .flag("-fropi") .flag("-frwpi"); diff --git a/ledger_secure_sdk_sys/sdk_flex.h b/ledger_secure_sdk_sys/sdk_flex.h index 7b4d1556..5ab7def1 100644 --- a/ledger_secure_sdk_sys/sdk_flex.h +++ b/ledger_secure_sdk_sys/sdk_flex.h @@ -27,11 +27,6 @@ #define SCREEN_SIZE_WALLET #define HAVE_FAST_HOLD_TO_APPROVE -// WEB USB -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL - // BLE SUPPORT #define HAVE_BLE #define HAVE_BLE_APDU @@ -39,18 +34,23 @@ #define BLE_SEGMENT_SIZE 32 #define HAVE_INAPP_BLE_PAIRING -// NFC SUPPORT +// WEB USB (not supported in Rust SDK) +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL + +// NFC SUPPORT (feature dependent) //#define HAVE_NFC //#define HAVE_NFC_READER -// APP STORAGE +// APP STORAGE (feature dependent) //#define HAVE_APP_STORAGE -// NBGL QRCODE -#define NBGL_QRCODE +// NBGL QRCODE (feature dependent) +#define NBGL_QRCODE -// NBGL KEYBOARD +// NBGL KEYBOARD (feature dependent) //#define NBGL_KEYBOARD -// NBGL KEYPAD +// NBGL KEYPAD (feature dependent) //#define NBGL_KEYPAD diff --git a/ledger_secure_sdk_sys/sdk_nanosp.h b/ledger_secure_sdk_sys/sdk_nanosp.h index 29792604..9fa00a00 100644 --- a/ledger_secure_sdk_sys/sdk_nanosp.h +++ b/ledger_secure_sdk_sys/sdk_nanosp.h @@ -25,16 +25,16 @@ #define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX #define SCREEN_SIZE_NANO -// WEB USB +// WEB USB (not supported in Rust SDK) //#define HAVE_WEBUSB //#define WEBUSB_URL_SIZE_B //#define WEBUSB_URL -// APP STORAGE +// APP STORAGE (feature dependent) //#define HAVE_APP_STORAGE -// NBGL KEYBOARD +// NBGL KEYBOARD (feature dependent) //#define NBGL_KEYBOARD -// NBGL KEYPAD +// NBGL KEYPAD (feature dependent) //#define NBGL_KEYPAD \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_nanox.h b/ledger_secure_sdk_sys/sdk_nanox.h index 7c04b35e..48cea500 100644 --- a/ledger_secure_sdk_sys/sdk_nanox.h +++ b/ledger_secure_sdk_sys/sdk_nanox.h @@ -13,9 +13,6 @@ #define __IO volatile #define main _start -#define HAVE_SEPROXYHAL_MCU -#define HAVE_MCU_PROTECT - #define HAVE_SE_BUTTON #define HAVE_SE_SCREEN #define HAVE_FONTS @@ -28,10 +25,8 @@ #define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX #define SCREEN_SIZE_NANO -// WEB USB -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL +#define HAVE_SEPROXYHAL_MCU +#define HAVE_MCU_PROTECT // BLE SUPPORT #define HAVE_BLE @@ -40,11 +35,16 @@ #define BLE_SEGMENT_SIZE 32 #define HAVE_INAPP_BLE_PAIRING -// APP STORAGE +// WEB USB (not supported in Rust SDK) +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL + +// APP STORAGE (feature dependent) //#define HAVE_APP_STORAGE -// NBGL KEYBOARD +// NBGL KEYBOARD (feature dependent) //#define NBGL_KEYBOARD -// NBGL KEYPAD +// NBGL KEYPAD (feature dependent) //#define NBGL_KEYPAD \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_stax.h b/ledger_secure_sdk_sys/sdk_stax.h index 40cb016b..7b4277b1 100644 --- a/ledger_secure_sdk_sys/sdk_stax.h +++ b/ledger_secure_sdk_sys/sdk_stax.h @@ -26,31 +26,30 @@ #define NBGL_USE_CASE #define SCREEN_SIZE_WALLET -// WEB USB -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL - -// BLE SUPPORT +// BLE SUPPORT #define HAVE_BLE #define HAVE_BLE_APDU #define BLE_COMMAND_TIMEOUT_MS 2000 #define BLE_SEGMENT_SIZE 32 #define HAVE_INAPP_BLE_PAIRING -// NFC SUPPORT +// WEB USB (not supported in Rust SDK) +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL + +// NFC SUPPORT (feature dependent) //#define HAVE_NFC //#define HAVE_NFC_READER -// APP STORAGE +// APP STORAGE (feature dependent) //#define HAVE_APP_STORAGE -// NBGL QRCODE +// NBGL QRCODE (feature dependent) #define NBGL_QRCODE -// NBGL KEYBOARD +// NBGL KEYBOARD (feature dependent) //#define NBGL_KEYBOARD -// NBGL KEYPAD +// NBGL KEYPAD (feature dependent) //#define NBGL_KEYPAD - From 49105be758055bd2148fd75958ee4f5f62a3fd7b Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Feb 2025 15:03:10 +0100 Subject: [PATCH 067/154] Update header for each target --- ledger_secure_sdk_sys/build.rs | 1 + ledger_secure_sdk_sys/sdk_flex.h | 68 ++++++++++++++++-------------- ledger_secure_sdk_sys/sdk_nanos.h | 3 +- ledger_secure_sdk_sys/sdk_nanosp.h | 48 ++++++++++++--------- ledger_secure_sdk_sys/sdk_nanox.h | 63 +++++++++++++++------------ ledger_secure_sdk_sys/sdk_stax.h | 67 +++++++++++++++-------------- 6 files changed, 137 insertions(+), 113 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index dc1e6e04..16f8e202 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -519,6 +519,7 @@ impl SDKBuilder { .flag("-nostdlib") .flag("-nodefaultlibs") .flag("-Wno-unused-command-line-argument") + .define("main", "_start") .clone(); // #[cfg(feature = "ccid")] diff --git a/ledger_secure_sdk_sys/sdk_flex.h b/ledger_secure_sdk_sys/sdk_flex.h index 5ab7def1..7c64a534 100644 --- a/ledger_secure_sdk_sys/sdk_flex.h +++ b/ledger_secure_sdk_sys/sdk_flex.h @@ -1,4 +1,25 @@ -// Standard Defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.standard_app +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// BLUETOOTH +#define HAVE_BLE +#define HAVE_BLE_APDU +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define BLE_SEGMENT_SIZE 32 +// NFC SUPPORT (feature dependent) +//#define HAVE_NFC +//#define HAVE_NFC_READER +// APP STORAGE (feature dependent) +//#define HAVE_APP_STORAGE +// IO SEPROXY BUFFER SIZE +#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +// NBGL QRCODE (feature dependent) +#define NBGL_QRCODE +// NBGL KEYBOARD (feature dependent) +//#define NBGL_KEYBOARD +// NBGL KEYPAD (feature dependent) +//#define NBGL_KEYPAD +// STANDARD DEFINES #define IO_HID_EP_LENGTH 64 #define HAVE_SPRINTF #define HAVE_SNPRINTF_FORMAT_U @@ -7,13 +28,16 @@ #define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU #define USB_SEGMENT_SIZE 64 +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL #define OS_IO_SEPROXYHAL -#define HAVE_LOCAL_APDU_BUFFER -#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define gcc #define __IO volatile -#define main _start - -// NBGL +// Flex #define HAVE_BAGL_FONT_INTER_REGULAR_28PX #define HAVE_BAGL_FONT_INTER_SEMIBOLD_28PX #define HAVE_BAGL_FONT_INTER_MEDIUM_36PX @@ -22,35 +46,15 @@ #define HAVE_PIEZO_SOUND #define HAVE_SE_TOUCH #define HAVE_SE_EINK_DISPLAY +//#define HAVE_HW_TOUCH_SWIPE #define NBGL_PAGE #define NBGL_USE_CASE #define SCREEN_SIZE_WALLET #define HAVE_FAST_HOLD_TO_APPROVE -// BLE SUPPORT -#define HAVE_BLE -#define HAVE_BLE_APDU -#define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 -#define HAVE_INAPP_BLE_PAIRING - -// WEB USB (not supported in Rust SDK) -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL - -// NFC SUPPORT (feature dependent) -//#define HAVE_NFC -//#define HAVE_NFC_READER +#define HAVE_LEDGER_PKI -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE - -// NBGL QRCODE (feature dependent) -#define NBGL_QRCODE - -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD - -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Misc +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define HAVE_LOCAL_APDU_BUFFER \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_nanos.h b/ledger_secure_sdk_sys/sdk_nanos.h index 7d665ec9..2d5e6937 100644 --- a/ledger_secure_sdk_sys/sdk_nanos.h +++ b/ledger_secure_sdk_sys/sdk_nanos.h @@ -7,5 +7,4 @@ #define HAVE_USB_APDU #define __IO volatile #define IO_USB_MAX_ENDPOINTS 6 -#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 -#define main _start \ No newline at end of file +#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_nanosp.h b/ledger_secure_sdk_sys/sdk_nanosp.h index 9fa00a00..c4c20033 100644 --- a/ledger_secure_sdk_sys/sdk_nanosp.h +++ b/ledger_secure_sdk_sys/sdk_nanosp.h @@ -1,4 +1,15 @@ -// Standard Defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.standard_app +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// APP STORAGE (feature dependent) +//#define HAVE_APP_STORAGE +// IO SEPROXY BUFFER SIZE +#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +// NBGL KEYBOARD (feature dependent) +//#define NBGL_KEYBOARD +// NBGL KEYPAD (feature dependent) +//#define NBGL_KEYPAD +// STANDARD DEFINES #define IO_HID_EP_LENGTH 64 #define HAVE_SPRINTF #define HAVE_SNPRINTF_FORMAT_U @@ -7,15 +18,15 @@ #define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU #define USB_SEGMENT_SIZE 64 +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL #define OS_IO_SEPROXYHAL -#define HAVE_LOCAL_APDU_BUFFER -#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define gcc #define __IO volatile -#define main _start - -#define HAVE_SE_BUTTON -#define HAVE_SE_SCREEN -#define HAVE_FONTS #define BAGL_HEIGHT 64 #define BAGL_WIDTH 128 @@ -25,16 +36,15 @@ #define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX #define SCREEN_SIZE_NANO -// WEB USB (not supported in Rust SDK) -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL - -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE +#define HAVE_SE_BUTTON +#define HAVE_SE_SCREEN +#define HAVE_FONTS +#define HAVE_INAPP_BLE_PAIRING +#define HAVE_BATTERY -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD +#define HAVE_LEDGER_PKI -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD \ No newline at end of file +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Misc +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define HAVE_LOCAL_APDU_BUFFER \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_nanox.h b/ledger_secure_sdk_sys/sdk_nanox.h index 48cea500..67d758c3 100644 --- a/ledger_secure_sdk_sys/sdk_nanox.h +++ b/ledger_secure_sdk_sys/sdk_nanox.h @@ -1,4 +1,20 @@ -// Standard Defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.standard_app +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// BLUETOOTH +#define HAVE_BLE +#define HAVE_BLE_APDU +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define BLE_SEGMENT_SIZE 32 +// APP STORAGE (feature dependent) +//#define HAVE_APP_STORAGE +// IO SEPROXY BUFFER SIZE +#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +// NBGL KEYBOARD (feature dependent) +//#define NBGL_KEYBOARD +// NBGL KEYPAD (feature dependent) +//#define NBGL_KEYPAD +// STANDARD DEFINES #define IO_HID_EP_LENGTH 64 #define HAVE_SPRINTF #define HAVE_SNPRINTF_FORMAT_U @@ -7,15 +23,15 @@ #define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU #define USB_SEGMENT_SIZE 64 +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL #define OS_IO_SEPROXYHAL -#define HAVE_LOCAL_APDU_BUFFER -#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define gcc #define __IO volatile -#define main _start - -#define HAVE_SE_BUTTON -#define HAVE_SE_SCREEN -#define HAVE_FONTS #define BAGL_HEIGHT 64 #define BAGL_WIDTH 128 @@ -25,26 +41,17 @@ #define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX #define SCREEN_SIZE_NANO -#define HAVE_SEPROXYHAL_MCU -#define HAVE_MCU_PROTECT - -// BLE SUPPORT -#define HAVE_BLE -#define HAVE_BLE_APDU -#define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 +#define HAVE_SE_BUTTON +#define HAVE_SE_SCREEN +#define HAVE_FONTS #define HAVE_INAPP_BLE_PAIRING +#define HAVE_BATTERY -// WEB USB (not supported in Rust SDK) -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL - -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE - -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD +#define HAVE_LEDGER_PKI -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD \ No newline at end of file +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Misc +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define HAVE_LOCAL_APDU_BUFFER +#define HAVE_SEPROXYHAL_MCU +#define HAVE_MCU_PROTECT \ No newline at end of file diff --git a/ledger_secure_sdk_sys/sdk_stax.h b/ledger_secure_sdk_sys/sdk_stax.h index 7b4277b1..85b27aa9 100644 --- a/ledger_secure_sdk_sys/sdk_stax.h +++ b/ledger_secure_sdk_sys/sdk_stax.h @@ -1,4 +1,25 @@ -// Standard Defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.standard_app +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// BLUETOOTH +#define HAVE_BLE +#define HAVE_BLE_APDU +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define BLE_SEGMENT_SIZE 32 +// NFC SUPPORT (feature dependent) +//#define HAVE_NFC +//#define HAVE_NFC_READER +// APP STORAGE (feature dependent) +//#define HAVE_APP_STORAGE +// IO SEPROXY BUFFER SIZE +#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +// NBGL QRCODE (feature dependent) +#define NBGL_QRCODE +// NBGL KEYBOARD (feature dependent) +//#define NBGL_KEYBOARD +// NBGL KEYPAD (feature dependent) +//#define NBGL_KEYPAD +// STANDARD DEFINES #define IO_HID_EP_LENGTH 64 #define HAVE_SPRINTF #define HAVE_SNPRINTF_FORMAT_U @@ -7,13 +28,16 @@ #define IO_USB_MAX_ENDPOINTS 4 #define HAVE_USB_APDU #define USB_SEGMENT_SIZE 64 +//#define HAVE_WEBUSB +//#define WEBUSB_URL_SIZE_B +//#define WEBUSB_URL #define OS_IO_SEPROXYHAL -#define HAVE_LOCAL_APDU_BUFFER -#define IO_SEPROXYHAL_BUFFER_SIZE_B 300 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Makefile.defines +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define gcc #define __IO volatile -#define main _start - -// NBGL +// Stax #define HAVE_BAGL_FONT_INTER_REGULAR_24PX #define HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX #define HAVE_BAGL_FONT_INTER_MEDIUM_32PX @@ -26,30 +50,9 @@ #define NBGL_USE_CASE #define SCREEN_SIZE_WALLET -// BLE SUPPORT -#define HAVE_BLE -#define HAVE_BLE_APDU -#define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 -#define HAVE_INAPP_BLE_PAIRING - -// WEB USB (not supported in Rust SDK) -//#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL - -// NFC SUPPORT (feature dependent) -//#define HAVE_NFC -//#define HAVE_NFC_READER +#define HAVE_LEDGER_PKI -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE - -// NBGL QRCODE (feature dependent) -#define NBGL_QRCODE - -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD - -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Misc +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define HAVE_LOCAL_APDU_BUFFER \ No newline at end of file From a8fd1261bfda31fddb0482583597fb6f749993e8 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Feb 2025 15:54:17 +0100 Subject: [PATCH 068/154] Add build.rs time monitoring --- ledger_secure_sdk_sys/build.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 16f8e202..6ff2c769 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -3,6 +3,7 @@ use glob::glob; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; +use std::time::Instant; use std::{env, fs::File, io::BufRead, io::BufReader, io::Read}; #[cfg(feature = "ccid")] @@ -474,7 +475,7 @@ impl SDKBuilder { Ok(()) } - pub fn build_c_sdk(&self) { + pub fn build_c_sdk(&self) -> Result<(), SDKBuildError> { let mut command = cc::Build::new(); if env::var_os("CC").is_none() { command.compiler("clang"); @@ -561,9 +562,10 @@ impl SDKBuilder { }; println!("cargo:rustc-link-lib=c"); println!("cargo:rustc-link-search={path}"); + Ok(()) } - fn generate_bindings(&self) { + fn generate_bindings(&self) -> Result<(), SDKBuildError> { let bsdk = self.bolos_sdk.display().to_string(); let gcc_tc = self.gcc_toolchain.display().to_string(); let args = [ @@ -679,9 +681,11 @@ impl SDKBuilder { bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings"); + + Ok(()) } - fn generate_heap_size(&self) { + fn generate_heap_size(&self) -> Result<(), SDKBuildError> { // Read the HEAP_SIZE environment variable, default to 8192 if not set let heap_size = env::var("HEAP_SIZE").unwrap_or_else(|_| "8192".to_string()); @@ -700,19 +704,26 @@ impl SDKBuilder { format!("pub const HEAP_SIZE: usize = {};", heap_size), ) .expect("Unable to write file"); + Ok(()) } } fn main() { + let start = Instant::now(); let mut sdk_builder = SDKBuilder::new(); sdk_builder.gcc_toolchain().unwrap(); sdk_builder.device().unwrap(); sdk_builder.bolos_sdk().unwrap(); sdk_builder.cxdefines().unwrap(); sdk_builder.generate_glyphs().unwrap(); - sdk_builder.build_c_sdk(); - sdk_builder.generate_bindings(); - sdk_builder.generate_heap_size(); + sdk_builder.build_c_sdk().unwrap(); + sdk_builder.generate_bindings().unwrap(); + sdk_builder.generate_heap_size().unwrap(); + let end = start.elapsed(); + println!( + "cargo:warning=Total build.rs time: {} seconds", + end.as_secs() + ); } fn finalize_nanos_configuration(command: &mut cc::Build, bolos_sdk: &Path) { From 963d75d16366cd7825c42ce973e4d4818cabc3f6 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 12 Feb 2025 17:50:33 +0100 Subject: [PATCH 069/154] Update CFLAGS (same as C SDK) --- ledger_secure_sdk_sys/build.rs | 322 ++++++++++-------- ledger_secure_sdk_sys/c_sdk_build_flex.cflags | 34 ++ .../c_sdk_build_nanosplus.cflags | 34 ++ .../c_sdk_build_nanox.cflags | 34 ++ ledger_secure_sdk_sys/c_sdk_build_stax.cflags | 34 ++ 5 files changed, 314 insertions(+), 144 deletions(-) create mode 100644 ledger_secure_sdk_sys/c_sdk_build_flex.cflags create mode 100644 ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags create mode 100644 ledger_secure_sdk_sys/c_sdk_build_nanox.cflags create mode 100644 ledger_secure_sdk_sys/c_sdk_build_stax.cflags diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 6ff2c769..fe985b51 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -45,23 +45,95 @@ const CCID_FILES: [&str; 9] = [ "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_if.c", ]; -#[derive(Debug, PartialEq)] -enum Device { +const CFLAGS_NANOS: [&str; 11] = [ + "-Oz", + "-fomit-frame-pointer", + "-fno-common", + "-fdata-sections", + "-ffunction-sections", + "-mthumb", + "-fno-jump-tables", + "-fshort-enums", + "-mno-unaligned-access", + "-fropi", + "-Wno-unused-command-line-argument", +]; + +const CFLAGS_NANOSPLUS: [&str; 22] = [ + "-Oz", + "-g0", + "-fomit-frame-pointer", + "-momit-leaf-frame-pointer", + "-fno-common", + "-mlittle-endian", + "-std=gnu99", + "-fdata-sections", + "-ffunction-sections", + "-funsigned-char", + "-fshort-enums", + "-mno-unaligned-access", + "-fropi", + "-fno-jump-tables", + "-nostdlib", + "-nodefaultlibs", + "-frwpi", + "--target=armv8m-none-eabi", + "-mcpu=cortex-m35p+nodsp", + "-mthumb", + "-msoft-float", + "-Wno-unused-command-line-argument", +]; +const CFLAGS_STAX: [&str; 22] = CFLAGS_NANOSPLUS; +const CFLAGS_FLEX: [&str; 22] = CFLAGS_NANOSPLUS; +const CFLAGS_NANOX: [&str; 21] = [ + "-Oz", + "-g0", + "-fomit-frame-pointer", + "-momit-leaf-frame-pointer", + "-fno-common", + "-mlittle-endian", + "-std=gnu99", + "-fdata-sections", + "-ffunction-sections", + "-funsigned-char", + "-fshort-enums", + "-mno-unaligned-access", + "-fropi", + "-fno-jump-tables", + "-nostdlib", + "-nodefaultlibs", + "-frwpi", + "-mthumb", + "--target=armv6m-none-eabi", + "-mcpu=cortex-m0plus", + "-Wno-unused-command-line-argument", +]; + +#[derive(Debug, Default, PartialEq)] +enum DeviceName { NanoS, + #[default] NanoSPlus, NanoX, Stax, Flex, } -impl std::fmt::Display for Device { +#[derive(Debug, Default)] +struct Device<'a> { + pub name: DeviceName, + pub defines: Vec<(String, Option)>, + pub cflags: Vec<&'a str>, +} + +impl std::fmt::Display for DeviceName { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Device::NanoS => write!(f, "nanos"), - Device::NanoSPlus => write!(f, "nanos2"), - Device::NanoX => write!(f, "nanox"), - Device::Stax => write!(f, "stax"), - Device::Flex => write!(f, "flex"), + DeviceName::NanoS => write!(f, "nanos"), + DeviceName::NanoSPlus => write!(f, "nanos2"), + DeviceName::NanoX => write!(f, "nanox"), + DeviceName::Stax => write!(f, "stax"), + DeviceName::Flex => write!(f, "flex"), } } } @@ -174,10 +246,10 @@ fn retrieve_target_file_infos( device: &Device, bolos_sdk: &Path, ) -> Result<(String, String), SDKBuildError> { - let prefix = if *device == Device::NanoS { + let prefix = if device.name == DeviceName::NanoS { "".to_string() } else { - format!("target/{}/", device) + format!("target/{}/", device.name) }; let target_file_path = bolos_sdk.join(format!("{}include/bolos_target.h", prefix)); let target_file = @@ -220,24 +292,24 @@ fn retrieve_target_file_infos( /// Fetch the appropriate C SDK to build fn clone_sdk(device: &Device) -> PathBuf { - let (repo_url, sdk_branch) = match device { - Device::NanoS => ( + let (repo_url, sdk_branch) = match device.name { + DeviceName::NanoS => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_LNS", ), - Device::NanoX => ( + DeviceName::NanoX => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", ), - Device::NanoSPlus => ( + DeviceName::NanoSPlus => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", ), - Device::Stax => ( + DeviceName::Stax => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", ), - Device::Flex => ( + DeviceName::Flex => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", ), @@ -299,22 +371,22 @@ fn header2define(headername: &str) -> Vec<(String, Option)> { .collect() } -struct SDKBuilder { +struct SDKBuilder<'a> { bolos_sdk: PathBuf, api_level: u32, gcc_toolchain: PathBuf, - device: Device, + device: Device<'a>, glyphs_folders: Vec, cxdefines: Vec, } -impl SDKBuilder { +impl SDKBuilder<'_> { pub fn new() -> Self { SDKBuilder { bolos_sdk: PathBuf::new(), api_level: 0, gcc_toolchain: PathBuf::new(), - device: Device::NanoS, + device: Device::default(), glyphs_folders: Vec::new(), cxdefines: Vec::new(), } @@ -349,19 +421,39 @@ impl SDKBuilder { .to_str() .unwrap() { - "nanos" => Device::NanoS, - "nanosplus" => Device::NanoSPlus, - "nanox" => Device::NanoX, - "stax" => Device::Stax, - "flex" => Device::Flex, + "nanos" => Device { + name: DeviceName::NanoS, + defines: header2define("sdk_nanos.h"), + cflags: Vec::from(CFLAGS_NANOS), + }, + "nanosplus" => Device { + name: DeviceName::NanoSPlus, + defines: header2define("sdk_nanosp.h"), + cflags: Vec::from(CFLAGS_NANOSPLUS), + }, + "nanox" => Device { + name: DeviceName::NanoX, + defines: header2define("sdk_nanox.h"), + cflags: Vec::from(CFLAGS_NANOX), + }, + "stax" => Device { + name: DeviceName::Stax, + defines: header2define("sdk_stax.h"), + cflags: Vec::from(CFLAGS_STAX), + }, + "flex" => Device { + name: DeviceName::Flex, + defines: header2define("sdk_flex.h"), + cflags: Vec::from(CFLAGS_FLEX), + }, _ => { return Err(SDKBuildError::UnsupportedDevice); } }; // export TARGET into env for 'infos.rs' - println!("cargo:rustc-env=TARGET={}", self.device); - println!("cargo:warning=Device is {:?}", self.device); + println!("cargo:rustc-env=TARGET={}", self.device.name); + println!("cargo:warning=Device is {:?}", self.device.name); Ok(()) } @@ -381,15 +473,15 @@ impl SDKBuilder { println!("cargo:warning=API_LEVEL is {}", self.api_level); } None => { - if self.device != Device::NanoS { + if self.device.name != DeviceName::NanoS { return Err(SDKBuildError::InvalidAPILevel); } } } // set glyphs folders - match self.device { - Device::Flex => { + match self.device.name { + DeviceName::Flex => { self.glyphs_folders .push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); self.glyphs_folders @@ -397,7 +489,7 @@ impl SDKBuilder { self.glyphs_folders .push(self.bolos_sdk.join("lib_nbgl/glyphs/40px")); } - Device::Stax => { + DeviceName::Stax => { self.glyphs_folders .push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); self.glyphs_folders @@ -445,7 +537,7 @@ impl SDKBuilder { } pub fn generate_glyphs(&self) -> Result<(), SDKBuildError> { - if self.device == Device::NanoS { + if self.device.name == DeviceName::NanoS { return Err(SDKBuildError::UnsupportedDevice); } @@ -503,23 +595,6 @@ impl SDKBuilder { .join("lib_stusb/STM32_USB_Device_Library/Class/HID/Inc"), ) .debug(true) - .flag("-Oz") - .flag("-fomit-frame-pointer") - .flag("-momit-leaf-frame-pointer") - .flag("-fno-common") - .flag("-mlittle-endian") - .flag("-std=gnu99") - .flag("-fdata-sections") - .flag("-ffunction-sections") - .flag("-funsigned-char") - .flag("-fshort-enums") - .flag("-mno-unaligned-access") - .flag("-fropi") - .flag("-mthumb") - .flag("-fno-jump-tables") - .flag("-nostdlib") - .flag("-nodefaultlibs") - .flag("-Wno-unused-command-line-argument") .define("main", "_start") .clone(); @@ -531,12 +606,24 @@ impl SDKBuilder { // command.files(str2path(&self.bolos_sdk, &CCID_FILES)); // } - match self.device { - Device::NanoS => finalize_nanos_configuration(&mut command, &self.bolos_sdk), - Device::NanoX => finalize_nanox_configuration(&mut command, &self.bolos_sdk), - Device::NanoSPlus => finalize_nanosplus_configuration(&mut command, &self.bolos_sdk), - Device::Stax => finalize_stax_configuration(&mut command, &self.bolos_sdk), - Device::Flex => finalize_flex_configuration(&mut command, &self.bolos_sdk), + // Set the #defines + for (define, value) in &self.device.defines { + command.define(define.as_str(), value.as_deref()); + } + + // Set the CFLAGS + for cflag in &self.device.cflags { + command.flag(cflag); + } + + match self.device.name { + DeviceName::NanoS => finalize_nanos_configuration(&mut command, &self.bolos_sdk), + DeviceName::NanoX => finalize_nanox_configuration(&mut command, &self.bolos_sdk), + DeviceName::NanoSPlus => { + finalize_nanosplus_configuration(&mut command, &self.bolos_sdk) + } + DeviceName::Stax => finalize_stax_configuration(&mut command, &self.bolos_sdk), + DeviceName::Flex => finalize_flex_configuration(&mut command, &self.bolos_sdk), }; // Add the defines found in the Makefile.conf.cx to our build command. @@ -548,15 +635,15 @@ impl SDKBuilder { /* Link with libc for unresolved symbols */ let mut path = self.bolos_sdk.display().to_string(); - match self.device { - Device::NanoS => { + match self.device.name { + DeviceName::NanoS => { path = self.gcc_toolchain.display().to_string(); path.push_str("/lib"); } - Device::NanoX => { + DeviceName::NanoX => { path.push_str("/arch/st33/lib"); } - Device::NanoSPlus | Device::Flex | Device::Stax => { + DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax => { path.push_str("/arch/st33k1/lib"); } }; @@ -601,12 +688,12 @@ impl SDKBuilder { .use_core(); // Target specific files - let (include_path, header) = match self.device { - Device::NanoS => ("nanos", "sdk_nanos.h"), - Device::NanoX => ("nanox", "sdk_nanox.h"), - Device::NanoSPlus => ("nanos2", "sdk_nanosp.h"), - Device::Stax => ("stax", "sdk_stax.h"), - Device::Flex => ("flex", "sdk_flex.h"), + let (include_path, header) = match self.device.name { + DeviceName::NanoS => ("nanos", "sdk_nanos.h"), + DeviceName::NanoX => ("nanox", "sdk_nanox.h"), + DeviceName::NanoSPlus => ("nanos2", "sdk_nanosp.h"), + DeviceName::Stax => ("stax", "sdk_stax.h"), + DeviceName::Flex => ("flex", "sdk_flex.h"), }; bindings = bindings.clang_arg(format!("-I{bsdk}/target/{include_path}/include/")); bindings = bindings.header(header); @@ -617,15 +704,16 @@ impl SDKBuilder { } // BAGL or NBGL bindings - match self.device { - Device::NanoS => { + match self.device.name { + DeviceName::NanoS => { bindings = bindings.header(self.bolos_sdk.join("include/bagl.h").to_str().unwrap()) } - Device::NanoSPlus | Device::NanoX | Device::Stax | Device::Flex => { - if ((self.device == Device::NanoX || self.device == Device::NanoSPlus) + DeviceName::NanoSPlus | DeviceName::NanoX | DeviceName::Stax | DeviceName::Flex => { + if ((self.device.name == DeviceName::NanoX + || self.device.name == DeviceName::NanoSPlus) && env::var_os("CARGO_FEATURE_NBGL").is_some()) - || self.device == Device::Stax - || self.device == Device::Flex + || self.device.name == DeviceName::Stax + || self.device.name == DeviceName::Flex { let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let mut include_path = "-I".to_string(); @@ -655,8 +743,8 @@ impl SDKBuilder { } // BLE bindings - match self.device { - Device::NanoX | Device::Flex | Device::Stax => { + match self.device.name { + DeviceName::NanoX | DeviceName::Flex | DeviceName::Stax => { bindings = bindings.header( self.bolos_sdk .join("lib_blewbxx_impl/include/ledger_ble.h") @@ -727,44 +815,18 @@ fn main() { } fn finalize_nanos_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - let defines = header2define("sdk_nanos.h"); - for (define, value) in defines { - command.define(define.as_str(), value.as_deref()); - } - command .target("thumbv6m-none-eabi") .define("ST31", None) - .include(bolos_sdk.join("target/nanos/include")) - .flag("-fropi"); + .include(bolos_sdk.join("target/nanos/include")); } fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - let defines = header2define("sdk_nanox.h"); - for (define, value) in defines { - command.define(define.as_str(), value.as_deref()); - } - command .target("thumbv6m-none-eabi") - .file(bolos_sdk.join("src/ledger_protocol.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/template/osal.c")) - .file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c")) - .include(bolos_sdk.join("lib_blewbxx/include")) - .include(bolos_sdk.join("lib_blewbxx/core")) - .include(bolos_sdk.join("lib_blewbxx/core/auto")) - .include(bolos_sdk.join("lib_blewbxx/core/template")) - .include(bolos_sdk.join("lib_blewbxx_impl/include")) - .include(bolos_sdk.join("target/nanox/include")) - .flag("-mno-movt") - .flag("-ffixed-r9") - .flag("-fropi") - .flag("-frwpi"); + .include(bolos_sdk.join("target/nanox/include")); + + configure_lib_ble(command, bolos_sdk); if env::var_os("CARGO_FEATURE_NBGL").is_some() { println!("cargo:warning=NBGL is built"); @@ -779,16 +841,9 @@ fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &Path) { } fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - let defines = header2define("sdk_nanosp.h"); - for (define, value) in defines { - command.define(define.as_str(), value.as_deref()); - } - command .target("thumbv8m.main-none-eabi") - .include(bolos_sdk.join("target/nanos2/include")) - .flag("-fropi") - .flag("-frwpi"); + .include(bolos_sdk.join("target/nanos2/include")); if env::var_os("CARGO_FEATURE_NBGL").is_some() { println!("cargo:warning=NBGL is built"); @@ -803,40 +858,25 @@ fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { } fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - let defines = header2define("sdk_stax.h"); - for (define, value) in defines { - command.define(define.as_str(), value.as_deref()); - } - command .target("thumbv8m.main-none-eabi") - .file(bolos_sdk.join("src/ledger_protocol.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/template/osal.c")) - .file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c")) - .include(bolos_sdk.join("lib_blewbxx/include")) - .include(bolos_sdk.join("lib_blewbxx/core")) - .include(bolos_sdk.join("lib_blewbxx/core/auto")) - .include(bolos_sdk.join("lib_blewbxx/core/template")) - .include(bolos_sdk.join("lib_blewbxx_impl/include")) - .include(bolos_sdk.join("target/stax/include/")) - .flag("-fropi") - .flag("-frwpi"); + .include(bolos_sdk.join("target/stax/include/")); + + configure_lib_ble(command, bolos_sdk); configure_lib_nbgl(command, bolos_sdk); } fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - let defines = header2define("sdk_flex.h"); - for (define, value) in defines { - command.define(define.as_str(), value.as_deref()); - } - command .target("thumbv8m.main-none-eabi") + .include(bolos_sdk.join("target/flex/include/")); + + configure_lib_ble(command, bolos_sdk); + configure_lib_nbgl(command, bolos_sdk); +} + +fn configure_lib_ble(command: &mut cc::Build, bolos_sdk: &Path) { + command .file(bolos_sdk.join("src/ledger_protocol.c")) .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) @@ -849,18 +889,12 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { .include(bolos_sdk.join("lib_blewbxx/core")) .include(bolos_sdk.join("lib_blewbxx/core/auto")) .include(bolos_sdk.join("lib_blewbxx/core/template")) - .include(bolos_sdk.join("lib_blewbxx_impl/include")) - .include(bolos_sdk.join("target/flex/include/")) - .flag("-fropi") - .flag("-frwpi"); - configure_lib_nbgl(command, bolos_sdk); + .include(bolos_sdk.join("lib_blewbxx_impl/include")); } fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) { let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command - .flag("-Wno-microsoft-anon-tag") - .flag("-fms-extensions") .include(bolos_sdk.join("lib_nbgl/include/")) .include(bolos_sdk.join("lib_nbgl/include/fonts/")) .include(bolos_sdk.join("lib_ux_nbgl/")) diff --git a/ledger_secure_sdk_sys/c_sdk_build_flex.cflags b/ledger_secure_sdk_sys/c_sdk_build_flex.cflags new file mode 100644 index 00000000..519cb514 --- /dev/null +++ b/ledger_secure_sdk_sys/c_sdk_build_flex.cflags @@ -0,0 +1,34 @@ +--sysroot="/usr/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-mlittle-endian +-std=gnu99 +-Wall +-Wextra +-Wno-main +-Werror=int-to-pointer-cast +-Wno-error=int-conversion +-Wimplicit-fallthrough +-Wvla +-Wundef +-Wshadow +-Wformat=2 +-Wformat-security +-Wwrite-strings +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-nostdlib +-nodefaultlibs +-frwpi +-mthumb +--target=armv8m-none-eabi +-mcpu=cortex-m35p+nodsp +-msoft-float \ No newline at end of file diff --git a/ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags b/ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags new file mode 100644 index 00000000..519cb514 --- /dev/null +++ b/ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags @@ -0,0 +1,34 @@ +--sysroot="/usr/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-mlittle-endian +-std=gnu99 +-Wall +-Wextra +-Wno-main +-Werror=int-to-pointer-cast +-Wno-error=int-conversion +-Wimplicit-fallthrough +-Wvla +-Wundef +-Wshadow +-Wformat=2 +-Wformat-security +-Wwrite-strings +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-nostdlib +-nodefaultlibs +-frwpi +-mthumb +--target=armv8m-none-eabi +-mcpu=cortex-m35p+nodsp +-msoft-float \ No newline at end of file diff --git a/ledger_secure_sdk_sys/c_sdk_build_nanox.cflags b/ledger_secure_sdk_sys/c_sdk_build_nanox.cflags new file mode 100644 index 00000000..db9a2818 --- /dev/null +++ b/ledger_secure_sdk_sys/c_sdk_build_nanox.cflags @@ -0,0 +1,34 @@ +--sysroot="/usr/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-mlittle-endian +-std=gnu99 +-Wall +-Wextra +-Wno-main +-Werror=int-to-pointer-cast +-Wno-error=int-conversion +-Wimplicit-fallthrough +-Wvla +-Wundef +-Wshadow +-Wformat=2 +-Wformat-security +-Wwrite-strings +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-nostdlib +-nodefaultlibs +-frwpi +-mthumb +--target=armv6m-none-eabi +-mcpu=cortex-m0plus + diff --git a/ledger_secure_sdk_sys/c_sdk_build_stax.cflags b/ledger_secure_sdk_sys/c_sdk_build_stax.cflags new file mode 100644 index 00000000..519cb514 --- /dev/null +++ b/ledger_secure_sdk_sys/c_sdk_build_stax.cflags @@ -0,0 +1,34 @@ +--sysroot="/usr/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-mlittle-endian +-std=gnu99 +-Wall +-Wextra +-Wno-main +-Werror=int-to-pointer-cast +-Wno-error=int-conversion +-Wimplicit-fallthrough +-Wvla +-Wundef +-Wshadow +-Wformat=2 +-Wformat-security +-Wwrite-strings +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-nostdlib +-nodefaultlibs +-frwpi +-mthumb +--target=armv8m-none-eabi +-mcpu=cortex-m35p+nodsp +-msoft-float \ No newline at end of file From 5d507facecfa0b5afa0a235a75aece4f85374095 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 12 Feb 2025 17:53:29 +0100 Subject: [PATCH 070/154] Remove CCID feature --- ledger_secure_sdk_sys/Cargo.toml | 1 - ledger_secure_sdk_sys/build.rs | 25 ------------------------- 2 files changed, 26 deletions(-) diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index ba09348c..5ea5adaa 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -18,7 +18,6 @@ critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] -ccid = [] nbgl = [] [lints.rust.unexpected_cfgs] diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index fe985b51..d01be119 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -6,10 +6,6 @@ use std::process::Command; use std::time::Instant; use std::{env, fs::File, io::BufRead, io::BufReader, io::Read}; -#[cfg(feature = "ccid")] -const DEFINES_CCID: [(&str, Option<&str>); 2] = - [("HAVE_USB_CLASS_CCID", None), ("HAVE_CCID", None)]; - const AUX_C_FILES: [&str; 2] = ["./src/c/src.c", "./src/c/sjlj.s"]; const SDK_C_FILES: [&str; 8] = [ @@ -32,19 +28,6 @@ const SDK_USB_FILES: [&str; 6] = [ "lib_stusb/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c", ]; -#[cfg(feature = "ccid")] -const CCID_FILES: [&str; 9] = [ - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_cmd.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_core.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_if.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_cmd.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_core.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_if.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_cmd.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_core.c", - "lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_if.c", -]; - const CFLAGS_NANOS: [&str; 11] = [ "-Oz", "-fomit-frame-pointer", @@ -598,14 +581,6 @@ impl SDKBuilder<'_> { .define("main", "_start") .clone(); - // #[cfg(feature = "ccid")] - // { - // for (define, value) in DEFINES_CCID { - // command.define(define, value); - // } - // command.files(str2path(&self.bolos_sdk, &CCID_FILES)); - // } - // Set the #defines for (define, value) in &self.device.defines { command.define(define.as_str(), value.as_deref()); From d5c29edae0c72f3c5a81a818ca8ac9ae516beb2a Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 12 Feb 2025 18:03:24 +0100 Subject: [PATCH 071/154] Remove CCID feature bis --- ledger_device_sdk/Cargo.toml | 1 - ledger_device_sdk/src/ccid.rs | 11 ----------- ledger_device_sdk/src/io.rs | 6 ------ ledger_device_sdk/src/lib.rs | 2 -- ledger_secure_sdk_sys/src/c/src.c | 8 -------- 5 files changed, 28 deletions(-) delete mode 100644 ledger_device_sdk/src/ccid.rs diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index f0d9a880..e81fe816 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -26,7 +26,6 @@ ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.7" } [features] debug = [] speculos = [] -ccid = [] heap = [ "ledger_secure_sdk_sys/heap" ] default = [ "heap" ] diff --git a/ledger_device_sdk/src/ccid.rs b/ledger_device_sdk/src/ccid.rs deleted file mode 100644 index 0b40b2c6..00000000 --- a/ledger_device_sdk/src/ccid.rs +++ /dev/null @@ -1,11 +0,0 @@ -extern "C" { - pub static mut G_io_apdu_buffer: [u8; 260]; - pub fn io_usb_ccid_reply_bare(length: u16); -} - -pub fn send(buf: &[u8]) { - unsafe { - G_io_apdu_buffer[..buf.len()].copy_from_slice(buf); - io_usb_ccid_reply_bare(buf.len() as u16); - } -} diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index f689a7b4..812c62f1 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -5,8 +5,6 @@ use ledger_secure_sdk_sys::buttons::{get_button_event, ButtonEvent, ButtonsState use ledger_secure_sdk_sys::seph as sys_seph; use ledger_secure_sdk_sys::*; -#[cfg(feature = "ccid")] -use crate::ccid; use crate::seph; use core::convert::{Infallible, TryFrom}; use core::ops::{Index, IndexMut}; @@ -193,10 +191,6 @@ impl Comm { sys_seph::seph_send(&[sys_seph::SephTags::RawAPDU as u8, len[0], len[1]]); sys_seph::seph_send(&self.apdu_buffer[..self.tx]); } - #[cfg(feature = "ccid")] - APDU_USB_CCID => { - ccid::send(&self.apdu_buffer[..self.tx]); - } #[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] APDU_BLE => { ble::send(&self.apdu_buffer[..self.tx]); diff --git a/ledger_device_sdk/src/lib.rs b/ledger_device_sdk/src/lib.rs index 523a220c..380512f1 100644 --- a/ledger_device_sdk/src/lib.rs +++ b/ledger_device_sdk/src/lib.rs @@ -10,8 +10,6 @@ #[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] pub mod ble; -#[cfg(feature = "ccid")] -pub mod ccid; pub mod ecc; pub mod hash; pub mod hmac; diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index 74cbadab..93697eae 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -253,11 +253,6 @@ void link_pass_nvram( nvm_write(nvram_prev_val_ptr, &nvram_current, sizeof(void*)); } -#ifdef HAVE_CCID - #include "usbd_ccid_if.h" -uint8_t G_io_apdu_buffer[260]; -#endif - void c_reset_bss() { size_t bss_len; SYMBOL_ABSOLUTE_VALUE(bss_len, _bss_len); @@ -312,9 +307,6 @@ void c_boot_std() { USB_power(0); USB_power(1); -#ifdef HAVE_CCID - io_usb_ccid_set_card_inserted(1); -#endif #ifdef HAVE_BLE memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback)); From 327e86eb2ab461396dadb0db09a23c166e852dda Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 13 Feb 2025 12:38:57 +0100 Subject: [PATCH 072/154] remove device match in bindings --- ledger_secure_sdk_sys/build.rs | 14 +++++--------- .../{sdk_nanosp.h => sdk_nanos2.h} | 0 2 files changed, 5 insertions(+), 9 deletions(-) rename ledger_secure_sdk_sys/{sdk_nanosp.h => sdk_nanos2.h} (100%) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index d01be119..faa384d8 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -411,7 +411,7 @@ impl SDKBuilder<'_> { }, "nanosplus" => Device { name: DeviceName::NanoSPlus, - defines: header2define("sdk_nanosp.h"), + defines: header2define("sdk_nanos2.h"), cflags: Vec::from(CFLAGS_NANOSPLUS), }, "nanox" => Device { @@ -663,14 +663,10 @@ impl SDKBuilder<'_> { .use_core(); // Target specific files - let (include_path, header) = match self.device.name { - DeviceName::NanoS => ("nanos", "sdk_nanos.h"), - DeviceName::NanoX => ("nanox", "sdk_nanox.h"), - DeviceName::NanoSPlus => ("nanos2", "sdk_nanosp.h"), - DeviceName::Stax => ("stax", "sdk_stax.h"), - DeviceName::Flex => ("flex", "sdk_flex.h"), - }; - bindings = bindings.clang_arg(format!("-I{bsdk}/target/{include_path}/include/")); + let csdk_target_name = self.device.name.to_string(); + let header = format!("sdk_{csdk_target_name}.h"); + + bindings = bindings.clang_arg(format!("-I{bsdk}/target/{csdk_target_name}/include/")); bindings = bindings.header(header); // SDK headers to bind against diff --git a/ledger_secure_sdk_sys/sdk_nanosp.h b/ledger_secure_sdk_sys/sdk_nanos2.h similarity index 100% rename from ledger_secure_sdk_sys/sdk_nanosp.h rename to ledger_secure_sdk_sys/sdk_nanos2.h From 754ff65df6bdc62c756c75674264ed010a085dd9 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 13 Feb 2025 15:37:12 +0100 Subject: [PATCH 073/154] Cleanup --- ledger_secure_sdk_sys/build.rs | 116 ++++++++++++------------------ ledger_secure_sdk_sys/sdk_nanos.h | 3 +- 2 files changed, 47 insertions(+), 72 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index faa384d8..b50bafc5 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -105,6 +105,7 @@ enum DeviceName { #[derive(Debug, Default)] struct Device<'a> { pub name: DeviceName, + pub target: &'a str, pub defines: Vec<(String, Option)>, pub cflags: Vec<&'a str>, } @@ -406,26 +407,55 @@ impl SDKBuilder<'_> { { "nanos" => Device { name: DeviceName::NanoS, + target: "thumbv6m-none-eabi", defines: header2define("sdk_nanos.h"), cflags: Vec::from(CFLAGS_NANOS), }, "nanosplus" => Device { name: DeviceName::NanoSPlus, - defines: header2define("sdk_nanos2.h"), + target: "thumbv8m.main-none-eabi", + defines: { + let mut v = header2define("sdk_nanos2.h"); + if env::var_os("CARGO_FEATURE_NBGL").is_some() { + println!("cargo:warning=NBGL is built"); + v.push((String::from("HAVE_NBGL"), None)); + v.push((String::from("NBGL_STEP"), None)); + v.push((String::from("NBGL_USE_CASE"), None)); + } else { + println!("cargo:warning=BAGL is built"); + v.push((String::from("HAVE_BAGL"), None)); + } + v + }, cflags: Vec::from(CFLAGS_NANOSPLUS), }, "nanox" => Device { name: DeviceName::NanoX, - defines: header2define("sdk_nanox.h"), + target: "thumbv6m-none-eabi", + defines: { + let mut v = header2define("sdk_nanox.h"); + if env::var_os("CARGO_FEATURE_NBGL").is_some() { + println!("cargo:warning=NBGL is built"); + v.push((String::from("HAVE_NBGL"), None)); + v.push((String::from("NBGL_STEP"), None)); + v.push((String::from("NBGL_USE_CASE"), None)); + } else { + println!("cargo:warning=BAGL is built"); + v.push((String::from("HAVE_BAGL"), None)); + } + v + }, cflags: Vec::from(CFLAGS_NANOX), }, "stax" => Device { name: DeviceName::Stax, + target: "thumbv8m.main-none-eabi", defines: header2define("sdk_stax.h"), cflags: Vec::from(CFLAGS_STAX), }, "flex" => Device { name: DeviceName::Flex, + target: "thumbv8m.main-none-eabi", defines: header2define("sdk_flex.h"), cflags: Vec::from(CFLAGS_FLEX), }, @@ -591,15 +621,20 @@ impl SDKBuilder<'_> { command.flag(cflag); } - match self.device.name { - DeviceName::NanoS => finalize_nanos_configuration(&mut command, &self.bolos_sdk), - DeviceName::NanoX => finalize_nanox_configuration(&mut command, &self.bolos_sdk), - DeviceName::NanoSPlus => { - finalize_nanosplus_configuration(&mut command, &self.bolos_sdk) + command.target(self.device.target).include( + self.bolos_sdk + .join(format!("target/{}/include", self.device.name)), + ); + + // Configure BLE and NBGL + for s in self.device.defines.iter() { + if s.0 == "HAVE_BLE" { + configure_lib_ble(&mut command, &self.bolos_sdk); } - DeviceName::Stax => finalize_stax_configuration(&mut command, &self.bolos_sdk), - DeviceName::Flex => finalize_flex_configuration(&mut command, &self.bolos_sdk), - }; + if s.0 == "HAVE_NBGL" { + configure_lib_nbgl(&mut command, &self.bolos_sdk); + } + } // Add the defines found in the Makefile.conf.cx to our build command. for define in self.cxdefines.iter() { @@ -785,67 +820,6 @@ fn main() { ); } -fn finalize_nanos_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - command - .target("thumbv6m-none-eabi") - .define("ST31", None) - .include(bolos_sdk.join("target/nanos/include")); -} - -fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - command - .target("thumbv6m-none-eabi") - .include(bolos_sdk.join("target/nanox/include")); - - configure_lib_ble(command, bolos_sdk); - - if env::var_os("CARGO_FEATURE_NBGL").is_some() { - println!("cargo:warning=NBGL is built"); - command.define("HAVE_NBGL", None); - command.define("NBGL_STEP", None); - command.define("NBGL_USE_CASE", None); - configure_lib_nbgl(command, bolos_sdk); - } else { - println!("cargo:warning=BAGL is built"); - command.define("HAVE_BAGL", None); - } -} - -fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - command - .target("thumbv8m.main-none-eabi") - .include(bolos_sdk.join("target/nanos2/include")); - - if env::var_os("CARGO_FEATURE_NBGL").is_some() { - println!("cargo:warning=NBGL is built"); - command.define("HAVE_NBGL", None); - command.define("NBGL_STEP", None); - command.define("NBGL_USE_CASE", None); - configure_lib_nbgl(command, bolos_sdk); - } else { - println!("cargo:warning=BAGL is built"); - command.define("HAVE_BAGL", None); - } -} - -fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - command - .target("thumbv8m.main-none-eabi") - .include(bolos_sdk.join("target/stax/include/")); - - configure_lib_ble(command, bolos_sdk); - configure_lib_nbgl(command, bolos_sdk); -} - -fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) { - command - .target("thumbv8m.main-none-eabi") - .include(bolos_sdk.join("target/flex/include/")); - - configure_lib_ble(command, bolos_sdk); - configure_lib_nbgl(command, bolos_sdk); -} - fn configure_lib_ble(command: &mut cc::Build, bolos_sdk: &Path) { command .file(bolos_sdk.join("src/ledger_protocol.c")) diff --git a/ledger_secure_sdk_sys/sdk_nanos.h b/ledger_secure_sdk_sys/sdk_nanos.h index 2d5e6937..157b0b37 100644 --- a/ledger_secure_sdk_sys/sdk_nanos.h +++ b/ledger_secure_sdk_sys/sdk_nanos.h @@ -7,4 +7,5 @@ #define HAVE_USB_APDU #define __IO volatile #define IO_USB_MAX_ENDPOINTS 6 -#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 \ No newline at end of file +#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 +#define ST31 \ No newline at end of file From be9b7c2395db52c6009f031945c77964765b3c6f Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Feb 2025 11:41:31 +0100 Subject: [PATCH 074/154] Add libm.a and libgcc.a for linking + os_printf.c shall be built for all targets --- ledger_secure_sdk_sys/build.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b50bafc5..b622286b 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -8,7 +8,7 @@ use std::{env, fs::File, io::BufRead, io::BufReader, io::Read}; const AUX_C_FILES: [&str; 2] = ["./src/c/src.c", "./src/c/sjlj.s"]; -const SDK_C_FILES: [&str; 8] = [ +const SDK_C_FILES: [&str; 9] = [ "src/os_io_usb.c", "src/pic.c", "src/checks.c", @@ -17,6 +17,7 @@ const SDK_C_FILES: [&str; 8] = [ "src/svc_call.s", "src/svc_cx_call.s", "src/syscalls.c", + "src/os_printf.c", ]; const SDK_USB_FILES: [&str; 6] = [ @@ -658,6 +659,8 @@ impl SDKBuilder<'_> { } }; println!("cargo:rustc-link-lib=c"); + println!("cargo:rustc-link-lib=m"); + println!("cargo:rustc-link-lib=gcc"); println!("cargo:rustc-link-search={path}"); Ok(()) } @@ -846,8 +849,6 @@ fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) { .include(bolos_sdk.join("qrcode/include/")) .include(bolos_sdk.join("lib_bagl/include/")) .file(bolos_sdk.join("lib_ux_nbgl/ux.c")) - .file(bolos_sdk.join("lib_bagl/src/bagl_fonts.c")) - .file(bolos_sdk.join("src/os_printf.c")) .file(bolos_sdk.join("qrcode/src/qrcodegen.c")) .files( glob(bolos_sdk.join("lib_nbgl/src/*.c").to_str().unwrap()) From 348a1627019d22bdfe3e2107ac2d12201b9c6e5d Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Feb 2025 11:42:04 +0100 Subject: [PATCH 075/154] Add nbgl feature --- ledger_device_sdk/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index e81fe816..3de4c95a 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -27,6 +27,7 @@ ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.7" } debug = [] speculos = [] heap = [ "ledger_secure_sdk_sys/heap" ] +nbgl = [ "ledger_secure_sdk_sys/nbgl" ] default = [ "heap" ] From 17e3a8bb658d46385e05407727761dd20aecd33b Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Feb 2025 14:13:32 +0100 Subject: [PATCH 076/154] Rename header files --- ledger_secure_sdk_sys/build.rs | 12 ++++++------ ledger_secure_sdk_sys/{sdk_flex.h => csdk_flex.h} | 0 ledger_secure_sdk_sys/{sdk_nanos.h => csdk_nanos.h} | 0 .../{sdk_nanos2.h => csdk_nanos2.h} | 0 ledger_secure_sdk_sys/{sdk_nanox.h => csdk_nanox.h} | 0 ledger_secure_sdk_sys/{sdk_stax.h => csdk_stax.h} | 0 6 files changed, 6 insertions(+), 6 deletions(-) rename ledger_secure_sdk_sys/{sdk_flex.h => csdk_flex.h} (100%) rename ledger_secure_sdk_sys/{sdk_nanos.h => csdk_nanos.h} (100%) rename ledger_secure_sdk_sys/{sdk_nanos2.h => csdk_nanos2.h} (100%) rename ledger_secure_sdk_sys/{sdk_nanox.h => csdk_nanox.h} (100%) rename ledger_secure_sdk_sys/{sdk_stax.h => csdk_stax.h} (100%) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b622286b..d35e5256 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -409,14 +409,14 @@ impl SDKBuilder<'_> { "nanos" => Device { name: DeviceName::NanoS, target: "thumbv6m-none-eabi", - defines: header2define("sdk_nanos.h"), + defines: header2define("csdk_nanos.h"), cflags: Vec::from(CFLAGS_NANOS), }, "nanosplus" => Device { name: DeviceName::NanoSPlus, target: "thumbv8m.main-none-eabi", defines: { - let mut v = header2define("sdk_nanos2.h"); + let mut v = header2define("csdk_nanos2.h"); if env::var_os("CARGO_FEATURE_NBGL").is_some() { println!("cargo:warning=NBGL is built"); v.push((String::from("HAVE_NBGL"), None)); @@ -434,7 +434,7 @@ impl SDKBuilder<'_> { name: DeviceName::NanoX, target: "thumbv6m-none-eabi", defines: { - let mut v = header2define("sdk_nanox.h"); + let mut v = header2define("csdk_nanox.h"); if env::var_os("CARGO_FEATURE_NBGL").is_some() { println!("cargo:warning=NBGL is built"); v.push((String::from("HAVE_NBGL"), None)); @@ -451,13 +451,13 @@ impl SDKBuilder<'_> { "stax" => Device { name: DeviceName::Stax, target: "thumbv8m.main-none-eabi", - defines: header2define("sdk_stax.h"), + defines: header2define("csdk_stax.h"), cflags: Vec::from(CFLAGS_STAX), }, "flex" => Device { name: DeviceName::Flex, target: "thumbv8m.main-none-eabi", - defines: header2define("sdk_flex.h"), + defines: header2define("csdk_flex.h"), cflags: Vec::from(CFLAGS_FLEX), }, _ => { @@ -702,7 +702,7 @@ impl SDKBuilder<'_> { // Target specific files let csdk_target_name = self.device.name.to_string(); - let header = format!("sdk_{csdk_target_name}.h"); + let header = format!("csdk_{csdk_target_name}.h"); bindings = bindings.clang_arg(format!("-I{bsdk}/target/{csdk_target_name}/include/")); bindings = bindings.header(header); diff --git a/ledger_secure_sdk_sys/sdk_flex.h b/ledger_secure_sdk_sys/csdk_flex.h similarity index 100% rename from ledger_secure_sdk_sys/sdk_flex.h rename to ledger_secure_sdk_sys/csdk_flex.h diff --git a/ledger_secure_sdk_sys/sdk_nanos.h b/ledger_secure_sdk_sys/csdk_nanos.h similarity index 100% rename from ledger_secure_sdk_sys/sdk_nanos.h rename to ledger_secure_sdk_sys/csdk_nanos.h diff --git a/ledger_secure_sdk_sys/sdk_nanos2.h b/ledger_secure_sdk_sys/csdk_nanos2.h similarity index 100% rename from ledger_secure_sdk_sys/sdk_nanos2.h rename to ledger_secure_sdk_sys/csdk_nanos2.h diff --git a/ledger_secure_sdk_sys/sdk_nanox.h b/ledger_secure_sdk_sys/csdk_nanox.h similarity index 100% rename from ledger_secure_sdk_sys/sdk_nanox.h rename to ledger_secure_sdk_sys/csdk_nanox.h diff --git a/ledger_secure_sdk_sys/sdk_stax.h b/ledger_secure_sdk_sys/csdk_stax.h similarity index 100% rename from ledger_secure_sdk_sys/sdk_stax.h rename to ledger_secure_sdk_sys/csdk_stax.h From b5fd671cc13be0cb776d27f797543b32e8535ce8 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Feb 2025 14:39:01 +0100 Subject: [PATCH 077/154] Move linker files from sdk crate to sys crate --- ledger_device_sdk/build.rs | 43 ------------------- ledger_secure_sdk_sys/build.rs | 18 ++++++++ .../link.ld | 0 .../nanos_layout.ld | 0 .../nanosplus_layout.ld | 0 .../nanox_layout.ld | 0 .../stax_flex_layout.ld | 0 7 files changed, 18 insertions(+), 43 deletions(-) delete mode 100644 ledger_device_sdk/build.rs rename {ledger_device_sdk => ledger_secure_sdk_sys}/link.ld (100%) rename {ledger_device_sdk => ledger_secure_sdk_sys}/nanos_layout.ld (100%) rename {ledger_device_sdk => ledger_secure_sdk_sys}/nanosplus_layout.ld (100%) rename {ledger_device_sdk => ledger_secure_sdk_sys}/nanox_layout.ld (100%) rename {ledger_device_sdk => ledger_secure_sdk_sys}/stax_flex_layout.ld (100%) diff --git a/ledger_device_sdk/build.rs b/ledger_device_sdk/build.rs deleted file mode 100644 index 1c4d50d4..00000000 --- a/ledger_device_sdk/build.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::path::PathBuf; -use std::{env, error::Error}; - -fn main() -> Result<(), Box> { - enum Device { - NanoS, - NanoSPlus, - NanoX, - Stax, - Flex, - } - use Device::*; - - // determine device - let device = match env::var_os("CARGO_CFG_TARGET_OS").unwrap().to_str().unwrap() { - "nanos" => NanoS, - "nanosplus" => NanoSPlus, - "nanox" => NanoX, - "stax" => Stax, - "flex" => Flex, - target_name => panic!( - "invalid target `{target_name}`, expected one of `nanos`, `nanox`, `nanosplus`, `stax` or `flex`. Run with `-Z build-std=core --target=./.json`" - ), - }; - - // Copy this crate's linker script into the working directory of - // the application so that it can be used there for the layout. - // Trick taken from https://docs.rust-embedded.org/embedonomicon/main.html - let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - - // extend the library search path - println!("cargo:rustc-link-search={}", out_dir.display()); - // copy - let linkerscript = match device { - NanoS => "nanos_layout.ld", - NanoX => "nanox_layout.ld", - NanoSPlus => "nanosplus_layout.ld", - Stax | Flex => "stax_flex_layout.ld", - }; - std::fs::copy(linkerscript, out_dir.join(linkerscript))?; - std::fs::copy("link.ld", out_dir.join("link.ld"))?; - Ok(()) -} diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index d35e5256..d2eb6258 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -803,6 +803,23 @@ impl SDKBuilder<'_> { .expect("Unable to write file"); Ok(()) } + + fn copy_linker_script(&self) -> Result<(), SDKBuildError> { + let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + // extend the library search path + println!("cargo:rustc-link-search={}", out_dir.display()); + // copy + let linkerscript = match self.device.name { + DeviceName::NanoS => "nanos_layout.ld", + DeviceName::NanoX => "nanox_layout.ld", + DeviceName::NanoSPlus => "nanosplus_layout.ld", + DeviceName::Stax => "stax_flex_layout.ld", + DeviceName::Flex => "stax_flex_layout.ld", + }; + std::fs::copy(linkerscript, out_dir.join(linkerscript)).unwrap(); + std::fs::copy("link.ld", out_dir.join("link.ld")).unwrap(); + Ok(()) + } } fn main() { @@ -816,6 +833,7 @@ fn main() { sdk_builder.build_c_sdk().unwrap(); sdk_builder.generate_bindings().unwrap(); sdk_builder.generate_heap_size().unwrap(); + sdk_builder.copy_linker_script().unwrap(); let end = start.elapsed(); println!( "cargo:warning=Total build.rs time: {} seconds", diff --git a/ledger_device_sdk/link.ld b/ledger_secure_sdk_sys/link.ld similarity index 100% rename from ledger_device_sdk/link.ld rename to ledger_secure_sdk_sys/link.ld diff --git a/ledger_device_sdk/nanos_layout.ld b/ledger_secure_sdk_sys/nanos_layout.ld similarity index 100% rename from ledger_device_sdk/nanos_layout.ld rename to ledger_secure_sdk_sys/nanos_layout.ld diff --git a/ledger_device_sdk/nanosplus_layout.ld b/ledger_secure_sdk_sys/nanosplus_layout.ld similarity index 100% rename from ledger_device_sdk/nanosplus_layout.ld rename to ledger_secure_sdk_sys/nanosplus_layout.ld diff --git a/ledger_device_sdk/nanox_layout.ld b/ledger_secure_sdk_sys/nanox_layout.ld similarity index 100% rename from ledger_device_sdk/nanox_layout.ld rename to ledger_secure_sdk_sys/nanox_layout.ld diff --git a/ledger_device_sdk/stax_flex_layout.ld b/ledger_secure_sdk_sys/stax_flex_layout.ld similarity index 100% rename from ledger_device_sdk/stax_flex_layout.ld rename to ledger_secure_sdk_sys/stax_flex_layout.ld From 74756bb6fbc1457115805bae026f513c4def202c Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Feb 2025 15:26:11 +0100 Subject: [PATCH 078/154] Set the C SDK path in Device --- ledger_secure_sdk_sys/build.rs | 91 +++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index d2eb6258..7ff88a76 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -106,6 +106,7 @@ enum DeviceName { #[derive(Debug, Default)] struct Device<'a> { pub name: DeviceName, + pub c_sdk: PathBuf, pub target: &'a str, pub defines: Vec<(String, Option)>, pub cflags: Vec<&'a str>, @@ -276,8 +277,8 @@ fn retrieve_target_file_infos( } /// Fetch the appropriate C SDK to build -fn clone_sdk(device: &Device) -> PathBuf { - let (repo_url, sdk_branch) = match device.name { +fn clone_sdk(devicename: &DeviceName) -> PathBuf { + let (repo_url, sdk_branch) = match devicename { DeviceName::NanoS => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_LNS", @@ -357,7 +358,6 @@ fn header2define(headername: &str) -> Vec<(String, Option)> { } struct SDKBuilder<'a> { - bolos_sdk: PathBuf, api_level: u32, gcc_toolchain: PathBuf, device: Device<'a>, @@ -368,7 +368,6 @@ struct SDKBuilder<'a> { impl SDKBuilder<'_> { pub fn new() -> Self { SDKBuilder { - bolos_sdk: PathBuf::new(), api_level: 0, gcc_toolchain: PathBuf::new(), device: Device::default(), @@ -400,6 +399,7 @@ impl SDKBuilder<'_> { } pub fn device(&mut self) -> Result<(), SDKBuildError> { + println!("cargo:rerun-if-env-changed=LEDGER_SDK_PATH"); // determine device self.device = match env::var_os("CARGO_CFG_TARGET_OS") .unwrap() @@ -408,12 +408,14 @@ impl SDKBuilder<'_> { { "nanos" => Device { name: DeviceName::NanoS, + c_sdk: Default::default(), target: "thumbv6m-none-eabi", defines: header2define("csdk_nanos.h"), cflags: Vec::from(CFLAGS_NANOS), }, "nanosplus" => Device { name: DeviceName::NanoSPlus, + c_sdk: Default::default(), target: "thumbv8m.main-none-eabi", defines: { let mut v = header2define("csdk_nanos2.h"); @@ -432,6 +434,7 @@ impl SDKBuilder<'_> { }, "nanox" => Device { name: DeviceName::NanoX, + c_sdk: Default::default(), target: "thumbv6m-none-eabi", defines: { let mut v = header2define("csdk_nanox.h"); @@ -450,12 +453,14 @@ impl SDKBuilder<'_> { }, "stax" => Device { name: DeviceName::Stax, + c_sdk: Default::default(), target: "thumbv8m.main-none-eabi", defines: header2define("csdk_stax.h"), cflags: Vec::from(CFLAGS_STAX), }, "flex" => Device { name: DeviceName::Flex, + c_sdk: Default::default(), target: "thumbv8m.main-none-eabi", defines: header2define("csdk_flex.h"), cflags: Vec::from(CFLAGS_FLEX), @@ -465,6 +470,12 @@ impl SDKBuilder<'_> { } }; + // set the C SDK path + self.device.c_sdk = match env::var("LEDGER_SDK_PATH") { + Err(_) => clone_sdk(&self.device.name), + Ok(path) => PathBuf::from(path), + }; + // export TARGET into env for 'infos.rs' println!("cargo:rustc-env=TARGET={}", self.device.name); println!("cargo:warning=Device is {:?}", self.device.name); @@ -472,13 +483,8 @@ impl SDKBuilder<'_> { } pub fn bolos_sdk(&mut self) -> Result<(), SDKBuildError> { - println!("cargo:rerun-if-env-changed=LEDGER_SDK_PATH"); - self.bolos_sdk = match env::var("LEDGER_SDK_PATH") { - Err(_) => clone_sdk(&self.device), - Ok(path) => PathBuf::from(path), - }; - - let sdk_info = retrieve_csdk_info(&self.device, &self.bolos_sdk)?; + // Retrieve the C SDK infos + let sdk_info = retrieve_csdk_info(&self.device, &self.device.c_sdk)?; match sdk_info.api_level { Some(api_level) => { self.api_level = api_level; @@ -497,23 +503,23 @@ impl SDKBuilder<'_> { match self.device.name { DeviceName::Flex => { self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/64px")); self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/40px")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/40px")); } DeviceName::Stax => { self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/wallet")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/64px")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/64px")); self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/32px")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/32px")); } _ => { self.glyphs_folders - .push(self.bolos_sdk.join("lib_nbgl/glyphs/nano")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/nano")); } } @@ -532,7 +538,7 @@ impl SDKBuilder<'_> { } fn cxdefines(&mut self) -> Result<(), SDKBuildError> { - let mut makefile = File::open(self.bolos_sdk.join("Makefile.conf.cx")) + let mut makefile = File::open(self.device.c_sdk.join("Makefile.conf.cx")) .expect("Could not find Makefile.conf.cx"); let mut content = String::new(); makefile.read_to_string(&mut content).unwrap(); @@ -555,7 +561,7 @@ impl SDKBuilder<'_> { return Err(SDKBuildError::UnsupportedDevice); } - let icon2glyph = self.bolos_sdk.join("lib_nbgl/tools/icon2glyph.py"); + let icon2glyph = self.device.c_sdk.join("lib_nbgl/tools/icon2glyph.py"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let dest_path = out_path.join("glyphs"); @@ -591,21 +597,23 @@ impl SDKBuilder<'_> { command .files(&AUX_C_FILES) - .files(str2path(&self.bolos_sdk, &SDK_C_FILES)) - .files(str2path(&self.bolos_sdk, &SDK_USB_FILES)); + .files(str2path(&self.device.c_sdk, &SDK_C_FILES)) + .files(str2path(&self.device.c_sdk, &SDK_USB_FILES)); command = command .include(self.gcc_toolchain.join("include")) - .include(self.bolos_sdk.join("include")) - .include(self.bolos_sdk.join("lib_cxng/include")) - .include(self.bolos_sdk.join("lib_stusb")) - .include(self.bolos_sdk.join("lib_stusb_impl")) + .include(self.device.c_sdk.join("include")) + .include(self.device.c_sdk.join("lib_cxng/include")) + .include(self.device.c_sdk.join("lib_stusb")) + .include(self.device.c_sdk.join("lib_stusb_impl")) .include( - self.bolos_sdk + self.device + .c_sdk .join("lib_stusb/STM32_USB_Device_Library/Core/Inc"), ) .include( - self.bolos_sdk + self.device + .c_sdk .join("lib_stusb/STM32_USB_Device_Library/Class/HID/Inc"), ) .debug(true) @@ -623,17 +631,18 @@ impl SDKBuilder<'_> { } command.target(self.device.target).include( - self.bolos_sdk + self.device + .c_sdk .join(format!("target/{}/include", self.device.name)), ); // Configure BLE and NBGL for s in self.device.defines.iter() { if s.0 == "HAVE_BLE" { - configure_lib_ble(&mut command, &self.bolos_sdk); + configure_lib_ble(&mut command, &self.device.c_sdk); } if s.0 == "HAVE_NBGL" { - configure_lib_nbgl(&mut command, &self.bolos_sdk); + configure_lib_nbgl(&mut command, &self.device.c_sdk); } } @@ -644,8 +653,8 @@ impl SDKBuilder<'_> { command.compile("ledger-secure-sdk"); - /* Link with libc for unresolved symbols */ - let mut path = self.bolos_sdk.display().to_string(); + /* Link with libc, libm and libgcc */ + let mut path = self.device.c_sdk.display().to_string(); match self.device.name { DeviceName::NanoS => { path = self.gcc_toolchain.display().to_string(); @@ -666,7 +675,7 @@ impl SDKBuilder<'_> { } fn generate_bindings(&self) -> Result<(), SDKBuildError> { - let bsdk = self.bolos_sdk.display().to_string(); + let bsdk = self.device.c_sdk.display().to_string(); let gcc_tc = self.gcc_toolchain.display().to_string(); let args = [ "--target=thumbv6m-none-eabi".to_string(), // exact target is irrelevant for bindings @@ -678,7 +687,7 @@ impl SDKBuilder<'_> { format!("-I{bsdk}/lib_stusb/"), ]; let headers = str2path( - &self.bolos_sdk, + &self.device.c_sdk, &[ "lib_cxng/include/libcxng.h", /* cxlib */ "include/os.h", /* syscalls */ @@ -715,7 +724,8 @@ impl SDKBuilder<'_> { // BAGL or NBGL bindings match self.device.name { DeviceName::NanoS => { - bindings = bindings.header(self.bolos_sdk.join("include/bagl.h").to_str().unwrap()) + bindings = + bindings.header(self.device.c_sdk.join("include/bagl.h").to_str().unwrap()) } DeviceName::NanoSPlus | DeviceName::NanoX | DeviceName::Stax | DeviceName::Flex => { if ((self.device.name == DeviceName::NanoX @@ -736,13 +746,15 @@ impl SDKBuilder<'_> { ]); bindings = bindings .header( - self.bolos_sdk + self.device + .c_sdk .join("lib_nbgl/include/nbgl_use_case.h") .to_str() .unwrap(), ) .header( - self.bolos_sdk + self.device + .c_sdk .join("lib_ux_nbgl/ux_nbgl.h") .to_str() .unwrap(), @@ -755,7 +767,8 @@ impl SDKBuilder<'_> { match self.device.name { DeviceName::NanoX | DeviceName::Flex | DeviceName::Stax => { bindings = bindings.header( - self.bolos_sdk + self.device + .c_sdk .join("lib_blewbxx_impl/include/ledger_ble.h") .to_str() .unwrap(), From 4a47de627bb73cb11546b2c0e76029f85e0b00a7 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Feb 2025 14:47:45 +0100 Subject: [PATCH 079/154] rename bolos_sdk as c_sdk --- ledger_secure_sdk_sys/build.rs | 82 +++++++++++++++++----------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 7ff88a76..a8c921fe 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -148,10 +148,10 @@ fn retrieve_csdk_info(device: &Device, path: &PathBuf) -> Result (String, String) { +fn retrieve_csdk_git_info(c_sdk: &Path) -> (String, String) { let c_sdk_hash = match Command::new("git") .arg("-C") - .arg(bolos_sdk) + .arg(c_sdk) .arg("describe") .arg("--always") .arg("--dirty") @@ -173,7 +173,7 @@ fn retrieve_csdk_git_info(bolos_sdk: &Path) -> (String, String) { let c_sdk_version = match Command::new("git") .arg("-C") - .arg(bolos_sdk) + .arg(c_sdk) .arg("describe") .arg("--tags") .arg("--match") @@ -194,9 +194,9 @@ fn retrieve_csdk_git_info(bolos_sdk: &Path) -> (String, String) { (c_sdk_hash, c_sdk_version) } -fn retrieve_makefile_infos(bolos_sdk: &Path) -> Result<(Option, String), SDKBuildError> { +fn retrieve_makefile_infos(c_sdk: &Path) -> Result<(Option, String), SDKBuildError> { let makefile = - File::open(bolos_sdk.join("Makefile.defines")).expect("Could not find Makefile.defines"); + File::open(c_sdk.join("Makefile.defines")).expect("Could not find Makefile.defines"); let mut api_level: Option = None; for line in BufReader::new(makefile).lines().flatten() { if let Some(value) = line.split(":=").nth(1).map(str::trim) { @@ -210,7 +210,7 @@ fn retrieve_makefile_infos(bolos_sdk: &Path) -> Result<(Option, String), SD } } let makefile = - File::open(bolos_sdk.join("Makefile.target")).expect("Could not find Makefile.defines"); + File::open(c_sdk.join("Makefile.target")).expect("Could not find Makefile.defines"); let mut sdk_name: Option = None; for line in BufReader::new(makefile).lines().flatten() { if let Some(value) = line.split(":=").nth(1).map(str::trim) { @@ -230,14 +230,14 @@ fn retrieve_makefile_infos(bolos_sdk: &Path) -> Result<(Option, String), SD fn retrieve_target_file_infos( device: &Device, - bolos_sdk: &Path, + c_sdk: &Path, ) -> Result<(String, String), SDKBuildError> { let prefix = if device.name == DeviceName::NanoS { "".to_string() } else { format!("target/{}/", device.name) }; - let target_file_path = bolos_sdk.join(format!("{}include/bolos_target.h", prefix)); + let target_file_path = c_sdk.join(format!("{}include/bolos_target.h", prefix)); let target_file = File::open(target_file_path).map_err(|_| SDKBuildError::TargetFileNotFound)?; let mut target_id: Option = None; @@ -302,18 +302,18 @@ fn clone_sdk(devicename: &DeviceName) -> PathBuf { }; let out_dir = env::var("OUT_DIR").unwrap(); - let bolos_sdk = Path::new(out_dir.as_str()).join("ledger-secure-sdk"); - if !bolos_sdk.exists() { + let c_sdk = Path::new(out_dir.as_str()).join("ledger-secure-sdk"); + if !c_sdk.exists() { Command::new("git") .arg("clone") .arg(repo_url.to_str().unwrap()) .arg("-b") .arg(sdk_branch) - .arg(bolos_sdk.as_path()) + .arg(c_sdk.as_path()) .output() .ok(); } - bolos_sdk + c_sdk } #[derive(Debug)] @@ -326,11 +326,11 @@ enum SDKBuildError { MissingTargetName, } -/// Helper function to concatenate all paths in pathlist to bolos_sdk's path -fn str2path(bolos_sdk: &Path, pathlist: &[&str]) -> Vec { +/// Helper function to concatenate all paths in pathlist to c_sdk's path +fn str2path(c_sdk: &Path, pathlist: &[&str]) -> Vec { pathlist .iter() - .map(|p| bolos_sdk.join(p)) + .map(|p| c_sdk.join(p)) .collect::>() } @@ -482,8 +482,8 @@ impl SDKBuilder<'_> { Ok(()) } - pub fn bolos_sdk(&mut self) -> Result<(), SDKBuildError> { - // Retrieve the C SDK infos + pub fn get_info(&mut self) -> Result<(), SDKBuildError> { + // Retrieve the C SDK information let sdk_info = retrieve_csdk_info(&self.device, &self.device.c_sdk)?; match sdk_info.api_level { Some(api_level) => { @@ -840,7 +840,7 @@ fn main() { let mut sdk_builder = SDKBuilder::new(); sdk_builder.gcc_toolchain().unwrap(); sdk_builder.device().unwrap(); - sdk_builder.bolos_sdk().unwrap(); + sdk_builder.get_info().unwrap(); sdk_builder.cxdefines().unwrap(); sdk_builder.generate_glyphs().unwrap(); sdk_builder.build_c_sdk().unwrap(); @@ -854,35 +854,35 @@ fn main() { ); } -fn configure_lib_ble(command: &mut cc::Build, bolos_sdk: &Path) { +fn configure_lib_ble(command: &mut cc::Build, c_sdk: &Path) { command - .file(bolos_sdk.join("src/ledger_protocol.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c")) - .file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c")) - .file(bolos_sdk.join("lib_blewbxx/core/template/osal.c")) - .file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c")) - .include(bolos_sdk.join("lib_blewbxx/include")) - .include(bolos_sdk.join("lib_blewbxx/core")) - .include(bolos_sdk.join("lib_blewbxx/core/auto")) - .include(bolos_sdk.join("lib_blewbxx/core/template")) - .include(bolos_sdk.join("lib_blewbxx_impl/include")); + .file(c_sdk.join("src/ledger_protocol.c")) + .file(c_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c")) + .file(c_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c")) + .file(c_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c")) + .file(c_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c")) + .file(c_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c")) + .file(c_sdk.join("lib_blewbxx/core/template/osal.c")) + .file(c_sdk.join("lib_blewbxx_impl/src/ledger_ble.c")) + .include(c_sdk.join("lib_blewbxx/include")) + .include(c_sdk.join("lib_blewbxx/core")) + .include(c_sdk.join("lib_blewbxx/core/auto")) + .include(c_sdk.join("lib_blewbxx/core/template")) + .include(c_sdk.join("lib_blewbxx_impl/include")); } -fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) { +fn configure_lib_nbgl(command: &mut cc::Build, c_sdk: &Path) { let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command - .include(bolos_sdk.join("lib_nbgl/include/")) - .include(bolos_sdk.join("lib_nbgl/include/fonts/")) - .include(bolos_sdk.join("lib_ux_nbgl/")) - .include(bolos_sdk.join("qrcode/include/")) - .include(bolos_sdk.join("lib_bagl/include/")) - .file(bolos_sdk.join("lib_ux_nbgl/ux.c")) - .file(bolos_sdk.join("qrcode/src/qrcodegen.c")) + .include(c_sdk.join("lib_nbgl/include/")) + .include(c_sdk.join("lib_nbgl/include/fonts/")) + .include(c_sdk.join("lib_ux_nbgl/")) + .include(c_sdk.join("qrcode/include/")) + .include(c_sdk.join("lib_bagl/include/")) + .file(c_sdk.join("lib_ux_nbgl/ux.c")) + .file(c_sdk.join("qrcode/src/qrcodegen.c")) .files( - glob(bolos_sdk.join("lib_nbgl/src/*.c").to_str().unwrap()) + glob(c_sdk.join("lib_nbgl/src/*.c").to_str().unwrap()) .unwrap() .map(|x| x.unwrap()) .collect::>(), From 6320ef201f3fb851dee7893e835b64650f27f40f Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Feb 2025 15:14:02 +0100 Subject: [PATCH 080/154] Move glyphs_folders into Device --- ledger_secure_sdk_sys/build.rs | 123 ++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 57 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index a8c921fe..5849b972 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -110,6 +110,7 @@ struct Device<'a> { pub target: &'a str, pub defines: Vec<(String, Option)>, pub cflags: Vec<&'a str>, + pub glyphs_folders: Vec, } impl std::fmt::Display for DeviceName { @@ -316,6 +317,31 @@ fn clone_sdk(devicename: &DeviceName) -> PathBuf { c_sdk } +pub fn generate_glyphs(c_sdk: &PathBuf, glyphs_folders: &[PathBuf]) { + let icon2glyph = c_sdk.join("lib_nbgl/tools/icon2glyph.py"); + + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let dest_path = out_path.join("glyphs"); + if !dest_path.exists() { + fs::create_dir_all(&dest_path).ok(); + } + + let mut cmd = Command::new(icon2glyph.as_os_str()); + cmd.arg("--glyphcheader") + .arg(dest_path.join("glyphs.h").as_os_str()) + .arg("--glyphcfile") + .arg(dest_path.join("glyphs.c").as_os_str()); + + for folder in glyphs_folders.iter() { + for file in std::fs::read_dir(folder).unwrap() { + let path = file.unwrap().path(); + let path_str = path.to_str().unwrap().to_string(); + cmd.arg(path_str); + } + } + let _ = cmd.output(); +} + #[derive(Debug)] enum SDKBuildError { UnsupportedDevice, @@ -361,7 +387,6 @@ struct SDKBuilder<'a> { api_level: u32, gcc_toolchain: PathBuf, device: Device<'a>, - glyphs_folders: Vec, cxdefines: Vec, } @@ -371,7 +396,6 @@ impl SDKBuilder<'_> { api_level: 0, gcc_toolchain: PathBuf::new(), device: Device::default(), - glyphs_folders: Vec::new(), cxdefines: Vec::new(), } } @@ -412,6 +436,7 @@ impl SDKBuilder<'_> { target: "thumbv6m-none-eabi", defines: header2define("csdk_nanos.h"), cflags: Vec::from(CFLAGS_NANOS), + glyphs_folders: Vec::new(), }, "nanosplus" => Device { name: DeviceName::NanoSPlus, @@ -431,6 +456,7 @@ impl SDKBuilder<'_> { v }, cflags: Vec::from(CFLAGS_NANOSPLUS), + glyphs_folders: Vec::new(), }, "nanox" => Device { name: DeviceName::NanoX, @@ -450,6 +476,7 @@ impl SDKBuilder<'_> { v }, cflags: Vec::from(CFLAGS_NANOX), + glyphs_folders: Vec::new(), }, "stax" => Device { name: DeviceName::Stax, @@ -457,6 +484,7 @@ impl SDKBuilder<'_> { target: "thumbv8m.main-none-eabi", defines: header2define("csdk_stax.h"), cflags: Vec::from(CFLAGS_STAX), + glyphs_folders: Vec::new(), }, "flex" => Device { name: DeviceName::Flex, @@ -464,6 +492,7 @@ impl SDKBuilder<'_> { target: "thumbv8m.main-none-eabi", defines: header2define("csdk_flex.h"), cflags: Vec::from(CFLAGS_FLEX), + glyphs_folders: Vec::new(), }, _ => { return Err(SDKBuildError::UnsupportedDevice); @@ -476,6 +505,37 @@ impl SDKBuilder<'_> { Ok(path) => PathBuf::from(path), }; + // set glyphs folders + match self.device.name { + DeviceName::Flex => { + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/64px")); + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/40px")); + } + DeviceName::Stax => { + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/64px")); + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/32px")); + } + _ => { + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/nano")); + } + } + // export TARGET into env for 'infos.rs' println!("cargo:rustc-env=TARGET={}", self.device.name); println!("cargo:warning=Device is {:?}", self.device.name); @@ -499,30 +559,6 @@ impl SDKBuilder<'_> { } } - // set glyphs folders - match self.device.name { - DeviceName::Flex => { - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/64px")); - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/40px")); - } - DeviceName::Stax => { - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/64px")); - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/32px")); - } - _ => { - self.glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/nano")); - } - } - // Export other SDK infos into env for 'infos.rs' println!("cargo:rustc-env=TARGET_ID={}", sdk_info.target_id); println!("cargo:warning=TARGET_ID is {}", sdk_info.target_id); @@ -556,38 +592,12 @@ impl SDKBuilder<'_> { Ok(()) } - pub fn generate_glyphs(&self) -> Result<(), SDKBuildError> { - if self.device.name == DeviceName::NanoS { - return Err(SDKBuildError::UnsupportedDevice); - } - - let icon2glyph = self.device.c_sdk.join("lib_nbgl/tools/icon2glyph.py"); - - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - let dest_path = out_path.join("glyphs"); - if !dest_path.exists() { - fs::create_dir_all(&dest_path).ok(); - } - - let mut cmd = Command::new(icon2glyph.as_os_str()); - cmd.arg("--glyphcheader") - .arg(dest_path.join("glyphs.h").as_os_str()) - .arg("--glyphcfile") - .arg(dest_path.join("glyphs.c").as_os_str()); - - for folder in self.glyphs_folders.iter() { - for file in std::fs::read_dir(folder).unwrap() { - let path = file.unwrap().path(); - let path_str = path.to_str().unwrap().to_string(); - cmd.arg(path_str); - } + pub fn build_c_sdk(&self) -> Result<(), SDKBuildError> { + // Generate glyphs + if self.device.name != DeviceName::NanoS { + generate_glyphs(&self.device.c_sdk, &self.device.glyphs_folders); } - let _ = cmd.output(); - Ok(()) - } - - pub fn build_c_sdk(&self) -> Result<(), SDKBuildError> { let mut command = cc::Build::new(); if env::var_os("CC").is_none() { command.compiler("clang"); @@ -842,7 +852,6 @@ fn main() { sdk_builder.device().unwrap(); sdk_builder.get_info().unwrap(); sdk_builder.cxdefines().unwrap(); - sdk_builder.generate_glyphs().unwrap(); sdk_builder.build_c_sdk().unwrap(); sdk_builder.generate_bindings().unwrap(); sdk_builder.generate_heap_size().unwrap(); From 33c5b7ac864b2423c7953148f48b4f34ace283ad Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Feb 2025 15:45:27 +0100 Subject: [PATCH 081/154] Set arm libs path in Device --- ledger_secure_sdk_sys/build.rs | 39 ++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 5849b972..8967b906 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -111,6 +111,7 @@ struct Device<'a> { pub defines: Vec<(String, Option)>, pub cflags: Vec<&'a str>, pub glyphs_folders: Vec, + pub arm_libs: String, } impl std::fmt::Display for DeviceName { @@ -437,6 +438,7 @@ impl SDKBuilder<'_> { defines: header2define("csdk_nanos.h"), cflags: Vec::from(CFLAGS_NANOS), glyphs_folders: Vec::new(), + arm_libs: Default::default(), }, "nanosplus" => Device { name: DeviceName::NanoSPlus, @@ -457,6 +459,7 @@ impl SDKBuilder<'_> { }, cflags: Vec::from(CFLAGS_NANOSPLUS), glyphs_folders: Vec::new(), + arm_libs: Default::default(), }, "nanox" => Device { name: DeviceName::NanoX, @@ -477,6 +480,7 @@ impl SDKBuilder<'_> { }, cflags: Vec::from(CFLAGS_NANOX), glyphs_folders: Vec::new(), + arm_libs: Default::default(), }, "stax" => Device { name: DeviceName::Stax, @@ -485,6 +489,7 @@ impl SDKBuilder<'_> { defines: header2define("csdk_stax.h"), cflags: Vec::from(CFLAGS_STAX), glyphs_folders: Vec::new(), + arm_libs: Default::default(), }, "flex" => Device { name: DeviceName::Flex, @@ -493,6 +498,7 @@ impl SDKBuilder<'_> { defines: header2define("csdk_flex.h"), cflags: Vec::from(CFLAGS_FLEX), glyphs_folders: Vec::new(), + arm_libs: Default::default(), }, _ => { return Err(SDKBuildError::UnsupportedDevice); @@ -536,6 +542,25 @@ impl SDKBuilder<'_> { } } + // Set ARM pre-compiled libraries path + self.device.arm_libs = match self.device.name { + DeviceName::NanoS => { + let mut path = self.gcc_toolchain.display().to_string(); + path.push_str("/lib"); + path + } + DeviceName::NanoX => { + let mut path = self.device.c_sdk.display().to_string(); + path.push_str("/arch/st33/lib"); + path + } + DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax => { + let mut path = self.device.c_sdk.display().to_string(); + path.push_str("/arch/st33k1/lib"); + path + } + }; + // export TARGET into env for 'infos.rs' println!("cargo:rustc-env=TARGET={}", self.device.name); println!("cargo:warning=Device is {:?}", self.device.name); @@ -664,19 +689,7 @@ impl SDKBuilder<'_> { command.compile("ledger-secure-sdk"); /* Link with libc, libm and libgcc */ - let mut path = self.device.c_sdk.display().to_string(); - match self.device.name { - DeviceName::NanoS => { - path = self.gcc_toolchain.display().to_string(); - path.push_str("/lib"); - } - DeviceName::NanoX => { - path.push_str("/arch/st33/lib"); - } - DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax => { - path.push_str("/arch/st33k1/lib"); - } - }; + let path = self.device.arm_libs.clone(); println!("cargo:rustc-link-lib=c"); println!("cargo:rustc-link-lib=m"); println!("cargo:rustc-link-lib=gcc"); From 30f43b3f423e3f0f62247e8c7455dc1c9b96c994 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Feb 2025 15:54:16 +0100 Subject: [PATCH 082/154] Move local functions --- ledger_secure_sdk_sys/build.rs | 468 +++++++++++++++++---------------- 1 file changed, 236 insertions(+), 232 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 8967b906..84a6a09a 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -142,207 +142,6 @@ impl CSDKInfo { } } -fn retrieve_csdk_info(device: &Device, path: &PathBuf) -> Result { - let mut csdk_info = CSDKInfo::new(); - (csdk_info.api_level, csdk_info.c_sdk_name) = retrieve_makefile_infos(path)?; - (csdk_info.target_id, csdk_info.target_name) = retrieve_target_file_infos(device, path)?; - (csdk_info.c_sdk_hash, csdk_info.c_sdk_version) = retrieve_csdk_git_info(path); - Ok(csdk_info) -} - -fn retrieve_csdk_git_info(c_sdk: &Path) -> (String, String) { - let c_sdk_hash = match Command::new("git") - .arg("-C") - .arg(c_sdk) - .arg("describe") - .arg("--always") - .arg("--dirty") - .arg("--exclude") - .arg("*") - .arg("--abbrev=40") - .output() - .ok() - { - Some(output) => { - if output.stdout.is_empty() { - "None".to_string() - } else { - String::from_utf8(output.stdout).unwrap_or("None".to_string()) - } - } - None => "None".to_string(), - }; - - let c_sdk_version = match Command::new("git") - .arg("-C") - .arg(c_sdk) - .arg("describe") - .arg("--tags") - .arg("--match") - .arg("v[0-9]*") - .arg("--dirty") - .output() - .ok() - { - Some(output) => { - if output.status.success() { - String::from_utf8(output.stdout).unwrap_or("None".to_string()) - } else { - String::from_utf8(output.stderr).unwrap_or("None".to_string()) - } - } - None => "None".to_string(), - }; - (c_sdk_hash, c_sdk_version) -} - -fn retrieve_makefile_infos(c_sdk: &Path) -> Result<(Option, String), SDKBuildError> { - let makefile = - File::open(c_sdk.join("Makefile.defines")).expect("Could not find Makefile.defines"); - let mut api_level: Option = None; - for line in BufReader::new(makefile).lines().flatten() { - if let Some(value) = line.split(":=").nth(1).map(str::trim) { - if line.contains("API_LEVEL") && api_level.is_none() { - api_level = Some(value.parse().map_err(|_| SDKBuildError::InvalidAPILevel)?); - } - } - if api_level.is_some() { - // Key found, break out of the loop - break; - } - } - let makefile = - File::open(c_sdk.join("Makefile.target")).expect("Could not find Makefile.defines"); - let mut sdk_name: Option = None; - for line in BufReader::new(makefile).lines().flatten() { - if let Some(value) = line.split(":=").nth(1).map(str::trim) { - if line.contains("SDK_NAME") && sdk_name.is_none() { - sdk_name = Some(value.to_string().replace('\"', "")); - } - } - if sdk_name.is_some() { - // Key found, break out of the loop - break; - } - } - - let sdk_name = sdk_name.ok_or(SDKBuildError::MissingSDKName)?; - Ok((api_level, sdk_name)) -} - -fn retrieve_target_file_infos( - device: &Device, - c_sdk: &Path, -) -> Result<(String, String), SDKBuildError> { - let prefix = if device.name == DeviceName::NanoS { - "".to_string() - } else { - format!("target/{}/", device.name) - }; - let target_file_path = c_sdk.join(format!("{}include/bolos_target.h", prefix)); - let target_file = - File::open(target_file_path).map_err(|_| SDKBuildError::TargetFileNotFound)?; - let mut target_id: Option = None; - let mut target_name: Option = None; - - for line in BufReader::new(target_file).lines().flatten() { - if target_id.is_none() && line.contains("#define TARGET_ID") { - target_id = Some( - line.split_whitespace() - .nth(2) - .ok_or("err") - .map_err(|_| SDKBuildError::MissingTargetId)? - .to_string(), - ); - } else if target_name.is_none() - && line.contains("#define TARGET_") - && !line.contains("#define TARGET_ID") - { - target_name = Some( - line.split_whitespace() - .nth(1) - .ok_or("err") - .map_err(|_| SDKBuildError::MissingTargetName)? - .to_string(), - ); - } - - if target_id.is_some() && target_name.is_some() { - // Both tokens found, break out of the loop - break; - } - } - - let target_id = target_id.ok_or(SDKBuildError::MissingTargetId)?; - let target_name = target_name.ok_or(SDKBuildError::MissingTargetName)?; - Ok((target_id, target_name)) -} - -/// Fetch the appropriate C SDK to build -fn clone_sdk(devicename: &DeviceName) -> PathBuf { - let (repo_url, sdk_branch) = match devicename { - DeviceName::NanoS => ( - Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_LNS", - ), - DeviceName::NanoX => ( - Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", - ), - DeviceName::NanoSPlus => ( - Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", - ), - DeviceName::Stax => ( - Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", - ), - DeviceName::Flex => ( - Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", - ), - }; - - let out_dir = env::var("OUT_DIR").unwrap(); - let c_sdk = Path::new(out_dir.as_str()).join("ledger-secure-sdk"); - if !c_sdk.exists() { - Command::new("git") - .arg("clone") - .arg(repo_url.to_str().unwrap()) - .arg("-b") - .arg(sdk_branch) - .arg(c_sdk.as_path()) - .output() - .ok(); - } - c_sdk -} - -pub fn generate_glyphs(c_sdk: &PathBuf, glyphs_folders: &[PathBuf]) { - let icon2glyph = c_sdk.join("lib_nbgl/tools/icon2glyph.py"); - - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - let dest_path = out_path.join("glyphs"); - if !dest_path.exists() { - fs::create_dir_all(&dest_path).ok(); - } - - let mut cmd = Command::new(icon2glyph.as_os_str()); - cmd.arg("--glyphcheader") - .arg(dest_path.join("glyphs.h").as_os_str()) - .arg("--glyphcfile") - .arg(dest_path.join("glyphs.c").as_os_str()); - - for folder in glyphs_folders.iter() { - for file in std::fs::read_dir(folder).unwrap() { - let path = file.unwrap().path(); - let path_str = path.to_str().unwrap().to_string(); - cmd.arg(path_str); - } - } - let _ = cmd.output(); -} - #[derive(Debug)] enum SDKBuildError { UnsupportedDevice, @@ -353,37 +152,6 @@ enum SDKBuildError { MissingTargetName, } -/// Helper function to concatenate all paths in pathlist to c_sdk's path -fn str2path(c_sdk: &Path, pathlist: &[&str]) -> Vec { - pathlist - .iter() - .map(|p| c_sdk.join(p)) - .collect::>() -} - -/// Get all #define from a header file -fn header2define(headername: &str) -> Vec<(String, Option)> { - let mut headerfile = File::open(headername).unwrap(); - let mut header = String::new(); - headerfile.read_to_string(&mut header).unwrap(); - - header - .lines() - .filter_map(|line| { - if line.trim_start().starts_with("#define") { - let parts: Vec<&str> = line.split_whitespace().collect(); - match parts.len() { - 2 => Some((parts[1].to_string(), None)), - 3 => Some((parts[1].to_string(), Some(parts[2].to_string()))), - _ => None, - } - } else { - None - } - }) - .collect() -} - struct SDKBuilder<'a> { api_level: u32, gcc_toolchain: PathBuf, @@ -876,6 +644,10 @@ fn main() { ); } +// -------------------------------------------------- +// Helper functions +// -------------------------------------------------- + fn configure_lib_ble(command: &mut cc::Build, c_sdk: &Path) { command .file(c_sdk.join("src/ledger_protocol.c")) @@ -912,3 +684,235 @@ fn configure_lib_nbgl(command: &mut cc::Build, c_sdk: &Path) { .include(&glyphs_path) .file(glyphs_path.join("glyphs.c")); } + +fn retrieve_csdk_info(device: &Device, path: &PathBuf) -> Result { + let mut csdk_info = CSDKInfo::new(); + (csdk_info.api_level, csdk_info.c_sdk_name) = retrieve_makefile_infos(path)?; + (csdk_info.target_id, csdk_info.target_name) = retrieve_target_file_infos(device, path)?; + (csdk_info.c_sdk_hash, csdk_info.c_sdk_version) = retrieve_csdk_git_info(path); + Ok(csdk_info) +} + +fn retrieve_csdk_git_info(c_sdk: &Path) -> (String, String) { + let c_sdk_hash = match Command::new("git") + .arg("-C") + .arg(c_sdk) + .arg("describe") + .arg("--always") + .arg("--dirty") + .arg("--exclude") + .arg("*") + .arg("--abbrev=40") + .output() + .ok() + { + Some(output) => { + if output.stdout.is_empty() { + "None".to_string() + } else { + String::from_utf8(output.stdout).unwrap_or("None".to_string()) + } + } + None => "None".to_string(), + }; + + let c_sdk_version = match Command::new("git") + .arg("-C") + .arg(c_sdk) + .arg("describe") + .arg("--tags") + .arg("--match") + .arg("v[0-9]*") + .arg("--dirty") + .output() + .ok() + { + Some(output) => { + if output.status.success() { + String::from_utf8(output.stdout).unwrap_or("None".to_string()) + } else { + String::from_utf8(output.stderr).unwrap_or("None".to_string()) + } + } + None => "None".to_string(), + }; + (c_sdk_hash, c_sdk_version) +} + +fn retrieve_makefile_infos(c_sdk: &Path) -> Result<(Option, String), SDKBuildError> { + let makefile = + File::open(c_sdk.join("Makefile.defines")).expect("Could not find Makefile.defines"); + let mut api_level: Option = None; + for line in BufReader::new(makefile).lines().flatten() { + if let Some(value) = line.split(":=").nth(1).map(str::trim) { + if line.contains("API_LEVEL") && api_level.is_none() { + api_level = Some(value.parse().map_err(|_| SDKBuildError::InvalidAPILevel)?); + } + } + if api_level.is_some() { + // Key found, break out of the loop + break; + } + } + let makefile = + File::open(c_sdk.join("Makefile.target")).expect("Could not find Makefile.defines"); + let mut sdk_name: Option = None; + for line in BufReader::new(makefile).lines().flatten() { + if let Some(value) = line.split(":=").nth(1).map(str::trim) { + if line.contains("SDK_NAME") && sdk_name.is_none() { + sdk_name = Some(value.to_string().replace('\"', "")); + } + } + if sdk_name.is_some() { + // Key found, break out of the loop + break; + } + } + + let sdk_name = sdk_name.ok_or(SDKBuildError::MissingSDKName)?; + Ok((api_level, sdk_name)) +} + +fn retrieve_target_file_infos( + device: &Device, + c_sdk: &Path, +) -> Result<(String, String), SDKBuildError> { + let prefix = if device.name == DeviceName::NanoS { + "".to_string() + } else { + format!("target/{}/", device.name) + }; + let target_file_path = c_sdk.join(format!("{}include/bolos_target.h", prefix)); + let target_file = + File::open(target_file_path).map_err(|_| SDKBuildError::TargetFileNotFound)?; + let mut target_id: Option = None; + let mut target_name: Option = None; + + for line in BufReader::new(target_file).lines().flatten() { + if target_id.is_none() && line.contains("#define TARGET_ID") { + target_id = Some( + line.split_whitespace() + .nth(2) + .ok_or("err") + .map_err(|_| SDKBuildError::MissingTargetId)? + .to_string(), + ); + } else if target_name.is_none() + && line.contains("#define TARGET_") + && !line.contains("#define TARGET_ID") + { + target_name = Some( + line.split_whitespace() + .nth(1) + .ok_or("err") + .map_err(|_| SDKBuildError::MissingTargetName)? + .to_string(), + ); + } + + if target_id.is_some() && target_name.is_some() { + // Both tokens found, break out of the loop + break; + } + } + + let target_id = target_id.ok_or(SDKBuildError::MissingTargetId)?; + let target_name = target_name.ok_or(SDKBuildError::MissingTargetName)?; + Ok((target_id, target_name)) +} + +/// Fetch the appropriate C SDK to build +fn clone_sdk(devicename: &DeviceName) -> PathBuf { + let (repo_url, sdk_branch) = match devicename { + DeviceName::NanoS => ( + Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), + "API_LEVEL_LNS", + ), + DeviceName::NanoX => ( + Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), + "API_LEVEL_22", + ), + DeviceName::NanoSPlus => ( + Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), + "API_LEVEL_22", + ), + DeviceName::Stax => ( + Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), + "API_LEVEL_22", + ), + DeviceName::Flex => ( + Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), + "API_LEVEL_22", + ), + }; + + let out_dir = env::var("OUT_DIR").unwrap(); + let c_sdk = Path::new(out_dir.as_str()).join("ledger-secure-sdk"); + if !c_sdk.exists() { + Command::new("git") + .arg("clone") + .arg(repo_url.to_str().unwrap()) + .arg("-b") + .arg(sdk_branch) + .arg(c_sdk.as_path()) + .output() + .ok(); + } + c_sdk +} + +pub fn generate_glyphs(c_sdk: &PathBuf, glyphs_folders: &[PathBuf]) { + let icon2glyph = c_sdk.join("lib_nbgl/tools/icon2glyph.py"); + + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let dest_path = out_path.join("glyphs"); + if !dest_path.exists() { + fs::create_dir_all(&dest_path).ok(); + } + + let mut cmd = Command::new(icon2glyph.as_os_str()); + cmd.arg("--glyphcheader") + .arg(dest_path.join("glyphs.h").as_os_str()) + .arg("--glyphcfile") + .arg(dest_path.join("glyphs.c").as_os_str()); + + for folder in glyphs_folders.iter() { + for file in std::fs::read_dir(folder).unwrap() { + let path = file.unwrap().path(); + let path_str = path.to_str().unwrap().to_string(); + cmd.arg(path_str); + } + } + let _ = cmd.output(); +} + +/// Helper function to concatenate all paths in pathlist to c_sdk's path +fn str2path(c_sdk: &Path, pathlist: &[&str]) -> Vec { + pathlist + .iter() + .map(|p| c_sdk.join(p)) + .collect::>() +} + +/// Get all #define from a header file +fn header2define(headername: &str) -> Vec<(String, Option)> { + let mut headerfile = File::open(headername).unwrap(); + let mut header = String::new(); + headerfile.read_to_string(&mut header).unwrap(); + + header + .lines() + .filter_map(|line| { + if line.trim_start().starts_with("#define") { + let parts: Vec<&str> = line.split_whitespace().collect(); + match parts.len() { + 2 => Some((parts[1].to_string(), None)), + 3 => Some((parts[1].to_string(), Some(parts[2].to_string()))), + _ => None, + } + } else { + None + } + }) + .collect() +} From 80a8e2e53f5bd3bb963f663d9c38648171e88aed Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Feb 2025 16:04:25 +0100 Subject: [PATCH 083/154] Update linker script name in custom targets for Stax and Flex --- ledger_secure_sdk_sys/flex.json | 4 ++-- ledger_secure_sdk_sys/stax.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ledger_secure_sdk_sys/flex.json b/ledger_secure_sdk_sys/flex.json index af01a46e..e4039ab9 100644 --- a/ledger_secure_sdk_sys/flex.json +++ b/ledger_secure_sdk_sys/flex.json @@ -13,11 +13,11 @@ "panic-strategy": "abort", "pre-link-args": { "ld.lld": [ - "-Tstax_flex_layout.ld", + "-Tflex_layout.ld", "-Tlink.ld" ], "ld": [ - "-Tstax_flex_layout.ld", + "-Tflex_layout.ld", "-Tlink.ld" ] }, diff --git a/ledger_secure_sdk_sys/stax.json b/ledger_secure_sdk_sys/stax.json index c39cd3d0..035c1e11 100644 --- a/ledger_secure_sdk_sys/stax.json +++ b/ledger_secure_sdk_sys/stax.json @@ -13,11 +13,11 @@ "panic-strategy": "abort", "pre-link-args": { "ld.lld": [ - "-Tstax_flex_layout.ld", + "-Tstax_layout.ld", "-Tlink.ld" ], "ld": [ - "-Tstax_flex_layout.ld", + "-Tstax_layout.ld", "-Tlink.ld" ] }, From f0a2b823f1410360314bfcd1cf55e2f00c9bf347 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Feb 2025 16:17:30 +0100 Subject: [PATCH 084/154] Move linker script in Device --- ledger_secure_sdk_sys/build.rs | 19 +++++++++++-------- .../{stax_flex_layout.ld => flex_layout.ld} | 0 ledger_secure_sdk_sys/stax_layout.ld | 10 ++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) rename ledger_secure_sdk_sys/{stax_flex_layout.ld => flex_layout.ld} (100%) create mode 100644 ledger_secure_sdk_sys/stax_layout.ld diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 84a6a09a..7f7ff8a4 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -112,6 +112,7 @@ struct Device<'a> { pub cflags: Vec<&'a str>, pub glyphs_folders: Vec, pub arm_libs: String, + pub linker_script: &'a str, } impl std::fmt::Display for DeviceName { @@ -207,6 +208,7 @@ impl SDKBuilder<'_> { cflags: Vec::from(CFLAGS_NANOS), glyphs_folders: Vec::new(), arm_libs: Default::default(), + linker_script: "nanos_layout.ld", }, "nanosplus" => Device { name: DeviceName::NanoSPlus, @@ -228,6 +230,7 @@ impl SDKBuilder<'_> { cflags: Vec::from(CFLAGS_NANOSPLUS), glyphs_folders: Vec::new(), arm_libs: Default::default(), + linker_script: "nanosplus_layout.ld", }, "nanox" => Device { name: DeviceName::NanoX, @@ -249,6 +252,7 @@ impl SDKBuilder<'_> { cflags: Vec::from(CFLAGS_NANOX), glyphs_folders: Vec::new(), arm_libs: Default::default(), + linker_script: "nanox_layout.ld", }, "stax" => Device { name: DeviceName::Stax, @@ -258,6 +262,7 @@ impl SDKBuilder<'_> { cflags: Vec::from(CFLAGS_STAX), glyphs_folders: Vec::new(), arm_libs: Default::default(), + linker_script: "stax_layout.ld", }, "flex" => Device { name: DeviceName::Flex, @@ -267,6 +272,7 @@ impl SDKBuilder<'_> { cflags: Vec::from(CFLAGS_FLEX), glyphs_folders: Vec::new(), arm_libs: Default::default(), + linker_script: "flex_layout.ld", }, _ => { return Err(SDKBuildError::UnsupportedDevice); @@ -613,14 +619,11 @@ impl SDKBuilder<'_> { // extend the library search path println!("cargo:rustc-link-search={}", out_dir.display()); // copy - let linkerscript = match self.device.name { - DeviceName::NanoS => "nanos_layout.ld", - DeviceName::NanoX => "nanox_layout.ld", - DeviceName::NanoSPlus => "nanosplus_layout.ld", - DeviceName::Stax => "stax_flex_layout.ld", - DeviceName::Flex => "stax_flex_layout.ld", - }; - std::fs::copy(linkerscript, out_dir.join(linkerscript)).unwrap(); + std::fs::copy( + self.device.linker_script, + out_dir.join(self.device.linker_script), + ) + .unwrap(); std::fs::copy("link.ld", out_dir.join("link.ld")).unwrap(); Ok(()) } diff --git a/ledger_secure_sdk_sys/stax_flex_layout.ld b/ledger_secure_sdk_sys/flex_layout.ld similarity index 100% rename from ledger_secure_sdk_sys/stax_flex_layout.ld rename to ledger_secure_sdk_sys/flex_layout.ld diff --git a/ledger_secure_sdk_sys/stax_layout.ld b/ledger_secure_sdk_sys/stax_layout.ld new file mode 100644 index 00000000..9418ef65 --- /dev/null +++ b/ledger_secure_sdk_sys/stax_layout.ld @@ -0,0 +1,10 @@ +MEMORY +{ + FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K + DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K +} + +PAGE_SIZE = 512; +STACK_SIZE = 1500; +END_STACK = ORIGIN(SRAM) + LENGTH(SRAM); \ No newline at end of file From e226641a79358c3f5e51e13590dcc78be33ab07d Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 18 Feb 2025 16:04:23 +0100 Subject: [PATCH 085/154] Enable NBGL build for all Nano* devices --- ledger_device_sdk/src/io.rs | 4 ++++ ledger_device_sdk/src/lib.rs | 4 ++-- ledger_device_sdk/src/nbgl.rs | 4 ++++ .../src/nbgl/nbgl_home_and_settings.rs | 10 ++++++++-- ledger_secure_sdk_sys/build.rs | 16 ++++++++++++---- ledger_secure_sdk_sys/csdk_flex.h | 8 +++++++- ledger_secure_sdk_sys/csdk_nanos2.h | 8 +++++++- ledger_secure_sdk_sys/csdk_nanox.h | 8 +++++++- ledger_secure_sdk_sys/csdk_stax.h | 8 +++++++- ledger_secure_sdk_sys/link.ld | 1 + ledger_secure_sdk_sys/src/c/src.c | 14 +++++++++++++- ledger_secure_sdk_sys/src/infos.rs | 5 +++++ 12 files changed, 77 insertions(+), 13 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 812c62f1..2f4558f1 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -372,6 +372,10 @@ impl Comm { match seph::Events::from(tag) { #[cfg(not(any(target_os = "stax", target_os = "flex")))] seph::Events::ButtonPush => { + #[cfg(feature = "nbgl")] + unsafe { + ux_process_button_event(spi_buffer.as_mut_ptr()); + } let button_info = spi_buffer[3] >> 1; if let Some(btn_evt) = get_button_event(&mut self.buttons, button_info) { return Some(Event::Button(btn_evt)); diff --git a/ledger_device_sdk/src/lib.rs b/ledger_device_sdk/src/lib.rs index 380512f1..5ed408bd 100644 --- a/ledger_device_sdk/src/lib.rs +++ b/ledger_device_sdk/src/lib.rs @@ -22,9 +22,9 @@ pub mod seph; pub mod testing; -#[cfg(any(target_os = "stax", target_os = "flex"))] +#[cfg(any(target_os = "stax", target_os = "flex", feature = "nbgl"))] pub mod nbgl; -#[cfg(not(any(target_os = "stax", target_os = "flex")))] +#[cfg(not(any(target_os = "stax", target_os = "flex", feature = "nbgl")))] pub mod ui; pub mod uxapp; diff --git a/ledger_device_sdk/src/nbgl.rs b/ledger_device_sdk/src/nbgl.rs index 2ad72609..dcb86907 100644 --- a/ledger_device_sdk/src/nbgl.rs +++ b/ledger_device_sdk/src/nbgl.rs @@ -10,6 +10,7 @@ use ledger_secure_sdk_sys::*; pub mod nbgl_address_review; pub mod nbgl_choice; +#[cfg(any(target_os = "stax", target_os = "flex"))] pub mod nbgl_generic_review; pub mod nbgl_home_and_settings; pub mod nbgl_review; @@ -20,6 +21,7 @@ pub mod nbgl_streaming_review; pub use nbgl_address_review::*; pub use nbgl_choice::*; +#[cfg(any(target_os = "stax", target_os = "flex"))] pub use nbgl_generic_review::*; pub use nbgl_home_and_settings::*; pub use nbgl_review::*; @@ -105,6 +107,7 @@ unsafe extern "C" fn quit_callback() { G_ENDED = true; } +#[cfg(any(target_os = "stax", target_os = "flex"))] unsafe extern "C" fn rejected_callback() { G_RET = SyncNbgl::UxSyncRetRejected.into(); G_ENDED = true; @@ -274,6 +277,7 @@ pub enum TuneIndex { // Direct translation of the C original. This was done to // avoid compiling `os_io_seproxyhal.c` which includes many other things #[no_mangle] +#[cfg(any(target_os = "stax", target_os = "flex"))] extern "C" fn io_seproxyhal_play_tune(tune_index: u8) { let mut buffer = [0u8; 4]; let mut spi_buffer = [0u8; 128]; diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index af9eb714..cd250672 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -173,7 +173,10 @@ impl<'a> NbglHomeAndSettings { }; SWITCH_ARRAY[i].initState = state; SWITCH_ARRAY[i].token = (FIRST_USER_TOKEN + i as u32) as u8; - SWITCH_ARRAY[i].tuneId = TuneIndex::TapCasual as u8; + #[cfg(any(target_os = "stax", target_os = "flex"))] + { + SWITCH_ARRAY[i].tuneId = TuneIndex::TapCasual as u8; + } } self.content = nbgl_content_t { @@ -257,7 +260,10 @@ impl<'a> NbglHomeAndSettings { }; SWITCH_ARRAY[i].initState = state; SWITCH_ARRAY[i].token = (FIRST_USER_TOKEN + i as u32) as u8; - SWITCH_ARRAY[i].tuneId = TuneIndex::TapCasual as u8; + #[cfg(any(target_os = "stax", target_os = "flex"))] + { + SWITCH_ARRAY[i].tuneId = TuneIndex::TapCasual as u8; + } } self.content = nbgl_content_t { diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 7f7ff8a4..0239f2a7 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -223,6 +223,7 @@ impl SDKBuilder<'_> { v.push((String::from("NBGL_USE_CASE"), None)); } else { println!("cargo:warning=BAGL is built"); + println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "bagl"); v.push((String::from("HAVE_BAGL"), None)); } v @@ -245,6 +246,7 @@ impl SDKBuilder<'_> { v.push((String::from("NBGL_USE_CASE"), None)); } else { println!("cargo:warning=BAGL is built"); + println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "bagl"); v.push((String::from("HAVE_BAGL"), None)); } v @@ -394,7 +396,7 @@ impl SDKBuilder<'_> { pub fn build_c_sdk(&self) -> Result<(), SDKBuildError> { // Generate glyphs if self.device.name != DeviceName::NanoS { - generate_glyphs(&self.device.c_sdk, &self.device.glyphs_folders); + generate_glyphs(&self.device); } let mut command = cc::Build::new(); @@ -669,6 +671,8 @@ fn configure_lib_ble(command: &mut cc::Build, c_sdk: &Path) { } fn configure_lib_nbgl(command: &mut cc::Build, c_sdk: &Path) { + println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "nbgl"); + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command .include(c_sdk.join("lib_nbgl/include/")) @@ -864,8 +868,8 @@ fn clone_sdk(devicename: &DeviceName) -> PathBuf { c_sdk } -pub fn generate_glyphs(c_sdk: &PathBuf, glyphs_folders: &[PathBuf]) { - let icon2glyph = c_sdk.join("lib_nbgl/tools/icon2glyph.py"); +fn generate_glyphs(device: &Device) { + let icon2glyph = device.c_sdk.join("lib_nbgl/tools/icon2glyph.py"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let dest_path = out_path.join("glyphs"); @@ -879,7 +883,11 @@ pub fn generate_glyphs(c_sdk: &PathBuf, glyphs_folders: &[PathBuf]) { .arg("--glyphcfile") .arg(dest_path.join("glyphs.c").as_os_str()); - for folder in glyphs_folders.iter() { + if device.name == DeviceName::NanoSPlus || device.name == DeviceName::NanoX { + cmd.arg("--reverse"); + } + + for folder in device.glyphs_folders.iter() { for file in std::fs::read_dir(folder).unwrap() { let path = file.unwrap().path(); let path_str = path.to_str().unwrap().to_string(); diff --git a/ledger_secure_sdk_sys/csdk_flex.h b/ledger_secure_sdk_sys/csdk_flex.h index 7c64a534..b878a6ab 100644 --- a/ledger_secure_sdk_sys/csdk_flex.h +++ b/ledger_secure_sdk_sys/csdk_flex.h @@ -57,4 +57,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Misc //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define HAVE_LOCAL_APDU_BUFFER \ No newline at end of file +#define HAVE_LOCAL_APDU_BUFFER + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// DEBUG C SDK +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//#define HAVE_PRINTF +//#define PRINTF mcu_usb_printf \ No newline at end of file diff --git a/ledger_secure_sdk_sys/csdk_nanos2.h b/ledger_secure_sdk_sys/csdk_nanos2.h index c4c20033..126ba21f 100644 --- a/ledger_secure_sdk_sys/csdk_nanos2.h +++ b/ledger_secure_sdk_sys/csdk_nanos2.h @@ -47,4 +47,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Misc //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define HAVE_LOCAL_APDU_BUFFER \ No newline at end of file +#define HAVE_LOCAL_APDU_BUFFER + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// DEBUG C SDK +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//#define HAVE_PRINTF +//#define PRINTF mcu_usb_printf diff --git a/ledger_secure_sdk_sys/csdk_nanox.h b/ledger_secure_sdk_sys/csdk_nanox.h index 67d758c3..c6f69c1d 100644 --- a/ledger_secure_sdk_sys/csdk_nanox.h +++ b/ledger_secure_sdk_sys/csdk_nanox.h @@ -54,4 +54,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define HAVE_LOCAL_APDU_BUFFER #define HAVE_SEPROXYHAL_MCU -#define HAVE_MCU_PROTECT \ No newline at end of file +#define HAVE_MCU_PROTECT + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// DEBUG C SDK +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//#define HAVE_PRINTF +//#define PRINTF mcu_usb_printf \ No newline at end of file diff --git a/ledger_secure_sdk_sys/csdk_stax.h b/ledger_secure_sdk_sys/csdk_stax.h index 85b27aa9..bfb3d7fa 100644 --- a/ledger_secure_sdk_sys/csdk_stax.h +++ b/ledger_secure_sdk_sys/csdk_stax.h @@ -55,4 +55,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Misc //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define HAVE_LOCAL_APDU_BUFFER \ No newline at end of file +#define HAVE_LOCAL_APDU_BUFFER + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// DEBUG C SDK +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//#define HAVE_PRINTF +//#define PRINTF mcu_usb_printf \ No newline at end of file diff --git a/ledger_secure_sdk_sys/link.ld b/ledger_secure_sdk_sys/link.ld index 4d5fd241..5736654c 100644 --- a/ledger_secure_sdk_sys/link.ld +++ b/ledger_secure_sdk_sys/link.ld @@ -141,6 +141,7 @@ SECTIONS ledger.rust_sdk_name (INFO): { KEEP(*(ledger.rust_sdk_name)) } ledger.sdk_name (INFO): { KEEP(*(ledger.sdk_name)) } ledger.sdk_hash (INFO): { KEEP(*(ledger.sdk_hash)) } + ledger.sdk_graphics (INFO): { KEEP(*(ledger.sdk_graphics)) } } PROVIDE(_nvram = ABSOLUTE(_nvram_start)); diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index 93697eae..cef9464b 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -369,4 +369,16 @@ int c_main(int arg0) { END_TRY; } return 0; -} \ No newline at end of file +} + +#ifdef HAVE_PRINTF +void mcu_usb_prints(const char *str, unsigned int charcount) +{ + unsigned char buf[4]; + buf[0] = SEPROXYHAL_TAG_PRINTF; + buf[1] = charcount >> 8; + buf[2] = charcount; + io_seproxyhal_spi_send(buf, 3); + io_seproxyhal_spi_send((const uint8_t *) str, charcount); +} +#endif \ No newline at end of file diff --git a/ledger_secure_sdk_sys/src/infos.rs b/ledger_secure_sdk_sys/src/infos.rs index 70013478..f0550a9b 100644 --- a/ledger_secure_sdk_sys/src/infos.rs +++ b/ledger_secure_sdk_sys/src/infos.rs @@ -59,3 +59,8 @@ const_cstr!( "ledger.sdk_version", env!("C_SDK_VERSION") ); +const_cstr!( + ELF_C_SDK_GRAPHICS, + "ledger.sdk_graphics", + env!("C_SDK_GRAPHICS") +); From 9076acc6dd133e45a55ba50c1edab41f2a20ac14 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 18 Feb 2025 17:59:54 +0100 Subject: [PATCH 086/154] Bump versions --- Cargo.lock | 6 +++--- cargo-ledger/Cargo.toml | 2 +- cargo-ledger/src/setup.rs | 2 +- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f58c2f1..1c640445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,7 +127,7 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cargo-ledger" -version = "1.6.0" +version = "1.7.0" dependencies = [ "cargo_metadata", "clap", @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.20.4" +version = "1.21.0" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.6.7" +version = "1.7.0" dependencies = [ "bindgen", "cc", diff --git a/cargo-ledger/Cargo.toml b/cargo-ledger/Cargo.toml index 60634adb..f05aed9a 100644 --- a/cargo-ledger/Cargo.toml +++ b/cargo-ledger/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-ledger" -version = "1.6.0" +version = "1.7.0" authors = ["yhql", "agrojean-ledger", "y333"] description = "Build and sideload Ledger devices apps" categories = ["development-tools::cargo-plugins"] diff --git a/cargo-ledger/src/setup.rs b/cargo-ledger/src/setup.rs index d6705b9b..3a7f3807 100644 --- a/cargo-ledger/src/setup.rs +++ b/cargo-ledger/src/setup.rs @@ -33,7 +33,7 @@ pub fn install_targets() { let sysroot_cmd = std::str::from_utf8(&sysroot_cmd).unwrap().trim(); let target_files_url = Path::new( - "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/y333/nbgl_support_for_nanos/ledger_secure_sdk_sys" + "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/refs/tags/ledger_secure_sdk_sys%401.7.0/ledger_secure_sdk_sys" ); let sysroot = Path::new(sysroot_cmd).join("lib").join("rustlib"); diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 3de4c95a..4884a199 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.20.4" +version = "1.21.0" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.7" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.0" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 5ea5adaa..10570a10 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.6.7" +version = "1.7.0" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From a54165f7eafa756dd38082a7d37dc1a9a14fba1c Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 21 Feb 2025 10:12:10 +0100 Subject: [PATCH 087/154] Emergency patch for building Nano S apps --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- ledger_secure_sdk_sys/build.rs | 12 ++++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c640445..274c4eb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.21.0" +version = "1.21.1" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.7.0" +version = "1.7.1" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 4884a199..35a2720b 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.21.0" +version = "1.21.1" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.0" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.1" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 10570a10..ca3a9d2d 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.7.0" +version = "1.7.1" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 0239f2a7..151901da 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -204,7 +204,13 @@ impl SDKBuilder<'_> { name: DeviceName::NanoS, c_sdk: Default::default(), target: "thumbv6m-none-eabi", - defines: header2define("csdk_nanos.h"), + defines: { + let mut v = header2define("csdk_nanos.h"); + println!("cargo:warning=BAGL is built"); + println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "bagl"); + v.push((String::from("HAVE_BAGL"), None)); + v + }, cflags: Vec::from(CFLAGS_NANOS), glyphs_folders: Vec::new(), arm_libs: Default::default(), @@ -468,7 +474,9 @@ impl SDKBuilder<'_> { let path = self.device.arm_libs.clone(); println!("cargo:rustc-link-lib=c"); println!("cargo:rustc-link-lib=m"); - println!("cargo:rustc-link-lib=gcc"); + if self.device.name != DeviceName::NanoS { + println!("cargo:rustc-link-lib=gcc"); + } println!("cargo:rustc-link-search={path}"); Ok(()) } From 7a16c29b09f1d21916b2d76c9f805580c64ff064 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Mon, 24 Feb 2025 15:49:15 +0400 Subject: [PATCH 088/154] fix: Change `UserCancelled` status word code --- ledger_device_sdk/src/io.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 2f4558f1..49124554 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -18,7 +18,7 @@ pub enum StatusWords { BadIns = 0x6e01, BadP1P2 = 0x6e02, BadLen = 0x6e03, - UserCancelled = 0x6e04, + UserCancelled = 0x6985, Unknown = 0x6d00, Panic = 0xe000, DeviceLocked = 0x5515, From 9e2babd884f727987e04c37a48af839b7ac21c66 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Mon, 24 Feb 2025 17:02:27 +0400 Subject: [PATCH 089/154] Bump version --- ledger_device_sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 35a2720b..ed15dc36 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.21.1" +version = "1.21.2" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From dabb0aebbb3d4c9a615f432fbd698df4358343a6 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Wed, 26 Feb 2025 01:21:59 +0400 Subject: [PATCH 090/154] Add coin configuartion to swap params --- ledger_device_sdk/src/libcall/swap.rs | 77 ++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 41a06978..ebf09098 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -9,8 +9,11 @@ use ledger_secure_sdk_sys::{ const DPATH_STAGE_SIZE: usize = 16; const ADDRESS_BUF_SIZE: usize = 64; const AMOUNT_BUF_SIZE: usize = 16; +const DEFAULT_COIN_CONFIG_BUF_SIZE: usize = 16; -pub struct CheckAddressParams { +pub struct CheckAddressParams { + pub coin_config: [u8; COIN_CONFIG_BUF_SIZE], + pub coin_config_len: usize, pub dpath: [u8; DPATH_STAGE_SIZE * 4], pub dpath_len: usize, pub ref_address: [u8; ADDRESS_BUF_SIZE], @@ -18,9 +21,11 @@ pub struct CheckAddressParams { pub result: *mut i32, } -impl Default for CheckAddressParams { +impl Default for CheckAddressParams { fn default() -> Self { CheckAddressParams { + coin_config: [0; COIN_CONFIG_BUF_SIZE], + coin_config_len: 0, dpath: [0; DPATH_STAGE_SIZE * 4], dpath_len: 0, ref_address: [0; ADDRESS_BUF_SIZE], @@ -30,16 +35,20 @@ impl Default for CheckAddressParams { } } -pub struct PrintableAmountParams { +pub struct PrintableAmountParams { + pub coin_config: [u8; COIN_CONFIG_BUF_SIZE], + pub coin_config_len: usize, pub amount: [u8; AMOUNT_BUF_SIZE], pub amount_len: usize, pub amount_str: *mut i8, pub is_fee: bool, } -impl Default for PrintableAmountParams { +impl Default for PrintableAmountParams { fn default() -> Self { PrintableAmountParams { + coin_config: [0; COIN_CONFIG_BUF_SIZE], + coin_config_len: 0, amount: [0; AMOUNT_BUF_SIZE], amount_len: 0, amount_str: core::ptr::null_mut(), @@ -48,7 +57,9 @@ impl Default for PrintableAmountParams { } } -pub struct CreateTxParams { +pub struct CreateTxParams { + pub coin_config: [u8; COIN_CONFIG_BUF_SIZE], + pub coin_config_len: usize, pub amount: [u8; AMOUNT_BUF_SIZE], pub amount_len: usize, pub fee_amount: [u8; AMOUNT_BUF_SIZE], @@ -58,9 +69,11 @@ pub struct CreateTxParams { pub result: *mut u8, } -impl Default for CreateTxParams { +impl Default for CreateTxParams { fn default() -> Self { CreateTxParams { + coin_config: [0; COIN_CONFIG_BUF_SIZE], + coin_config_len: 0, amount: [0; AMOUNT_BUF_SIZE], amount_len: 0, fee_amount: [0; AMOUNT_BUF_SIZE], @@ -72,7 +85,9 @@ impl Default for CreateTxParams { } } -pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { +pub fn get_check_address_params( + arg0: u32, +) -> CheckAddressParams { debug_print("=> get_check_address_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -88,7 +103,18 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { let params: check_address_parameters_t = unsafe { *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t) }; - let mut check_address_params: CheckAddressParams = Default::default(); + let mut check_address_params: CheckAddressParams = Default::default(); + + debug_print("==> GET_COIN_CONFIG_LENGTH\n"); + check_address_params.coin_config_len = params.coin_configuration_length as usize; + + debug_print("==> GET_COIN_CONFIG \n"); + unsafe { + params.coin_configuration.copy_to_nonoverlapping( + check_address_params.coin_config.as_mut_ptr(), + check_address_params.coin_config_len, + ); + } debug_print("==> GET_DPATH_LENGTH\n"); check_address_params.dpath_len = @@ -117,7 +143,9 @@ pub fn get_check_address_params(arg0: u32) -> CheckAddressParams { check_address_params } -pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { +pub fn get_printable_amount_params( + arg0: u32, +) -> PrintableAmountParams { debug_print("=> get_printable_amount_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -134,7 +162,19 @@ pub fn get_printable_amount_params(arg0: u32) -> PrintableAmountParams { *(libarg.__bindgen_anon_1.get_printable_amount as *const get_printable_amount_parameters_t) }; - let mut printable_amount_params: PrintableAmountParams = Default::default(); + let mut printable_amount_params: PrintableAmountParams = + Default::default(); + + debug_print("==> GET_COIN_CONFIG_LENGTH\n"); + printable_amount_params.coin_config_len = params.coin_configuration_length as usize; + + debug_print("==> GET_COIN_CONFIG \n"); + unsafe { + params.coin_configuration.copy_to_nonoverlapping( + printable_amount_params.coin_config.as_mut_ptr(), + printable_amount_params.coin_config_len, + ); + } debug_print("==> GET_IS_FEE\n"); printable_amount_params.is_fee = params.is_fee == true; @@ -162,7 +202,9 @@ extern "C" { fn c_boot_std(); } -pub fn sign_tx_params(arg0: u32) -> CreateTxParams { +pub fn sign_tx_params( + arg0: u32, +) -> CreateTxParams { debug_print("=> sign_tx_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -179,7 +221,18 @@ pub fn sign_tx_params(arg0: u32) -> CreateTxParams { *(libarg.__bindgen_anon_1.create_transaction as *const create_transaction_parameters_t) }; - let mut create_tx_params: CreateTxParams = Default::default(); + let mut create_tx_params: CreateTxParams = Default::default(); + + debug_print("==> GET_COIN_CONFIG_LENGTH\n"); + create_tx_params.coin_config_len = params.coin_configuration_length as usize; + + debug_print("==> GET_COIN_CONFIG \n"); + unsafe { + params.coin_configuration.copy_to_nonoverlapping( + create_tx_params.coin_config.as_mut_ptr(), + create_tx_params.coin_config_len, + ); + } debug_print("==> GET_AMOUNT\n"); create_tx_params.amount_len = AMOUNT_BUF_SIZE.min(params.amount_length as usize); From fc5a00407d70c8e932e45e20d436c1a23c5e1926 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Wed, 26 Feb 2025 01:23:32 +0400 Subject: [PATCH 091/154] Bump SDK version --- ledger_device_sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index ed15dc36..b31cd563 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.21.2" +version = "1.21.3" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 06805889136a03b5d3239d3071b867ab2c4ab483 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Wed, 26 Feb 2025 20:06:08 +0400 Subject: [PATCH 092/154] Fix buffer overwrite --- ledger_device_sdk/src/libcall/swap.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index ebf09098..8a7265b2 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -112,7 +112,9 @@ pub fn get_check_address_params( unsafe { params.coin_configuration.copy_to_nonoverlapping( check_address_params.coin_config.as_mut_ptr(), - check_address_params.coin_config_len, + check_address_params + .coin_config_len + .min(COIN_CONFIG_BUF_SIZE), ); } @@ -172,7 +174,9 @@ pub fn get_printable_amount_params( unsafe { params.coin_configuration.copy_to_nonoverlapping( printable_amount_params.coin_config.as_mut_ptr(), - printable_amount_params.coin_config_len, + printable_amount_params + .coin_config_len + .min(COIN_CONFIG_BUF_SIZE), ); } @@ -230,7 +234,7 @@ pub fn sign_tx_params( unsafe { params.coin_configuration.copy_to_nonoverlapping( create_tx_params.coin_config.as_mut_ptr(), - create_tx_params.coin_config_len, + create_tx_params.coin_config_len.min(COIN_CONFIG_BUF_SIZE), ); } From 78fc734ef6ce740970b556a83c1d20bf48aed06b Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 26 Feb 2025 22:35:26 +0100 Subject: [PATCH 093/154] Update Readme and publish workflow --- .github/workflows/publish.yml | 97 ++++++++++++--------------------- Cargo.lock | 2 +- README.md | 40 ++++++++++++-- cargo-ledger/README.md | 10 ++-- include_gif/README.md | 5 +- ledger_device_sdk/README.md | 42 ++++---------- ledger_secure_sdk_sys/README.md | 1 + testmacro/README.md | 1 + 8 files changed, 93 insertions(+), 105 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a0270190..4c21539a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,12 +2,12 @@ name: Publish to Crates.io on: push: - tags: - - '*@*.*.*' # Match tags like 'package1@1.2.3' + branches: + - master workflow_dispatch: # Allow manual workflow dispatch jobs: - test-dry-run: + dry-run-publish: runs-on: ubuntu-latest if: github.event_name == 'workflow_dispatch' # Only run this job for manual triggers @@ -21,33 +21,31 @@ jobs: profile: minimal toolchain: stable - - name: Retrieve Package Names from workspace root - id: get-root-packages - run: | - # Retrieve package names from the workspace root - PACKAGE_NAMES=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[].name' | tr '\n' ' ') - - # Set the package names as an output - echo "Package names from root Cargo.toml: $PACKAGE_NAMES" - echo "::set-output name=package-names::$PACKAGE_NAMES" - shell: bash - working-directory: ${{ github.workspace }} - - name: Test Dry-Run Publish for Each Package run: | # Iterate through package names retrieved - PACKAGE_NAMES="${{ steps.get-root-packages.outputs.package-names }}" + PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk" for PACKAGE_NAME in $PACKAGE_NAMES; do - # Test a dry-run publish for each package within the workspace - cargo publish --dry-run --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME" + # Test a dry-run publish for each package within the workspace if required + last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') + echo "Published version of $PACKAGE_NAME is $version_published" + manifest_version=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version') + echo "Current version in manifest for $PACKAGE_NAME is $manifest_version" + if [ "$last_published_version" == "$manifest_version" ]; then + echo "Package $PACKAGE_NAME is already published with version $manifest_version." + else + echo "Package $PACKAGE_NAME is not published with version $manifest_version." + echo "Dry-run publishing $PACKAGE_NAME..." + cargo publish --dry-run --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME" + fi done env: CARGO_TERM_COLOR: always working-directory: ${{ github.workspace }} - build-and-publish: + crates-io-publish: runs-on: ubuntu-latest - if: github.event_name == 'push' # Only run this job for tag pushes + if: github.event_name == 'push' # Only run this job for pushes steps: - name: Checkout Code @@ -58,48 +56,25 @@ jobs: with: profile: minimal toolchain: stable - - - name: Determine Package to Publish - id: determine-package - run: | - # Extract package name from the tag name - TAG_NAME="${{ github.ref }}" - PACKAGE_NAME=$(echo "$TAG_NAME" | cut -d'/' -f3 | cut -d'@' -f1) - - PACKAGE_NAMES=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[].name' | tr '\n' ' ') - - # Check if the extracted package name is a valid package in the workspace root Cargo.toml - if [[ ! " $PACKAGE_NAMES " =~ " $PACKAGE_NAME " ]]; then - echo "Invalid package name: $PACKAGE_NAME" - exit 1 - fi - echo "Package to publish: $PACKAGE_NAME" - echo "::set-output name=package::$PACKAGE_NAME" - shell: bash - working-directory: ${{ github.workspace }} - - - name: Check Package Version - id: check-version - run: | - PACKAGE_NAME="${{ steps.determine-package.outputs.package }}" - TAG_VERSION=$(echo "${{ github.ref }}" | cut -d'@' -f2) - MANIFEST_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version') - - if [ "$TAG_VERSION" != "$MANIFEST_VERSION" ]; then - echo "Package version in manifest $MANIFEST_VERSION does not match tag version $TAG_VERSION." - exit 1 - else - echo "Package version in manifest matches tag version." - fi - shell: bash - working-directory: ${{ github.workspace }} - - - name: Build and Publish + + - name: Publish Package on crates.io if required run: | - PACKAGE_NAME="${{ steps.determine-package.outputs.package }}" - - # Publish the specified package within the workspace to crates.io - cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME" + # Iterate through package names retrieved + PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk" + for PACKAGE_NAME in $PACKAGE_NAMES; do + # Publish each package within the workspace if required + last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') + echo "Published version of $PACKAGE_NAME is $version_published" + manifest_version=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version') + echo "Current version in manifest for $PACKAGE_NAME is $manifest_version" + if [ "$last_published_version" == "$manifest_version" ]; then + echo "Package $PACKAGE_NAME is already published with version $manifest_version." + else + echo "Package $PACKAGE_NAME is not published with version $manifest_version." + echo "Publishing $PACKAGE_NAME..." + cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME" + fi + done env: CARGO_TERM_COLOR: always working-directory: ${{ github.workspace }} diff --git a/Cargo.lock b/Cargo.lock index 274c4eb9..fe0f8f51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.21.1" +version = "1.21.3" dependencies = [ "const-zero", "include_gif", diff --git a/README.md b/README.md index f520eff2..0a920c45 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,36 @@ # Ledger Device Rust SDK -This workspace contains the 5 crates members of Ledger Device Rust SDK +[![DEV SUPPORT](https://img.shields.io/badge/Dev_Support-red?logo=discord +)](https://discord.com/channels/885256081289379850/912241185677000704) -* [ledger_device_sdk](./ledger_device_sdk): main Rust SDK crate used to build an application that runs on BOLOS OS, -* [ledger_secure_sdk_sys](./ledger_secure_sdk_sys): bindings to [ledger_secure_sdk](https://github.com/LedgerHQ/ledger-secure-sdk) -* [include_gif](./include_gif): procedural macro used to manage GIF -* [testmacro](./testmacro): procedural macro used by unit and integrations tests -* [cargo-ledger](./cargo-ledger): tool to build Ledger device applications developped in Rust +## Crates + +| Crate | Description | Latest Release | +| ------------------------------------------------ | --------------------------------------------------------------- | -------------- | +| [cargo-ledger](./cargo-ledger) | Cargo extension required to build Ledger applications | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fcargo-ledger%2FCargo.toml&query=%24.package.version&label=version) | +| [ledger_device_sdk](./ledger_device_sdk) | Rust SDK | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_device_sdk%2FCargo.toml&query=%24.package.version&label=version) | +| [ledger_secure_sdk_sys](./ledger_secure_sdk_sys) | [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk) bindings | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_secure_sdk_sys%2FCargo.toml&query=%24.package.version&label=version) | +| [include_gif](./include_gif) | Procedural macro to integrate logo in the UI/UX | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Finclude_gif%2FCargo.toml&query=%24.package.version&label=version) | +| [testmacro](./testmacro) | Procedural macro used by unit and integrations tests | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Ftestmacro%2FCargo.toml&query=%24.package.version&label=version) | + +## Docker builder + +Docker images are available and shall be used to build and test Rust applications for Ledger devices. + +||`full` | `dev-tools` | +| ---- | ----- | ----------- | +| Rust nightly-2024-12-01 toolchain | :white_check_mark: | :white_check_mark: | +| cargo-ledger | :white_check_mark: | :white_check_mark: | +| Rust Ledger devices custom targets | :white_check_mark: | :white_check_mark: | +| ARM & LLVM toolchains | :white_check_mark: | :white_check_mark: | +| [Speculos](https://github.com/LedgerHQ/speculos) | :x: | :white_check_mark: | +| [Ragger](https://github.com/LedgerHQ/ragger)  | :x: | :white_check_mark: | + +Please check [here](https://github.com/LedgerHQ/ledger-app-builder) for more details. + +## Links + +To learn more about using the SDK and what is required to publish an app on the Ledger Live app store, please don't hesitate to check the following resources: + +- 📚 [Developer's documentation](https://developers.ledger.com/) +- 🗣️ [Ledger's Discord server](https://discord.gg/Ledger) +- 📦 [Fully featured boilerplate app](https://github.com/LedgerHQ/app-boilerplate-rust) \ No newline at end of file diff --git a/cargo-ledger/README.md b/cargo-ledger/README.md index de09b020..3aaf138c 100644 --- a/cargo-ledger/README.md +++ b/cargo-ledger/README.md @@ -1,8 +1,9 @@ -# Cargo-ledger +# cargo-ledger +![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fcargo-ledger%2FCargo.toml&query=%24.package.version&label=version) -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. +Builds a Ledger device embedded app and outputs a JSON/TOML manifest file that can be used by [ledgerctl](https://github.com/LedgerHQ/ledgerctl) to install an application directly on a device. -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`. +In order to build for Nano X, Nano S Plus, Stax and Flex [custom target files](https://docs.rust-embedded.org/embedonomicon/custom-target.html) are used. They can be found at the root of the [ledger_secure_sdk_sys](https://github.com/LedgerHQ/ledger_secure_sdk_sys/) and can be installed automatically with the command `cargo ledger setup`. ## Installation @@ -41,9 +42,10 @@ cargo ledger setup ### Building ``` -cargo ledger build nanos cargo ledger build nanox cargo ledger build nanosplus +cargo ledger build stax +cargo ledger build flex ``` Loading on device can optionally be performed by appending `--load` or `-l` to the command. diff --git a/include_gif/README.md b/include_gif/README.md index f114e72a..2bda97f1 100644 --- a/include_gif/README.md +++ b/include_gif/README.md @@ -1,3 +1,4 @@ -# sdk_include_gif +# include_gif +![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Finclude_gif%2FCargo.toml&query=%24.package.version&label=version) -This crate provides a macro `include_gif!("path/to/image.gif")` that packs a gif image into a byte representation that can be understood by the [Rust Nano SDK](https://github.com/LedgerHQ/ledger-device-rust-sdk/tree/master/ledger_device_sdk) and included at compile time to produce black-and-white icons. +This crate provides a macro `include_gif!("path/to/image.gif")` that packs a gif image into a byte representation that can be understood by the [Rust SDK](https://github.com/LedgerHQ/ledger-device-rust-sdk/tree/master/ledger_device_sdk) and included at compile time to produce icons. diff --git a/ledger_device_sdk/README.md b/ledger_device_sdk/README.md index f5077e22..200cacae 100644 --- a/ledger_device_sdk/README.md +++ b/ledger_device_sdk/README.md @@ -1,4 +1,5 @@ -# Ledger wallets SDK for Rust Applications +# Ledger device SDK for Rust Applications +![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_device_sdk%2FCargo.toml&query=%24.package.version&label=version) Crate that allows developing Ledger device apps in Rust with a default configuration. @@ -9,20 +10,11 @@ Contains: - signature abstractions - UI libraries (the `ui` module for Nano (S/SP/X) apps, `nbgl` module for Stax and Flex apps) -## Links - -To learn more about using the SDK and what is required to publish an app on the Ledger Live app store, please don't hesitate to check the following resources : - -- 📚 [Developer's documentation](https://developers.ledger.com/) -- 🗣️ [Ledger's Discord server](https://discord.gg/Ledger) -- 📦 [Fully featured boilerplate app](https://github.com/LedgerHQ/app-boilerplate-rust) -- 📦 [A Password Manager app](https://github.com/LedgerHQ/rust-app-password-manager) - ## Supported devices -| Nano S | Nano X | Nano S Plus | Stax | Flex | -| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | -| :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| Nano X | Nano S Plus | Stax | Flex | +| ------------------ | ------------------ | ------------------ | ------------------ | +| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | ## Usage @@ -31,7 +23,7 @@ On Ubuntu, `gcc-multilib` might also be required. Using rustc nightly builds is mandatory as some unstable features are required. -- `rustup default nightly` +- `rustup default nightly-2024-12-01` - `rustup component add rust-src` - install [Clang](http://releases.llvm.org/download.html). - install an [ARM gcc toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) @@ -51,45 +43,33 @@ sudo pacman -S clang arm-none-eabi-gcc arm-none-eabi-newlib This SDK provides [custom target](https://doc.rust-lang.org/rustc/targets/custom.html) files. One for each supported device. -### Building for Nano S - -``` -cargo build --release -Z build-std=core --target=./nanos.json -``` - ### Building for Nano X ``` -cargo build --release -Z build-std=core --target=./nanox.json +cargo build --release --target=nanox ``` ### Building for Nano S+ ``` -cargo build --release -Z build-std=core --target=./nanosplus.json +cargo build --release --target=nanosplus ``` ### Building for Stax ``` -cargo build --release -Z build-std=core --target=./stax.json +cargo build --release --target=stax ``` ### Building for Flex ``` -cargo build --release -Z build-std=core --target=./flex.json +cargo build --release --target=flex ``` -## Building with rustc < 1.54 - -Building before rustc 1.54 should fail with `error[E0635]: unknown feature const_fn_trait_bound`. - -This is solved by activating a specific feature: `cargo build --features pre1_54` - ## Contributing -You can submit an issue or even a pull request if you wish to contribute, we will check what we can do. +You can submit an issue or even a pull request if you wish to contribute. Make sure you've followed the installation steps above. In order for your PR to be accepted, it will have to pass the CI, which performs the following checks: diff --git a/ledger_secure_sdk_sys/README.md b/ledger_secure_sdk_sys/README.md index 201a3584..268fd344 100644 --- a/ledger_secure_sdk_sys/README.md +++ b/ledger_secure_sdk_sys/README.md @@ -1,4 +1,5 @@ # Rust Low-level bindings to the Ledger C SDK +![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_secure_sdk_sys%2FCargo.toml&query=%24.package.version&label=version) Provides access to low-level APIs to the operating system of Ledger devices. diff --git a/testmacro/README.md b/testmacro/README.md index cc7c0d93..6fd8a94b 100644 --- a/testmacro/README.md +++ b/testmacro/README.md @@ -1,3 +1,4 @@ # testmacro +![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Ftestmacro%2FCargo.toml&query=%24.package.version&label=version) A macro inspired from [Writing an OS in Rust](https://os.phil-opp.com/testing/) and [Rust Raspberry OS tutorials](https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials/tree/master/13_integrated_testing) that helps building `#![no_std]` tests in some other projects. From 2809b96a4950bdf39b00d42257ae06bb6ef97e9f Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 27 Feb 2025 16:04:22 +0100 Subject: [PATCH 094/154] fix typo --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4c21539a..dd9a4728 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -64,13 +64,13 @@ jobs: for PACKAGE_NAME in $PACKAGE_NAMES; do # Publish each package within the workspace if required last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') - echo "Published version of $PACKAGE_NAME is $version_published" + echo "Published version of $PACKAGE_NAME is $last_published_version" manifest_version=$(cargo metadata --format-version=1 --no-deps | jq -r --arg PACKAGE_NAME "$PACKAGE_NAME" '.packages[] | select(.name == $PACKAGE_NAME) | .version') echo "Current version in manifest for $PACKAGE_NAME is $manifest_version" if [ "$last_published_version" == "$manifest_version" ]; then echo "Package $PACKAGE_NAME is already published with version $manifest_version." else - echo "Package $PACKAGE_NAME is not published with version $manifest_version." + echo "Package $PACKAGE_NAME with version $manifest_version is not published." echo "Publishing $PACKAGE_NAME..." cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --package "$PACKAGE_NAME" fi From 94fb4ba93fcc60cf0bef2f8192d41f6b035f408f Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 28 Feb 2025 15:28:07 +0100 Subject: [PATCH 095/154] Rename NBGL feature for Nano devices --- ledger_device_sdk/Cargo.toml | 2 +- ledger_device_sdk/src/io.rs | 2 +- ledger_device_sdk/src/lib.rs | 4 ++-- ledger_device_sdk/src/nbgl.rs | 2 -- ledger_secure_sdk_sys/Cargo.toml | 2 +- ledger_secure_sdk_sys/build.rs | 6 +++--- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index b31cd563..eb9e9158 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -27,7 +27,7 @@ ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.1" } debug = [] speculos = [] heap = [ "ledger_secure_sdk_sys/heap" ] -nbgl = [ "ledger_secure_sdk_sys/nbgl" ] +nano_nbgl = [ "ledger_secure_sdk_sys/nano_nbgl" ] default = [ "heap" ] diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 49124554..fd53ee8d 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -372,7 +372,7 @@ impl Comm { match seph::Events::from(tag) { #[cfg(not(any(target_os = "stax", target_os = "flex")))] seph::Events::ButtonPush => { - #[cfg(feature = "nbgl")] + #[cfg(feature = "nano_nbgl")] unsafe { ux_process_button_event(spi_buffer.as_mut_ptr()); } diff --git a/ledger_device_sdk/src/lib.rs b/ledger_device_sdk/src/lib.rs index 5ed408bd..763308c4 100644 --- a/ledger_device_sdk/src/lib.rs +++ b/ledger_device_sdk/src/lib.rs @@ -22,9 +22,9 @@ pub mod seph; pub mod testing; -#[cfg(any(target_os = "stax", target_os = "flex", feature = "nbgl"))] +#[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] pub mod nbgl; -#[cfg(not(any(target_os = "stax", target_os = "flex", feature = "nbgl")))] +#[cfg(not(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl")))] pub mod ui; pub mod uxapp; diff --git a/ledger_device_sdk/src/nbgl.rs b/ledger_device_sdk/src/nbgl.rs index dcb86907..0fa14e56 100644 --- a/ledger_device_sdk/src/nbgl.rs +++ b/ledger_device_sdk/src/nbgl.rs @@ -10,7 +10,6 @@ use ledger_secure_sdk_sys::*; pub mod nbgl_address_review; pub mod nbgl_choice; -#[cfg(any(target_os = "stax", target_os = "flex"))] pub mod nbgl_generic_review; pub mod nbgl_home_and_settings; pub mod nbgl_review; @@ -21,7 +20,6 @@ pub mod nbgl_streaming_review; pub use nbgl_address_review::*; pub use nbgl_choice::*; -#[cfg(any(target_os = "stax", target_os = "flex"))] pub use nbgl_generic_review::*; pub use nbgl_home_and_settings::*; pub use nbgl_review::*; diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index ca3a9d2d..45d465bc 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -18,7 +18,7 @@ critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] -nbgl = [] +nano_nbgl = [] [lints.rust.unexpected_cfgs] level = "warn" diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 151901da..467efcc8 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -222,7 +222,7 @@ impl SDKBuilder<'_> { target: "thumbv8m.main-none-eabi", defines: { let mut v = header2define("csdk_nanos2.h"); - if env::var_os("CARGO_FEATURE_NBGL").is_some() { + if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() { println!("cargo:warning=NBGL is built"); v.push((String::from("HAVE_NBGL"), None)); v.push((String::from("NBGL_STEP"), None)); @@ -245,7 +245,7 @@ impl SDKBuilder<'_> { target: "thumbv6m-none-eabi", defines: { let mut v = header2define("csdk_nanox.h"); - if env::var_os("CARGO_FEATURE_NBGL").is_some() { + if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() { println!("cargo:warning=NBGL is built"); v.push((String::from("HAVE_NBGL"), None)); v.push((String::from("NBGL_STEP"), None)); @@ -537,7 +537,7 @@ impl SDKBuilder<'_> { DeviceName::NanoSPlus | DeviceName::NanoX | DeviceName::Stax | DeviceName::Flex => { if ((self.device.name == DeviceName::NanoX || self.device.name == DeviceName::NanoSPlus) - && env::var_os("CARGO_FEATURE_NBGL").is_some()) + && env::var_os("CARGO_FEATURE_NANO_NBGL").is_some()) || self.device.name == DeviceName::Stax || self.device.name == DeviceName::Flex { From 98c769ecea31fe3e891121024b41549906b15d8b Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 4 Mar 2025 11:45:33 +0100 Subject: [PATCH 096/154] Exclude NBGL GenericReview usecase for Nanos --- ledger_device_sdk/src/nbgl.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ledger_device_sdk/src/nbgl.rs b/ledger_device_sdk/src/nbgl.rs index 0fa14e56..dcb86907 100644 --- a/ledger_device_sdk/src/nbgl.rs +++ b/ledger_device_sdk/src/nbgl.rs @@ -10,6 +10,7 @@ use ledger_secure_sdk_sys::*; pub mod nbgl_address_review; pub mod nbgl_choice; +#[cfg(any(target_os = "stax", target_os = "flex"))] pub mod nbgl_generic_review; pub mod nbgl_home_and_settings; pub mod nbgl_review; @@ -20,6 +21,7 @@ pub mod nbgl_streaming_review; pub use nbgl_address_review::*; pub use nbgl_choice::*; +#[cfg(any(target_os = "stax", target_os = "flex"))] pub use nbgl_generic_review::*; pub use nbgl_home_and_settings::*; pub use nbgl_review::*; From a8d0265db54125cfa7fffe8b3b5ded27055a881b Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 4 Mar 2025 12:10:05 +0100 Subject: [PATCH 097/154] Bump versions --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe0f8f51..09b2d6fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.21.3" +version = "1.21.4" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.7.1" +version = "1.7.2" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index eb9e9158..56501a69 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.21.3" +version = "1.21.4" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.1" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.2" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 45d465bc..806e3647 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.7.1" +version = "1.7.2" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From d27fa676d0ccd56a126f3280989a1e41057f0018 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 13 Mar 2025 15:07:12 +0100 Subject: [PATCH 098/154] When calling detect_apdu(), returns DeviceLocked when pin locked --- ledger_device_sdk/src/io.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index fd53ee8d..ae387934 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -451,14 +451,14 @@ impl Comm { T: TryFrom, Reply: From<>::Error>, { - let _: Option> = self.decode_event(spi_buffer); - - if unsafe { G_io_app.apdu_state } != APDU_IDLE && unsafe { G_io_app.apdu_length } > 0 { - self.rx = unsafe { G_io_app.apdu_length as usize }; - self.event_pending = true; - return true; + match self.decode_event::(spi_buffer) { + Some(Event::Command(_)) => { + self.rx = unsafe { G_io_app.apdu_length as usize }; + self.event_pending = true; + return true; + } + _ => return false, } - false } /// Wait for the next Command event. Discards received button events. From abaa3ae3d84c76787096ec7f79aea5196759b974 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 13 Mar 2025 15:12:50 +0100 Subject: [PATCH 099/154] Bump version --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09b2d6fd..761d61b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.21.4" +version = "1.21.5" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 56501a69..48bb7a64 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.21.4" +version = "1.21.5" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 5c14797bee1346b6b79c92d4a4905829b0e2d864 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 6 Mar 2025 16:30:09 +0100 Subject: [PATCH 100/154] Update build all Rust apps CI using ledgered --- .github/workflows/build_all_apps.yml | 114 +++++++++++++-------------- .github/workflows/get_rust_apps.py | 28 +++++++ 2 files changed, 84 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/get_rust_apps.py diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index 87183174..5cf46d4d 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -7,58 +7,71 @@ on: type: string required: false default: '' - pull_request: +jobs: + retrieve-rust-apps: + name: Retrieve Rust Apps + runs-on: ubuntu-latest + outputs: + rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install ledgered + run: pip install ledgered + - name: Get all rust apps + id: get_rust_apps + run: | + python .github/workflows/get_rust_apps.py ${{ secrets.GH_TOKEN }} > rust_apps.txt + echo "rust_apps=$(cat rust_apps.txt)" >> $GITHUB_OUTPUT + + display-rust-apps: + name: Display Rust Apps + runs-on: ubuntu-latest + needs: retrieve-rust-apps + steps: + - name: Display Rust Apps + run: | + echo "Rust apps: ${{ needs.retrieve-rust-apps.outputs.rust_apps }}" -jobs: test-build: name: Build for all targets + needs: retrieve-rust-apps strategy: fail-fast: false matrix: - include: - - repo: 'app-radix-babylon' - branch: 'develop' - - repo: 'app-sui' - branch: 'develop' - - repo: 'app-pocket' - branch: 'develop' - - repo: 'app-starknet' - branch: 'develop' - - repo: 'app-alephium' - branch: 'develop' - - repo: 'app-boilerplate-rust' - branch: 'main' - - repo: 'app-near' - branch: 'develop' - + app-name: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} + exclude: + - app-name: "app-kadena-legacy" + - app-name: "app-age" + - app-name: "app-provenance" + - app-name: "app-conflux" runs-on: ubuntu-latest container: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest steps: - - name: Install dependencies + - name: Install ledgered run: pip install ledgered - - name: Clone SDK uses: actions/checkout@v4 with: path: sdk - - name: Clone App uses: actions/checkout@v4 with: - repository: LedgerHQ/${{ matrix.repo }} + repository: LedgerHQ/${{ matrix.app-name }} submodules: true - ref: ${{ matrix.branch }} - path: ${{ matrix.repo }}-${{ matrix.branch }} - + path: ${{ matrix.app-name }} - name: Patch Cargo.toml continue-on-error: false run: | - cd ${{ matrix.repo }}-${{ matrix.branch }} + cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) cd $build_directory - # Determine if the project is a workspace and get the workspace root path if cargo metadata --no-deps --format-version 1 | jq -e '.workspace_members | length > 0' > /dev/null; then echo "Workspace detected. Retrieving workspace root path." @@ -70,42 +83,27 @@ jobs: fi # Patch ledger_device_sdk - if grep -Fxq "[patch.crates-io.ledger_device_sdk]" $cargo_toml_path; then - echo "The patch already exists in the file." - exit 1 - else - echo "" >> $cargo_toml_path - echo "[patch.crates-io.ledger_device_sdk]" >> $cargo_toml_path - path=\"$GITHUB_WORKSPACE/sdk/ledger_device_sdk\" - echo "path=$path" >> $cargo_toml_path - echo "Patch added to Cargo.toml" - fi + echo "" >> $cargo_toml_path + echo "[patch.crates-io.ledger_device_sdk]" >> $cargo_toml_path + path=\"$GITHUB_WORKSPACE/sdk/ledger_device_sdk\" + echo "path=$path" >> $cargo_toml_path + echo "Patch added to Cargo.toml" # Patch ledger_secure_sdk_sys - if grep -Fxq "[patch.crates-io.ledger_secure_sdk_sys]" $cargo_toml_path; then - echo "The patch already exists in the file." - exit 1 - else - echo "" >> $cargo_toml_path - echo "[patch.crates-io.ledger_secure_sdk_sys]" >> $cargo_toml_path - path=\"$GITHUB_WORKSPACE/sdk/ledger_secure_sdk_sys\" - echo "path=$path" >> $cargo_toml_path - echo "Patch added to Cargo.toml" - fi + echo "" >> $cargo_toml_path + echo "[patch.crates-io.ledger_secure_sdk_sys]" >> $cargo_toml_path + path=\"$GITHUB_WORKSPACE/sdk/ledger_secure_sdk_sys\" + echo "path=$path" >> $cargo_toml_path + echo "Patch added to Cargo.toml" # Patch include_gif - if grep -Fxq "[patch.crates-io.include_gif]" $cargo_toml_path; then - echo "The patch already exists in the file." - exit 1 - else - echo "" >> $cargo_toml_path - echo "[patch.crates-io.include_gif]" >> $cargo_toml_path - path=\"$GITHUB_WORKSPACE/sdk/include_gif\" - echo "path=$path" >> $cargo_toml_path - echo "Patch added to Cargo.toml" - fi + echo "" >> $cargo_toml_path + echo "[patch.crates-io.include_gif]" >> $cargo_toml_path + path=\"$GITHUB_WORKSPACE/sdk/include_gif\" + echo "path=$path" >> $cargo_toml_path + echo "Patch added to Cargo.toml" - name: Build run: | - cd ${{ matrix.repo }}-${{ matrix.branch }} + cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) devices="$(ledger-manifest --output-devices ledger_app.toml -j | sed 's/+/plus/' | jq -rc '.devices[]')" cd $build_directory diff --git a/.github/workflows/get_rust_apps.py b/.github/workflows/get_rust_apps.py new file mode 100644 index 00000000..b65828d3 --- /dev/null +++ b/.github/workflows/get_rust_apps.py @@ -0,0 +1,28 @@ +from ledgered.github import GitHubLedgerHQ, NoManifestException +from github.GithubException import GithubException +import sys + +if len(sys.argv) != 2: + print("Usage: get_rust_apps.py ") + sys.exit(1) + +token = sys.argv[1] +gh = GitHubLedgerHQ(token) +apps=gh.apps + +rust_apps = [] +# loop all apps in gh.apps +for app in apps: + try: + manifest = app.manifest + except NoManifestException as e: + pass + except GithubException as e: + pass + else: + if manifest.app.sdk == "rust": + # store app_name in a list + rust_apps.append(app.name) + +# print the list of rust apps in between [] +print(rust_apps) From 18f552bf3d21b0fa6b143969a0f6ba64de62af6c Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Mar 2025 10:37:03 +0100 Subject: [PATCH 101/154] Add PR event to trigger all Rust apps building --- .github/workflows/build_all_apps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index 5cf46d4d..ded5c122 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -7,6 +7,7 @@ on: type: string required: false default: '' + pull_request: jobs: retrieve-rust-apps: From 659e138426bd3ff5dc05fd242461719b6ebc4023 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Mar 2025 13:50:07 +0100 Subject: [PATCH 102/154] Exclude app-pocket --- .github/workflows/build_all_apps.yml | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index ded5c122..c78e80a5 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -51,6 +51,7 @@ jobs: - app-name: "app-age" - app-name: "app-provenance" - app-name: "app-conflux" + - app-name: "app-pocket" runs-on: ubuntu-latest container: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest @@ -73,46 +74,45 @@ jobs: cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) cd $build_directory - # Determine if the project is a workspace and get the workspace root path - if cargo metadata --no-deps --format-version 1 | jq -e '.workspace_members | length > 0' > /dev/null; then - echo "Workspace detected. Retrieving workspace root path." - workspace_root=$(cargo metadata --no-deps --format-version 1 | jq -r '.workspace_root') - cargo_toml_path="$workspace_root/Cargo.toml" - else - echo "No workspace detected. Using Cargo.toml in the current directory." - cargo_toml_path="$(pwd)/Cargo.toml" - fi - + workspace_root=$(cargo metadata --no-deps --format-version 1 | jq -r '.workspace_root') + cargo_toml_path="$workspace_root/Cargo.toml" + # Patch ledger_device_sdk echo "" >> $cargo_toml_path echo "[patch.crates-io.ledger_device_sdk]" >> $cargo_toml_path path=\"$GITHUB_WORKSPACE/sdk/ledger_device_sdk\" echo "path=$path" >> $cargo_toml_path echo "Patch added to Cargo.toml" + # Patch ledger_secure_sdk_sys echo "" >> $cargo_toml_path echo "[patch.crates-io.ledger_secure_sdk_sys]" >> $cargo_toml_path path=\"$GITHUB_WORKSPACE/sdk/ledger_secure_sdk_sys\" echo "path=$path" >> $cargo_toml_path echo "Patch added to Cargo.toml" + # Patch include_gif echo "" >> $cargo_toml_path echo "[patch.crates-io.include_gif]" >> $cargo_toml_path path=\"$GITHUB_WORKSPACE/sdk/include_gif\" echo "path=$path" >> $cargo_toml_path echo "Patch added to Cargo.toml" - + + # Print Cargo.toml + echo "Cargo.toml:" + cat $cargo_toml_path + - name: Build run: | cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) devices="$(ledger-manifest --output-devices ledger_app.toml -j | sed 's/+/plus/' | jq -rc '.devices[]')" cd $build_directory + # Required as patch has a different version from what is locked in Cargo.lock + cargo +$RUST_NIGHTLY update include_gif + cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys + cargo +$RUST_NIGHTLY update ledger_device_sdk for device in $devices; do - # Required as patch has a different version from what is locked in Cargo.lock - cargo +$RUST_NIGHTLY update include_gif - cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys - cargo +$RUST_NIGHTLY update ledger_device_sdk echo "Build for "$device cargo ledger build $device done From 9976ea1acfc09dea532ae57cc068386c8b97aa37 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 09:55:22 +0100 Subject: [PATCH 103/154] Try to parallelize all builds --- .github/workflows/build_all_apps.yml | 26 +++++++++++++------------- .github/workflows/get_rust_apps.py | 28 ++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index c78e80a5..ef8ccff7 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -15,6 +15,8 @@ jobs: runs-on: ubuntu-latest outputs: rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }} + exclude_apps: ${{ steps.get_rust_apps.outputs.exclude_apps }} + ledger_devices: ${{ steps.get_rust_apps.outputs.ledger_devices }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -27,8 +29,10 @@ jobs: - name: Get all rust apps id: get_rust_apps run: | - python .github/workflows/get_rust_apps.py ${{ secrets.GH_TOKEN }} > rust_apps.txt - echo "rust_apps=$(cat rust_apps.txt)" >> $GITHUB_OUTPUT + python .github/workflows/get_rust_apps.py ${{ secrets.GH_TOKEN }} + echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT + echo "exclude_apps=$(cat exclude_apps.json)" >> $GITHUB_OUTPUT + echo "ledger_devices=$(cat ledger_devices.json)" >> $GITHUB_OUTPUT display-rust-apps: name: Display Rust Apps @@ -38,6 +42,8 @@ jobs: - name: Display Rust Apps run: | echo "Rust apps: ${{ needs.retrieve-rust-apps.outputs.rust_apps }}" + echo "Exclude apps: ${{ needs.retrieve-rust-apps.outputs.exclude_apps }}" + echo "Ledger devices: ${{ needs.retrieve-rust-apps.outputs.ledger_devices }}" test-build: name: Build for all targets @@ -46,12 +52,8 @@ jobs: fail-fast: false matrix: app-name: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} - exclude: - - app-name: "app-kadena-legacy" - - app-name: "app-age" - - app-name: "app-provenance" - - app-name: "app-conflux" - - app-name: "app-pocket" + device: ${{ fromJSON(needs.retrieve-rust-apps.outputs.ledger_devices) }} + exclude: ${{ fromJSON(needs.retrieve-rust-apps.outputs.exclude_apps) }} runs-on: ubuntu-latest container: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest @@ -106,13 +108,11 @@ jobs: run: | cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) - devices="$(ledger-manifest --output-devices ledger_app.toml -j | sed 's/+/plus/' | jq -rc '.devices[]')" cd $build_directory # Required as patch has a different version from what is locked in Cargo.lock cargo +$RUST_NIGHTLY update include_gif cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys cargo +$RUST_NIGHTLY update ledger_device_sdk - for device in $devices; do - echo "Build for "$device - cargo ledger build $device - done + device=$(echo ${{ matrix.device }} | sed 's/+/plus/') + echo "Build for "$device + cargo ledger build $device diff --git a/.github/workflows/get_rust_apps.py b/.github/workflows/get_rust_apps.py index b65828d3..7ea99109 100644 --- a/.github/workflows/get_rust_apps.py +++ b/.github/workflows/get_rust_apps.py @@ -1,16 +1,23 @@ from ledgered.github import GitHubLedgerHQ, NoManifestException from github.GithubException import GithubException + import sys +import json if len(sys.argv) != 2: print("Usage: get_rust_apps.py ") sys.exit(1) +ledger_devices = ["nanos+", "nanox", "stax", "flex"] +filtered_apps = ["app-kadena-legacy", "app-pocket", "app-age", "app-provenance"] + +# Retrieve all apps on LedgerHQ GitHub organization token = sys.argv[1] gh = GitHubLedgerHQ(token) apps=gh.apps rust_apps = [] +exclude_apps = [] # loop all apps in gh.apps for app in apps: try: @@ -20,9 +27,22 @@ except GithubException as e: pass else: + # Filter out apps that are Rust based if manifest.app.sdk == "rust": - # store app_name in a list - rust_apps.append(app.name) + rust_apps.append(app.name) + # filter out app for specific devices + for d in ledger_devices: + if d not in manifest.app.devices or app.name in filtered_apps: + exclude_apps.append({"app-name": app.name, "device": d}) + +# save the list of Rust apps in a json format: +with open("rust_apps.json", "w") as f: + f.write(json.dumps(rust_apps)) + +# save the list of Excluded apps in a json format: +with open("exclude_apps.json", "w") as f: + f.write(json.dumps(exclude_apps)) -# print the list of rust apps in between [] -print(rust_apps) +# save the list of Ledger devices in a json format: +with open("ledger_devices.json", "w") as f: + f.write(json.dumps(ledger_devices)) \ No newline at end of file From dd898666711bbcdca513223416bab093dd39766c Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 12:06:11 +0100 Subject: [PATCH 104/154] Make build all rust apps workflow callable --- ...l_apps.yml => reusable_build_all_apps.yml} | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) rename .github/workflows/{build_all_apps.yml => reusable_build_all_apps.yml} (86%) diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml similarity index 86% rename from .github/workflows/build_all_apps.yml rename to .github/workflows/reusable_build_all_apps.yml index ef8ccff7..efa52f3f 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -1,14 +1,23 @@ name: Build all Rust apps on: + workflow_call: + inputs: + c_sdk_branch: + required: false + default: '' + type: string workflow_dispatch: - inputs: - sdk_branch: - type: string - required: false - default: '' + inputs: + c_sdk_branch: + type: string + required: false + default: '' pull_request: +env: + C_SDK_URL: 'https://github.com/LedgerHQ/ledger-secure-sdk.git' + jobs: retrieve-rust-apps: name: Retrieve Rust Apps @@ -106,6 +115,14 @@ jobs: - name: Build run: | + # Clone C SDK if provided + if [ -n "${{ github.event.inputs.c_sdk_branch }}" ]; then + git clone $C_SDK_URL --branch ${{ github.event.inputs.c_sdk_branch }} --single-branch c_sdk + echo "setting LEDGER_SDK_PATH to $(realpath c_sdk)" + LEDGER_SDK_PATH=$(realpath c_sdk) + else + echo "using C SDK from ledger-app-builder" + fi cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) cd $build_directory From ca533e0eb511cc8b023c258f7d058f340c845d7a Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 15:33:02 +0100 Subject: [PATCH 105/154] Fix when workflow is called from another workflow --- .github/workflows/reusable_build_all_apps.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index efa52f3f..01ec6da1 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -29,6 +29,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/master' || github.ref }} - name: Set up Python uses: actions/setup-python@v4 with: From 67b2b817928b73417b2a0550385114802fa0bc74 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 15:38:44 +0100 Subject: [PATCH 106/154] Fix SDK checkout when building apps --- .github/workflows/reusable_build_all_apps.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 01ec6da1..27a1e0b2 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -76,6 +76,8 @@ jobs: uses: actions/checkout@v4 with: path: sdk + repository: ${{ github.repository }} + ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/master' || github.ref }} - name: Clone App uses: actions/checkout@v4 with: From e51d665ed5922929c0e044a5544f584b6a4997c0 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 16:03:15 +0100 Subject: [PATCH 107/154] Display context info --- .github/workflows/reusable_build_all_apps.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 27a1e0b2..8eb45cfd 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -27,6 +27,13 @@ jobs: exclude_apps: ${{ steps.get_rust_apps.outputs.exclude_apps }} ledger_devices: ${{ steps.get_rust_apps.outputs.ledger_devices }} steps: + - name: Display context + run: | + echo "github.repository: ${{ github.repository }}" + echo "github.ref: ${{ github.ref }}" + echo "github.event_name: ${{ github.event_name }}" + echo "github.head_ref: ${{ github.head_ref }}" + echo "github.event.inputs.c_sdk_branch: ${{ github.event.inputs.c_sdk_branch }}" - name: Checkout repository uses: actions/checkout@v4 with: From 98f3c6dc88e2302d76393a5eed521ad36d16813f Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 16:44:37 +0100 Subject: [PATCH 108/154] Add an additional job to determine how the workflow is called --- .github/workflows/reusable_build_all_apps.yml | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 8eb45cfd..04e5867a 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -8,37 +8,44 @@ on: default: '' type: string workflow_dispatch: - inputs: - c_sdk_branch: - type: string - required: false - default: '' pull_request: env: C_SDK_URL: 'https://github.com/LedgerHQ/ledger-secure-sdk.git' + RUST_SDK_URL: 'https://github.com/LedgerHQ/ledger-device-rust-sdk.git' jobs: + how-workflow-is-called: + name: Determine how the workflow is called + runs-on: ubuntu-latest + outputs: + repository: ${{ steps.get_repo_and_branch.outputs.repo }} + branch: ${{ steps.get_repo_and_branch.outputs.branch }} + steps: + - name: Get repository and branch + id: get_repo_and_branch + run: | + if [ -n "${{ github.event.inputs.c_sdk_branch }}" ]; then + echo "repo=$RUST_SDK_URL" >> $GITHUB_OUTPUT + echo "branch='refs/heads/master'" >> $GITHUB_OUTPUT + else + echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT + echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT + fi retrieve-rust-apps: name: Retrieve Rust Apps runs-on: ubuntu-latest + needs: how-workflow-is-called outputs: rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }} exclude_apps: ${{ steps.get_rust_apps.outputs.exclude_apps }} ledger_devices: ${{ steps.get_rust_apps.outputs.ledger_devices }} steps: - - name: Display context - run: | - echo "github.repository: ${{ github.repository }}" - echo "github.ref: ${{ github.ref }}" - echo "github.event_name: ${{ github.event_name }}" - echo "github.head_ref: ${{ github.head_ref }}" - echo "github.event.inputs.c_sdk_branch: ${{ github.event.inputs.c_sdk_branch }}" - name: Checkout repository uses: actions/checkout@v4 with: - repository: ${{ github.repository }} - ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/master' || github.ref }} + repository: ${{ needs.how-workflow-is-called.outputs.repository }} + ref: ${{ needs.how-workflow-is-called.outputs.branch }} - name: Set up Python uses: actions/setup-python@v4 with: @@ -66,7 +73,7 @@ jobs: test-build: name: Build for all targets - needs: retrieve-rust-apps + needs: [retrieve-rust-apps, how-workflow-is-called] strategy: fail-fast: false matrix: @@ -83,8 +90,8 @@ jobs: uses: actions/checkout@v4 with: path: sdk - repository: ${{ github.repository }} - ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/master' || github.ref }} + repository: ${{ needs.how-workflow-is-called.outputs.repository }} + ref: ${{ needs.how-workflow-is-called.outputs.branch }} - name: Clone App uses: actions/checkout@v4 with: From a1decc60fd12fe8e8b44e74c11c11db712f1aac6 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 17:10:21 +0100 Subject: [PATCH 109/154] Fix inputs workflow parameters --- .github/workflows/reusable_build_all_apps.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 04e5867a..a498335b 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -12,7 +12,6 @@ on: env: C_SDK_URL: 'https://github.com/LedgerHQ/ledger-secure-sdk.git' - RUST_SDK_URL: 'https://github.com/LedgerHQ/ledger-device-rust-sdk.git' jobs: how-workflow-is-called: @@ -25,8 +24,8 @@ jobs: - name: Get repository and branch id: get_repo_and_branch run: | - if [ -n "${{ github.event.inputs.c_sdk_branch }}" ]; then - echo "repo=$RUST_SDK_URL" >> $GITHUB_OUTPUT + if [ -n "${{ inputs.c_sdk_branch }}" ]; then + echo "repo='LedgerHQ/ledger-device-rust-sdk'" >> $GITHUB_OUTPUT echo "branch='refs/heads/master'" >> $GITHUB_OUTPUT else echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT @@ -135,8 +134,8 @@ jobs: - name: Build run: | # Clone C SDK if provided - if [ -n "${{ github.event.inputs.c_sdk_branch }}" ]; then - git clone $C_SDK_URL --branch ${{ github.event.inputs.c_sdk_branch }} --single-branch c_sdk + if [ -n "${{ inputs.c_sdk_branch }}" ]; then + git clone $C_SDK_URL --branch ${{ inputs.c_sdk_branch }} --single-branch c_sdk echo "setting LEDGER_SDK_PATH to $(realpath c_sdk)" LEDGER_SDK_PATH=$(realpath c_sdk) else From a847a75bf50afe10ffc9afdf3425092b2018fc40 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 17:17:16 +0100 Subject: [PATCH 110/154] Fix repo URL --- .github/workflows/reusable_build_all_apps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index a498335b..8b6ae97a 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -25,8 +25,8 @@ jobs: id: get_repo_and_branch run: | if [ -n "${{ inputs.c_sdk_branch }}" ]; then - echo "repo='LedgerHQ/ledger-device-rust-sdk'" >> $GITHUB_OUTPUT - echo "branch='refs/heads/master'" >> $GITHUB_OUTPUT + echo "repo=LedgerHQ/ledger-device-rust-sdk" >> $GITHUB_OUTPUT + echo "branch=refs/heads/master" >> $GITHUB_OUTPUT else echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT From f3362bba995b6b3755077c1974e0bd902b1df997 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 17:21:15 +0100 Subject: [PATCH 111/154] Use PR branch when using workflow_call --- .github/workflows/reusable_build_all_apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 8b6ae97a..d69ef798 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -26,7 +26,7 @@ jobs: run: | if [ -n "${{ inputs.c_sdk_branch }}" ]; then echo "repo=LedgerHQ/ledger-device-rust-sdk" >> $GITHUB_OUTPUT - echo "branch=refs/heads/master" >> $GITHUB_OUTPUT + echo "branch=y333/update_ci" >> $GITHUB_OUTPUT else echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT From 877227231232f4bce7e63f127648b3d366cd1ede Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 11 Mar 2025 17:47:21 +0100 Subject: [PATCH 112/154] Share GH token --- .github/workflows/reusable_build_all_apps.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index d69ef798..e4e07823 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -7,6 +7,9 @@ on: required: false default: '' type: string + secrets: + GH_TOKEN: + required: true workflow_dispatch: pull_request: From e4b92a08b9beca3643f20b4027455365b947e254 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 12 Mar 2025 16:25:24 +0100 Subject: [PATCH 113/154] Use CI GITHUB_TOKEN + filter out archived apps --- .github/workflows/get_rust_apps.py | 6 +++--- .github/workflows/reusable_build_all_apps.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/get_rust_apps.py b/.github/workflows/get_rust_apps.py index 7ea99109..f61b0ad0 100644 --- a/.github/workflows/get_rust_apps.py +++ b/.github/workflows/get_rust_apps.py @@ -1,4 +1,4 @@ -from ledgered.github import GitHubLedgerHQ, NoManifestException +from ledgered.github import GitHubLedgerHQ, NoManifestException, Condition from github.GithubException import GithubException import sys @@ -9,12 +9,12 @@ sys.exit(1) ledger_devices = ["nanos+", "nanox", "stax", "flex"] -filtered_apps = ["app-kadena-legacy", "app-pocket", "app-age", "app-provenance"] +filtered_apps = ["app-kadena-legacy", "app-pocket"] # Retrieve all apps on LedgerHQ GitHub organization token = sys.argv[1] gh = GitHubLedgerHQ(token) -apps=gh.apps +apps=gh.apps.filter(archived=Condition.WITHOUT) rust_apps = [] exclude_apps = [] diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index e4e07823..5024c5ad 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -57,7 +57,7 @@ jobs: - name: Get all rust apps id: get_rust_apps run: | - python .github/workflows/get_rust_apps.py ${{ secrets.GH_TOKEN }} + python .github/workflows/get_rust_apps.py ${{ secrets.GITHUB_TOKEN }} echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT echo "exclude_apps=$(cat exclude_apps.json)" >> $GITHUB_OUTPUT echo "ledger_devices=$(cat ledger_devices.json)" >> $GITHUB_OUTPUT From 04f8dc099a7199fc80fd587bea311504ee56ff1b Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 12 Mar 2025 16:27:18 +0100 Subject: [PATCH 114/154] Suppress shared GH token --- .github/workflows/reusable_build_all_apps.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 5024c5ad..50aad588 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -7,9 +7,6 @@ on: required: false default: '' type: string - secrets: - GH_TOKEN: - required: true workflow_dispatch: pull_request: From f5f0b54ed336b00a5d041d8627f7fed4a4d64c85 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 13 Mar 2025 09:24:12 +0100 Subject: [PATCH 115/154] Update after PR review --- .github/workflows/get_rust_apps.py | 34 ++++++++----------- .github/workflows/reusable_build_all_apps.yml | 14 +++----- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/.github/workflows/get_rust_apps.py b/.github/workflows/get_rust_apps.py index f61b0ad0..b2e6ed8c 100644 --- a/.github/workflows/get_rust_apps.py +++ b/.github/workflows/get_rust_apps.py @@ -8,13 +8,18 @@ print("Usage: get_rust_apps.py ") sys.exit(1) -ledger_devices = ["nanos+", "nanox", "stax", "flex"] -filtered_apps = ["app-kadena-legacy", "app-pocket"] +# Excluded Rust apps +# app-kadena-legacy: has been replaced by app-kadena +# app-pocket: does not build (Obsidians' Alamgu issue) +excluded_apps = ["app-kadena-legacy", "app-pocket"] -# Retrieve all apps on LedgerHQ GitHub organization +# Excluded devices +excluded_devices = ["nanos"] + +# Retrieve all public apps on LedgerHQ GitHub organization token = sys.argv[1] gh = GitHubLedgerHQ(token) -apps=gh.apps.filter(archived=Condition.WITHOUT) +apps=gh.apps.filter(private=Condition.WITHOUT, archived=Condition.WITHOUT) rust_apps = [] exclude_apps = [] @@ -29,20 +34,11 @@ else: # Filter out apps that are Rust based if manifest.app.sdk == "rust": - rust_apps.append(app.name) - # filter out app for specific devices - for d in ledger_devices: - if d not in manifest.app.devices or app.name in filtered_apps: - exclude_apps.append({"app-name": app.name, "device": d}) + if app.name not in excluded_apps: + for d in manifest.app.devices: + if d not in excluded_devices: + rust_apps.append({"app-name": app.name, "device": d}) -# save the list of Rust apps in a json format: +# save the list of (apps, device) pairs to build in a json format: with open("rust_apps.json", "w") as f: - f.write(json.dumps(rust_apps)) - -# save the list of Excluded apps in a json format: -with open("exclude_apps.json", "w") as f: - f.write(json.dumps(exclude_apps)) - -# save the list of Ledger devices in a json format: -with open("ledger_devices.json", "w") as f: - f.write(json.dumps(ledger_devices)) \ No newline at end of file + f.write(json.dumps(rust_apps)) \ No newline at end of file diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 50aad588..f9c29324 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -26,7 +26,7 @@ jobs: run: | if [ -n "${{ inputs.c_sdk_branch }}" ]; then echo "repo=LedgerHQ/ledger-device-rust-sdk" >> $GITHUB_OUTPUT - echo "branch=y333/update_ci" >> $GITHUB_OUTPUT + echo "branch=master" >> $GITHUB_OUTPUT else echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT @@ -37,8 +37,6 @@ jobs: needs: how-workflow-is-called outputs: rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }} - exclude_apps: ${{ steps.get_rust_apps.outputs.exclude_apps }} - ledger_devices: ${{ steps.get_rust_apps.outputs.ledger_devices }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -56,8 +54,6 @@ jobs: run: | python .github/workflows/get_rust_apps.py ${{ secrets.GITHUB_TOKEN }} echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT - echo "exclude_apps=$(cat exclude_apps.json)" >> $GITHUB_OUTPUT - echo "ledger_devices=$(cat ledger_devices.json)" >> $GITHUB_OUTPUT display-rust-apps: name: Display Rust Apps @@ -67,8 +63,6 @@ jobs: - name: Display Rust Apps run: | echo "Rust apps: ${{ needs.retrieve-rust-apps.outputs.rust_apps }}" - echo "Exclude apps: ${{ needs.retrieve-rust-apps.outputs.exclude_apps }}" - echo "Ledger devices: ${{ needs.retrieve-rust-apps.outputs.ledger_devices }}" test-build: name: Build for all targets @@ -76,9 +70,9 @@ jobs: strategy: fail-fast: false matrix: - app-name: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} - device: ${{ fromJSON(needs.retrieve-rust-apps.outputs.ledger_devices) }} - exclude: ${{ fromJSON(needs.retrieve-rust-apps.outputs.exclude_apps) }} + app-name: ["app-boilerplate-rust"] + device: ["nanos+", "nanox", "stax", "flex"] + include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} runs-on: ubuntu-latest container: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest From 473daad6640f623a5c8dd9b9929d9b43b37bb571 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 13 Mar 2025 17:31:55 +0100 Subject: [PATCH 116/154] Remove excluded devices list --- .github/workflows/get_rust_apps.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/get_rust_apps.py b/.github/workflows/get_rust_apps.py index b2e6ed8c..34b36bc9 100644 --- a/.github/workflows/get_rust_apps.py +++ b/.github/workflows/get_rust_apps.py @@ -13,9 +13,6 @@ # app-pocket: does not build (Obsidians' Alamgu issue) excluded_apps = ["app-kadena-legacy", "app-pocket"] -# Excluded devices -excluded_devices = ["nanos"] - # Retrieve all public apps on LedgerHQ GitHub organization token = sys.argv[1] gh = GitHubLedgerHQ(token) @@ -36,8 +33,7 @@ if manifest.app.sdk == "rust": if app.name not in excluded_apps: for d in manifest.app.devices: - if d not in excluded_devices: - rust_apps.append({"app-name": app.name, "device": d}) + rust_apps.append({"app-name": app.name, "device": d}) # save the list of (apps, device) pairs to build in a json format: with open("rust_apps.json", "w") as f: From 81f27b62cdc2dc4e98d8c73f62b4b33b63de310d Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Mar 2025 14:52:46 +0100 Subject: [PATCH 117/154] Remove Nano S support --- cargo-ledger/src/main.rs | 27 +- ledger_device_sdk/.cargo/config.toml | 3 - ledger_device_sdk/Cargo.toml | 2 +- ledger_device_sdk/src/io.rs | 1 - ledger_device_sdk/src/lib.rs | 8 - ledger_device_sdk/src/nvm.rs | 2 - ledger_device_sdk/src/ui.rs | 8 - ledger_device_sdk/src/ui/bagls.rs | 7 - ledger_device_sdk/src/ui/bagls/mcu.rs | 451 ------------------------ ledger_device_sdk/src/ui/gadgets.rs | 43 +-- ledger_device_sdk/src/ui/layout.rs | 4 - ledger_device_sdk/src/ui/screen_util.rs | 1 - ledger_device_sdk/src/ui/string_mcu.rs | 65 ---- ledger_secure_sdk_sys/Cargo.toml | 2 +- ledger_secure_sdk_sys/build.rs | 121 ++----- ledger_secure_sdk_sys/csdk_nanos.h | 11 - ledger_secure_sdk_sys/nanos.json | 32 -- ledger_secure_sdk_sys/nanos_layout.ld | 10 - ledger_secure_sdk_sys/src/c/src.c | 14 +- ledger_secure_sdk_sys/src/lib.rs | 18 +- 20 files changed, 68 insertions(+), 762 deletions(-) delete mode 100644 ledger_device_sdk/src/ui/bagls/mcu.rs delete mode 100644 ledger_device_sdk/src/ui/string_mcu.rs delete mode 100644 ledger_secure_sdk_sys/csdk_nanos.h delete mode 100644 ledger_secure_sdk_sys/nanos.json delete mode 100644 ledger_secure_sdk_sys/nanos_layout.ld diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs index 061319fd..b03566a4 100644 --- a/cargo-ledger/src/main.rs +++ b/cargo-ledger/src/main.rs @@ -52,7 +52,6 @@ struct CliArgs { #[derive(ValueEnum, Clone, Copy, Debug, PartialEq)] enum Device { - Nanos, Nanox, Nanosplus, Stax, @@ -68,7 +67,6 @@ impl Display for Device { impl AsRef for Device { fn as_ref(&self) -> &str { match self { - Device::Nanos => "nanos", Device::Nanox => "nanox", Device::Nanosplus => "nanosplus", Device::Stax => "stax", @@ -159,7 +157,6 @@ fn build_app( let exe_path = match use_prebuilt { None => { let c_sdk_path = match device { - Device::Nanos => std::env::var("NANOS_SDK"), Device::Nanosplus => std::env::var("NANOSP_SDK"), Device::Nanox => std::env::var("NANOX_SDK"), Device::Stax => std::env::var("STAX_SDK"), @@ -264,7 +261,7 @@ fn build_app( None => match metadata_ledger.flags { Some(flags) => match device { // Modify flags to enable BLE if targeting Nano X - Device::Nanos | Device::Nanosplus => flags, + Device::Nanosplus => flags, Device::Nanox | Device::Stax | Device::Flex => { let base = u32::from_str_radix(flags.trim_start_matches("0x"), 16) @@ -279,7 +276,6 @@ fn build_app( // Target ID according to target, in case it // is not present in the retrieved ELF infos. let backup_targetid: String = match device { - Device::Nanos => String::from("0x31100004"), Device::Nanox => String::from("0x33000004"), Device::Nanosplus => String::from("0x33100004"), Device::Stax => String::from("0x33200004"), @@ -301,13 +297,8 @@ fn build_app( "binary": hex_file, "dataSize": infos.size }); - // Ignore apiLevel for Nano S as it is unsupported for now - match device { - Device::Nanos => (), - _ => { - json["apiLevel"] = infos.api_level.into(); - } - } + + json["apiLevel"] = infos.api_level.into(); serde_json::to_writer_pretty(file, &json).unwrap(); // Copy icon to the same directory as the app.json @@ -359,20 +350,20 @@ mod tests { #[test] fn valid_metadata() { let (_, metadata_ledger, metadata_nanos) = - retrieve_metadata(Device::Nanos, Some("./tests/valid/Cargo.toml")); + retrieve_metadata(Device::Flex, Some("./tests/valid/Cargo.toml")); assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); assert_eq!(metadata_ledger.curve, ["secp256k1"]); assert_eq!(metadata_ledger.flags, "0x38"); assert_eq!(metadata_ledger.path, ["'44/123"]); - assert_eq!(metadata_nanos.icon, "./assets/nanos.gif") + //assert_eq!(metadata_nanos.icon, "./assets/nanos.gif") } #[test] fn valid_metadata_variant() { let (_, metadata_ledger, metadata_nanos) = retrieve_metadata( - Device::Nanos, + Device::Flex, Some("./tests/valid_variant/Cargo.toml"), ); @@ -380,13 +371,13 @@ mod tests { assert_eq!(metadata_ledger.curve, ["secp256k1"]); assert_eq!(metadata_ledger.flags, "0x38"); assert_eq!(metadata_ledger.path, ["'44/123"]); - assert_eq!(metadata_nanos.icon, "./assets/nanos.gif") + //assert_eq!(metadata_nanos.icon, "./assets/nanos.gif") } #[test] fn valid_outdated_metadata() { let (_, metadata_ledger, metadata_nanos) = retrieve_metadata( - Device::Nanos, + Device::Flex, Some("./tests/valid_outdated/Cargo.toml"), ); @@ -394,6 +385,6 @@ mod tests { assert_eq!(metadata_ledger.curve, ["secp256k1"]); assert_eq!(metadata_ledger.flags, "0"); assert_eq!(metadata_ledger.path, ["'44/123"]); - assert_eq!(metadata_nanos.icon, "nanos.gif") + //assert_eq!(metadata_nanos.icon, "nanos.gif") } } diff --git a/ledger_device_sdk/.cargo/config.toml b/ledger_device_sdk/.cargo/config.toml index bf0bd24b..20c8bf74 100644 --- a/ledger_device_sdk/.cargo/config.toml +++ b/ledger_device_sdk/.cargo/config.toml @@ -1,6 +1,3 @@ -[target.nanos] -runner = "speculos -m nanos --display=headless" - [target.nanox] runner = "speculos -m nanox --display=headless" diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 48bb7a64..285b6eb7 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -33,4 +33,4 @@ default = [ "heap" ] [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] +check-cfg = ['cfg(target_os, values("stax", "flex", "nanox", "nanosplus"))'] diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index ae387934..a2a27cf7 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -430,7 +430,6 @@ impl Comm { } if unsafe { G_io_app.apdu_state } != APDU_IDLE && unsafe { G_io_app.apdu_length } > 0 { - #[cfg(not(any(target_os = "nanos")))] unsafe { if os_perso_is_pin_set() == BOLOS_TRUE.try_into().unwrap() && os_global_pin_is_validated() != BOLOS_TRUE.try_into().unwrap() diff --git a/ledger_device_sdk/src/lib.rs b/ledger_device_sdk/src/lib.rs index 763308c4..63ba76f9 100644 --- a/ledger_device_sdk/src/lib.rs +++ b/ledger_device_sdk/src/lib.rs @@ -123,17 +123,11 @@ impl NVMData { NVMData { data } } - #[cfg(target_os = "nanos")] - pub fn get_mut(&mut self) -> &mut T { - ledger_secure_sdk_sys::pic_rs_mut(&mut self.data) - } - /// This will return a mutable access by casting the pointer /// to the correct offset in `.nvm_data` manually. /// This is necessary when using the `rwpi` relocation model, /// because a static mutable will be assumed to be located in /// RAM, and be accessed through the static base (r9) - #[cfg(not(target_os = "nanos"))] fn get_addr(&self) -> *mut T { use core::arch::asm; unsafe { @@ -148,7 +142,6 @@ impl NVMData { } } - #[cfg(not(target_os = "nanos"))] pub fn get_mut(&mut self) -> &mut T { unsafe { let pic_addr = self.get_addr(); @@ -156,7 +149,6 @@ impl NVMData { } } - #[cfg(not(target_os = "nanos"))] pub fn get_ref(&self) -> &T { unsafe { let pic_addr = self.get_addr(); diff --git a/ledger_device_sdk/src/nvm.rs b/ledger_device_sdk/src/nvm.rs index fe343bf5..de0caa24 100644 --- a/ledger_device_sdk/src/nvm.rs +++ b/ledger_device_sdk/src/nvm.rs @@ -184,8 +184,6 @@ macro_rules! atomic_storage { }; } -#[cfg(target_os = "nanos")] -atomic_storage!(64); #[cfg(target_os = "nanox")] atomic_storage!(256); #[cfg(any(target_os = "nanosplus", target_os = "stax", target_os = "flex"))] diff --git a/ledger_device_sdk/src/ui.rs b/ledger_device_sdk/src/ui.rs index 2b05ba48..6017c03e 100644 --- a/ledger_device_sdk/src/ui.rs +++ b/ledger_device_sdk/src/ui.rs @@ -2,12 +2,8 @@ pub mod bagls; -#[cfg(not(target_os = "nanos"))] pub mod string_se; -#[cfg(target_os = "nanos")] -pub mod string_mcu; - pub mod bitmaps; pub mod fonts; pub mod layout; @@ -19,8 +15,4 @@ pub const PADDING: usize = 2; pub const Y_PADDING: usize = 3; pub const SCREEN_WIDTH: usize = 128; -#[cfg(target_os = "nanos")] -pub const SCREEN_HEIGHT: usize = 32; - -#[cfg(not(target_os = "nanos"))] pub const SCREEN_HEIGHT: usize = 64; diff --git a/ledger_device_sdk/src/ui/bagls.rs b/ledger_device_sdk/src/ui/bagls.rs index b4b4c96b..830f52c2 100644 --- a/ledger_device_sdk/src/ui/bagls.rs +++ b/ledger_device_sdk/src/ui/bagls.rs @@ -1,11 +1,4 @@ -#[cfg(target_os = "nanos")] -pub mod mcu; -#[cfg(target_os = "nanos")] -pub use self::mcu::*; - -#[cfg(not(target_os = "nanos"))] pub mod se; -#[cfg(not(target_os = "nanos"))] pub use self::se::*; use bitmaps::Glyph; diff --git a/ledger_device_sdk/src/ui/bagls/mcu.rs b/ledger_device_sdk/src/ui/bagls/mcu.rs deleted file mode 100644 index c41cbe20..00000000 --- a/ledger_device_sdk/src/ui/bagls/mcu.rs +++ /dev/null @@ -1,451 +0,0 @@ -use super::Icon; -use crate::ui::layout::{Draw, Layout, Location}; -use ledger_secure_sdk_sys; -use ledger_secure_sdk_sys::seph::SephTags; - -#[repr(u8)] -pub enum BaglTypes { - NoneType = 0, - Button = 1, - Label = 2, - Rectangle = 3, - Line = 4, - Icon = 5, - Circle = 6, - LabelLine = 7, -} - -pub const BAGL_FONT_ALIGNMENT_CENTER: u32 = 32768; - -#[repr(C)] -pub struct BaglComponent { - pub type_: u8, - pub userid: u8, - pub x: i16, - pub y: i16, - pub width: u16, - pub height: u16, - pub stroke: u8, - pub radius: u8, - pub fill: u8, - pub fgcolor: u32, - pub bgcolor: u32, - pub font_id: u16, - pub icon_id: u8, -} - -impl BaglComponent { - pub fn paint(&self) { - let bagl_comp = unsafe { - core::slice::from_raw_parts( - self as *const BaglComponent as *const u8, - core::mem::size_of::(), - ) - }; - - ledger_secure_sdk_sys::seph::seph_send(&[ - SephTags::ScreenDisplayStatus as u8, - 0, - bagl_comp.len() as u8, - ]); - ledger_secure_sdk_sys::seph::seph_send(bagl_comp); - } -} - -pub trait SendToDisplay { - fn wait_for_status(&self) { - if ledger_secure_sdk_sys::seph::is_status_sent() { - // TODO: this does not seem like the right way to fix the problem... - let mut spi_buffer = [0u8; 16]; - ledger_secure_sdk_sys::seph::seph_recv(&mut spi_buffer, 0); - } - } - fn paint(&self); - fn send_to_display(&self) { - BLANK.paint(); - self.paint(); - } -} - -pub enum Bagl<'a> { - LABELLINE(Label<'a>), - RECT(Rect), - ICON(Icon<'a>), -} - -impl Bagl<'_> { - /// Erase screen and display the bagl - pub fn display(&self) { - match self { - Bagl::LABELLINE(x) => x.send_to_display(), - Bagl::RECT(x) => x.send_to_display(), - Bagl::ICON(x) => x.send_to_display(), - } - } - - /// Only paint to current screen (draw over) - pub fn paint(&self) { - match self { - Bagl::LABELLINE(x) => x.paint(), - Bagl::RECT(x) => x.paint(), - Bagl::ICON(x) => x.paint(), - } - } -} - -#[repr(C)] -pub struct bagl_element_rs<'a> { - pub component: BaglComponent, - pub text: Option<&'a str>, -} - -impl Draw for Icon<'_> { - fn display(&self) { - self.paint(); - } - fn erase(&self) { - let icon = ledger_secure_sdk_sys::pic_rs(self.icon); - Rect::new() - .pos(self.pos.0, self.pos.1) - .dims(icon.width as u16, icon.height as u16) - .colors(0, 0xffffff) - .fill(true) - .paint(); - } -} - -#[repr(u8)] -pub enum Font { - LucidaConsole8px = 0, - OpenSansLight16_22px, - OpenSansRegular8_11px, - OpenSansRegular10_13px, - OpenSansRegular11_14px, - OpenSansRegular13_18px, - OpenSansRegular22_30px, - OpenSansSemibold8_11px, - OpenSansExtrabold11px, - OpenSansLight16px, - OpenSansRegular11px, - OpenSansSemibold10_13px, - OpenSansSemibold11_16px, - OpenSansSemibold13_18px, - Symbols0, - Symbols1, -} - -#[derive(Clone, Copy)] -pub struct Label<'a> { - pub loc: Location, - pub layout: Layout, - pub dims: (u16, u16), - pub bold: bool, - pub text: &'a str, -} - -impl Default for Label<'_> { - fn default() -> Self { - Label { - text: "", - bold: false, - dims: (128, 11), - loc: Location::Middle, - layout: Layout::Centered, - } - } -} - -impl<'a> Label<'a> { - pub const fn new() -> Self { - Label { - loc: Location::Middle, - layout: Layout::Centered, - dims: (128, 11), - bold: false, - text: "", - } - } - - pub const fn from_const(text: &'static str) -> Self { - Label { - loc: Location::Middle, - layout: Layout::Centered, - dims: (128, 11), - bold: false, - text, - } - } - - pub const fn location(self, loc: Location) -> Self { - Label { loc, ..self } - } - pub const fn layout(self, layout: Layout) -> Self { - Label { layout, ..self } - } - pub const fn dims(self, w: u16, h: u16) -> Self { - Label { - dims: (w, h), - ..self - } - } - pub const fn bold(self) -> Self { - Label { bold: true, ..self } - } - pub fn text(self, text: &'a str) -> Self { - Label { text, ..self } - } -} - -impl<'a> From<&'a str> for Label<'a> { - fn from(text: &'a str) -> Label<'a> { - Label::new().text(text) - } -} - -impl<'a> Draw for Label<'a> { - fn display(&self) { - self.paint(); - } - fn erase(&self) { - let x = self.layout.get_x(self.dims.0 as usize) as i16; - let y = self.loc.get_y(self.dims.1 as usize) as i16; - Rect::new() - .pos(x, y) - .dims(self.dims.0, self.dims.1) - .colors(0, 0xffffff) - .fill(true) - .paint(); - } -} - -pub struct Rect { - pub pos: (i16, i16), - pub dims: (u16, u16), - pub colors: (u32, u32), - pub fill: bool, - pub userid: u8, -} - -impl Rect { - pub const fn new() -> Rect { - Rect { - pos: (32 - 5, 64 - 5), - dims: (10, 10), - colors: (0xffffffu32, 0), - fill: false, - userid: 0, - } - } - pub const fn pos(self, x: i16, y: i16) -> Rect { - Rect { - pos: (x, y), - ..self - } - } - pub const fn colors(self, fg: u32, bg: u32) -> Rect { - Rect { - colors: (fg, bg), - ..self - } - } - pub const fn dims(self, w: u16, h: u16) -> Rect { - Rect { - dims: (w, h), - ..self - } - } - pub const fn fill(self, x: bool) -> Rect { - Rect { fill: x, ..self } - } - pub const fn userid(self, id: u8) -> Rect { - Rect { userid: id, ..self } - } -} - -impl Draw for Rect { - fn display(&self) { - self.paint(); - } - fn erase(&self) { - Rect::new() - .pos(self.pos.0, self.pos.1) - .dims(self.dims.0, self.dims.1) - .colors(0, 0xffffff) - .fill(true) - .paint(); - } -} - -impl Draw for RectFull { - fn display(&self) { - self.paint(); - } - fn erase(&self) { - Rect::new() - .pos(self.pos.0 as i16, self.pos.1 as i16) - .dims(self.width as u16, self.height as u16) - .colors(0, 0xffffff) - .fill(true) - .paint(); - } -} - -impl SendToDisplay for Icon<'_> { - fn paint(&self) { - self.wait_for_status(); - let icon = ledger_secure_sdk_sys::pic_rs(self.icon); - let baglcomp = BaglComponent { - type_: BaglTypes::Icon as u8, - userid: 0, - x: self.pos.0, - y: self.pos.1, - width: icon.width as u16, - height: icon.height as u16, - stroke: 0, - radius: 0, - fill: 0, - fgcolor: 0, - bgcolor: 0, - font_id: 0, - icon_id: 0, - }; - let bagl_comp = unsafe { - core::slice::from_raw_parts( - &baglcomp as *const BaglComponent as *const u8, - core::mem::size_of::(), - ) - }; - let lenbytes = ((bagl_comp.len() + 1 + (2 * 4) + icon.bitmap.len()) as u16).to_be_bytes(); - ledger_secure_sdk_sys::seph::seph_send(&[ - SephTags::ScreenDisplayStatus as u8, - lenbytes[0], - lenbytes[1], - ]); - ledger_secure_sdk_sys::seph::seph_send(bagl_comp); - // bpp (1), 'color_index' (2*4) - ledger_secure_sdk_sys::seph::seph_send(&[1, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0]); - let bmp = unsafe { - core::slice::from_raw_parts( - ledger_secure_sdk_sys::pic(icon.bitmap.as_ptr() as *mut c_void) as *const u8, - icon.bitmap.len(), - ) - }; - ledger_secure_sdk_sys::seph::seph_send(bmp); - } -} - -impl SendToDisplay for Rect { - fn paint(&self) { - self.wait_for_status(); - let baglcomp = BaglComponent { - type_: BaglTypes::Rectangle as u8, - userid: self.userid, - x: self.pos.0, - y: self.pos.1, - width: self.dims.0, - height: self.dims.1, - stroke: 0, - radius: 0, - fill: self.fill as u8, - fgcolor: self.colors.0, - bgcolor: self.colors.1, - font_id: 0, - icon_id: 0, - }; - baglcomp.paint(); - } -} - -use super::RectFull; - -impl SendToDisplay for RectFull { - fn paint(&self) { - self.wait_for_status(); - let baglcomp = BaglComponent { - type_: BaglTypes::Rectangle as u8, - userid: 0, - x: self.pos.0 as i16, - y: self.pos.1 as i16, - width: self.width as u16, - height: self.height as u16, - stroke: 0, - radius: 0, - fill: 1, - fgcolor: 0xffffff, - bgcolor: 0, - font_id: 0, - icon_id: 0, - }; - baglcomp.paint(); - } -} - -use core::ffi::c_void; - -impl<'a> SendToDisplay for Label<'a> { - fn paint(&self) { - self.wait_for_status(); - let font_id = if self.bold { - Font::OpenSansExtrabold11px - } else { - Font::OpenSansRegular11px - }; - let x = match self.layout { - Layout::RightAligned => self.layout.get_x(self.text.len() * 7), - Layout::Custom(x) => x, - _ => 0, - }; - let y = self.loc.get_y(self.dims.1 as usize) as i16; - let width = match self.layout { - Layout::Centered => crate::ui::SCREEN_WIDTH, - _ => self.text.len() * 6, - }; - let alignment = match self.layout { - Layout::LeftAligned => 0_u16, - Layout::Centered => BAGL_FONT_ALIGNMENT_CENTER as u16, - Layout::RightAligned => BAGL_FONT_ALIGNMENT_CENTER as u16, - Layout::Custom(_) => 0_u16, - }; - let baglcomp = BaglComponent { - type_: BaglTypes::LabelLine as u8, - userid: 0, // FIXME - x: x as i16, - y: y - 1 + self.dims.1 as i16, - width: width as u16, //self.dims.0, - height: self.dims.1, - stroke: 0, - radius: 0, - fill: 0, - fgcolor: 0xffffffu32, - bgcolor: 0, - font_id: font_id as u16 | alignment, - icon_id: 0, - }; - - let bagl_comp = unsafe { - core::slice::from_raw_parts( - &baglcomp as *const BaglComponent as *const u8, - core::mem::size_of::(), - ) - }; - let lenbytes = ((bagl_comp.len() + self.text.len()) as u16).to_be_bytes(); - ledger_secure_sdk_sys::seph::seph_send(&[ - SephTags::ScreenDisplayStatus as u8, - lenbytes[0], - lenbytes[1], - ]); - ledger_secure_sdk_sys::seph::seph_send(bagl_comp); - - unsafe { - let pic_text = ledger_secure_sdk_sys::pic(self.text.as_ptr() as *mut u8 as *mut c_void); - ledger_secure_sdk_sys::io_seph_send(pic_text as *mut u8, self.text.len() as u16); - } - } -} - -/// Some common constant Bagls -pub const BLANK: Rect = Rect::new() - .pos(0, 0) - .dims(128, 32) - .colors(0, 0xffffff) - .fill(true); diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index 236d2879..27d3f1e8 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -42,25 +42,19 @@ pub fn get_event(buttons: &mut ButtonsState) -> Option { } pub fn clear_screen() { - #[cfg(not(target_os = "nanos"))] - { - #[cfg(not(feature = "speculos"))] - unsafe { - ledger_secure_sdk_sys::screen_clear(); - } - - #[cfg(feature = "speculos")] - { - // Speculos does not emulate the screen_clear syscall yet - RectFull::new() - .width(crate::ui::SCREEN_WIDTH as u32) - .height(crate::ui::SCREEN_HEIGHT as u32) - .erase(); - } + #[cfg(not(feature = "speculos"))] + unsafe { + ledger_secure_sdk_sys::screen_clear(); } - #[cfg(target_os = "nanos")] - BLANK.paint(); + #[cfg(feature = "speculos")] + { + // Speculos does not emulate the screen_clear syscall yet + RectFull::new() + .width(crate::ui::SCREEN_WIDTH as u32) + .height(crate::ui::SCREEN_HEIGHT as u32) + .erase(); + } } /// Display a developer mode / pending review popup, cleared with user interaction. @@ -89,18 +83,9 @@ pub fn display_pending_review(comm: &mut Comm) { clear_screen(); // Add icon and text to match the C SDK equivalent. - #[cfg(target_os = "nanos")] - { - "Pending".place(Location::Custom(2), Layout::Centered, true); - "Ledger review".place(Location::Custom(14), Layout::Centered, true); - } - - #[cfg(not(target_os = "nanos"))] - { - WARNING.draw(57, 10); - "Pending".place(Location::Custom(28), Layout::Centered, true); - "Ledger review".place(Location::Custom(42), Layout::Centered, true); - } + WARNING.draw(57, 10); + "Pending".place(Location::Custom(28), Layout::Centered, true); + "Ledger review".place(Location::Custom(42), Layout::Centered, true); crate::ui::screen_util::screen_update(); diff --git a/ledger_device_sdk/src/ui/layout.rs b/ledger_device_sdk/src/ui/layout.rs index f66f87fb..5be999bb 100644 --- a/ledger_device_sdk/src/ui/layout.rs +++ b/ledger_device_sdk/src/ui/layout.rs @@ -36,10 +36,6 @@ impl Location { } } -#[cfg(target_os = "nanos")] -pub const MAX_LINES: usize = 2; - -#[cfg(not(target_os = "nanos"))] pub const MAX_LINES: usize = 4; pub trait Place { diff --git a/ledger_device_sdk/src/ui/screen_util.rs b/ledger_device_sdk/src/ui/screen_util.rs index ce70a544..2fbcd148 100644 --- a/ledger_device_sdk/src/ui/screen_util.rs +++ b/ledger_device_sdk/src/ui/screen_util.rs @@ -24,7 +24,6 @@ pub fn fulldraw(x_pos: i32, y_pos: i32, bmp: &[u8]) { } pub fn screen_update() { - #[cfg(not(target_os = "nanos"))] unsafe { ledger_secure_sdk_sys::screen_update(); } diff --git a/ledger_device_sdk/src/ui/string_mcu.rs b/ledger_device_sdk/src/ui/string_mcu.rs deleted file mode 100644 index 13ea61a9..00000000 --- a/ledger_device_sdk/src/ui/string_mcu.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::ui::bagls::*; -use crate::ui::layout::*; - -impl StringPlace for &str { - // unused when using MCU display - fn compute_width(&self, _bold: bool) -> usize { - 0 - } - - fn place(&self, loc: Location, layout: Layout, bold: bool) { - let mut lbl = Label::new() - .dims(128, 11) - .location(loc) - .layout(layout) - .text(self); - if bold { - lbl = lbl.bold(); - } - lbl.paint(); - } -} - -impl StringPlace for [&str] { - // unused when using MCU display - fn compute_width(&self, _bold: bool) -> usize { - 0 - } - - fn place(&self, loc: Location, layout: Layout, bold: bool) { - let c_height = 11; // Default font height - let total_height = self.len() * c_height; - let mut cur_y = loc.get_y(total_height); - for string in self.iter() { - string.place(Location::Custom(cur_y), layout, bold); - cur_y += c_height; - } - } -} - -impl<'a> StringPlace for Label<'a> { - fn compute_width(&self, _bold: bool) -> usize { - self.text.compute_width(self.bold) - } - - fn place(&self, loc: Location, layout: Layout, bold: bool) { - self.text.place(loc, layout, bold); - } -} - -impl<'a> StringPlace for [Label<'a>] { - fn compute_width(&self, bold: bool) -> usize { - self.iter() - .fold(0, |acc, lbl| acc.max(lbl.compute_width(bold))) - } - - fn place(&self, loc: Location, layout: Layout, _bold: bool) { - let padding = if self.len() > 4 { 0 } else { 2 }; - let total_height = self.iter().fold(0, |acc, _| acc + padding + 11); - let mut cur_y = loc.get_y(total_height); - for label in self.iter() { - label.place(Location::Custom(cur_y), layout, label.bold); - cur_y += 11 + padding; - } - } -} diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 806e3647..504fe79a 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -22,4 +22,4 @@ nano_nbgl = [] [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] +check-cfg = ['cfg(target_os, values("stax", "flex", "nanox", "nanosplus"))'] diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 467efcc8..05093db5 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -29,20 +29,6 @@ const SDK_USB_FILES: [&str; 6] = [ "lib_stusb/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c", ]; -const CFLAGS_NANOS: [&str; 11] = [ - "-Oz", - "-fomit-frame-pointer", - "-fno-common", - "-fdata-sections", - "-ffunction-sections", - "-mthumb", - "-fno-jump-tables", - "-fshort-enums", - "-mno-unaligned-access", - "-fropi", - "-Wno-unused-command-line-argument", -]; - const CFLAGS_NANOSPLUS: [&str; 22] = [ "-Oz", "-g0", @@ -95,7 +81,6 @@ const CFLAGS_NANOX: [&str; 21] = [ #[derive(Debug, Default, PartialEq)] enum DeviceName { - NanoS, #[default] NanoSPlus, NanoX, @@ -118,7 +103,6 @@ struct Device<'a> { impl std::fmt::Display for DeviceName { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - DeviceName::NanoS => write!(f, "nanos"), DeviceName::NanoSPlus => write!(f, "nanos2"), DeviceName::NanoX => write!(f, "nanox"), DeviceName::Stax => write!(f, "stax"), @@ -200,22 +184,6 @@ impl SDKBuilder<'_> { .to_str() .unwrap() { - "nanos" => Device { - name: DeviceName::NanoS, - c_sdk: Default::default(), - target: "thumbv6m-none-eabi", - defines: { - let mut v = header2define("csdk_nanos.h"); - println!("cargo:warning=BAGL is built"); - println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "bagl"); - v.push((String::from("HAVE_BAGL"), None)); - v - }, - cflags: Vec::from(CFLAGS_NANOS), - glyphs_folders: Vec::new(), - arm_libs: Default::default(), - linker_script: "nanos_layout.ld", - }, "nanosplus" => Device { name: DeviceName::NanoSPlus, c_sdk: Default::default(), @@ -326,11 +294,6 @@ impl SDKBuilder<'_> { // Set ARM pre-compiled libraries path self.device.arm_libs = match self.device.name { - DeviceName::NanoS => { - let mut path = self.gcc_toolchain.display().to_string(); - path.push_str("/lib"); - path - } DeviceName::NanoX => { let mut path = self.device.c_sdk.display().to_string(); path.push_str("/arch/st33/lib"); @@ -359,11 +322,7 @@ impl SDKBuilder<'_> { println!("cargo:rustc-env=API_LEVEL={}", self.api_level); println!("cargo:warning=API_LEVEL is {}", self.api_level); } - None => { - if self.device.name != DeviceName::NanoS { - return Err(SDKBuildError::InvalidAPILevel); - } - } + None => Err(SDKBuildError::InvalidAPILevel), } // Export other SDK infos into env for 'infos.rs' @@ -474,9 +433,8 @@ impl SDKBuilder<'_> { let path = self.device.arm_libs.clone(); println!("cargo:rustc-link-lib=c"); println!("cargo:rustc-link-lib=m"); - if self.device.name != DeviceName::NanoS { - println!("cargo:rustc-link-lib=gcc"); - } + println!("cargo:rustc-link-lib=gcc"); + println!("cargo:rustc-link-search={path}"); Ok(()) } @@ -529,45 +487,36 @@ impl SDKBuilder<'_> { } // BAGL or NBGL bindings - match self.device.name { - DeviceName::NanoS => { - bindings = - bindings.header(self.device.c_sdk.join("include/bagl.h").to_str().unwrap()) - } - DeviceName::NanoSPlus | DeviceName::NanoX | DeviceName::Stax | DeviceName::Flex => { - if ((self.device.name == DeviceName::NanoX - || self.device.name == DeviceName::NanoSPlus) - && env::var_os("CARGO_FEATURE_NANO_NBGL").is_some()) - || self.device.name == DeviceName::Stax - || self.device.name == DeviceName::Flex - { - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - let mut include_path = "-I".to_string(); - let glyphs = out_path.join("glyphs"); - include_path += glyphs.to_str().unwrap(); - bindings = bindings.clang_args([include_path.as_str()]); - - bindings = bindings.clang_args([ - format!("-I{bsdk}/lib_nbgl/include/").as_str(), - format!("-I{bsdk}/lib_ux_nbgl/").as_str(), - ]); - bindings = bindings - .header( - self.device - .c_sdk - .join("lib_nbgl/include/nbgl_use_case.h") - .to_str() - .unwrap(), - ) - .header( - self.device - .c_sdk - .join("lib_ux_nbgl/ux_nbgl.h") - .to_str() - .unwrap(), - ); - } - } + if ((self.device.name == DeviceName::NanoX || self.device.name == DeviceName::NanoSPlus) + && env::var_os("CARGO_FEATURE_NANO_NBGL").is_some()) + || self.device.name == DeviceName::Stax + || self.device.name == DeviceName::Flex + { + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let mut include_path = "-I".to_string(); + let glyphs = out_path.join("glyphs"); + include_path += glyphs.to_str().unwrap(); + bindings = bindings.clang_args([include_path.as_str()]); + + bindings = bindings.clang_args([ + format!("-I{bsdk}/lib_nbgl/include/").as_str(), + format!("-I{bsdk}/lib_ux_nbgl/").as_str(), + ]); + bindings = bindings + .header( + self.device + .c_sdk + .join("lib_nbgl/include/nbgl_use_case.h") + .to_str() + .unwrap(), + ) + .header( + self.device + .c_sdk + .join("lib_ux_nbgl/ux_nbgl.h") + .to_str() + .unwrap(), + ); } // BLE bindings @@ -839,10 +788,6 @@ fn retrieve_target_file_infos( /// Fetch the appropriate C SDK to build fn clone_sdk(devicename: &DeviceName) -> PathBuf { let (repo_url, sdk_branch) = match devicename { - DeviceName::NanoS => ( - Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_LNS", - ), DeviceName::NanoX => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), "API_LEVEL_22", diff --git a/ledger_secure_sdk_sys/csdk_nanos.h b/ledger_secure_sdk_sys/csdk_nanos.h deleted file mode 100644 index 157b0b37..00000000 --- a/ledger_secure_sdk_sys/csdk_nanos.h +++ /dev/null @@ -1,11 +0,0 @@ -#define HAVE_LOCAL_APDU_BUFFER -#define IO_HID_EP_LENGTH 64 -#define USB_SEGMENT_SIZE 64 -#define OS_IO_SEPROXYHAL -#define HAVE_IO_USB -#define HAVE_L4_USBLIB -#define HAVE_USB_APDU -#define __IO volatile -#define IO_USB_MAX_ENDPOINTS 6 -#define IO_SEPROXYHAL_BUFFER_SIZE_B 128 -#define ST31 \ No newline at end of file diff --git a/ledger_secure_sdk_sys/nanos.json b/ledger_secure_sdk_sys/nanos.json deleted file mode 100644 index 4d893faf..00000000 --- a/ledger_secure_sdk_sys/nanos.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "abi": "eabi", - "arch": "arm", - "atomic-cas": false, - "c-enum-min-bits": 8, - "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "emit-debug-gdb-scripts": false, - "executables": true, - "features": "+strict-align", - "frame-pointer": "always", - "linker": "link_wrap.sh", - "linker-flavor": "ld.lld", - "llvm-target": "thumbv6m-none-eabi", - "panic-strategy": "abort", - "pre-link-args": { - "ld.lld": [ - "-Tnanos_layout.ld", - "-Tlink.ld", - "--emit-relocs" - ], - "ld": [ - "-Tnanos_layout.ld", - "-Tlink.ld", - "--emit-relocs" - ] - }, - "relocation-model": "ropi", - "singlethread": true, - "target-pointer-width": "32", - "os": "nanos", - "target-family": [ "bolos" ] -} diff --git a/ledger_secure_sdk_sys/nanos_layout.ld b/ledger_secure_sdk_sys/nanos_layout.ld deleted file mode 100644 index 129399e6..00000000 --- a/ledger_secure_sdk_sys/nanos_layout.ld +++ /dev/null @@ -1,10 +0,0 @@ -MEMORY -{ - FLASH (rx) : ORIGIN = 0xc0d00000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0x20000200, LENGTH = 4K+512 - CXSRAM (rwx) : ORIGIN = 0x20001400, LENGTH = 1K -} - -PAGE_SIZE = 64; -STACK_SIZE = DEFINED(stack_size) ? stack_size : 1024; -END_STACK = ORIGIN(SRAM) + LENGTH(SRAM); \ No newline at end of file diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index cef9464b..f2da5897 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -62,9 +62,6 @@ void printhex_c(char* str, uint32_t m); "ldr %[result], =" #SYM "(sbrel)\n\t" \ "add %[result], r9, %[result]" \ : [result] "=r" (DST)) -#elif defined(TARGET_NANOS) -# define SYMBOL_SBREL_ADDRESS(DST, SYM) \ - SYMBOL_ABSOLUTE_VALUE(DST, SYM) #else # error "unknown machine" #endif @@ -78,11 +75,7 @@ void link_pass( void* envram_prev, int dst_ram) { -#ifdef TARGET_NANOS - uint32_t buf[16]; -#else uint32_t buf[128]; -#endif typedef typeof(*buf) link_addr_t; @@ -173,10 +166,7 @@ void get_link_time_nvram_values( void** nvram_ptr_p, void** envram_ptr_p) { -#if defined(ST31) - SYMBOL_ABSOLUTE_VALUE(*nvram_ptr_p, _nvram); - SYMBOL_ABSOLUTE_VALUE(*envram_ptr_p, _envram); -#elif defined(ST33) || defined(ST33K1M5) +#if defined(ST33) || defined(ST33K1M5) __asm volatile("ldr %0, =_nvram":"=r"(*nvram_ptr_p)); __asm volatile("ldr %0, =_envram":"=r"(*envram_ptr_p)); #else @@ -274,7 +264,6 @@ void c_boot_std() { io_seproxyhal_spi_send(c, 4); #endif -#ifndef TARGET_NANOS // Warn UX layer of io reset to avoid unwanted pin lock memset(&G_ux_params, 0, sizeof(G_ux_params)); G_ux_params.ux_id = BOLOS_UX_IO_RESET; @@ -287,7 +276,6 @@ void c_boot_std() { break; } } -#endif #ifdef HAVE_BLE unsigned int plane = G_io_app.plane_mode; diff --git a/ledger_secure_sdk_sys/src/lib.rs b/ledger_secure_sdk_sys/src/lib.rs index e05c3e8e..0759acae 100644 --- a/ledger_secure_sdk_sys/src/lib.rs +++ b/ledger_secure_sdk_sys/src/lib.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] use core::ffi::c_void; -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] use core::mem::MaybeUninit; pub mod buttons; @@ -35,22 +35,22 @@ pub fn pic_rs_mut(x: &mut T) -> &mut T { unsafe { &mut *ptr } } -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] use critical_section::RawRestoreState; -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] use embedded_alloc::Heap; -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] #[global_allocator] static HEAP: Heap = Heap::empty(); -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] struct CriticalSection; -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] critical_section::set_impl!(CriticalSection); /// Default empty implementation as we don't have concurrency. -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] unsafe impl critical_section::Impl for CriticalSection { unsafe fn acquire() -> RawRestoreState {} unsafe fn release(_restore_state: RawRestoreState) {} @@ -61,7 +61,7 @@ unsafe impl critical_section::Impl for CriticalSection { /// The heap is stored in the stack, and has a fixed size. /// This method is called just before [sample_main]. #[no_mangle] -#[cfg(all(feature = "heap", not(target_os = "nanos")))] +#[cfg(all(feature = "heap"))] extern "C" fn heap_init() { // HEAP_SIZE comes from heap_size.rs, which is defined via env var and build.rs static mut HEAP_MEM: [MaybeUninit; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE]; @@ -69,7 +69,7 @@ extern "C" fn heap_init() { } #[no_mangle] -#[cfg(any(not(feature = "heap"), target_os = "nanos"))] +#[cfg(any(not(feature = "heap")))] extern "C" fn heap_init() {} include!(concat!(env!("OUT_DIR"), "/bindings.rs")); From 38c2ee3336aef300ff8eb62378b1c59664881b13 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Mar 2025 15:07:45 +0100 Subject: [PATCH 118/154] Remove NanoS refs --- ledger_secure_sdk_sys/build.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 05093db5..647565ab 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -360,9 +360,7 @@ impl SDKBuilder<'_> { pub fn build_c_sdk(&self) -> Result<(), SDKBuildError> { // Generate glyphs - if self.device.name != DeviceName::NanoS { - generate_glyphs(&self.device); - } + generate_glyphs(&self.device); let mut command = cc::Build::new(); if env::var_os("CC").is_none() { @@ -741,11 +739,7 @@ fn retrieve_target_file_infos( device: &Device, c_sdk: &Path, ) -> Result<(String, String), SDKBuildError> { - let prefix = if device.name == DeviceName::NanoS { - "".to_string() - } else { - format!("target/{}/", device.name) - }; + let prefix = format!("target/{}/", device.name); let target_file_path = c_sdk.join(format!("{}include/bolos_target.h", prefix)); let target_file = File::open(target_file_path).map_err(|_| SDKBuildError::TargetFileNotFound)?; From bfa16acf8f385fb03d69925ce81e9b8919b40ad4 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Mar 2025 15:29:29 +0100 Subject: [PATCH 119/154] Still NanoS refs to be removed --- ledger_secure_sdk_sys/build.rs | 2 +- ledger_secure_sdk_sys/src/infos.rs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 647565ab..651d49c2 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -322,7 +322,7 @@ impl SDKBuilder<'_> { println!("cargo:rustc-env=API_LEVEL={}", self.api_level); println!("cargo:warning=API_LEVEL is {}", self.api_level); } - None => Err(SDKBuildError::InvalidAPILevel), + None => return Err(SDKBuildError::InvalidAPILevel), } // Export other SDK infos into env for 'infos.rs' diff --git a/ledger_secure_sdk_sys/src/infos.rs b/ledger_secure_sdk_sys/src/infos.rs index f0550a9b..b327cc3e 100644 --- a/ledger_secure_sdk_sys/src/infos.rs +++ b/ledger_secure_sdk_sys/src/infos.rs @@ -17,7 +17,6 @@ macro_rules! const_cstr { }; } -#[cfg(not(target_os = "nanos"))] const fn const_parse_api_level(x: &str) -> u8 { let a = x.as_bytes(); let mut res = a[0] - b'0'; @@ -32,11 +31,9 @@ const fn const_parse_api_level(x: &str) -> u8 { /// Expose the API_LEVEL #[used] -#[cfg(not(target_os = "nanos"))] static API_LEVEL: u8 = const_parse_api_level(env!("API_LEVEL")); // Store metadata in the ELF file -#[cfg(not(target_os = "nanos"))] const_cstr!(ELF_API_LEVEL, "ledger.api_level", env!("API_LEVEL")); const_cstr!(ELF_TARGET, "ledger.target", env!("TARGET")); From 6d62dff81f5818545af84e098f3360867053fc7f Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 7 Mar 2025 15:34:49 +0100 Subject: [PATCH 120/154] Remove Nano S from CI --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afba35fe..7791c5e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanos", "nanox", "nanosplus", "stax", "flex"] + target: ["nanox", "nanosplus", "stax", "flex"] package: [include_gif, testmacro, ledger_secure_sdk_sys, ledger_device_sdk] steps: - name: Print Environment variables @@ -66,7 +66,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanos", "nanox", "nanosplus", "stax", "flex"] + target: ["nanox", "nanosplus", "stax", "flex"] steps: - name: Clone uses: actions/checkout@v4 @@ -95,7 +95,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest strategy: matrix: - target: ["nanos", "nanox", "nanosplus", "stax", "flex"] + target: ["nanox", "nanosplus", "stax", "flex"] steps: - name: Clone uses: actions/checkout@v4 From 762b447b52403402dae45fd889529d58ef0d9ba9 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Mar 2025 11:15:14 +0100 Subject: [PATCH 121/154] Bump versions --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 761d61b4..d09d1084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.21.5" +version = "1.22.0" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.7.2" +version = "1.8.0" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 285b6eb7..8abe20fb 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.21.5" +version = "1.22.0" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.7.2" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.0" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 504fe79a..3ab2654b 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.7.2" +version = "1.8.0" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From 443ed9fbf33a05e466a541c65664c51687379fe5 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 14 Mar 2025 14:31:13 +0100 Subject: [PATCH 122/154] Update after PR review --- Cargo.lock | 2 +- cargo-ledger/Cargo.toml | 2 +- cargo-ledger/README.md | 4 +- cargo-ledger/src/main.rs | 4 -- cargo-ledger/src/setup.rs | 2 +- cargo-ledger/tests/valid/Cargo.toml | 3 - cargo-ledger/tests/valid_outdated/Cargo.toml | 6 +- cargo-ledger/tests/valid_variant/Cargo.toml | 1 - ledger_device_sdk/src/ui/gadgets.rs | 70 +++++++------------- ledger_secure_sdk_sys/README.md | 2 +- 10 files changed, 32 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d09d1084..5366f6af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,7 +127,7 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cargo-ledger" -version = "1.7.0" +version = "1.8.0" dependencies = [ "cargo_metadata", "clap", diff --git a/cargo-ledger/Cargo.toml b/cargo-ledger/Cargo.toml index f05aed9a..d0fdbecb 100644 --- a/cargo-ledger/Cargo.toml +++ b/cargo-ledger/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-ledger" -version = "1.7.0" +version = "1.8.0" authors = ["yhql", "agrojean-ledger", "y333"] description = "Build and sideload Ledger devices apps" categories = ["development-tools::cargo-plugins"] diff --git a/cargo-ledger/README.md b/cargo-ledger/README.md index 3aaf138c..44872ef9 100644 --- a/cargo-ledger/README.md +++ b/cargo-ledger/README.md @@ -50,10 +50,10 @@ cargo ledger build flex 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`) +By default, this program will attempt to build the current program with in `release` mode (full command: `cargo build --release --target=nanosplus --message-format=json`) Arguments can be passed to modify this behaviour after inserting a `--` like so: ``` -cargo ledger build nanos --load -- --features one -Z unstable-options --out-dir ./output/ +cargo ledger build nanosplus --load -- --features one -Z unstable-options --out-dir ./output/ ``` \ No newline at end of file diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs index b03566a4..0b137682 100644 --- a/cargo-ledger/src/main.rs +++ b/cargo-ledger/src/main.rs @@ -356,8 +356,6 @@ mod tests { assert_eq!(metadata_ledger.curve, ["secp256k1"]); assert_eq!(metadata_ledger.flags, "0x38"); assert_eq!(metadata_ledger.path, ["'44/123"]); - - //assert_eq!(metadata_nanos.icon, "./assets/nanos.gif") } #[test] @@ -371,7 +369,6 @@ mod tests { assert_eq!(metadata_ledger.curve, ["secp256k1"]); assert_eq!(metadata_ledger.flags, "0x38"); assert_eq!(metadata_ledger.path, ["'44/123"]); - //assert_eq!(metadata_nanos.icon, "./assets/nanos.gif") } #[test] @@ -385,6 +382,5 @@ mod tests { assert_eq!(metadata_ledger.curve, ["secp256k1"]); assert_eq!(metadata_ledger.flags, "0"); assert_eq!(metadata_ledger.path, ["'44/123"]); - //assert_eq!(metadata_nanos.icon, "nanos.gif") } } diff --git a/cargo-ledger/src/setup.rs b/cargo-ledger/src/setup.rs index 3a7f3807..9f200eac 100644 --- a/cargo-ledger/src/setup.rs +++ b/cargo-ledger/src/setup.rs @@ -39,7 +39,7 @@ pub fn install_targets() { // Retrieve each target file independently // TODO: handle target.json modified upstream - for target in &["nanos", "nanox", "nanosplus", "stax", "flex"] { + for target in &["nanox", "nanosplus", "stax", "flex"] { let outfilepath = sysroot.join(target).join("target.json"); let targetpath = outfilepath.clone().into_os_string().into_string().unwrap(); diff --git a/cargo-ledger/tests/valid/Cargo.toml b/cargo-ledger/tests/valid/Cargo.toml index d75f2633..794a22c8 100644 --- a/cargo-ledger/tests/valid/Cargo.toml +++ b/cargo-ledger/tests/valid/Cargo.toml @@ -12,9 +12,6 @@ curve = ["secp256k1"] flags = "0x38" path = ["'44/123"] -[package.metadata.ledger.nanos] -icon = "./assets/nanos.gif" - [package.metadata.ledger.nanox] icon = "./assets/nanox.gif" diff --git a/cargo-ledger/tests/valid_outdated/Cargo.toml b/cargo-ledger/tests/valid_outdated/Cargo.toml index f661fbb9..d1a0351f 100644 --- a/cargo-ledger/tests/valid_outdated/Cargo.toml +++ b/cargo-ledger/tests/valid_outdated/Cargo.toml @@ -6,11 +6,11 @@ version = "0.0.0" name = "test" path = "" -[package.metadata.nanos] +[package.metadata.ledger] api_level = "1" name = "TestApp" curve = ["secp256k1"] flags = "0" -icon = "nanos.gif" -icon_small = "nanox.gif" +nanosplus.icon = "nanosplus.gif" +nanox.icon = "nanox.gif" path = ["'44/123"] diff --git a/cargo-ledger/tests/valid_variant/Cargo.toml b/cargo-ledger/tests/valid_variant/Cargo.toml index 1c0ff573..84ea359b 100644 --- a/cargo-ledger/tests/valid_variant/Cargo.toml +++ b/cargo-ledger/tests/valid_variant/Cargo.toml @@ -11,6 +11,5 @@ name = "TestApp" curve = ["secp256k1"] flags = "0x38" path = ["'44/123"] -nanos.icon = "./assets/nanos.gif" nanox.icon = "./assets/nanox.gif" nanosplus.icon = "./assets/nanosplus.gif" diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index 27d3f1e8..4c54cc86 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -423,33 +423,20 @@ impl<'a> Page<'a> { self.label.place(Location::Middle, Layout::Centered, true); } PageStyle::PictureNormal => { - let mut icon_x = 16; - let mut icon_y = 8; - if cfg!(target_os = "nanos") { - self.label - .place(Location::Middle, Layout::Custom(41), false); - } else { - icon_x = 57; - icon_y = 10; - self.label - .place(Location::Custom(28), Layout::Centered, false); - } + let icon_x = 57; + let icon_y = 10; + self.label + .place(Location::Custom(28), Layout::Centered, false); if let Some(glyph) = self.glyph { let icon = Icon::from(glyph); icon.set_x(icon_x).set_y(icon_y).display(); } } PageStyle::PictureBold => { - let mut icon_x = 56; - let mut icon_y = 2; - if cfg!(target_os = "nanos") { - self.label[0].place(Location::Bottom, Layout::Centered, true); - } else { - icon_x = 57; - icon_y = 17; - self.label[0].place(Location::Custom(35), Layout::Centered, true); - self.label[1].place(Location::Custom(49), Layout::Centered, true); - } + let icon_x = 57; + let icon_y = 17; + self.label[0].place(Location::Custom(35), Layout::Centered, true); + self.label[1].place(Location::Custom(49), Layout::Centered, true); if let Some(glyph) = self.glyph { let icon = Icon::from(glyph); icon.set_x(icon_x).set_y(icon_y).display(); @@ -457,10 +444,7 @@ impl<'a> Page<'a> { } PageStyle::BoldNormal => { let padding = 1; - let mut max_text_lines = 3; - if cfg!(target_os = "nanos") { - max_text_lines = 1; - } + let max_text_lines = 3; let total_height = (OPEN_SANS[0].height * max_text_lines) as usize + OPEN_SANS[1].height as usize + 2 * padding as usize; @@ -469,29 +453,21 @@ impl<'a> Page<'a> { self.label[0].place(Location::Custom(cur_y), Layout::Centered, true); cur_y += OPEN_SANS[0].height as usize + 2 * padding as usize; - // If the device is a Nano S, display the second label as - // a single line of text - if cfg!(target_os = "nanos") { - self.label[1].place(Location::Custom(cur_y), Layout::Centered, false); - } - // Otherwise, display the second label as up to 3 lines of text - else { - let mut indices = [(0, 0); 3]; - let len = self.label[1].len(); - for (i, indice) in indices.iter_mut().enumerate() { - let start = (i * MAX_CHAR_PER_LINE).min(len); - if start >= len { - break; // Break if we reach the end of the string - } - let end = (start + MAX_CHAR_PER_LINE).min(len); - *indice = (start, end); - (&self.label[1][start..end]).place( - Location::Custom(cur_y), - Layout::Centered, - false, - ); - cur_y += OPEN_SANS[0].height as usize + 2 * padding as usize; + let mut indices = [(0, 0); 3]; + let len = self.label[1].len(); + for (i, indice) in indices.iter_mut().enumerate() { + let start = (i * MAX_CHAR_PER_LINE).min(len); + if start >= len { + break; // Break if we reach the end of the string } + let end = (start + MAX_CHAR_PER_LINE).min(len); + *indice = (start, end); + (&self.label[1][start..end]).place( + Location::Custom(cur_y), + Layout::Centered, + false, + ); + cur_y += OPEN_SANS[0].height as usize + 2 * padding as usize; } } } diff --git a/ledger_secure_sdk_sys/README.md b/ledger_secure_sdk_sys/README.md index 268fd344..bb493ba9 100644 --- a/ledger_secure_sdk_sys/README.md +++ b/ledger_secure_sdk_sys/README.md @@ -5,7 +5,7 @@ Provides access to low-level APIs to the operating system of Ledger devices. ## Build -Depending on the target (`--target nanos`, `--target nanox`, ...), this crate will `git clone` the appropriate branch (`API_LEVEL_x`) of the [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk/) and compile the subset of files necessary for the [Rust SDK](https://github.com/LedgerHQ/ledger-nanos-sdk/) to work. +Depending on the target (`--target nanosplus`, `--target nanox`, ...), this crate will `git clone` the appropriate branch (`API_LEVEL_x`) of the [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk/) and compile the subset of files necessary for the [Rust SDK](https://github.com/LedgerHQ/ledger-device-rust-sdk/) to work. To use an already-cloned C SDK, you can pass its path through the environment variable `LEDGER_SDK_PATH=/path/to/c_sdk` or through `cargo`'s `--config` flag: From 7e816044527e7a90e2eb93931ed77c3b5716ccde Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 17 Mar 2025 10:51:37 +0100 Subject: [PATCH 123/154] Add cargo-ledger in publish CI --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd9a4728..e7939680 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,7 +24,7 @@ jobs: - name: Test Dry-Run Publish for Each Package run: | # Iterate through package names retrieved - PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk" + PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk cargo-ledger" for PACKAGE_NAME in $PACKAGE_NAMES; do # Test a dry-run publish for each package within the workspace if required last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') @@ -60,7 +60,7 @@ jobs: - name: Publish Package on crates.io if required run: | # Iterate through package names retrieved - PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk" + PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk cargo-ledger" for PACKAGE_NAME in $PACKAGE_NAMES; do # Publish each package within the workspace if required last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') From b9ea628a07dbb3ddb69e8ae5ee4d9c9d8d3aa05b Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 18 Mar 2025 10:29:54 +0100 Subject: [PATCH 124/154] Panic if unknown UX event is set --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- ledger_device_sdk/src/uxapp.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5366f6af..c88477ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.0" +version = "1.22.1" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 8abe20fb..c323c246 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.0" +version = "1.22.1" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 6b9f705e..6d110c8d 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -21,7 +21,7 @@ pub enum UxEvent { Keyboard = BOLOS_UX_KEYBOARD, WakeUp = BOLOS_UX_WAKE_UP, ValidatePIN = BOLOS_UX_VALIDATE_PIN, - LastID = BOLOS_UX_LAST_ID, + LastID, } impl UxEvent { @@ -38,7 +38,7 @@ impl UxEvent { Self::ValidatePIN as u8 } - Self::LastID => Self::LastID as u8, + Self::LastID => panic!("Unknown UX Event"), }; os_ux_rs(¶ms); From b44e965db145b5ecb1a02d75296797469bf399fa Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 18 Mar 2025 10:52:46 +0100 Subject: [PATCH 125/154] Update after Copilot PR review --- ledger_device_sdk/src/uxapp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 6d110c8d..83c9057b 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -21,7 +21,7 @@ pub enum UxEvent { Keyboard = BOLOS_UX_KEYBOARD, WakeUp = BOLOS_UX_WAKE_UP, ValidatePIN = BOLOS_UX_VALIDATE_PIN, - LastID, + LastID = BOLOS_UX_VALIDATE_PIN + 1, } impl UxEvent { From 134a3dc32c77b5d0218b0e3aaf741e1c7c359b53 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 21 Mar 2025 09:32:36 +0100 Subject: [PATCH 126/154] Delay lock + better ticker management --- ledger_device_sdk/src/io.rs | 2 +- ledger_device_sdk/src/seph.rs | 7 +++- ledger_device_sdk/src/ui/gadgets.rs | 2 +- ledger_device_sdk/src/uxapp.rs | 61 ++++++++++++++++++----------- ledger_secure_sdk_sys/src/c/src.c | 2 +- 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index a2a27cf7..071d6084 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -397,7 +397,7 @@ impl Comm { seph::Events::BleReceive => ble::receive(&mut self.apdu_buffer, spi_buffer), seph::Events::TickerEvent => { - #[cfg(any(target_os = "stax", target_os = "flex"))] + #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] unsafe { ux_process_ticker_event(); } diff --git a/ledger_device_sdk/src/seph.rs b/ledger_device_sdk/src/seph.rs index b429a0ac..2f902519 100644 --- a/ledger_device_sdk/src/seph.rs +++ b/ledger_device_sdk/src/seph.rs @@ -201,7 +201,12 @@ pub fn handle_event(apdu_buffer: &mut [u8], spi_buffer: &[u8]) { #[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] Events::BleReceive => ble::receive(apdu_buffer, spi_buffer), Events::CAPDUEvent => handle_capdu_event(apdu_buffer, spi_buffer), - Events::TickerEvent => { /* unsafe{ G_io_app.ms += 100; } */ } + Events::TickerEvent => { + #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + unsafe { + ux_process_ticker_event(); + } + } _ => (), } } diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index 4c54cc86..b4a86f00 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -567,7 +567,7 @@ impl<'a> MultiPageMenu<'a> { }, io::Event::Command(ins) => return EventOrPageIndex::Event(io::Event::Command(ins)), io::Event::Ticker => { - if UxEvent::Event.request() != BOLOS_UX_OK { + if UxEvent::Event.request(None) != BOLOS_UX_OK { // pin lock management UxEvent::block_and_get_event::(self.comm); // notify Ticker event only when redisplay is required diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 83c9057b..404a6b24 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -11,8 +11,8 @@ pub use ledger_secure_sdk_sys::BOLOS_UX_IGNORE; pub use ledger_secure_sdk_sys::BOLOS_UX_OK; pub use ledger_secure_sdk_sys::BOLOS_UX_REDRAW; -fn os_ux_rs(params: &bolos_ux_params_t) { - unsafe { os_ux(params as *const bolos_ux_params_t as *mut bolos_ux_params_t) }; +unsafe extern "C" { + pub unsafe static mut G_ux_params: bolos_ux_params_t; } #[repr(u8)] @@ -21,31 +21,46 @@ pub enum UxEvent { Keyboard = BOLOS_UX_KEYBOARD, WakeUp = BOLOS_UX_WAKE_UP, ValidatePIN = BOLOS_UX_VALIDATE_PIN, - LastID = BOLOS_UX_VALIDATE_PIN + 1, + DelayLock = BOLOS_UX_DELAY_LOCK, + LastID = BOLOS_UX_DELAY_LOCK + 1, } impl UxEvent { - pub fn request(&self) -> u32 { - let mut params = bolos_ux_params_t::default(); - params.ux_id = match self { - Self::Event => Self::Event as u8, - Self::Keyboard => Self::Keyboard as u8, - Self::WakeUp => Self::WakeUp as u8, - Self::ValidatePIN => { - // Perform pre-wake up - params.ux_id = Self::WakeUp as u8; - os_ux_rs(¶ms); + #[allow(unused)] + pub fn request(&self, val: Option) -> u32 { + unsafe { + //let mut params = bolos_ux_params_t::default(); + G_ux_params.ux_id = match self { + Self::Event => Self::Event as u8, + Self::Keyboard => Self::Keyboard as u8, + Self::WakeUp => Self::WakeUp as u8, + Self::ValidatePIN => { + // Perform pre-wake up + G_ux_params.ux_id = Self::WakeUp as u8; + os_ux(&raw mut G_ux_params as *mut bolos_ux_params_t); - Self::ValidatePIN as u8 - } - Self::LastID => panic!("Unknown UX Event"), - }; + Self::ValidatePIN as u8 + } + Self::DelayLock => { + #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + { + G_ux_params.u = bolos_ux_params_s__bindgen_ty_1 { + lock_delay: bolos_ux_params_s__bindgen_ty_1__bindgen_ty_3 { + delay_ms: val.unwrap_or(10000), + }, + }; + } + Self::DelayLock as u8 + } + Self::LastID => panic!("Unknown UX Event"), + }; - os_ux_rs(¶ms); + os_ux(&raw mut G_ux_params as *mut bolos_ux_params_t); - match self { - Self::ValidatePIN => Self::block(), - _ => unsafe { os_sched_last_status(TASK_BOLOS_UX as u32) as u32 }, + match self { + Self::ValidatePIN => Self::block(), + _ => os_sched_last_status(TASK_BOLOS_UX as u32) as u32, + } } } @@ -58,7 +73,7 @@ impl UxEvent { let mut spi_buffer = [0u8; 256]; sys_seph::send_general_status(); sys_seph::seph_recv(&mut spi_buffer, 0); - UxEvent::Event.request(); + UxEvent::Event.request(None); } else { unsafe { os_sched_yield(BOLOS_UX_OK as u8) }; } @@ -83,7 +98,7 @@ impl UxEvent { seph::seph_recv(&mut spi_buffer, 0); event = comm.decode_event(&mut spi_buffer); - UxEvent::Event.request(); + UxEvent::Event.request(None); if let Option::Some(Event::Command(_)) = event { return (ret, event); diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index f2da5897..5b7c94d0 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -251,7 +251,7 @@ void c_reset_bss() { memset(bss, 0, bss_len); } -bolos_ux_params_t G_ux_params; +bolos_ux_params_t G_ux_params = {0}; void c_boot_std() { // below is a 'manual' implementation of `io_seproxyhal_init` From b480a3cedd58de4d846abd264723565771b6e723 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 21 Mar 2025 09:52:44 +0100 Subject: [PATCH 127/154] Bump versions --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c88477ea..f72a6af8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.1" +version = "1.22.2" dependencies = [ "const-zero", "include_gif", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.8.0" +version = "1.8.1" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index c323c246..2b1aac38 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.1" +version = "1.22.2" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.0" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.1" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 3ab2654b..f3e09cc4 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.8.0" +version = "1.8.1" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From 2b79ab38f92f75e76233a0dd3e33cac562fc8d4c Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 21 Mar 2025 14:00:31 +0100 Subject: [PATCH 128/154] set delay using struct field (no binding names) --- ledger_device_sdk/src/uxapp.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 404a6b24..01263b45 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -44,12 +44,9 @@ impl UxEvent { Self::DelayLock => { #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] { - G_ux_params.u = bolos_ux_params_s__bindgen_ty_1 { - lock_delay: bolos_ux_params_s__bindgen_ty_1__bindgen_ty_3 { - delay_ms: val.unwrap_or(10000), - }, - }; + G_ux_params.u.lock_delay.delay_ms = val.unwrap_or(10000); } + Self::DelayLock as u8 } Self::LastID => panic!("Unknown UX Event"), From 91144dd423891ebb2121c68a2cf82765417f13c8 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 25 Mar 2025 11:13:04 +0100 Subject: [PATCH 129/154] Set default delay lock duration to 10000ms --- ledger_device_sdk/src/ui/gadgets.rs | 2 +- ledger_device_sdk/src/uxapp.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index b4a86f00..4c54cc86 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -567,7 +567,7 @@ impl<'a> MultiPageMenu<'a> { }, io::Event::Command(ins) => return EventOrPageIndex::Event(io::Event::Command(ins)), io::Event::Ticker => { - if UxEvent::Event.request(None) != BOLOS_UX_OK { + if UxEvent::Event.request() != BOLOS_UX_OK { // pin lock management UxEvent::block_and_get_event::(self.comm); // notify Ticker event only when redisplay is required diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 01263b45..27e57a00 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -27,7 +27,7 @@ pub enum UxEvent { impl UxEvent { #[allow(unused)] - pub fn request(&self, val: Option) -> u32 { + pub fn request(&self) -> u32 { unsafe { //let mut params = bolos_ux_params_t::default(); G_ux_params.ux_id = match self { @@ -44,7 +44,7 @@ impl UxEvent { Self::DelayLock => { #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] { - G_ux_params.u.lock_delay.delay_ms = val.unwrap_or(10000); + G_ux_params.u.lock_delay.delay_ms = 10000; } Self::DelayLock as u8 @@ -70,7 +70,7 @@ impl UxEvent { let mut spi_buffer = [0u8; 256]; sys_seph::send_general_status(); sys_seph::seph_recv(&mut spi_buffer, 0); - UxEvent::Event.request(None); + UxEvent::Event.request(); } else { unsafe { os_sched_yield(BOLOS_UX_OK as u8) }; } @@ -95,7 +95,7 @@ impl UxEvent { seph::seph_recv(&mut spi_buffer, 0); event = comm.decode_event(&mut spi_buffer); - UxEvent::Event.request(None); + UxEvent::Event.request(); if let Option::Some(Event::Command(_)) = event { return (ret, event); From 18f029cefbfcabd1d3a1fa1b4805984de780057b Mon Sep 17 00:00:00 2001 From: tdejoigny-ledger <123755370+tdejoigny-ledger@users.noreply.github.com> Date: Fri, 28 Mar 2025 09:21:42 +0100 Subject: [PATCH 130/154] Update reusable_build_all_apps.yml following docker image switch to debian --- .github/workflows/reusable_build_all_apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index f9c29324..da92e04f 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -78,7 +78,7 @@ jobs: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest steps: - name: Install ledgered - run: pip install ledgered + run: pip install ledgered --break-system-packages - name: Clone SDK uses: actions/checkout@v4 with: From cebfbb9c3e111f6b9e3ff23c639a0ac1fabac12c Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 28 Mar 2025 10:23:29 +0100 Subject: [PATCH 131/154] Foward button event to OS to prevent early pin lock --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- ledger_device_sdk/src/ui/gadgets.rs | 44 +++++++++++++++-------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f72a6af8..1b567337 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.2" +version = "1.22.3" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 2b1aac38..aca65f3e 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.2" +version = "1.22.3" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index 4c54cc86..06420b88 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -538,31 +538,33 @@ impl<'a> MultiPageMenu<'a> { loop { match self.comm.next_event() { - io::Event::Button(button) => match button { - BothButtonsRelease => return EventOrPageIndex::Index(index), - b => { - match b { - LeftButtonRelease => { - if index as i16 - 1 < 0 { - index = self.pages.len() - 1; - } else { - index = index.saturating_sub(1); + io::Event::Button(button) => if UxEvent::Event.request() == BOLOS_UX_OK { + match button { + BothButtonsRelease => return EventOrPageIndex::Index(index), + b => { + match b { + LeftButtonRelease => { + if index as i16 - 1 < 0 { + index = self.pages.len() - 1; + } else { + index = index.saturating_sub(1); + } } - } - RightButtonRelease => { - if index < self.pages.len() - 1 { - index += 1; - } else { - index = 0; + RightButtonRelease => { + if index < self.pages.len() - 1 { + index += 1; + } else { + index = 0; + } } + _ => (), } - _ => (), + clear_screen(); + self.pages[index].place(); + LEFT_ARROW.display(); + RIGHT_ARROW.display(); + crate::ui::screen_util::screen_update(); } - clear_screen(); - self.pages[index].place(); - LEFT_ARROW.display(); - RIGHT_ARROW.display(); - crate::ui::screen_util::screen_update(); } }, io::Event::Command(ins) => return EventOrPageIndex::Event(io::Event::Command(ins)), From c561c4ad254898705d2e76a279f5793b78aa6b5b Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 28 Mar 2025 11:22:44 +0100 Subject: [PATCH 132/154] run cargo fmt --- ledger_device_sdk/src/ui/gadgets.rs | 48 +++++++++++++++-------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index 06420b88..5a1e8066 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -538,35 +538,37 @@ impl<'a> MultiPageMenu<'a> { loop { match self.comm.next_event() { - io::Event::Button(button) => if UxEvent::Event.request() == BOLOS_UX_OK { - match button { - BothButtonsRelease => return EventOrPageIndex::Index(index), - b => { - match b { - LeftButtonRelease => { - if index as i16 - 1 < 0 { - index = self.pages.len() - 1; - } else { - index = index.saturating_sub(1); + io::Event::Button(button) => { + if UxEvent::Event.request() == BOLOS_UX_OK { + match button { + BothButtonsRelease => return EventOrPageIndex::Index(index), + b => { + match b { + LeftButtonRelease => { + if index as i16 - 1 < 0 { + index = self.pages.len() - 1; + } else { + index = index.saturating_sub(1); + } } - } - RightButtonRelease => { - if index < self.pages.len() - 1 { - index += 1; - } else { - index = 0; + RightButtonRelease => { + if index < self.pages.len() - 1 { + index += 1; + } else { + index = 0; + } } + _ => (), } - _ => (), + clear_screen(); + self.pages[index].place(); + LEFT_ARROW.display(); + RIGHT_ARROW.display(); + crate::ui::screen_util::screen_update(); } - clear_screen(); - self.pages[index].place(); - LEFT_ARROW.display(); - RIGHT_ARROW.display(); - crate::ui::screen_util::screen_update(); } } - }, + } io::Event::Command(ins) => return EventOrPageIndex::Event(io::Event::Command(ins)), io::Event::Ticker => { if UxEvent::Event.request() != BOLOS_UX_OK { From 87d2a0be0ab37316a3b7a769b28cf317bc525338 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 14 Apr 2025 15:05:28 +0200 Subject: [PATCH 133/154] When no settings set, pass NULL pointer to C NBGL API --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- .../src/nbgl/nbgl_home_and_settings.rs | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b567337..9adce889 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.3" +version = "1.22.4" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index aca65f3e..2c8d900d 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.3" +version = "1.22.4" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index cd250672..1faa3cd1 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -195,7 +195,7 @@ impl<'a> NbglHomeAndSettings { __bindgen_anon_1: nbgl_genericContents_t__bindgen_ty_1 { contentsList: &self.content as *const nbgl_content_t, }, - nbContents: if self.nb_settings > 0 { 1 } else { 0 }, + nbContents: self.nb_settings, }; self.ux_sync_init(); @@ -207,7 +207,10 @@ impl<'a> NbglHomeAndSettings { PageIndex::Home => INIT_HOME_PAGE as u8, PageIndex::Settings(idx) => idx, }, - &self.generic_contents as *const nbgl_genericContents_t, + match self.nb_settings { + 0 => core::ptr::null(), + _ => &self.generic_contents as *const nbgl_genericContents_t + }, &self.info_list as *const nbgl_contentInfoList_t, core::ptr::null(), Some(quit_callback), @@ -282,7 +285,7 @@ impl<'a> NbglHomeAndSettings { __bindgen_anon_1: nbgl_genericContents_t__bindgen_ty_1 { contentsList: &self.content as *const nbgl_content_t, }, - nbContents: if self.nb_settings > 0 { 1 } else { 0 }, + nbContents: self.nb_settings, }; nbgl_useCaseHomeAndSettings( @@ -293,7 +296,10 @@ impl<'a> NbglHomeAndSettings { PageIndex::Home => INIT_HOME_PAGE as u8, PageIndex::Settings(idx) => idx, }, - &self.generic_contents as *const nbgl_genericContents_t, + match self.nb_settings { + 0 => core::ptr::null(), + _ => &self.generic_contents as *const nbgl_genericContents_t + }, &self.info_list as *const nbgl_contentInfoList_t, core::ptr::null(), Some(quit_cb), From f0f51ece5b6179c0b9ad4639baf4d28abfb61cb3 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 14 Apr 2025 15:09:18 +0200 Subject: [PATCH 134/154] Run cargo fmt --- ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index 1faa3cd1..42906172 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -209,7 +209,7 @@ impl<'a> NbglHomeAndSettings { }, match self.nb_settings { 0 => core::ptr::null(), - _ => &self.generic_contents as *const nbgl_genericContents_t + _ => &self.generic_contents as *const nbgl_genericContents_t, }, &self.info_list as *const nbgl_contentInfoList_t, core::ptr::null(), @@ -298,7 +298,7 @@ impl<'a> NbglHomeAndSettings { }, match self.nb_settings { 0 => core::ptr::null(), - _ => &self.generic_contents as *const nbgl_genericContents_t + _ => &self.generic_contents as *const nbgl_genericContents_t, }, &self.info_list as *const nbgl_contentInfoList_t, core::ptr::null(), From 6f5dca05fc4e4c09ac311db1895b8141107224f0 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Tue, 22 Apr 2025 03:37:44 +0400 Subject: [PATCH 135/154] feat: Add const generic address buffer size to swap params --- ledger_device_sdk/src/libcall/swap.rs | 84 ++++++++++++++++++++------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 8a7265b2..45a54a5f 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -6,12 +6,16 @@ use ledger_secure_sdk_sys::{ libargs_s__bindgen_ty_1, libargs_t, MAX_PRINTABLE_AMOUNT_SIZE, }; +pub const DEFAULT_COIN_CONFIG_BUF_SIZE: usize = 16; +pub const DEFAULT_ADDRESS_BUF_SIZE: usize = 64; + const DPATH_STAGE_SIZE: usize = 16; -const ADDRESS_BUF_SIZE: usize = 64; const AMOUNT_BUF_SIZE: usize = 16; -const DEFAULT_COIN_CONFIG_BUF_SIZE: usize = 16; -pub struct CheckAddressParams { +pub struct CheckAddressParams< + const COIN_CONFIG_BUF_SIZE: usize = DEFAULT_COIN_CONFIG_BUF_SIZE, + const ADDRESS_BUF_SIZE: usize = DEFAULT_ADDRESS_BUF_SIZE, +> { pub coin_config: [u8; COIN_CONFIG_BUF_SIZE], pub coin_config_len: usize, pub dpath: [u8; DPATH_STAGE_SIZE * 4], @@ -21,7 +25,9 @@ pub struct CheckAddressParams Default for CheckAddressParams { +impl Default + for CheckAddressParams +{ fn default() -> Self { CheckAddressParams { coin_config: [0; COIN_CONFIG_BUF_SIZE], @@ -35,7 +41,11 @@ impl Default for CheckAddressParams { +pub struct PrintableAmountParams< + const COIN_CONFIG_BUF_SIZE: usize = DEFAULT_COIN_CONFIG_BUF_SIZE, + // Unused const generic paramer here, to allow type inference in `swap_return` fn + const ADDRESS_BUF_SIZE: usize = DEFAULT_ADDRESS_BUF_SIZE, +> { pub coin_config: [u8; COIN_CONFIG_BUF_SIZE], pub coin_config_len: usize, pub amount: [u8; AMOUNT_BUF_SIZE], @@ -44,7 +54,9 @@ pub struct PrintableAmountParams Default for PrintableAmountParams { +impl Default + for PrintableAmountParams +{ fn default() -> Self { PrintableAmountParams { coin_config: [0; COIN_CONFIG_BUF_SIZE], @@ -57,7 +69,10 @@ impl Default for PrintableAmountParams { +pub struct CreateTxParams< + const COIN_CONFIG_BUF_SIZE: usize = DEFAULT_COIN_CONFIG_BUF_SIZE, + const ADDRESS_BUF_SIZE: usize = DEFAULT_ADDRESS_BUF_SIZE, +> { pub coin_config: [u8; COIN_CONFIG_BUF_SIZE], pub coin_config_len: usize, pub amount: [u8; AMOUNT_BUF_SIZE], @@ -69,7 +84,9 @@ pub struct CreateTxParams Default for CreateTxParams { +impl Default + for CreateTxParams +{ fn default() -> Self { CreateTxParams { coin_config: [0; COIN_CONFIG_BUF_SIZE], @@ -85,9 +102,12 @@ impl Default for CreateTxParams( +pub fn get_check_address_params< + const COIN_CONFIG_BUF_SIZE: usize, + const ADDRESS_BUF_SIZE: usize, +>( arg0: u32, -) -> CheckAddressParams { +) -> CheckAddressParams { debug_print("=> get_check_address_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -103,7 +123,8 @@ pub fn get_check_address_params( let params: check_address_parameters_t = unsafe { *(libarg.__bindgen_anon_1.check_address as *const check_address_parameters_t) }; - let mut check_address_params: CheckAddressParams = Default::default(); + let mut check_address_params: CheckAddressParams = + Default::default(); debug_print("==> GET_COIN_CONFIG_LENGTH\n"); check_address_params.coin_config_len = params.coin_configuration_length as usize; @@ -145,9 +166,12 @@ pub fn get_check_address_params( check_address_params } -pub fn get_printable_amount_params( +pub fn get_printable_amount_params< + const COIN_CONFIG_BUF_SIZE: usize, + const ADDRESS_BUF_SIZE: usize, +>( arg0: u32, -) -> PrintableAmountParams { +) -> PrintableAmountParams { debug_print("=> get_printable_amount_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -164,7 +188,7 @@ pub fn get_printable_amount_params( *(libarg.__bindgen_anon_1.get_printable_amount as *const get_printable_amount_parameters_t) }; - let mut printable_amount_params: PrintableAmountParams = + let mut printable_amount_params: PrintableAmountParams = Default::default(); debug_print("==> GET_COIN_CONFIG_LENGTH\n"); @@ -206,9 +230,9 @@ extern "C" { fn c_boot_std(); } -pub fn sign_tx_params( +pub fn sign_tx_params( arg0: u32, -) -> CreateTxParams { +) -> CreateTxParams { debug_print("=> sign_tx_params\n"); let mut libarg: libargs_t = libargs_t::default(); @@ -225,7 +249,8 @@ pub fn sign_tx_params( *(libarg.__bindgen_anon_1.create_transaction as *const create_transaction_parameters_t) }; - let mut create_tx_params: CreateTxParams = Default::default(); + let mut create_tx_params: CreateTxParams = + Default::default(); debug_print("==> GET_COIN_CONFIG_LENGTH\n"); create_tx_params.coin_config_len = params.coin_configuration_length as usize; @@ -279,13 +304,28 @@ pub fn sign_tx_params( create_tx_params } -pub enum SwapResult<'a> { - CheckAddressResult(&'a mut CheckAddressParams, i32), - PrintableAmountResult(&'a mut PrintableAmountParams, &'a str), - CreateTxResult(&'a mut CreateTxParams, u8), +pub enum SwapResult< + 'a, + const COIN_CONFIG_BUF_SIZE: usize = DEFAULT_COIN_CONFIG_BUF_SIZE, + const ADDRESS_BUF_SIZE: usize = DEFAULT_ADDRESS_BUF_SIZE, +> { + CheckAddressResult( + &'a mut CheckAddressParams, + i32, + ), + PrintableAmountResult( + &'a mut PrintableAmountParams, + &'a str, + ), + CreateTxResult( + &'a mut CreateTxParams, + u8, + ), } -pub fn swap_return(res: SwapResult) { +pub fn swap_return( + res: SwapResult, +) { match res { SwapResult::CheckAddressResult(&mut ref p, r) => { unsafe { *(p.result) = r }; From 296bf0c4a3a0118a7a2b0389d1f42e1fe82bb203 Mon Sep 17 00:00:00 2001 From: Roman Maslennikov Date: Tue, 22 Apr 2025 12:34:53 +0400 Subject: [PATCH 136/154] Bump version --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9adce889..51c95d0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.4" +version = "1.22.5" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 2c8d900d..cf80ac55 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.4" +version = "1.22.5" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 4b3398c898b6d267f4c45a46f8bf8e46e75473ee Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 12 May 2025 10:59:53 +0200 Subject: [PATCH 137/154] Fix nanosp -> nanosplus resolution following ledgered update --- .github/workflows/reusable_build_all_apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index da92e04f..ff6dd075 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -142,6 +142,6 @@ jobs: cargo +$RUST_NIGHTLY update include_gif cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys cargo +$RUST_NIGHTLY update ledger_device_sdk - device=$(echo ${{ matrix.device }} | sed 's/+/plus/') + device=$(echo ${{ matrix.device }} | sed 's/p/plus/') echo "Build for "$device cargo ledger build $device From 15b48d35cbccd7cdc3018dea625d5bebce3e9591 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 12 May 2025 11:10:29 +0200 Subject: [PATCH 138/154] Fix hardcoded nanos+ --- .github/workflows/reusable_build_all_apps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index ff6dd075..3bf323d8 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -71,7 +71,7 @@ jobs: fail-fast: false matrix: app-name: ["app-boilerplate-rust"] - device: ["nanos+", "nanox", "stax", "flex"] + device: ["nanosp", "nanox", "stax", "flex"] include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} runs-on: ubuntu-latest container: From 8b1a3fceb8b23013339d43c3246d3d70705ea483 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 28 Apr 2025 15:19:44 +0200 Subject: [PATCH 139/154] Test if CString is empty before calling C API --- .../src/nbgl/nbgl_address_review.rs | 7 +++++-- ledger_device_sdk/src/nbgl/nbgl_review.rs | 21 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_address_review.rs b/ledger_device_sdk/src/nbgl/nbgl_address_review.rs index 14b03ac2..0df40887 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_address_review.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_address_review.rs @@ -12,7 +12,7 @@ impl SyncNBGL for NbglAddressReview<'_> {} impl<'a> NbglAddressReview<'a> { pub fn new() -> NbglAddressReview<'a> { NbglAddressReview { - verify_str: CString::new("").unwrap(), + verify_str: CString::default(), glyph: None, } } @@ -45,7 +45,10 @@ impl<'a> NbglAddressReview<'a> { address.as_ptr(), core::ptr::null(), &icon as *const nbgl_icon_details_t, - self.verify_str.as_ptr(), + match self.verify_str.is_empty() { + true => core::ptr::null(), + false => self.verify_str.as_ptr() + }, core::ptr::null(), Some(choice_callback), ); diff --git a/ledger_device_sdk/src/nbgl/nbgl_review.rs b/ledger_device_sdk/src/nbgl/nbgl_review.rs index 8c9567b5..cf6ddf2b 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_review.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_review.rs @@ -17,9 +17,9 @@ impl SyncNBGL for NbglReview<'_> {} impl<'a> NbglReview<'a> { pub fn new() -> NbglReview<'a> { NbglReview { - title: CString::new("").unwrap(), - subtitle: CString::new("").unwrap(), - finish_title: CString::new("").unwrap(), + title: CString::default(), + subtitle: CString::default(), + finish_title: CString::default(), glyph: None, tx_type: TransactionType::Transaction, blind: false, @@ -130,9 +130,18 @@ impl<'a> NbglReview<'a> { self.tx_type.to_c_type(false), &tag_value_list as *const nbgl_contentTagValueList_t, &icon as *const nbgl_icon_details_t, - self.title.as_ptr() as *const c_char, - self.subtitle.as_ptr() as *const c_char, - self.finish_title.as_ptr() as *const c_char, + match self.title.is_empty() { + true => core::ptr::null(), + false => self.title.as_ptr() as *const c_char + }, + match self.subtitle.is_empty() { + true => core::ptr::null(), + false => self.subtitle.as_ptr() as *const c_char + }, + match self.finish_title.is_empty() { + true => core::ptr::null(), + false => self.finish_title.as_ptr() as *const c_char + }, Some(choice_callback), ); } From 2dd6a61cdba613469ecc02882fc0ddda131a5bba Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 28 Apr 2025 16:39:44 +0200 Subject: [PATCH 140/154] Run cargo fmt --- ledger_device_sdk/src/nbgl/nbgl_address_review.rs | 2 +- ledger_device_sdk/src/nbgl/nbgl_review.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_address_review.rs b/ledger_device_sdk/src/nbgl/nbgl_address_review.rs index 0df40887..3abe7bfc 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_address_review.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_address_review.rs @@ -47,7 +47,7 @@ impl<'a> NbglAddressReview<'a> { &icon as *const nbgl_icon_details_t, match self.verify_str.is_empty() { true => core::ptr::null(), - false => self.verify_str.as_ptr() + false => self.verify_str.as_ptr(), }, core::ptr::null(), Some(choice_callback), diff --git a/ledger_device_sdk/src/nbgl/nbgl_review.rs b/ledger_device_sdk/src/nbgl/nbgl_review.rs index cf6ddf2b..7a5daa1c 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_review.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_review.rs @@ -132,15 +132,15 @@ impl<'a> NbglReview<'a> { &icon as *const nbgl_icon_details_t, match self.title.is_empty() { true => core::ptr::null(), - false => self.title.as_ptr() as *const c_char + false => self.title.as_ptr() as *const c_char, }, match self.subtitle.is_empty() { true => core::ptr::null(), - false => self.subtitle.as_ptr() as *const c_char + false => self.subtitle.as_ptr() as *const c_char, }, match self.finish_title.is_empty() { true => core::ptr::null(), - false => self.finish_title.as_ptr() as *const c_char + false => self.finish_title.as_ptr() as *const c_char, }, Some(choice_callback), ); From e66af80124f85581c32d207daeb67c4dc23f1c51 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 28 Apr 2025 16:40:19 +0200 Subject: [PATCH 141/154] Bump version --- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51c95d0b..28b90dd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.5" +version = "1.22.6" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index cf80ac55..7f7c564b 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.5" +version = "1.22.6" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 786d983d90d0434d66360f0cf5c995f86e9082f3 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 15 May 2025 15:21:44 +0200 Subject: [PATCH 142/154] revert nanosp->nanos+ --- .github/workflows/reusable_build_all_apps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 3bf323d8..da92e04f 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -71,7 +71,7 @@ jobs: fail-fast: false matrix: app-name: ["app-boilerplate-rust"] - device: ["nanosp", "nanox", "stax", "flex"] + device: ["nanos+", "nanox", "stax", "flex"] include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} runs-on: ubuntu-latest container: @@ -142,6 +142,6 @@ jobs: cargo +$RUST_NIGHTLY update include_gif cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys cargo +$RUST_NIGHTLY update ledger_device_sdk - device=$(echo ${{ matrix.device }} | sed 's/p/plus/') + device=$(echo ${{ matrix.device }} | sed 's/+/plus/') echo "Build for "$device cargo ledger build $device From 024a11dba8c6a5205d93d832d43637ff6ca1e633 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 30 Apr 2025 16:25:48 +0200 Subject: [PATCH 143/154] Enable to use rust-analyzer from the devtools container --- .cargo/config.toml | 6 + Cargo.lock | 238 ----------------------- Cargo.toml | 4 +- cargo-ledger/src/main.rs | 54 +++-- ledger_device_sdk/.cargo/config.toml | 2 +- ledger_secure_sdk_sys/.cargo/config.toml | 2 +- 6 files changed, 43 insertions(+), 263 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..1d55c22e --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,6 @@ +[unstable] +build-std = ["core", "alloc"] +build-std-features = ["compiler-builtins-mem"] + +[build] +target = "flex" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 28b90dd6..541105d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,55 +17,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "anstream" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys", -] - [[package]] name = "autocfg" version = "1.3.0" @@ -125,29 +76,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "cargo-ledger" -version = "1.8.0" -dependencies = [ - "cargo_metadata", - "clap", - "goblin", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "cargo_metadata" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a567c24b86754d629addc2db89e340ac9398d07b5875efcff837e3878e17ec" -dependencies = [ - "semver", - "serde", - "serde_json", -] - [[package]] name = "cc" version = "1.0.98" @@ -180,58 +108,12 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "4.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.66", -] - -[[package]] -name = "clap_lex" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" - [[package]] name = "color_quant" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" -[[package]] -name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - [[package]] name = "const-zero" version = "0.1.1" @@ -370,17 +252,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "goblin" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884" -dependencies = [ - "log", - "plain", - "scroll", -] - [[package]] name = "half" version = "2.4.1" @@ -391,12 +262,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - [[package]] name = "home" version = "0.5.9" @@ -433,18 +298,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - [[package]] name = "jpeg-decoder" version = "0.3.1" @@ -601,12 +454,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - [[package]] name = "png" version = "0.17.13" @@ -731,85 +578,12 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scroll" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "semver" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394cec28fa623e00903caf7ba4fa6fb9a0e260280bb8cdbbba029611108a0190" -dependencies = [ - "semver-parser", - "serde", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - -[[package]] -name = "serde_json" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" -dependencies = [ - "itoa", - "ryu", - "serde", -] - [[package]] name = "shlex" version = "1.3.0" @@ -837,12 +611,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - [[package]] name = "syn" version = "1.0.109" @@ -890,12 +658,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - [[package]] name = "weezl" version = "0.1.8" diff --git a/Cargo.toml b/Cargo.toml index 0eb9c9cb..aad8f4d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,9 +3,9 @@ members = [ "ledger_device_sdk", "ledger_secure_sdk_sys", "include_gif", - "testmacro", - "cargo-ledger" + "testmacro" ] +exclude = ["cargo-ledger"] resolver = "2" [workspace.package] diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs index 0b137682..1e860b73 100644 --- a/cargo-ledger/src/main.rs +++ b/cargo-ledger/src/main.rs @@ -349,38 +349,50 @@ mod tests { #[test] fn valid_metadata() { - let (_, metadata_ledger, metadata_nanos) = - retrieve_metadata(Device::Flex, Some("./tests/valid/Cargo.toml")); - - assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); - assert_eq!(metadata_ledger.curve, ["secp256k1"]); - assert_eq!(metadata_ledger.flags, "0x38"); - assert_eq!(metadata_ledger.path, ["'44/123"]); + match retrieve_metadata(Device::Flex, Some("./tests/valid/Cargo.toml")) { + Ok(res) => { + let (_, metadata_ledger, _metadata_nanos) = res; + assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); + assert_eq!(metadata_ledger.curve, ["secp256k1"]); + assert_eq!(metadata_ledger.flags, Some(String::from("0x38"))); + assert_eq!(metadata_ledger.path, ["'44/123"]); + }, + Err(_) => panic!("Failed to retrieve metadata"), + }; } #[test] fn valid_metadata_variant() { - let (_, metadata_ledger, metadata_nanos) = retrieve_metadata( + match retrieve_metadata( Device::Flex, Some("./tests/valid_variant/Cargo.toml"), - ); - - assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); - assert_eq!(metadata_ledger.curve, ["secp256k1"]); - assert_eq!(metadata_ledger.flags, "0x38"); - assert_eq!(metadata_ledger.path, ["'44/123"]); + ) { + Ok(res) => { + let (_, metadata_ledger, _metadata_nanos) = res; + assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); + assert_eq!(metadata_ledger.curve, ["secp256k1"]); + assert_eq!(metadata_ledger.flags, Some(String::from("0x38"))); + assert_eq!(metadata_ledger.path, ["'44/123"]); + }, + Err(_) => panic!("Failed to retrieve metadata"), + }; } #[test] fn valid_outdated_metadata() { - let (_, metadata_ledger, metadata_nanos) = retrieve_metadata( + + match retrieve_metadata( Device::Flex, Some("./tests/valid_outdated/Cargo.toml"), - ); - - assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); - assert_eq!(metadata_ledger.curve, ["secp256k1"]); - assert_eq!(metadata_ledger.flags, "0"); - assert_eq!(metadata_ledger.path, ["'44/123"]); + ) { + Ok(res) => { + let (_, metadata_ledger, _metadata_nanos) = res; + assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); + assert_eq!(metadata_ledger.curve, ["secp256k1"]); + assert_eq!(metadata_ledger.flags, Some(String::from("0x38"))); + assert_eq!(metadata_ledger.path, ["'44/123"]); + }, + Err(_) => panic!("Failed to retrieve metadata"), + }; } } diff --git a/ledger_device_sdk/.cargo/config.toml b/ledger_device_sdk/.cargo/config.toml index 20c8bf74..bf4bd2e1 100644 --- a/ledger_device_sdk/.cargo/config.toml +++ b/ledger_device_sdk/.cargo/config.toml @@ -15,4 +15,4 @@ build-std = ["core", "alloc"] build-std-features = ["compiler-builtins-mem"] [build] -target = "stax" +target = "flex" diff --git a/ledger_secure_sdk_sys/.cargo/config.toml b/ledger_secure_sdk_sys/.cargo/config.toml index 42dbacd3..e70e544a 100644 --- a/ledger_secure_sdk_sys/.cargo/config.toml +++ b/ledger_secure_sdk_sys/.cargo/config.toml @@ -3,4 +3,4 @@ build-std = ["core"] build-std-features = ["compiler-builtins-mem"] [build] -target = "nanosplus" \ No newline at end of file +target = "flex" \ No newline at end of file From 720e0dbe8f0be4ffa41fb2f0f10d959909578962 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 15 May 2025 13:54:00 +0200 Subject: [PATCH 144/154] Remove cargo-ledger from workspace --- .cargo/config.toml | 5 +- .github/workflows/ci.yml | 37 +- .github/workflows/publish.yml | 4 +- Cargo.toml | 1 - cargo-ledger/.rustfmt.toml | 1 - cargo-ledger/Cargo.toml | 18 - cargo-ledger/LICENSE.md | 201 ---------- cargo-ledger/README.md | 59 --- cargo-ledger/src/main.rs | 398 ------------------- cargo-ledger/src/setup.rs | 96 ----- cargo-ledger/src/utils.rs | 129 ------ cargo-ledger/tests/valid/Cargo.toml | 19 - cargo-ledger/tests/valid_outdated/Cargo.toml | 16 - cargo-ledger/tests/valid_variant/Cargo.toml | 15 - ledger_device_sdk/.cargo/config.toml | 9 +- ledger_secure_sdk_sys/.cargo/config.toml | 6 - rust-toolchain.toml | 2 + 17 files changed, 13 insertions(+), 1003 deletions(-) delete mode 100644 cargo-ledger/.rustfmt.toml delete mode 100644 cargo-ledger/Cargo.toml delete mode 100644 cargo-ledger/LICENSE.md delete mode 100644 cargo-ledger/README.md delete mode 100644 cargo-ledger/src/main.rs delete mode 100644 cargo-ledger/src/setup.rs delete mode 100644 cargo-ledger/src/utils.rs delete mode 100644 cargo-ledger/tests/valid/Cargo.toml delete mode 100644 cargo-ledger/tests/valid_outdated/Cargo.toml delete mode 100644 cargo-ledger/tests/valid_variant/Cargo.toml delete mode 100644 ledger_secure_sdk_sys/.cargo/config.toml create mode 100644 rust-toolchain.toml diff --git a/.cargo/config.toml b/.cargo/config.toml index 1d55c22e..b5f3a40e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,4 +3,7 @@ build-std = ["core", "alloc"] build-std-features = ["compiler-builtins-mem"] [build] -target = "flex" \ No newline at end of file +target = "flex" + +[env] +LEDGER_SDK_PATH="/opt/flex-secure-sdk/" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7791c5e7..ccdb7aa0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,28 +24,12 @@ jobs: target: ["nanox", "nanosplus", "stax", "flex"] package: [include_gif, testmacro, ledger_secure_sdk_sys, ledger_device_sdk] steps: - - name: Print Environment variables - run: - echo "The value of RUST_NIGHTLY is $RUST_NIGHTLY" - name: Clone uses: actions/checkout@v4 - name: Cargo clippy working-directory: ${{ matrix.package }} run: | - cargo +$RUST_NIGHTLY clippy --target ${{ matrix.target }} - - clippy-cargo-ledger: - name: Run static analysis for cargo-ledger - runs-on: ubuntu-latest - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest - steps: - - name: Clone - uses: actions/checkout@v4 - - name: Cargo clippy for cargo-ledger - working-directory: cargo-ledger - run: | - cargo +$RUST_STABLE clippy --no-deps + cargo clippy --target ${{ matrix.target }} format: name: Check code formatting @@ -57,7 +41,7 @@ jobs: uses: actions/checkout@v4 - name: Run cargo fmt run: | - cargo +$RUST_NIGHTLY fmt --all --check + cargo fmt --all --check build: name: Build SDK @@ -73,20 +57,7 @@ jobs: - name: Cargo build working-directory: ledger_device_sdk run: | - cargo +$RUST_NIGHTLY build --target ${{ matrix.target }} - - build-cargo-ledger: - name: Build SDK - runs-on: ubuntu-latest - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest - steps: - - name: Clone - uses: actions/checkout@v4 - - name: Cargo build - working-directory: cargo-ledger - run: | - cargo +$RUST_STABLE build + cargo build --target ${{ matrix.target }} test: name: Run unit and integration tests @@ -102,4 +73,4 @@ jobs: - name: Unit tests working-directory: ledger_device_sdk run: | - cargo +$RUST_NIGHTLY test --target ${{ matrix.target }} --features speculos --tests + cargo test --target ${{ matrix.target }} --features speculos --tests diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e7939680..dd9a4728 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,7 +24,7 @@ jobs: - name: Test Dry-Run Publish for Each Package run: | # Iterate through package names retrieved - PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk cargo-ledger" + PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk" for PACKAGE_NAME in $PACKAGE_NAMES; do # Test a dry-run publish for each package within the workspace if required last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') @@ -60,7 +60,7 @@ jobs: - name: Publish Package on crates.io if required run: | # Iterate through package names retrieved - PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk cargo-ledger" + PACKAGE_NAMES="testmacro include_gif ledger_secure_sdk_sys ledger_device_sdk" for PACKAGE_NAME in $PACKAGE_NAMES; do # Publish each package within the workspace if required last_published_version=$(cargo search -q --limit 1 $PACKAGE_NAME | grep -oP '\d+\.\d+\.\d+') diff --git a/Cargo.toml b/Cargo.toml index aad8f4d0..a5006acc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "include_gif", "testmacro" ] -exclude = ["cargo-ledger"] resolver = "2" [workspace.package] diff --git a/cargo-ledger/.rustfmt.toml b/cargo-ledger/.rustfmt.toml deleted file mode 100644 index df99c691..00000000 --- a/cargo-ledger/.rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -max_width = 80 diff --git a/cargo-ledger/Cargo.toml b/cargo-ledger/Cargo.toml deleted file mode 100644 index d0fdbecb..00000000 --- a/cargo-ledger/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "cargo-ledger" -version = "1.8.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" -readme = "README.md" -license = "Apache-2.0" -edition = "2018" - -[dependencies] -cargo_metadata = "0.11.0" -clap = { version = "4.1.8", features = ["derive"] } -goblin = "0.2.3" -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" diff --git a/cargo-ledger/LICENSE.md b/cargo-ledger/LICENSE.md deleted file mode 100644 index 8dada3ed..00000000 --- a/cargo-ledger/LICENSE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/cargo-ledger/README.md b/cargo-ledger/README.md deleted file mode 100644 index 44872ef9..00000000 --- a/cargo-ledger/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# cargo-ledger -![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fcargo-ledger%2FCargo.toml&query=%24.package.version&label=version) - -Builds a Ledger device embedded app and outputs a JSON/TOML manifest file that can be used by [ledgerctl](https://github.com/LedgerHQ/ledgerctl) to install an application directly on a device. - -In order to build for Nano X, Nano S Plus, Stax and Flex [custom target files](https://docs.rust-embedded.org/embedonomicon/custom-target.html) are used. They can be found at the root of the [ledger_secure_sdk_sys](https://github.com/LedgerHQ/ledger_secure_sdk_sys/) and can be installed automatically with the command `cargo ledger setup`. - -## Installation - -This program requires: - -- `arm-none-eabi-objcopy` -- [`ledgerctl`](https://github.com/LedgerHQ/ledgerctl) - -Install this repo with: - -``` -cargo install --git https://github.com/LedgerHQ/ledger-device-rust-sdk cargo-ledger -``` - -or download it manually and install with: - -``` -cargo install --path cargo-ledger -``` - -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. - -## Usage - -General usage is displayed when invoking `cargo ledger`. - -### Setup - -This will install custom target files from the SDK directly into your environment. - -``` -cargo ledger setup -``` - -### Building - -``` -cargo ledger build nanox -cargo ledger build nanosplus -cargo ledger build stax -cargo ledger build flex -``` - -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=nanosplus --message-format=json`) - -Arguments can be passed to modify this behaviour after inserting a `--` like so: - -``` -cargo ledger build nanosplus --load -- --features one -Z unstable-options --out-dir ./output/ -``` \ No newline at end of file diff --git a/cargo-ledger/src/main.rs b/cargo-ledger/src/main.rs deleted file mode 100644 index 1e860b73..00000000 --- a/cargo-ledger/src/main.rs +++ /dev/null @@ -1,398 +0,0 @@ -use std::fmt::{Display, Formatter}; -use std::fs; -use std::path::PathBuf; -use std::process::Command; -use std::process::Stdio; -use std::str::from_utf8; - -use cargo_metadata::{Message, Package}; -use clap::{Parser, Subcommand, ValueEnum}; -use serde_derive::Deserialize; -use serde_json::json; - -use setup::install_targets; -use utils::*; - -mod setup; -mod utils; - -#[derive(Debug, Deserialize)] -struct LedgerMetadata { - curve: Vec, - path: Vec, - flags: Option, - name: Option, -} - -#[derive(Debug, Deserialize)] -struct DeviceMetadata { - icon: String, - flags: Option, -} - -#[derive(Parser, Debug)] -#[command(name = "cargo")] -#[command(bin_name = "cargo")] -#[clap(name = "Ledger devices build and load commands")] -#[clap(version = "0.0")] -#[clap(about = "Builds the project and emits a JSON manifest for ledgerctl.")] -enum Cli { - Ledger(CliArgs), -} - -#[derive(clap::Args, Debug)] -struct CliArgs { - #[clap(long)] - #[clap(value_name = "prebuilt ELF exe")] - use_prebuilt: Option, - - #[clap(subcommand)] - command: MainCommand, -} - -#[derive(ValueEnum, Clone, Copy, Debug, PartialEq)] -enum Device { - Nanox, - Nanosplus, - Stax, - Flex, -} - -impl Display for Device { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.write_str(self.as_ref()) - } -} - -impl AsRef for Device { - fn as_ref(&self) -> &str { - match self { - Device::Nanox => "nanox", - Device::Nanosplus => "nanosplus", - Device::Stax => "stax", - Device::Flex => "flex", - } - } -} - -#[derive(Subcommand, Debug)] -enum MainCommand { - #[clap(about = "install custom target files")] - Setup, - #[clap(about = "build the project for a given device")] - Build { - #[clap(value_enum)] - #[clap(help = "device to build for")] - device: Device, - #[clap(short, long)] - #[clap(help = "load on a device")] - load: bool, - #[clap(last = true)] - remaining_args: Vec, - }, -} - -fn main() { - let Cli::Ledger(cli) = Cli::parse(); - - match cli.command { - MainCommand::Setup => install_targets(), - MainCommand::Build { - device: d, - load: a, - remaining_args: r, - } => { - build_app(d, a, cli.use_prebuilt, r); - } - } -} - -fn retrieve_metadata( - device: Device, - manifest_path: Option<&str>, -) -> Result<(Package, LedgerMetadata, DeviceMetadata), ()> { - let mut cmd = cargo_metadata::MetadataCommand::new(); - - // Only used during tests - if let Some(manifestpath) = manifest_path { - cmd = cmd.manifest_path(manifestpath).clone(); - } - - let res = cmd - .no_deps() - .exec() - .expect("Could not execute `cargo metadata`"); - - let this_pkg = res.packages.last().unwrap(); - let metadata_section = this_pkg.metadata.get("ledger"); - - if let Some(metadatasection) = metadata_section { - let metadata_device = metadata_section - .unwrap() - .clone() - .get(device.as_ref()) - .unwrap() - .clone(); - - let ledger_metadata: LedgerMetadata = - serde_json::from_value(metadatasection.clone()) - .expect("Could not deserialize medatada.ledger"); - let device_metadata: DeviceMetadata = - serde_json::from_value(metadata_device) - .expect("Could not deserialize device medatada"); - - Ok((this_pkg.clone(), ledger_metadata, device_metadata)) - } else { - println!("No metadata found for device: {}", device); - Err(()) - } -} - -fn build_app( - device: Device, - is_load: bool, - use_prebuilt: Option, - remaining_args: Vec, -) { - let exe_path = match use_prebuilt { - None => { - let c_sdk_path = match device { - Device::Nanosplus => std::env::var("NANOSP_SDK"), - Device::Nanox => std::env::var("NANOX_SDK"), - Device::Stax => std::env::var("STAX_SDK"), - Device::Flex => std::env::var("FLEX_SDK"), - }; - - let mut args: Vec = vec![]; - match std::env::var("RUST_NIGHTLY") { - Ok(version) => { - println!("Use Rust nightly toolchain: {}", version); - args.push(format!("+{}", version)) - } - Err(_) => { - let rustup_cmd = - Command::new("rustup").arg("default").output().unwrap(); - println!( - "Use Rust default toolchain: {}", - from_utf8(rustup_cmd.stdout.as_slice()).unwrap() - ); - } - } - args.push(String::from("build")); - args.push(String::from("--release")); - args.push(format!("--target={}", device.as_ref())); - args.push(String::from( - "--message-format=json-diagnostic-rendered-ansi", - )); - - match std::env::var("LEDGER_SDK_PATH") { - Ok(_) => (), - Err(_) => match c_sdk_path { - Ok(path) => args.push(format!( - "--config=env.LEDGER_SDK_PATH=\"{}\"", - path - )), - Err(_) => println!("C SDK will have to be cloned"), - }, - } - - let mut cargo_cmd = Command::new("cargo") - .args(args) - .args(&remaining_args) - .stdout(Stdio::piped()) - .spawn() - .unwrap(); - - let mut exe_path = PathBuf::new(); - let out = cargo_cmd.stdout.take().unwrap(); - let reader = std::io::BufReader::new(out); - for message in Message::parse_stream(reader) { - match message.as_ref().unwrap() { - Message::CompilerArtifact(artifact) => { - if let Some(n) = &artifact.executable { - exe_path = n.to_path_buf(); - } - } - Message::CompilerMessage(message) => { - println!("{message}"); - } - _ => (), - } - } - - cargo_cmd.wait().expect("Couldn't get cargo's exit status"); - - exe_path - } - Some(prebuilt) => prebuilt.canonicalize().unwrap(), - }; - - let (this_pkg, metadata_ledger, metadata_device) = - retrieve_metadata(device, None).unwrap(); - - let package_path = this_pkg - .manifest_path - .parent() - .expect("Could not find package's parent path"); - - /* exe_path = "exe_parent" + "exe_name" */ - let exe_name = exe_path.file_name().unwrap(); - let exe_parent = exe_path.parent().unwrap(); - - let hex_file_abs = exe_path - .parent() - .unwrap() - .join(exe_name) - .with_extension("hex"); - - let hex_file = hex_file_abs.strip_prefix(exe_parent).unwrap(); - - export_binary(&exe_path, &hex_file_abs); - - // app.json will be placed next to hex file - let app_json_name = format!("app_{}.json", device.as_ref()); - let app_json = exe_parent.join(app_json_name); - - // Retrieve real data size and SDK infos from ELF - let infos = retrieve_infos(&exe_path).unwrap(); - - 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::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("0x000"), - }, - }; - - // Target ID according to target, in case it - // is not present in the retrieved ELF infos. - let backup_targetid: String = match device { - Device::Nanox => String::from("0x33000004"), - Device::Nanosplus => String::from("0x33100004"), - Device::Stax => String::from("0x33200004"), - Device::Flex => String::from("0x33300004"), - }; - - // create manifest - let file = fs::File::create(&app_json).unwrap(); - let mut json = json!({ - "name": metadata_ledger.name.as_ref().unwrap_or(&this_pkg.name), - "version": &this_pkg.version, - "icon": metadata_device.icon, - "targetId": infos.target_id.unwrap_or(backup_targetid), - "flags": flags, - "derivationPath": { - "curves": metadata_ledger.curve, - "paths": metadata_ledger.path - }, - "binary": hex_file, - "dataSize": infos.size - }); - - json["apiLevel"] = infos.api_level.into(); - serde_json::to_writer_pretty(file, &json).unwrap(); - - // Copy icon to the same directory as the app.json - let icon_path = package_path.join(&metadata_device.icon); - let icon_dest = - exe_parent.join(&metadata_device.icon.split('/').last().unwrap()); - - fs::copy(icon_path, icon_dest).unwrap(); - - // Use ledgerctl to dump the APDU installation file. - // Either dump to the location provided by the --out-dir cargo - // argument if provided or use the default binary path. - let output_dir: Option = remaining_args - .iter() - .position(|arg| arg == "--out-dir" || arg.starts_with("--out-dir=")) - .and_then(|index| { - let out_dir_arg = &remaining_args[index]; - // Extracting the value from "--out-dir=" or "--out-dir " - if out_dir_arg.contains('=') { - Some(out_dir_arg.split('=').nth(1).unwrap().to_string()) - } else { - remaining_args - .get(index + 1) - .map(|path_str| path_str.to_string()) - } - }) - .map(PathBuf::from); - let exe_filename = exe_path.file_name().unwrap().to_str(); - let exe_parent = exe_path.parent().unwrap().to_path_buf(); - let apdu_file_path = output_dir - .unwrap_or(exe_parent) - .join(exe_filename.unwrap()) - .with_extension("apdu"); - dump_with_ledgerctl( - package_path, - &app_json, - apdu_file_path.to_str().unwrap(), - ); - - if is_load { - install_with_ledgerctl(package_path, &app_json); - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn valid_metadata() { - match retrieve_metadata(Device::Flex, Some("./tests/valid/Cargo.toml")) { - Ok(res) => { - let (_, metadata_ledger, _metadata_nanos) = res; - assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); - assert_eq!(metadata_ledger.curve, ["secp256k1"]); - assert_eq!(metadata_ledger.flags, Some(String::from("0x38"))); - assert_eq!(metadata_ledger.path, ["'44/123"]); - }, - Err(_) => panic!("Failed to retrieve metadata"), - }; - } - - #[test] - fn valid_metadata_variant() { - match retrieve_metadata( - Device::Flex, - Some("./tests/valid_variant/Cargo.toml"), - ) { - Ok(res) => { - let (_, metadata_ledger, _metadata_nanos) = res; - assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); - assert_eq!(metadata_ledger.curve, ["secp256k1"]); - assert_eq!(metadata_ledger.flags, Some(String::from("0x38"))); - assert_eq!(metadata_ledger.path, ["'44/123"]); - }, - Err(_) => panic!("Failed to retrieve metadata"), - }; - } - - #[test] - fn valid_outdated_metadata() { - - match retrieve_metadata( - Device::Flex, - Some("./tests/valid_outdated/Cargo.toml"), - ) { - Ok(res) => { - let (_, metadata_ledger, _metadata_nanos) = res; - assert_eq!(metadata_ledger.name, Some("TestApp".to_string())); - assert_eq!(metadata_ledger.curve, ["secp256k1"]); - assert_eq!(metadata_ledger.flags, Some(String::from("0x38"))); - assert_eq!(metadata_ledger.path, ["'44/123"]); - }, - Err(_) => panic!("Failed to retrieve metadata"), - }; - } -} diff --git a/cargo-ledger/src/setup.rs b/cargo-ledger/src/setup.rs deleted file mode 100644 index 9f200eac..00000000 --- a/cargo-ledger/src/setup.rs +++ /dev/null @@ -1,96 +0,0 @@ -use std::path::Path; -use std::process::Command; -use std::str::from_utf8; - -pub fn install_targets() { - println!("[ ] Install custom targets..."); - // Check if target files are installed - let mut args: Vec = vec![]; - match std::env::var("RUST_NIGHTLY") { - Ok(version) => { - println!( - "Install custom targets for nightly toolchain: {}", - version - ); - args.push(format!("+{}", version)); - } - Err(_) => { - let rustup_cmd = - Command::new("rustup").arg("default").output().unwrap(); - println!( - "Install custom targets for default toolchain {}", - from_utf8(rustup_cmd.stdout.as_slice()).unwrap() - ); - } - } - args.push(String::from("--print")); - args.push(String::from("sysroot")); - let sysroot_cmd = Command::new("rustc") - .args(&args) - .output() - .expect("failed to call rustc") - .stdout; - let sysroot_cmd = std::str::from_utf8(&sysroot_cmd).unwrap().trim(); - - let target_files_url = Path::new( - "https://raw.githubusercontent.com/LedgerHQ/ledger-device-rust-sdk/refs/tags/ledger_secure_sdk_sys%401.7.0/ledger_secure_sdk_sys" - ); - let sysroot = Path::new(sysroot_cmd).join("lib").join("rustlib"); - - // Retrieve each target file independently - // TODO: handle target.json modified upstream - for target in &["nanox", "nanosplus", "stax", "flex"] { - let outfilepath = sysroot.join(target).join("target.json"); - let targetpath = - outfilepath.clone().into_os_string().into_string().unwrap(); - println!("* Adding \x1b[1;32m{target}\x1b[0m in \x1b[1;33m{targetpath}\x1b[0m"); - - let target_url = target_files_url.join(format!("{target}.json")); - let cmd = Command::new("curl") - .arg(target_url) - .arg("-o") - .arg(outfilepath) - .arg("--create-dirs") - .output() - .expect("failed to execute 'curl'"); - println!("{}", std::str::from_utf8(&cmd.stderr).unwrap()); - } - - // Install link_wrap.sh script needed for relocation - println!("[ ] Install custom link script..."); - - /* Shall be put at the same place as rust-lld */ - let custom_link_script = "link_wrap.sh"; - - let cmd = Command::new("find") - .arg(sysroot_cmd) - .arg("-name") - .arg("rust-lld") - .output() - .expect("failed to find rust-lld linker") - .stdout; - - let rust_lld_path = std::str::from_utf8(&cmd).unwrap(); - let end = rust_lld_path.rfind('/').unwrap(); - - let outfilepath = - sysroot.join(&rust_lld_path[..end]).join(custom_link_script); - - /* Retrieve the linker script */ - let target_url = target_files_url.join(custom_link_script); - Command::new("curl") - .arg(target_url) - .arg("-o") - .arg(&outfilepath) - .output() - .expect("failed to execute 'curl'"); - - println!("* Custom link script is {}", outfilepath.display()); - - /* Make the linker script executable */ - Command::new("chmod") - .arg("+x") - .arg(outfilepath) - .output() - .expect("failed to execute chmod"); -} diff --git a/cargo-ledger/src/utils.rs b/cargo-ledger/src/utils.rs deleted file mode 100644 index de0f8609..00000000 --- a/cargo-ledger/src/utils.rs +++ /dev/null @@ -1,129 +0,0 @@ -use std::env; -use std::fs; -use std::io; -use std::io::Write; -use std::process::Command; - -#[derive(Default, Debug)] -pub struct LedgerAppInfos { - pub api_level: String, - pub target_id: Option, - pub size: u64, -} - -fn get_string_from_offset(vector: &[u8], offset: &usize) -> String { - // Find the end of the string (search for a line feed character) - let end_index = vector[*offset..] - .iter() - .position(|&x| x == b'\n') - .map(|pos| *offset + pos) - .unwrap_or(*offset); // Use the start offset if the delimiter position is not found - String::from_utf8(vector[*offset..end_index].to_vec()) - .expect("Invalid UTF-8") -} - -pub fn retrieve_infos( - file: &std::path::Path, -) -> Result { - let buffer = fs::read(file)?; - let elf = goblin::elf::Elf::parse(&buffer).unwrap(); - - let mut infos = LedgerAppInfos::default(); - - // All infos coming from the SDK are expected to be regrouped - // in various `.ledger.` (rust SDK <= 1.0.0) or - // `ledger. (rust SDK > 1.0.0) section of the binary. - for section in elf.section_headers.iter() { - if let Some(Ok(name)) = elf.shdr_strtab.get(section.sh_name) { - if name == "ledger.api_level" { - // For rust SDK > 1.0.0, the API level is stored as a string (like C SDK) - infos.api_level = get_string_from_offset( - &buffer, - &(section.sh_offset as usize), - ); - } else if name == ".ledger.api_level" { - // For rust SDK <= 1.0.0, the API level is stored as a byte - infos.api_level = - buffer[section.sh_offset as usize].to_string(); - } else if name == "ledger.target_id" { - infos.target_id = Some(get_string_from_offset( - &buffer, - &(section.sh_offset as usize), - )); - } - } - } - - let mut nvram_data = 0; - let mut envram_data = 0; - for s in elf.syms.iter() { - let symbol_name = elf.strtab.get(s.st_name); - let name = symbol_name.unwrap().unwrap(); - match name { - "_nvram_data" => nvram_data = s.st_value, - "_envram_data" => envram_data = s.st_value, - _ => (), - } - } - infos.size = envram_data - nvram_data; - Ok(infos) -} - -pub fn export_binary(elf_path: &std::path::Path, dest_bin: &std::path::Path) { - let objcopy = env::var_os("CARGO_TARGET_THUMBV6M_NONE_EABI_OBJCOPY") - .unwrap_or_else(|| "arm-none-eabi-objcopy".into()); - - Command::new(objcopy) - .arg(elf_path) - .arg(dest_bin) - .args(["-O", "ihex"]) - .output() - .expect("Objcopy failed"); - - let size = env::var_os("CARGO_TARGET_THUMBV6M_NONE_EABI_SIZE") - .unwrap_or_else(|| "arm-none-eabi-size".into()); - - // print some size info while we're here - let out = Command::new(size) - .arg(elf_path) - .output() - .expect("Size failed"); - - io::stdout().write_all(&out.stdout).unwrap(); - io::stderr().write_all(&out.stderr).unwrap(); -} - -pub fn install_with_ledgerctl( - dir: &std::path::Path, - app_json: &std::path::Path, -) { - let out = Command::new("ledgerctl") - .current_dir(dir) - .args(["install", "-f", app_json.to_str().unwrap()]) - .output() - .expect("fail"); - - io::stdout().write_all(&out.stdout).unwrap(); - io::stderr().write_all(&out.stderr).unwrap(); -} - -pub fn dump_with_ledgerctl( - dir: &std::path::Path, - app_json: &std::path::Path, - out_file_name: &str, -) { - let out = Command::new("ledgerctl") - .current_dir(dir) - .args([ - "install", - app_json.to_str().unwrap(), - "-o", - out_file_name, - "-f", - ]) - .output() - .expect("fail"); - - io::stdout().write_all(&out.stdout).unwrap(); - io::stderr().write_all(&out.stderr).unwrap(); -} diff --git a/cargo-ledger/tests/valid/Cargo.toml b/cargo-ledger/tests/valid/Cargo.toml deleted file mode 100644 index 794a22c8..00000000 --- a/cargo-ledger/tests/valid/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "test" -version = "0.0.0" - -[[bin]] -name = "test" -path = "" - -[package.metadata.ledger] -name = "TestApp" -curve = ["secp256k1"] -flags = "0x38" -path = ["'44/123"] - -[package.metadata.ledger.nanox] -icon = "./assets/nanox.gif" - -[package.metadata.ledger.nanosplus] -icon = "./assets/nanosplus.gif" diff --git a/cargo-ledger/tests/valid_outdated/Cargo.toml b/cargo-ledger/tests/valid_outdated/Cargo.toml deleted file mode 100644 index d1a0351f..00000000 --- a/cargo-ledger/tests/valid_outdated/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "test" -version = "0.0.0" - -[[bin]] -name = "test" -path = "" - -[package.metadata.ledger] -api_level = "1" -name = "TestApp" -curve = ["secp256k1"] -flags = "0" -nanosplus.icon = "nanosplus.gif" -nanox.icon = "nanox.gif" -path = ["'44/123"] diff --git a/cargo-ledger/tests/valid_variant/Cargo.toml b/cargo-ledger/tests/valid_variant/Cargo.toml deleted file mode 100644 index 84ea359b..00000000 --- a/cargo-ledger/tests/valid_variant/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "test" -version = "0.0.0" - -[[bin]] -name = "test" -path = "" - -[package.metadata.ledger] -name = "TestApp" -curve = ["secp256k1"] -flags = "0x38" -path = ["'44/123"] -nanox.icon = "./assets/nanox.gif" -nanosplus.icon = "./assets/nanosplus.gif" diff --git a/ledger_device_sdk/.cargo/config.toml b/ledger_device_sdk/.cargo/config.toml index bf4bd2e1..8e953584 100644 --- a/ledger_device_sdk/.cargo/config.toml +++ b/ledger_device_sdk/.cargo/config.toml @@ -8,11 +8,4 @@ runner = "speculos -m nanosp --display=headless" runner = "speculos --model stax --display=headless" [target.flex] -runner = "speculos --model flex --display=headless" - -[unstable] -build-std = ["core", "alloc"] -build-std-features = ["compiler-builtins-mem"] - -[build] -target = "flex" +runner = "speculos --model flex --display=headless" \ No newline at end of file diff --git a/ledger_secure_sdk_sys/.cargo/config.toml b/ledger_secure_sdk_sys/.cargo/config.toml deleted file mode 100644 index e70e544a..00000000 --- a/ledger_secure_sdk_sys/.cargo/config.toml +++ /dev/null @@ -1,6 +0,0 @@ -[unstable] -build-std = ["core"] -build-std-features = ["compiler-builtins-mem"] - -[build] -target = "flex" \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..a9c14142 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly-2024-12-01" \ No newline at end of file From 2aa8a76dc8017d957140f52979bed2aaa4f7e960 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 15 May 2025 16:54:49 +0200 Subject: [PATCH 145/154] Set C SDK path when building sys crate --- .cargo/config.toml | 5 +---- ledger_secure_sdk_sys/build.rs | 40 +++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index b5f3a40e..1d55c22e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,7 +3,4 @@ build-std = ["core", "alloc"] build-std-features = ["compiler-builtins-mem"] [build] -target = "flex" - -[env] -LEDGER_SDK_PATH="/opt/flex-secure-sdk/" \ No newline at end of file +target = "flex" \ No newline at end of file diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 651d49c2..dcf9fd8d 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -132,6 +132,7 @@ enum SDKBuildError { UnsupportedDevice, InvalidAPILevel, MissingSDKName, + MissingSDKPath, TargetFileNotFound, MissingTargetId, MissingTargetName, @@ -186,7 +187,13 @@ impl SDKBuilder<'_> { { "nanosplus" => Device { name: DeviceName::NanoSPlus, - c_sdk: Default::default(), + c_sdk: match env::var("LEDGER_SDK_PATH") { + Ok(path) => PathBuf::from(path), + Err(_) => match env::var("NANOSP_SDK") { + Ok(path) => PathBuf::from(path), + Err(_) => return Err(SDKBuildError::MissingSDKPath), + }, + }, target: "thumbv8m.main-none-eabi", defines: { let mut v = header2define("csdk_nanos2.h"); @@ -209,7 +216,13 @@ impl SDKBuilder<'_> { }, "nanox" => Device { name: DeviceName::NanoX, - c_sdk: Default::default(), + c_sdk: match env::var("LEDGER_SDK_PATH") { + Ok(path) => PathBuf::from(path), + Err(_) => match env::var("NANOX_SDK") { + Ok(path) => PathBuf::from(path), + Err(_) => return Err(SDKBuildError::MissingSDKPath), + }, + }, target: "thumbv6m-none-eabi", defines: { let mut v = header2define("csdk_nanox.h"); @@ -232,7 +245,13 @@ impl SDKBuilder<'_> { }, "stax" => Device { name: DeviceName::Stax, - c_sdk: Default::default(), + c_sdk: match env::var("LEDGER_SDK_PATH") { + Ok(path) => PathBuf::from(path), + Err(_) => match env::var("STAX_SDK") { + Ok(path) => PathBuf::from(path), + Err(_) => return Err(SDKBuildError::MissingSDKPath), + }, + }, target: "thumbv8m.main-none-eabi", defines: header2define("csdk_stax.h"), cflags: Vec::from(CFLAGS_STAX), @@ -242,7 +261,13 @@ impl SDKBuilder<'_> { }, "flex" => Device { name: DeviceName::Flex, - c_sdk: Default::default(), + c_sdk: match env::var("LEDGER_SDK_PATH") { + Ok(path) => PathBuf::from(path), + Err(_) => match env::var("FLEX_SDK") { + Ok(path) => PathBuf::from(path), + Err(_) => return Err(SDKBuildError::MissingSDKPath), + }, + }, target: "thumbv8m.main-none-eabi", defines: header2define("csdk_flex.h"), cflags: Vec::from(CFLAGS_FLEX), @@ -255,12 +280,6 @@ impl SDKBuilder<'_> { } }; - // set the C SDK path - self.device.c_sdk = match env::var("LEDGER_SDK_PATH") { - Err(_) => clone_sdk(&self.device.name), - Ok(path) => PathBuf::from(path), - }; - // set glyphs folders match self.device.name { DeviceName::Flex => { @@ -780,6 +799,7 @@ fn retrieve_target_file_infos( } /// Fetch the appropriate C SDK to build +#[allow(dead_code)] fn clone_sdk(devicename: &DeviceName) -> PathBuf { let (repo_url, sdk_branch) = match devicename { DeviceName::NanoX => ( From d786cd46887c3babb723b9d1cb741015e0ef1612 Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 20 May 2025 06:13:27 +0200 Subject: [PATCH 146/154] RUST_NIGHTLY env variable no more needed --- .github/workflows/build_with_current_nightly.yml | 1 - .github/workflows/reusable_build_all_apps.yml | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_with_current_nightly.yml b/.github/workflows/build_with_current_nightly.yml index 7a829ae5..8d96a86c 100644 --- a/.github/workflows/build_with_current_nightly.yml +++ b/.github/workflows/build_with_current_nightly.yml @@ -32,7 +32,6 @@ jobs: BUILD_DEVICE_NAME="$(echo ${{ matrix.device }})" BIN_DIR_NAME="$(echo ${{ matrix.device }} | sed 's/nanosplus/nanos2/')" cd app-boilerplate - RUST_NIGHTLY=nightly cargo ledger build ${{ matrix.device }} #- name: Upload binary artifacts diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index da92e04f..97c240a4 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -139,9 +139,9 @@ jobs: build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) cd $build_directory # Required as patch has a different version from what is locked in Cargo.lock - cargo +$RUST_NIGHTLY update include_gif - cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys - cargo +$RUST_NIGHTLY update ledger_device_sdk + cargo update include_gif + cargo update ledger_secure_sdk_sys + cargo update ledger_device_sdk device=$(echo ${{ matrix.device }} | sed 's/+/plus/') echo "Build for "$device cargo ledger build $device From f404f5e5be8dbd8adeaf4cb6a56d312f882043bb Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 20 May 2025 06:23:07 +0200 Subject: [PATCH 147/154] Bump SDK version --- Cargo.lock | 4 ++-- ledger_device_sdk/Cargo.toml | 4 ++-- ledger_secure_sdk_sys/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 541105d0..9016940f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,7 +327,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.6" +version = "1.22.7" dependencies = [ "const-zero", "include_gif", @@ -342,7 +342,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.8.1" +version = "1.8.2" dependencies = [ "bindgen", "cc", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 7f7c564b..cdb1513d 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.6" +version = "1.22.7" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false } zeroize = { version = "1.6.0", default-features = false } numtoa = "0.2.4" const-zero = "0.1.1" -ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.1" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.2" } [features] debug = [] diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index f3e09cc4..ba721419 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.8.1" +version = "1.8.2" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true From 08930462a96ab3ae67eac7c68992591e53c98783 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 21 May 2025 15:54:00 +0200 Subject: [PATCH 148/154] refactor setting C SDK path code --- ledger_secure_sdk_sys/build.rs | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index dcf9fd8d..a0cba0fa 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -187,12 +187,11 @@ impl SDKBuilder<'_> { { "nanosplus" => Device { name: DeviceName::NanoSPlus, - c_sdk: match env::var("LEDGER_SDK_PATH") { + c_sdk: match env::var("LEDGER_SDK_PATH") + .or_else(|_| env::var("NANOSP_SDK")) + { Ok(path) => PathBuf::from(path), - Err(_) => match env::var("NANOSP_SDK") { - Ok(path) => PathBuf::from(path), - Err(_) => return Err(SDKBuildError::MissingSDKPath), - }, + Err(_) => return Err(SDKBuildError::MissingSDKPath), }, target: "thumbv8m.main-none-eabi", defines: { @@ -216,12 +215,11 @@ impl SDKBuilder<'_> { }, "nanox" => Device { name: DeviceName::NanoX, - c_sdk: match env::var("LEDGER_SDK_PATH") { + c_sdk: match env::var("LEDGER_SDK_PATH") + .or_else(|_| env::var("NANOX_SDK")) + { Ok(path) => PathBuf::from(path), - Err(_) => match env::var("NANOX_SDK") { - Ok(path) => PathBuf::from(path), - Err(_) => return Err(SDKBuildError::MissingSDKPath), - }, + Err(_) => return Err(SDKBuildError::MissingSDKPath), }, target: "thumbv6m-none-eabi", defines: { @@ -245,12 +243,11 @@ impl SDKBuilder<'_> { }, "stax" => Device { name: DeviceName::Stax, - c_sdk: match env::var("LEDGER_SDK_PATH") { + c_sdk: match env::var("LEDGER_SDK_PATH") + .or_else(|_| env::var("STAX_SDK")) + { Ok(path) => PathBuf::from(path), - Err(_) => match env::var("STAX_SDK") { - Ok(path) => PathBuf::from(path), - Err(_) => return Err(SDKBuildError::MissingSDKPath), - }, + Err(_) => return Err(SDKBuildError::MissingSDKPath), }, target: "thumbv8m.main-none-eabi", defines: header2define("csdk_stax.h"), @@ -261,12 +258,11 @@ impl SDKBuilder<'_> { }, "flex" => Device { name: DeviceName::Flex, - c_sdk: match env::var("LEDGER_SDK_PATH") { + c_sdk: match env::var("LEDGER_SDK_PATH") + .or_else(|_| env::var("FLEX_SDK")) + { Ok(path) => PathBuf::from(path), - Err(_) => match env::var("FLEX_SDK") { - Ok(path) => PathBuf::from(path), - Err(_) => return Err(SDKBuildError::MissingSDKPath), - }, + Err(_) => return Err(SDKBuildError::MissingSDKPath), }, target: "thumbv8m.main-none-eabi", defines: header2define("csdk_flex.h"), From 99b75d432b22105587113a74a9196699a12ef8a2 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 21 May 2025 16:12:50 +0200 Subject: [PATCH 149/154] run cargo fmt --- ledger_secure_sdk_sys/build.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index a0cba0fa..4f263a94 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -187,9 +187,7 @@ impl SDKBuilder<'_> { { "nanosplus" => Device { name: DeviceName::NanoSPlus, - c_sdk: match env::var("LEDGER_SDK_PATH") - .or_else(|_| env::var("NANOSP_SDK")) - { + c_sdk: match env::var("LEDGER_SDK_PATH").or_else(|_| env::var("NANOSP_SDK")) { Ok(path) => PathBuf::from(path), Err(_) => return Err(SDKBuildError::MissingSDKPath), }, @@ -215,9 +213,7 @@ impl SDKBuilder<'_> { }, "nanox" => Device { name: DeviceName::NanoX, - c_sdk: match env::var("LEDGER_SDK_PATH") - .or_else(|_| env::var("NANOX_SDK")) - { + c_sdk: match env::var("LEDGER_SDK_PATH").or_else(|_| env::var("NANOX_SDK")) { Ok(path) => PathBuf::from(path), Err(_) => return Err(SDKBuildError::MissingSDKPath), }, @@ -243,9 +239,7 @@ impl SDKBuilder<'_> { }, "stax" => Device { name: DeviceName::Stax, - c_sdk: match env::var("LEDGER_SDK_PATH") - .or_else(|_| env::var("STAX_SDK")) - { + c_sdk: match env::var("LEDGER_SDK_PATH").or_else(|_| env::var("STAX_SDK")) { Ok(path) => PathBuf::from(path), Err(_) => return Err(SDKBuildError::MissingSDKPath), }, @@ -258,9 +252,7 @@ impl SDKBuilder<'_> { }, "flex" => Device { name: DeviceName::Flex, - c_sdk: match env::var("LEDGER_SDK_PATH") - .or_else(|_| env::var("FLEX_SDK")) - { + c_sdk: match env::var("LEDGER_SDK_PATH").or_else(|_| env::var("FLEX_SDK")) { Ok(path) => PathBuf::from(path), Err(_) => return Err(SDKBuildError::MissingSDKPath), }, From 4378a63f9bcc3731d9c154babc27527cbf6af31c Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 4 Jun 2025 19:11:49 +0200 Subject: [PATCH 150/154] Enable to set a tagline when invoking NbglHomeAndSettings --- .../src/nbgl/nbgl_home_and_settings.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index 42906172..a8400b2d 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -47,6 +47,7 @@ pub enum PageIndex { /// information fields, and settings switches. pub struct NbglHomeAndSettings { app_name: CString, + tag_line: Option, info_contents: Vec, info_contents_ptr: Vec<*const c_char>, setting_contents: Vec<[CString; 2]>, @@ -74,6 +75,7 @@ impl<'a> NbglHomeAndSettings { pub fn new() -> NbglHomeAndSettings { NbglHomeAndSettings { app_name: CString::new("").unwrap(), + tag_line: None, info_contents: Vec::default(), info_contents_ptr: Vec::default(), setting_contents: Vec::default(), @@ -109,6 +111,15 @@ impl<'a> NbglHomeAndSettings { } } + pub fn tagline( + self, + tagline: &'a str) -> NbglHomeAndSettings { + NbglHomeAndSettings { + tag_line: Some(CString::new(tagline).unwrap()), + ..self + } + } + pub fn settings( self, nvm_data: &'a mut AtomicStorage<[u8; SETTINGS_SIZE]>, @@ -202,7 +213,10 @@ impl<'a> NbglHomeAndSettings { nbgl_useCaseHomeAndSettings( self.app_name.as_ptr() as *const c_char, &self.icon as *const nbgl_icon_details_t, - core::ptr::null(), + match self.tag_line { + None => core::ptr::null(), + Some(ref tag) => tag.as_ptr() as *const c_char, + }, match self.start_page { PageIndex::Home => INIT_HOME_PAGE as u8, PageIndex::Settings(idx) => idx, From a03312b0ebbad8cc0a8fd2f77c4f1896bc51143c Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 4 Jun 2025 19:14:34 +0200 Subject: [PATCH 151/154] added in show_and_return() as well --- ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index a8400b2d..bcf670d0 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -305,7 +305,10 @@ impl<'a> NbglHomeAndSettings { nbgl_useCaseHomeAndSettings( self.app_name.as_ptr() as *const c_char, &self.icon as *const nbgl_icon_details_t, - core::ptr::null(), + match self.tag_line { + None => core::ptr::null(), + Some(ref tag) => tag.as_ptr() as *const c_char, + }, match self.start_page { PageIndex::Home => INIT_HOME_PAGE as u8, PageIndex::Settings(idx) => idx, From a8507f07f5702d1750d894b2327d3bc8b444a0ff Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 4 Jun 2025 19:17:23 +0200 Subject: [PATCH 152/154] Run cargo fmt --- ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs index bcf670d0..cc4064c6 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs @@ -111,13 +111,11 @@ impl<'a> NbglHomeAndSettings { } } - pub fn tagline( - self, - tagline: &'a str) -> NbglHomeAndSettings { - NbglHomeAndSettings { - tag_line: Some(CString::new(tagline).unwrap()), - ..self - } + pub fn tagline(self, tagline: &'a str) -> NbglHomeAndSettings { + NbglHomeAndSettings { + tag_line: Some(CString::new(tagline).unwrap()), + ..self + } } pub fn settings( From 533ded5b6c97d2ac064c06f6d21efbdcf8eaa8e6 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 5 Jun 2025 09:11:03 +0200 Subject: [PATCH 153/154] Bump version and filter app-age --- .github/workflows/get_rust_apps.py | 3 ++- Cargo.lock | 2 +- ledger_device_sdk/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/get_rust_apps.py b/.github/workflows/get_rust_apps.py index 34b36bc9..245ceb0a 100644 --- a/.github/workflows/get_rust_apps.py +++ b/.github/workflows/get_rust_apps.py @@ -11,7 +11,8 @@ # Excluded Rust apps # app-kadena-legacy: has been replaced by app-kadena # app-pocket: does not build (Obsidians' Alamgu issue) -excluded_apps = ["app-kadena-legacy", "app-pocket"] +# app-age: not maintained anymore +excluded_apps = ["app-kadena-legacy", "app-pocket", "app-age"] # Retrieve all public apps on LedgerHQ GitHub organization token = sys.argv[1] diff --git a/Cargo.lock b/Cargo.lock index 9016940f..1a176b89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,7 +327,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.22.7" +version = "1.22.8" dependencies = [ "const-zero", "include_gif", diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index cdb1513d..8fad5022 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.22.7" +version = "1.22.8" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true From 37e2dbee3f5c5efb25e874bccb04b3e42ceace90 Mon Sep 17 00:00:00 2001 From: Harrison Chin <2943043+harrychin@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:44:46 -0600 Subject: [PATCH 154/154] Make link-wrap.sh Linux and macOS cross-platform compatible Replace `stat -c %z` with `wc -c <` as the native stat command for macOS doesn't support that option. --- ledger_secure_sdk_sys/link_wrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger_secure_sdk_sys/link_wrap.sh b/ledger_secure_sdk_sys/link_wrap.sh index 31f6cb7e..7decd9e3 100755 --- a/ledger_secure_sdk_sys/link_wrap.sh +++ b/ledger_secure_sdk_sys/link_wrap.sh @@ -28,7 +28,7 @@ llvm-objcopy --dump-section .rel.nvm_data=$OUT-nvm-reloc $OUT /dev/null || true cat $OUT-rodata-reloc $OUT-nvm-reloc $OUT-data-reloc > $OUT-relocs || true reloc_allocated_size="$((0x$(llvm-nm $OUT | grep _reloc_size | cut -d' ' -f1)))" -reloc_real_size="$(stat -c %s $OUT-relocs)" +reloc_real_size="$(wc -c < "$OUT-relocs")" # Check that our relocations _actually_ fit. if [ "$reloc_real_size" -gt "$reloc_allocated_size" ] then