Skip to content

Commit 63c08b1

Browse files
authored
Merge pull request #226 from LedgerHQ/y333_161224/migration_to_updated_nightly
Y333 161224/migration to updated nightly
2 parents 6a607b4 + 5e7bd18 commit 63c08b1

File tree

9 files changed

+48
-42
lines changed

9 files changed

+48
-42
lines changed

.github/workflows/build_all_apps.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
branch: 'develop'
3030
- repo: 'app-boilerplate-rust'
3131
branch: 'main'
32+
- repo: 'app-near'
33+
branch: 'develop'
3234

3335
runs-on: ubuntu-latest
3436
container:

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ledger_device_sdk/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_device_sdk"
3-
version = "1.19.0"
3+
version = "1.19.1"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true
@@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false }
2121
zeroize = { version = "1.6.0", default-features = false }
2222
numtoa = "0.2.4"
2323
const-zero = "0.1.1"
24-
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.0" }
24+
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.6.1" }
2525

2626
[features]
2727
debug = []
@@ -30,3 +30,7 @@ ccid = []
3030
heap = [ "ledger_secure_sdk_sys/heap" ]
3131

3232
default = [ "heap" ]
33+
34+
[lints.rust.unexpected_cfgs]
35+
level = "warn"
36+
check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))']

ledger_device_sdk/src/nbgl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ trait SyncNBGL: Sized {
7979

8080
fn ux_sync_wait(&self, exit_on_apdu: bool) -> SyncNbgl {
8181
unsafe {
82-
if let Some(comm) = COMM_REF.as_mut() {
82+
if let Some(comm) = (*(&raw mut COMM_REF)).as_mut() {
8383
while !G_ENDED {
8484
let apdu_received = comm.next_event_ahead::<ApduHeader>();
8585
if exit_on_apdu && apdu_received {

ledger_device_sdk/src/nbgl/nbgl_home_and_settings.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ unsafe extern "C" fn settings_callback(token: c_int, _index: u8, _page: c_int) {
2020
_ => panic!("Invalid state."),
2121
}
2222

23-
if let Some(data) = NVM_REF.as_mut() {
23+
if let Some(data) = (*(&raw mut NVM_REF)).as_mut() {
2424
let mut switch_values: [u8; SETTINGS_SIZE] = *data.get_ref();
2525
if switch_values[setting_idx] == OFF_STATE {
2626
switch_values[setting_idx] = ON_STATE;
@@ -166,7 +166,7 @@ impl<'a> NbglHomeAndSettings {
166166
for (i, setting) in self.setting_contents.iter().enumerate() {
167167
SWITCH_ARRAY[i].text = setting[0].as_ptr();
168168
SWITCH_ARRAY[i].subText = setting[1].as_ptr();
169-
let state = if let Some(data) = NVM_REF.as_mut() {
169+
let state = if let Some(data) = (*(&raw mut NVM_REF)).as_mut() {
170170
data.get_ref()[i]
171171
} else {
172172
OFF_STATE
@@ -179,7 +179,7 @@ impl<'a> NbglHomeAndSettings {
179179
self.content = nbgl_content_t {
180180
content: nbgl_content_u {
181181
switchesList: nbgl_pageSwitchesList_s {
182-
switches: &SWITCH_ARRAY as *const nbgl_contentSwitch_t,
182+
switches: &raw const SWITCH_ARRAY as *const nbgl_contentSwitch_t,
183183
nbSwitches: self.nb_settings,
184184
},
185185
},
@@ -211,7 +211,7 @@ impl<'a> NbglHomeAndSettings {
211211
);
212212
match self.ux_sync_wait(true) {
213213
SyncNbgl::UxSyncRetApduReceived => {
214-
if let Some(comm) = COMM_REF.as_mut() {
214+
if let Some(comm) = (*(&raw mut COMM_REF)).as_mut() {
215215
if let Some(value) = comm.check_event() {
216216
return value;
217217
}
@@ -250,7 +250,7 @@ impl<'a> NbglHomeAndSettings {
250250
for (i, setting) in self.setting_contents.iter().enumerate() {
251251
SWITCH_ARRAY[i].text = setting[0].as_ptr();
252252
SWITCH_ARRAY[i].subText = setting[1].as_ptr();
253-
let state = if let Some(data) = NVM_REF.as_mut() {
253+
let state = if let Some(data) = (*(&raw mut NVM_REF)).as_mut() {
254254
data.get_ref()[i]
255255
} else {
256256
OFF_STATE
@@ -263,7 +263,7 @@ impl<'a> NbglHomeAndSettings {
263263
self.content = nbgl_content_t {
264264
content: nbgl_content_u {
265265
switchesList: nbgl_pageSwitchesList_s {
266-
switches: &SWITCH_ARRAY as *const nbgl_contentSwitch_t,
266+
switches: &raw const SWITCH_ARRAY as *const nbgl_contentSwitch_t,
267267
nbSwitches: self.nb_settings,
268268
},
269269
},

ledger_device_sdk/src/seph.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ pub fn handle_usb_event(event: u8) {
112112
match Events::from(event) {
113113
Events::USBEventReset => {
114114
unsafe {
115-
USBD_LL_SetSpeed(&mut USBD_Device, 1 /*USBD_SPEED_FULL*/);
116-
USBD_LL_Reset(&mut USBD_Device);
115+
USBD_LL_SetSpeed(&raw mut USBD_Device, 1 /*USBD_SPEED_FULL*/);
116+
USBD_LL_Reset(&raw mut USBD_Device);
117117

118118
if G_io_app.apdu_media != IO_APDU_MEDIA_NONE {
119119
return;
@@ -124,13 +124,13 @@ pub fn handle_usb_event(event: u8) {
124124
}
125125
}
126126
Events::USBEventSOF => unsafe {
127-
USBD_LL_SOF(&mut USBD_Device);
127+
USBD_LL_SOF(&raw mut USBD_Device);
128128
},
129129
Events::USBEventSuspend => unsafe {
130-
USBD_LL_Suspend(&mut USBD_Device);
130+
USBD_LL_Suspend(&raw mut USBD_Device);
131131
},
132132
Events::USBEventResume => unsafe {
133-
USBD_LL_Resume(&mut USBD_Device);
133+
USBD_LL_Resume(&raw mut USBD_Device);
134134
},
135135
_ => (),
136136
}
@@ -140,13 +140,13 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) {
140140
let endpoint = buffer[3] & 0x7f;
141141
match UsbEp::from(buffer[4]) {
142142
UsbEp::USBEpXFERSetup => unsafe {
143-
USBD_LL_SetupStage(&mut USBD_Device, &buffer[6]);
143+
USBD_LL_SetupStage(&raw mut USBD_Device, &buffer[6]);
144144
},
145145
UsbEp::USBEpXFERIn => {
146146
if (endpoint as u32) < IO_USB_MAX_ENDPOINTS {
147147
unsafe {
148148
G_io_app.usb_ep_timeouts[endpoint as usize].timeout = 0;
149-
USBD_LL_DataInStage(&mut USBD_Device, endpoint, &buffer[6]);
149+
USBD_LL_DataInStage(&raw mut USBD_Device, endpoint, &buffer[6]);
150150
}
151151
}
152152
}
@@ -158,7 +158,7 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) {
158158
buf: apdu_buffer.as_mut_ptr(),
159159
len: 260,
160160
};
161-
USBD_LL_DataOutStage(&mut USBD_Device, endpoint, &buffer[6], &mut apdu_buf);
161+
USBD_LL_DataOutStage(&raw mut USBD_Device, endpoint, &buffer[6], &mut apdu_buf);
162162
}
163163
}
164164
}
@@ -167,19 +167,21 @@ pub fn handle_usb_ep_xfer_event(apdu_buffer: &mut [u8], buffer: &[u8]) {
167167
}
168168

169169
pub fn handle_capdu_event(apdu_buffer: &mut [u8], buffer: &[u8]) {
170-
let io_app = unsafe { &mut G_io_app };
171-
if io_app.apdu_state == APDU_IDLE {
172-
let max = (apdu_buffer.len() - 3).min(buffer.len() - 3);
173-
let size = u16::from_be_bytes([buffer[1], buffer[2]]) as usize;
170+
let io_app = &raw mut G_io_app;
171+
unsafe {
172+
if (*io_app).apdu_state == APDU_IDLE {
173+
let max = (apdu_buffer.len() - 3).min(buffer.len() - 3);
174+
let size = u16::from_be_bytes([buffer[1], buffer[2]]) as usize;
174175

175-
io_app.apdu_media = IO_APDU_MEDIA_RAW;
176-
io_app.apdu_state = APDU_RAW;
176+
(*io_app).apdu_media = IO_APDU_MEDIA_RAW;
177+
(*io_app).apdu_state = APDU_RAW;
177178

178-
let len = size.min(max);
179+
let len = size.min(max);
179180

180-
io_app.apdu_length = len as u16;
181+
(*io_app).apdu_length = len as u16;
181182

182-
apdu_buffer[..len].copy_from_slice(&buffer[3..len + 3]);
183+
apdu_buffer[..len].copy_from_slice(&buffer[3..len + 3]);
184+
}
183185
}
184186
}
185187

ledger_secure_sdk_sys/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_secure_sdk_sys"
3-
version = "1.6.0"
3+
version = "1.6.1"
44
authors = ["yhql", "agrojean-ledger", "yogh333"]
55
edition = "2021"
66
license.workspace = true
@@ -18,3 +18,8 @@ critical-section = { version = "1.1.2", optional = true }
1818

1919
[features]
2020
heap = ["dep:embedded-alloc", "dep:critical-section"]
21+
ccid = []
22+
23+
[lints.rust.unexpected_cfgs]
24+
level = "warn"
25+
check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))']

ledger_secure_sdk_sys/build.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,19 @@ fn clone_sdk(device: &Device) -> PathBuf {
216216
),
217217
Device::NanoX => (
218218
Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"),
219-
"API_LEVEL_5",
219+
"API_LEVEL_22",
220220
),
221221
Device::NanoSPlus => (
222222
Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"),
223-
"API_LEVEL_5",
223+
"API_LEVEL_22",
224224
),
225225
Device::Stax => (
226226
Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"),
227-
"API_LEVEL_21",
227+
"API_LEVEL_22",
228228
),
229229
Device::Flex => (
230230
Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"),
231-
"API_LEVEL_21",
231+
"API_LEVEL_22",
232232
),
233233
};
234234

@@ -408,13 +408,6 @@ impl SDKBuilder {
408408
// Let cc::Build determine CC from the environment variable
409409
}
410410

411-
// Test if the file lib_cxng/src/cx_exported_functions.c exists
412-
// If it does, add it to the list of files to compile
413-
let cxng_src = self.bolos_sdk.join("lib_cxng/src/cx_exported_functions.c");
414-
if cxng_src.exists() {
415-
command.file(cxng_src);
416-
}
417-
418411
command
419412
.files(&AUX_C_FILES)
420413
.files(str2path(&self.bolos_sdk, &SDK_C_FILES))

ledger_secure_sdk_sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ unsafe impl critical_section::Impl for CriticalSection {
6565
extern "C" fn heap_init() {
6666
// HEAP_SIZE comes from heap_size.rs, which is defined via env var and build.rs
6767
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
68-
unsafe { HEAP.init(HEAP_MEM.as_ptr() as usize, HEAP_SIZE) }
68+
unsafe { HEAP.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) }
6969
}
7070

7171
#[no_mangle]

0 commit comments

Comments
 (0)