From 5a0fb4729c9fc901357f80219873561ae6da6d6d Mon Sep 17 00:00:00 2001 From: GroM Date: Tue, 14 Jan 2025 10:56:20 +0100 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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();