Skip to content

Commit

Permalink
Merge pull request #191 from LedgerHQ/y333/activate_bluetooth_stax
Browse files Browse the repository at this point in the history
Y333/activate bluetooth for Stax & Flex
  • Loading branch information
yogh333 authored Sep 26, 2024
2 parents 90590db + 159faa6 commit 8d19e15
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 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.16.1"
version = "1.17.0"
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.4.7" }
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.5.0" }

[features]
speculos = []
Expand Down
6 changes: 3 additions & 3 deletions ledger_device_sdk/src/io.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(target_os = "nanox")]
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
use crate::ble;
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_secure_sdk_sys::buttons::{get_button_event, ButtonEvent, ButtonsState};
Expand Down Expand Up @@ -196,7 +196,7 @@ impl Comm {
APDU_USB_CCID => {
ccid::send(&self.apdu_buffer[..self.tx]);
}
#[cfg(target_os = "nanox")]
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
APDU_BLE => {
ble::send(&self.apdu_buffer[..self.tx]);
}
Expand Down Expand Up @@ -387,7 +387,7 @@ impl Comm {
}
seph::Events::CAPDUEvent => seph::handle_capdu_event(&mut self.apdu_buffer, spi_buffer),

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

seph::Events::TickerEvent => {
Expand Down
2 changes: 1 addition & 1 deletion ledger_device_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![feature(generic_const_exprs)]
#![feature(cfg_version)]

#[cfg(target_os = "nanox")]
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
pub mod ble;

#[cfg(feature = "ccid")]
Expand Down
2 changes: 1 addition & 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.4.7"
version = "1.5.0"
authors = ["yhql", "agrojean-ledger"]
edition = "2021"
license.workspace = true
Expand Down
32 changes: 32 additions & 0 deletions ledger_secure_sdk_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,12 @@ impl SDKBuilder {
.to_str()
.unwrap(),
)
.header(
self.bolos_sdk
.join("lib_blewbxx_impl/include/ledger_ble.h")
.to_str()
.unwrap(),
)
}
_ => (),
}
Expand Down Expand Up @@ -716,6 +722,19 @@ fn finalize_stax_configuration(command: &mut cc::Build, bolos_sdk: &Path) {

command
.target("thumbv8m.main-none-eabi")
.file(bolos_sdk.join("src/ledger_protocol.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/template/osal.c"))
.file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c"))
.include(bolos_sdk.join("lib_blewbxx/include"))
.include(bolos_sdk.join("lib_blewbxx/core"))
.include(bolos_sdk.join("lib_blewbxx/core/auto"))
.include(bolos_sdk.join("lib_blewbxx/core/template"))
.include(bolos_sdk.join("lib_blewbxx_impl/include"))
.include(bolos_sdk.join("target/stax/include/"))
.flag("-fropi")
.flag("-frwpi")
Expand All @@ -732,6 +751,19 @@ fn finalize_flex_configuration(command: &mut cc::Build, bolos_sdk: &Path) {

command
.target("thumbv8m.main-none-eabi")
.file(bolos_sdk.join("src/ledger_protocol.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gap_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_gatt_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hal_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_hci_le.c"))
.file(bolos_sdk.join("lib_blewbxx/core/auto/ble_l2cap_aci.c"))
.file(bolos_sdk.join("lib_blewbxx/core/template/osal.c"))
.file(bolos_sdk.join("lib_blewbxx_impl/src/ledger_ble.c"))
.include(bolos_sdk.join("lib_blewbxx/include"))
.include(bolos_sdk.join("lib_blewbxx/core"))
.include(bolos_sdk.join("lib_blewbxx/core/auto"))
.include(bolos_sdk.join("lib_blewbxx/core/template"))
.include(bolos_sdk.join("lib_blewbxx_impl/include"))
.include(bolos_sdk.join("target/flex/include/"))
.flag("-fropi")
.flag("-frwpi")
Expand Down
35 changes: 23 additions & 12 deletions ledger_secure_sdk_sys/sdk_flex.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#define ST33K1M5
#define HAVE_DISPLAY_FAST_MODE
#define HAVE_SPRINTF
#define NBGL_QRCODE
#define HAVE_SE_EINK_DISPLAY
#define SCREEN_SIZE_WALLET
#define HAVE_NBGL
#define NBGL_USE_CASE
#define HAVE_SE_TOUCH
#define HAVE_PIEZO_SOUND
#define NBGL_PAGE
#define HAVE_LOCAL_APDU_BUFFER
#define IO_HID_EP_LENGTH 64
#define USB_SEGMENT_SIZE 64
Expand All @@ -18,5 +8,26 @@
#define HAVE_USB_APDU
#define __IO volatile
#define IO_USB_MAX_ENDPOINTS 6
#define IO_SEPROXYHAL_BUFFER_SIZE_B 128
#define main _start
#define IO_SEPROXYHAL_BUFFER_SIZE_B 300
#define main _start

#define NBGL_QRCODE

// from Makefile.defines
#define HAVE_BAGL_FONT_INTER_REGULAR_28PX
#define HAVE_BAGL_FONT_INTER_SEMIBOLD_28PX
#define HAVE_BAGL_FONT_INTER_MEDIUM_36PX
#define HAVE_INAPP_BLE_PAIRING
#define HAVE_NBGL
#define HAVE_PIEZO_SOUND
#define HAVE_SE_TOUCH
#define HAVE_SE_EINK_DISPLAY
#define NBGL_PAGE
#define NBGL_USE_CASE
#define SCREEN_SIZE_WALLET
#define HAVE_FAST_HOLD_TO_APPROVE

#define HAVE_BLE
#define HAVE_BLE_APDU
#define BLE_COMMAND_TIMEOUT_MS 2000
#define BLE_SEGMENT_SIZE 32
33 changes: 22 additions & 11 deletions ledger_secure_sdk_sys/sdk_stax.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#define ST33K1M5
#define HAVE_SPRINTF
#define NBGL_QRCODE
#define HAVE_SE_EINK_DISPLAY
#define SCREEN_SIZE_WALLET
#define HAVE_NBGL
#define NBGL_USE_CASE
#define HAVE_SE_TOUCH
#define HAVE_PIEZO_SOUND
#define NBGL_PAGE
#define HAVE_LOCAL_APDU_BUFFER
#define IO_HID_EP_LENGTH 64
#define USB_SEGMENT_SIZE 64
Expand All @@ -17,5 +8,25 @@
#define HAVE_USB_APDU
#define __IO volatile
#define IO_USB_MAX_ENDPOINTS 6
#define IO_SEPROXYHAL_BUFFER_SIZE_B 128
#define main _start
#define IO_SEPROXYHAL_BUFFER_SIZE_B 300
#define main _start

#define NBGL_QRCODE

// from Makefile.defines
#define HAVE_BAGL_FONT_INTER_REGULAR_24PX
#define HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX
#define HAVE_BAGL_FONT_INTER_MEDIUM_32PX
#define HAVE_INAPP_BLE_PAIRING
#define HAVE_NBGL
#define HAVE_PIEZO_SOUND
#define HAVE_SE_TOUCH
#define HAVE_SE_EINK_DISPLAY
#define NBGL_PAGE
#define NBGL_USE_CASE
#define SCREEN_SIZE_WALLET

#define HAVE_BLE
#define HAVE_BLE_APDU
#define BLE_COMMAND_TIMEOUT_MS 2000
#define BLE_SEGMENT_SIZE 32
12 changes: 8 additions & 4 deletions ledger_secure_sdk_sys/src/c/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "checks.h"
#ifdef HAVE_BLE
#include "ledger_ble.h"
bolos_ux_asynch_callback_t G_io_asynch_ux_callback;
#endif

extern void sample_main();
Expand Down Expand Up @@ -300,10 +301,12 @@ int c_main(void) {
c[2] = 1;
c[3] = SEPROXYHAL_TAG_MCU_TYPE_PROTECT;
io_seproxyhal_spi_send(c, 4);
#endif

#ifdef HAVE_BLE
unsigned int plane = G_io_app.plane_mode;
#endif
#endif

memset(&G_io_app, 0, sizeof(G_io_app));

#ifdef HAVE_BLE
Expand All @@ -321,15 +324,16 @@ int c_main(void) {
#ifdef HAVE_CCID
io_usb_ccid_set_card_inserted(1);
#endif

#ifdef HAVE_BLE
LEDGER_BLE_init();
memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback));
BLE_power(1, NULL);
#endif

#if !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN)
check_audited_app();
#endif // !defined(HAVE_BOLOS) && defined(HAVE_PENDING_REVIEW_SCREEN)

heap_init();
sample_main();
}
Expand Down

0 comments on commit 8d19e15

Please sign in to comment.