From e8103560501b41bdff2e7d8c393654f66aedc10e Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 31 May 2024 11:07:35 +0200 Subject: [PATCH 1/6] Generate USB drivers bindings automatically --- ledger_device_sdk/src/io.rs | 2 +- ledger_device_sdk/src/seph.rs | 41 ++++++++++++++++++---------------- ledger_secure_sdk_sys/build.rs | 1 + 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index a187bc7e..efc442b2 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -177,7 +177,7 @@ impl Comm { 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); + seph::handle_event(&mut self.apdu_buffer, &mut spi_buffer); } match unsafe { G_io_app.apdu_state } { diff --git a/ledger_device_sdk/src/seph.rs b/ledger_device_sdk/src/seph.rs index b429a0ac..80bb5283 100644 --- a/ledger_device_sdk/src/seph.rs +++ b/ledger_device_sdk/src/seph.rs @@ -67,7 +67,7 @@ impl From for UsbEp { /// FFI bindings to USBD functions inlined here for clarity /// and also because some of the generated ones are incorrectly /// assuming mutable pointers when they are not -#[repr(C)] +/*#[repr(C)] #[derive(Copy, Clone)] pub struct apdu_buffer_s { pub buf: *mut u8, @@ -104,25 +104,23 @@ extern "C" { pub fn USBD_LL_Suspend(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; pub fn USBD_LL_Resume(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; pub fn USBD_LL_SOF(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; -} +}*/ /// Below is a straightforward translation of the corresponding functions /// in the C SDK, they could be improved pub fn handle_usb_event(event: u8) { match Events::from(event) { - Events::USBEventReset => { - unsafe { - 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; - } + Events::USBEventReset => unsafe { + USBD_LL_SetSpeed(&raw mut USBD_Device, USBD_SPEED_FULL); + USBD_LL_Reset(&raw mut USBD_Device); - G_io_app.usb_ep_xfer_len = core::mem::zeroed(); - G_io_app.usb_ep_timeouts = core::mem::zeroed(); + if G_io_app.apdu_media != IO_APDU_MEDIA_NONE { + return; } - } + + G_io_app.usb_ep_xfer_len = core::mem::zeroed(); + G_io_app.usb_ep_timeouts = core::mem::zeroed(); + }, Events::USBEventSOF => unsafe { USBD_LL_SOF(&raw mut USBD_Device); }, @@ -136,17 +134,17 @@ pub fn handle_usb_event(event: u8) { } } -pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) { +pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &mut [u8]) { let endpoint = buffer[3] & 0x7f; match UsbEp::from(buffer[4]) { UsbEp::USBEpXFERSetup => unsafe { - USBD_LL_SetupStage(&raw mut USBD_Device, &buffer[6]); + USBD_LL_SetupStage(&raw mut USBD_Device, &mut 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(&raw mut USBD_Device, endpoint, &buffer[6]); + USBD_LL_DataInStage(&raw mut USBD_Device, endpoint, &mut buffer[6]); } } } @@ -154,11 +152,16 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) { if (endpoint as u32) < IO_USB_MAX_ENDPOINTS { unsafe { G_io_app.usb_ep_xfer_len[endpoint as usize] = buffer[5]; - let mut apdu_buf = ApduBufferT { + let mut apdu_buf = apdu_buffer_s { buf: apdu_buffer.as_mut_ptr(), len: 260, }; - USBD_LL_DataOutStage(&raw mut USBD_Device, endpoint, &buffer[6], &mut apdu_buf); + USBD_LL_DataOutStage( + &raw mut USBD_Device, + endpoint, + &mut buffer[6], + &mut apdu_buf, + ); } } } @@ -185,7 +188,7 @@ pub fn handle_capdu_event(apdu_buffer: &mut [u8], buffer: &[u8]) { } } -pub fn handle_event(apdu_buffer: &mut [u8], spi_buffer: &[u8]) { +pub fn handle_event(apdu_buffer: &mut [u8], spi_buffer: &mut [u8]) { let len = u16::from_be_bytes([spi_buffer[1], spi_buffer[2]]); match Events::from(spi_buffer[0]) { Events::USBEvent => { diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index b2f2eb6d..15a63f35 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -493,6 +493,7 @@ impl SDKBuilder { "include/os_ux.h", "include/ox.h", /* crypto-related syscalls */ "lib_stusb/STM32_USB_Device_Library/Core/Inc/usbd_def.h", + "lib_stusb/STM32_USB_Device_Library/Core/Inc/usbd_core.h", "include/os_io_usb.h", "lib_standard_app/swap_lib_calls.h", ], From 0eaea05783ebb766347bf2641389b56e931b9512 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 31 May 2024 11:11:37 +0200 Subject: [PATCH 2/6] Delete commented out lines --- ledger_device_sdk/src/seph.rs | 42 ----------------------------------- 1 file changed, 42 deletions(-) diff --git a/ledger_device_sdk/src/seph.rs b/ledger_device_sdk/src/seph.rs index 80bb5283..73acab8e 100644 --- a/ledger_device_sdk/src/seph.rs +++ b/ledger_device_sdk/src/seph.rs @@ -64,48 +64,6 @@ impl From for UsbEp { } } -/// FFI bindings to USBD functions inlined here for clarity -/// and also because some of the generated ones are incorrectly -/// assuming mutable pointers when they are not -/*#[repr(C)] -#[derive(Copy, Clone)] -pub struct apdu_buffer_s { - pub buf: *mut u8, - pub len: u16, -} -impl Default for apdu_buffer_s { - fn default() -> Self { - unsafe { ::core::mem::zeroed() } - } -} -pub type ApduBufferT = apdu_buffer_s; -extern "C" { - pub static mut USBD_Device: USBD_HandleTypeDef; - pub fn USBD_LL_SetupStage( - pdev: *mut USBD_HandleTypeDef, - psetup: *const u8, - ) -> USBD_StatusTypeDef; - pub fn USBD_LL_DataOutStage( - pdev: *mut USBD_HandleTypeDef, - epnum: u8, - pdata: *const u8, - arg1: *mut ApduBufferT, - ) -> USBD_StatusTypeDef; - pub fn USBD_LL_DataInStage( - pdev: *mut USBD_HandleTypeDef, - epnum: u8, - pdata: *const u8, - ) -> USBD_StatusTypeDef; - pub fn USBD_LL_Reset(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; - pub fn USBD_LL_SetSpeed( - pdev: *mut USBD_HandleTypeDef, - speed: USBD_SpeedTypeDef, - ) -> USBD_StatusTypeDef; - pub fn USBD_LL_Suspend(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; - pub fn USBD_LL_Resume(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; - pub fn USBD_LL_SOF(pdev: *mut USBD_HandleTypeDef) -> USBD_StatusTypeDef; -}*/ - /// Below is a straightforward translation of the corresponding functions /// in the C SDK, they could be improved pub fn handle_usb_event(event: u8) { From a68cc44eff74b6b456d049dc7b0e26370b61134e Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 17 Jan 2025 16:20:12 +0100 Subject: [PATCH 3/6] fix mutability --- 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 efc442b2..01dcd3c8 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -208,7 +208,7 @@ impl Comm { sys_seph::send_general_status() } sys_seph::seph_recv(&mut spi_buffer, 0); - seph::handle_event(&mut self.apdu_buffer, &spi_buffer); + seph::handle_event(&mut self.apdu_buffer, &mut spi_buffer); } self.tx = 0; self.rx = 0; From d2001a63a7b859a2b64ae7de681343eb48b51455 Mon Sep 17 00:00:00 2001 From: GroM Date: Fri, 17 Jan 2025 17:00:32 +0100 Subject: [PATCH 4/6] Bump bindgen and cc versions --- Cargo.lock | 105 ++++++------------------------- ledger_secure_sdk_sys/Cargo.toml | 4 +- ledger_secure_sdk_sys/build.rs | 2 +- 3 files changed, 23 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e65fdd0..f2696adf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,17 +74,15 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bindgen" -version = "0.65.1" +version = "0.71.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" +checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "cexpr", "clang-sys", - "lazy_static", - "lazycell", + "itertools", "log", - "peeking_take_while", "prettyplease", "proc-macro2", "quote", @@ -92,7 +90,6 @@ dependencies = [ "rustc-hash", "shlex", "syn 2.0.66", - "which", ] [[package]] @@ -150,9 +147,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +dependencies = [ + "shlex", +] [[package]] name = "cexpr" @@ -300,16 +300,6 @@ dependencies = [ "linked_list_allocator", ] -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys", -] - [[package]] name = "exr" version = "1.72.0" @@ -397,15 +387,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys", -] - [[package]] name = "image" version = "0.24.9" @@ -439,6 +420,15 @@ version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -454,18 +444,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "lebe" version = "0.5.2" @@ -520,12 +498,6 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - [[package]] name = "lock_api" version = "0.4.12" @@ -589,18 +561,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "plain" version = "0.2.3" @@ -714,22 +674,9 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustix" -version = "0.38.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" -dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "ryu" @@ -902,18 +849,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 378e37a8..eb5c0c23 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -8,8 +8,8 @@ repository.workspace = true description = "Bindings to Ledger C SDK" [build-dependencies] -bindgen = "0.65.1" -cc = "1.0.73" +bindgen = "0.71.1" +cc = "1.2.10" glob = "0.3.1" [dependencies] diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 15a63f35..59f9bab5 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -580,7 +580,7 @@ impl SDKBuilder { } let bindings = bindings - .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() .expect("Unable to generate bindings"); From 5151916e545ae1d1eaab1389a187a8e100f13a1d Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 20 Jan 2025 11:18:37 +0100 Subject: [PATCH 5/6] Update sys crate dependencies --- Cargo.lock | 53 +++++++++++++++++++++++++++++--- ledger_secure_sdk_sys/Cargo.toml | 4 +-- ledger_secure_sdk_sys/src/lib.rs | 2 +- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2696adf..ebcbec16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,6 +72,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "bindgen" version = "0.71.1" @@ -232,6 +238,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "const-default" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa" + [[package]] name = "const-zero" version = "0.1.1" @@ -249,9 +261,9 @@ dependencies = [ [[package]] name = "critical-section" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "crossbeam-deque" @@ -292,12 +304,14 @@ checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "embedded-alloc" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddae17915accbac2cfbc64ea0ae6e3b330e6ea124ba108dada63646fd3c6f815" +checksum = "8f2de9133f68db0d4627ad69db767726c99ff8585272716708227008d3f1bddd" dependencies = [ + "const-default", "critical-section", "linked_list_allocator", + "rlsf", ] [[package]] @@ -672,6 +686,18 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "rlsf" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222fb240c3286247ecdee6fa5341e7cdad0ffdf8e7e401d9937f2d58482a20bf" +dependencies = [ + "cfg-if", + "const-default", + "libc", + "svgbobdoc", +] + [[package]] name = "rustc-hash" version = "2.1.0" @@ -790,6 +816,19 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "svgbobdoc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c04b93fc15d79b39c63218f15e3fdffaa4c227830686e3b7c5f41244eb3e50" +dependencies = [ + "base64", + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-width", +] + [[package]] name = "syn" version = "1.0.109" @@ -837,6 +876,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "utf8parse" version = "0.2.1" diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index eb5c0c23..222323b8 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -13,8 +13,8 @@ cc = "1.2.10" glob = "0.3.1" [dependencies] -embedded-alloc = { version = "0.5.1", optional = true } -critical-section = { version = "1.1.2", optional = true } +embedded-alloc = { version = "0.6.0", optional = true, features = ["llff"] } +critical-section = { version = "1.2.0", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] diff --git a/ledger_secure_sdk_sys/src/lib.rs b/ledger_secure_sdk_sys/src/lib.rs index e05c3e8e..95d845eb 100644 --- a/ledger_secure_sdk_sys/src/lib.rs +++ b/ledger_secure_sdk_sys/src/lib.rs @@ -38,7 +38,7 @@ pub fn pic_rs_mut(x: &mut T) -> &mut T { #[cfg(all(feature = "heap", not(target_os = "nanos")))] use critical_section::RawRestoreState; #[cfg(all(feature = "heap", not(target_os = "nanos")))] -use embedded_alloc::Heap; +use embedded_alloc::LlffHeap as Heap; #[cfg(all(feature = "heap", not(target_os = "nanos")))] #[global_allocator] From 3987ac9e62f3667aa8286c75de52e1f25ad73bc8 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 20 Jan 2025 11:43:08 +0100 Subject: [PATCH 6/6] revert dependencies bump in sys crate --- Cargo.lock | 154 +++++++++++++++++-------------- ledger_secure_sdk_sys/Cargo.toml | 8 +- ledger_secure_sdk_sys/build.rs | 2 +- ledger_secure_sdk_sys/src/lib.rs | 2 +- 4 files changed, 93 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebcbec16..1e65fdd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,23 +72,19 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "bindgen" -version = "0.71.1" +version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags 2.5.0", + "bitflags 1.3.2", "cexpr", "clang-sys", - "itertools", + "lazy_static", + "lazycell", "log", + "peeking_take_while", "prettyplease", "proc-macro2", "quote", @@ -96,6 +92,7 @@ dependencies = [ "rustc-hash", "shlex", "syn 2.0.66", + "which", ] [[package]] @@ -153,12 +150,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.10" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" -dependencies = [ - "shlex", -] +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cexpr" @@ -238,12 +232,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" -[[package]] -name = "const-default" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa" - [[package]] name = "const-zero" version = "0.1.1" @@ -261,9 +249,9 @@ dependencies = [ [[package]] name = "critical-section" -version = "1.2.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" [[package]] name = "crossbeam-deque" @@ -304,14 +292,22 @@ checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "embedded-alloc" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f2de9133f68db0d4627ad69db767726c99ff8585272716708227008d3f1bddd" +checksum = "ddae17915accbac2cfbc64ea0ae6e3b330e6ea124ba108dada63646fd3c6f815" dependencies = [ - "const-default", "critical-section", "linked_list_allocator", - "rlsf", +] + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", ] [[package]] @@ -401,6 +397,15 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + [[package]] name = "image" version = "0.24.9" @@ -434,15 +439,6 @@ version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -458,6 +454,18 @@ dependencies = [ "rayon", ] +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "lebe" version = "0.5.2" @@ -512,6 +520,12 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "lock_api" version = "0.4.12" @@ -575,6 +589,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "plain" version = "0.2.3" @@ -687,22 +713,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] -name = "rlsf" -version = "0.2.1" +name = "rustc-hash" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222fb240c3286247ecdee6fa5341e7cdad0ffdf8e7e401d9937f2d58482a20bf" -dependencies = [ - "cfg-if", - "const-default", - "libc", - "svgbobdoc", -] +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] -name = "rustc-hash" -version = "2.1.0" +name = "rustix" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] [[package]] name = "ryu" @@ -816,19 +843,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "svgbobdoc" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c04b93fc15d79b39c63218f15e3fdffaa4c227830686e3b7c5f41244eb3e50" -dependencies = [ - "base64", - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-width", -] - [[package]] name = "syn" version = "1.0.109" @@ -876,12 +890,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "utf8parse" version = "0.2.1" @@ -894,6 +902,18 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "windows-sys" version = "0.52.0" diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 222323b8..378e37a8 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -8,13 +8,13 @@ repository.workspace = true description = "Bindings to Ledger C SDK" [build-dependencies] -bindgen = "0.71.1" -cc = "1.2.10" +bindgen = "0.65.1" +cc = "1.0.73" glob = "0.3.1" [dependencies] -embedded-alloc = { version = "0.6.0", optional = true, features = ["llff"] } -critical-section = { version = "1.2.0", optional = true } +embedded-alloc = { version = "0.5.1", optional = true } +critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 59f9bab5..15a63f35 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -580,7 +580,7 @@ impl SDKBuilder { } let bindings = bindings - .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .generate() .expect("Unable to generate bindings"); diff --git a/ledger_secure_sdk_sys/src/lib.rs b/ledger_secure_sdk_sys/src/lib.rs index 95d845eb..e05c3e8e 100644 --- a/ledger_secure_sdk_sys/src/lib.rs +++ b/ledger_secure_sdk_sys/src/lib.rs @@ -38,7 +38,7 @@ pub fn pic_rs_mut(x: &mut T) -> &mut T { #[cfg(all(feature = "heap", not(target_os = "nanos")))] use critical_section::RawRestoreState; #[cfg(all(feature = "heap", not(target_os = "nanos")))] -use embedded_alloc::LlffHeap as Heap; +use embedded_alloc::Heap; #[cfg(all(feature = "heap", not(target_os = "nanos")))] #[global_allocator]