Skip to content

Commit 8d19e15

Browse files
authored
Merge pull request #191 from LedgerHQ/y333/activate_bluetooth_stax
Y333/activate bluetooth for Stax & Flex
2 parents 90590db + 159faa6 commit 8d19e15

File tree

9 files changed

+94
-36
lines changed

9 files changed

+94
-36
lines changed

Cargo.lock

Lines changed: 2 additions & 2 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: 2 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.16.1"
3+
version = "1.17.0"
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.4.7" }
24+
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.5.0" }
2525

2626
[features]
2727
speculos = []

ledger_device_sdk/src/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(target_os = "nanox")]
1+
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
22
use crate::ble;
33
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
44
use ledger_secure_sdk_sys::buttons::{get_button_event, ButtonEvent, ButtonsState};
@@ -196,7 +196,7 @@ impl Comm {
196196
APDU_USB_CCID => {
197197
ccid::send(&self.apdu_buffer[..self.tx]);
198198
}
199-
#[cfg(target_os = "nanox")]
199+
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
200200
APDU_BLE => {
201201
ble::send(&self.apdu_buffer[..self.tx]);
202202
}
@@ -387,7 +387,7 @@ impl Comm {
387387
}
388388
seph::Events::CAPDUEvent => seph::handle_capdu_event(&mut self.apdu_buffer, spi_buffer),
389389

390-
#[cfg(target_os = "nanox")]
390+
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
391391
seph::Events::BleReceive => ble::receive(&mut self.apdu_buffer, spi_buffer),
392392

393393
seph::Events::TickerEvent => {

ledger_device_sdk/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#![feature(generic_const_exprs)]
88
#![feature(cfg_version)]
99

10-
#[cfg(target_os = "nanox")]
10+
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
1111
pub mod ble;
1212

1313
#[cfg(feature = "ccid")]

ledger_secure_sdk_sys/Cargo.toml

Lines changed: 1 addition & 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.4.7"
3+
version = "1.5.0"
44
authors = ["yhql", "agrojean-ledger"]
55
edition = "2021"
66
license.workspace = true

ledger_secure_sdk_sys/build.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@ impl SDKBuilder {
570570
.to_str()
571571
.unwrap(),
572572
)
573+
.header(
574+
self.bolos_sdk
575+
.join("lib_blewbxx_impl/include/ledger_ble.h")
576+
.to_str()
577+
.unwrap(),
578+
)
573579
}
574580
_ => (),
575581
}
@@ -716,6 +722,19 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) {
716722

717723
command
718724
.target("thumbv8m.main-none-eabi")
725+
.file(bolos_sdk.join("src/ledger_protocol.c"))
726+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c"))
727+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c"))
728+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c"))
729+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c"))
730+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c"))
731+
.file(bolos_sdk.join("lib_blewbxx/core/template/osal.c"))
732+
.file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c"))
733+
.include(bolos_sdk.join("lib_blewbxx/include"))
734+
.include(bolos_sdk.join("lib_blewbxx/core"))
735+
.include(bolos_sdk.join("lib_blewbxx/core/auto"))
736+
.include(bolos_sdk.join("lib_blewbxx/core/template"))
737+
.include(bolos_sdk.join("lib_blewbxx_impl/include"))
719738
.include(bolos_sdk.join("target/stax/include/"))
720739
.flag("-fropi")
721740
.flag("-frwpi")
@@ -732,6 +751,19 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) {
732751

733752
command
734753
.target("thumbv8m.main-none-eabi")
754+
.file(bolos_sdk.join("src/ledger_protocol.c"))
755+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c"))
756+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c"))
757+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c"))
758+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c"))
759+
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c"))
760+
.file(bolos_sdk.join("lib_blewbxx/core/template/osal.c"))
761+
.file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c"))
762+
.include(bolos_sdk.join("lib_blewbxx/include"))
763+
.include(bolos_sdk.join("lib_blewbxx/core"))
764+
.include(bolos_sdk.join("lib_blewbxx/core/auto"))
765+
.include(bolos_sdk.join("lib_blewbxx/core/template"))
766+
.include(bolos_sdk.join("lib_blewbxx_impl/include"))
735767
.include(bolos_sdk.join("target/flex/include/"))
736768
.flag("-fropi")
737769
.flag("-frwpi")

ledger_secure_sdk_sys/sdk_flex.h

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
#define ST33K1M5
2-
#define HAVE_DISPLAY_FAST_MODE
31
#define HAVE_SPRINTF
4-
#define NBGL_QRCODE
5-
#define HAVE_SE_EINK_DISPLAY
6-
#define SCREEN_SIZE_WALLET
7-
#define HAVE_NBGL
8-
#define NBGL_USE_CASE
9-
#define HAVE_SE_TOUCH
10-
#define HAVE_PIEZO_SOUND
11-
#define NBGL_PAGE
122
#define HAVE_LOCAL_APDU_BUFFER
133
#define IO_HID_EP_LENGTH 64
144
#define USB_SEGMENT_SIZE 64
@@ -18,5 +8,26 @@
188
#define HAVE_USB_APDU
199
#define __IO volatile
2010
#define IO_USB_MAX_ENDPOINTS 6
21-
#define IO_SEPROXYHAL_BUFFER_SIZE_B 128
22-
#define main _start
11+
#define IO_SEPROXYHAL_BUFFER_SIZE_B 300
12+
#define main _start
13+
14+
#define NBGL_QRCODE
15+
16+
// from Makefile.defines
17+
#define HAVE_BAGL_FONT_INTER_REGULAR_28PX
18+
#define HAVE_BAGL_FONT_INTER_SEMIBOLD_28PX
19+
#define HAVE_BAGL_FONT_INTER_MEDIUM_36PX
20+
#define HAVE_INAPP_BLE_PAIRING
21+
#define HAVE_NBGL
22+
#define HAVE_PIEZO_SOUND
23+
#define HAVE_SE_TOUCH
24+
#define HAVE_SE_EINK_DISPLAY
25+
#define NBGL_PAGE
26+
#define NBGL_USE_CASE
27+
#define SCREEN_SIZE_WALLET
28+
#define HAVE_FAST_HOLD_TO_APPROVE
29+
30+
#define HAVE_BLE
31+
#define HAVE_BLE_APDU
32+
#define BLE_COMMAND_TIMEOUT_MS 2000
33+
#define BLE_SEGMENT_SIZE 32

ledger_secure_sdk_sys/sdk_stax.h

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
#define ST33K1M5
21
#define HAVE_SPRINTF
3-
#define NBGL_QRCODE
4-
#define HAVE_SE_EINK_DISPLAY
5-
#define SCREEN_SIZE_WALLET
6-
#define HAVE_NBGL
7-
#define NBGL_USE_CASE
8-
#define HAVE_SE_TOUCH
9-
#define HAVE_PIEZO_SOUND
10-
#define NBGL_PAGE
112
#define HAVE_LOCAL_APDU_BUFFER
123
#define IO_HID_EP_LENGTH 64
134
#define USB_SEGMENT_SIZE 64
@@ -17,5 +8,25 @@
178
#define HAVE_USB_APDU
189
#define __IO volatile
1910
#define IO_USB_MAX_ENDPOINTS 6
20-
#define IO_SEPROXYHAL_BUFFER_SIZE_B 128
21-
#define main _start
11+
#define IO_SEPROXYHAL_BUFFER_SIZE_B 300
12+
#define main _start
13+
14+
#define NBGL_QRCODE
15+
16+
// from Makefile.defines
17+
#define HAVE_BAGL_FONT_INTER_REGULAR_24PX
18+
#define HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX
19+
#define HAVE_BAGL_FONT_INTER_MEDIUM_32PX
20+
#define HAVE_INAPP_BLE_PAIRING
21+
#define HAVE_NBGL
22+
#define HAVE_PIEZO_SOUND
23+
#define HAVE_SE_TOUCH
24+
#define HAVE_SE_EINK_DISPLAY
25+
#define NBGL_PAGE
26+
#define NBGL_USE_CASE
27+
#define SCREEN_SIZE_WALLET
28+
29+
#define HAVE_BLE
30+
#define HAVE_BLE_APDU
31+
#define BLE_COMMAND_TIMEOUT_MS 2000
32+
#define BLE_SEGMENT_SIZE 32

ledger_secure_sdk_sys/src/c/src.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "checks.h"
1212
#ifdef HAVE_BLE
1313
#include "ledger_ble.h"
14+
bolos_ux_asynch_callback_t G_io_asynch_ux_callback;
1415
#endif
1516

1617
extern void sample_main();
@@ -300,10 +301,12 @@ int c_main(void) {
300301
c[2] = 1;
301302
c[3] = SEPROXYHAL_TAG_MCU_TYPE_PROTECT;
302303
io_seproxyhal_spi_send(c, 4);
304+
#endif
305+
303306
#ifdef HAVE_BLE
304307
unsigned int plane = G_io_app.plane_mode;
305308
#endif
306-
#endif
309+
307310
memset(&G_io_app, 0, sizeof(G_io_app));
308311

309312
#ifdef HAVE_BLE
@@ -321,15 +324,16 @@ int c_main(void) {
321324
#ifdef HAVE_CCID
322325
io_usb_ccid_set_card_inserted(1);
323326
#endif
324-
327+
325328
#ifdef HAVE_BLE
326-
LEDGER_BLE_init();
329+
memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback));
330+
BLE_power(1, NULL);
327331
#endif
328332

329333
#if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN)
330334
check_audited_app();
331335
#endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN)
332-
336+
333337
heap_init();
334338
sample_main();
335339
}

0 commit comments

Comments
 (0)