From 7d256b9cc62ef7260f4518ce04184c84d99da584 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 14 Aug 2025 11:27:01 +0200 Subject: [PATCH 1/4] Add missing llvm-floatabi field in custom target files --- ledger_secure_sdk_sys/devices/apex_p/apex_p.json | 1 + ledger_secure_sdk_sys/devices/flex/flex.json | 1 + ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json | 1 + ledger_secure_sdk_sys/devices/nanox/nanox.json | 1 + ledger_secure_sdk_sys/devices/stax/stax.json | 1 + 5 files changed, 5 insertions(+) diff --git a/ledger_secure_sdk_sys/devices/apex_p/apex_p.json b/ledger_secure_sdk_sys/devices/apex_p/apex_p.json index f4931197..632fe371 100644 --- a/ledger_secure_sdk_sys/devices/apex_p/apex_p.json +++ b/ledger_secure_sdk_sys/devices/apex_p/apex_p.json @@ -9,6 +9,7 @@ "linker": "link_wrap.sh", "linker-flavor": "ld.lld", "llvm-target": "thumbv8m.main-none-eabi", + "llvm-floatabi": "soft", "max-atomic-width": 32, "panic-strategy": "abort", "pre-link-args": { diff --git a/ledger_secure_sdk_sys/devices/flex/flex.json b/ledger_secure_sdk_sys/devices/flex/flex.json index e4039ab9..cb7d49ec 100644 --- a/ledger_secure_sdk_sys/devices/flex/flex.json +++ b/ledger_secure_sdk_sys/devices/flex/flex.json @@ -9,6 +9,7 @@ "linker": "link_wrap.sh", "linker-flavor": "ld.lld", "llvm-target": "thumbv8m.main-none-eabi", + "llvm-floatabi": "soft", "max-atomic-width": 32, "panic-strategy": "abort", "pre-link-args": { diff --git a/ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json b/ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json index 5f3d2030..f54624b6 100644 --- a/ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json +++ b/ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json @@ -9,6 +9,7 @@ "linker": "link_wrap.sh", "linker-flavor": "ld.lld", "llvm-target": "thumbv8m.main-none-eabi", + "llvm-floatabi": "soft", "max-atomic-width": 32, "panic-strategy": "abort", "pre-link-args": { diff --git a/ledger_secure_sdk_sys/devices/nanox/nanox.json b/ledger_secure_sdk_sys/devices/nanox/nanox.json index 245672ec..ef40927c 100644 --- a/ledger_secure_sdk_sys/devices/nanox/nanox.json +++ b/ledger_secure_sdk_sys/devices/nanox/nanox.json @@ -10,6 +10,7 @@ "linker": "link_wrap.sh", "linker-flavor": "ld.lld", "llvm-target": "thumbv6m-none-eabi", + "llvm-floatabi": "soft", "panic-strategy": "abort", "pre-link-args": { "ld.lld": [ diff --git a/ledger_secure_sdk_sys/devices/stax/stax.json b/ledger_secure_sdk_sys/devices/stax/stax.json index 035c1e11..c2e93cd0 100644 --- a/ledger_secure_sdk_sys/devices/stax/stax.json +++ b/ledger_secure_sdk_sys/devices/stax/stax.json @@ -9,6 +9,7 @@ "linker": "link_wrap.sh", "linker-flavor": "ld.lld", "llvm-target": "thumbv8m.main-none-eabi", + "llvm-floatabi": "soft", "max-atomic-width": 32, "panic-strategy": "abort", "pre-link-args": { From 48dd9702e939e9a42d31daa9cdbf02b3810ee274 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 14 Aug 2025 11:28:11 +0200 Subject: [PATCH 2/4] Remove unnecessary_transmutes warnings --- ledger_secure_sdk_sys/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ledger_secure_sdk_sys/src/lib.rs b/ledger_secure_sdk_sys/src/lib.rs index 0759acae..bf64a9c8 100644 --- a/ledger_secure_sdk_sys/src/lib.rs +++ b/ledger_secure_sdk_sys/src/lib.rs @@ -2,6 +2,7 @@ #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] +#![allow(unnecessary_transmutes)] use core::ffi::c_void; #[cfg(all(feature = "heap"))] From 7c13c9aec49a8d0cb4b2185a59b5ba21617ea994 Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 14 Aug 2025 14:18:02 +0200 Subject: [PATCH 3/4] Few fixes --- ledger_device_sdk/src/ecc.rs | 2 +- ledger_device_sdk/src/io.rs | 2 +- ledger_device_sdk/src/libcall/swap.rs | 6 +++--- ledger_device_sdk/src/nbgl/nbgl_review.rs | 4 ++-- ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs | 4 ++-- rust-toolchain.toml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ledger_device_sdk/src/ecc.rs b/ledger_device_sdk/src/ecc.rs index 7730ab16..0976e5ae 100644 --- a/ledger_device_sdk/src/ecc.rs +++ b/ledger_device_sdk/src/ecc.rs @@ -189,7 +189,7 @@ impl ECPrivateKey { /// [here](https://blog.rust-lang.org/inside-rust/2021/09/06/Splitting-const-generics.html#featuregeneric_const_exprs) pub fn public_key(&self) -> Result, CxError> where - [(); Self::P]:, + [(); Self::P]: Sized, { let mut pubkey = ECPublicKey::<{ Self::P }, TY>::new(self.curve); let err = unsafe { diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index deaf0b3d..5c7622d8 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -407,7 +407,7 @@ impl Comm { G_ux_params.u.pairing_request.pairing_info_len = (_len - 2) as u32; for i in 0..G_ux_params.u.pairing_request.pairing_info_len as usize { G_ux_params.u.pairing_request.pairing_info[i as usize] = - seph_buffer[5 + i] as i8; + seph_buffer[5 + i] as u8; } G_ux_params.u.pairing_request.pairing_info [G_ux_params.u.pairing_request.pairing_info_len as usize] = 0; diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index fd77a3cd..6246f04e 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -156,7 +156,7 @@ pub fn get_check_address_params< 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 < ADDRESS_BUF_SIZE { + while c != '\0' as u8 && 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)) }; @@ -224,7 +224,7 @@ pub fn get_printable_amount_params< 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 as *const u8 as *mut i8 }; printable_amount_params @@ -285,7 +285,7 @@ pub fn sign_tx_params 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 < ADDRESS_BUF_SIZE { + while c != '\0' as u8 && 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) }; diff --git a/ledger_device_sdk/src/nbgl/nbgl_review.rs b/ledger_device_sdk/src/nbgl/nbgl_review.rs index 2d454652..a87fb919 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_review.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_review.rs @@ -80,8 +80,8 @@ impl<'a> NbglReview<'a> { let mut tag_value_array: Vec = Vec::new(); for field in v.iter() { let val = nbgl_contentTagValue_t { - item: field.name.as_ptr() as *const i8, - value: field.value.as_ptr() as *const i8, + item: field.name.as_ptr() as *const ::core::ffi::c_char, + value: field.value.as_ptr() as *const ::core::ffi::c_char, ..Default::default() }; tag_value_array.push(val); diff --git a/ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs b/ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs index 6aa9b1d8..beaf7530 100644 --- a/ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs +++ b/ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs @@ -101,8 +101,8 @@ impl NbglStreamingReview { let mut tag_value_array: Vec = Vec::new(); for field in v.iter() { let val = nbgl_contentTagValue_t { - item: field.name.as_ptr() as *const i8, - value: field.value.as_ptr() as *const i8, + item: field.name.as_ptr() as *const ::core::ffi::c_char, + value: field.value.as_ptr() as *const ::core::ffi::c_char, ..Default::default() }; tag_value_array.push(val); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a9c14142..271800cb 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2024-12-01" \ No newline at end of file +channel = "nightly" \ No newline at end of file From 253ffa42ba56427337fcb426cb48d28ef989303f Mon Sep 17 00:00:00 2001 From: GroM Date: Thu, 14 Aug 2025 15:07:30 +0200 Subject: [PATCH 4/4] Fix types --- ledger_device_sdk/src/io.rs | 2 +- ledger_device_sdk/src/libcall/swap.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 5c7622d8..d34c8de9 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -407,7 +407,7 @@ impl Comm { G_ux_params.u.pairing_request.pairing_info_len = (_len - 2) as u32; for i in 0..G_ux_params.u.pairing_request.pairing_info_len as usize { G_ux_params.u.pairing_request.pairing_info[i as usize] = - seph_buffer[5 + i] as u8; + seph_buffer[5 + i] as core::ffi::c_char; } G_ux_params.u.pairing_request.pairing_info [G_ux_params.u.pairing_request.pairing_info_len as usize] = 0; diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 6246f04e..dd849234 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -155,8 +155,8 @@ pub fn get_check_address_params< 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 u8 && address_length < ADDRESS_BUF_SIZE { + let mut c: core::ffi::c_char = unsafe { *(params.address_to_check.add(address_length)) }; + while c != '\0' as core::ffi::c_char && 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)) }; @@ -224,7 +224,7 @@ pub fn get_printable_amount_params< 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 u8 as *mut i8 + .printable_amount as *const core::ffi::c_char as *mut i8 }; printable_amount_params @@ -285,7 +285,7 @@ pub fn sign_tx_params 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 u8 && dest_address_length < ADDRESS_BUF_SIZE { + while c != '\0' as ::core::ffi::c_char && 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) };