Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Y333 161224/migration to updated nightly #226

Merged
merged 7 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build_all_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
branch: 'develop'
- repo: 'app-boilerplate-rust'
branch: 'main'
- repo: 'app-near'
branch: 'develop'

runs-on: ubuntu-latest
container:
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions ledger_device_sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = []
Expand All @@ -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"))']
2 changes: 1 addition & 1 deletion ledger_device_sdk/src/nbgl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ApduHeader>();
if exit_on_apdu && apdu_received {
Expand Down
12 changes: 6 additions & 6 deletions ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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,
},
},
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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,
},
},
Expand Down
36 changes: 19 additions & 17 deletions ledger_device_sdk/src/seph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
},
_ => (),
}
Expand All @@ -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]);
}
}
}
Expand All @@ -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);
}
}
}
Expand All @@ -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]);
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion ledger_secure_sdk_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,3 +18,8 @@ critical-section = { version = "1.1.2", optional = true }

[features]
heap = ["dep:embedded-alloc", "dep:critical-section"]
ccid = []

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))']
15 changes: 4 additions & 11 deletions ledger_secure_sdk_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
yogh333 marked this conversation as resolved.
Show resolved Hide resolved
),
};

Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion ledger_secure_sdk_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>; 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]
Expand Down
Loading