@@ -31,6 +31,7 @@ enum DeviceName {
31
31
NanoX ,
32
32
Stax ,
33
33
Flex ,
34
+ ApexP ,
34
35
}
35
36
36
37
#[ derive( Debug , Default ) ]
@@ -52,6 +53,7 @@ impl std::fmt::Display for DeviceName {
52
53
DeviceName :: NanoX => write ! ( f, "nanox" ) ,
53
54
DeviceName :: Stax => write ! ( f, "stax" ) ,
54
55
DeviceName :: Flex => write ! ( f, "flex" ) ,
56
+ DeviceName :: ApexP => write ! ( f, "apex_p" ) ,
55
57
}
56
58
}
57
59
}
@@ -238,6 +240,26 @@ impl SDKBuilder<'_> {
238
240
arm_libs : Default :: default ( ) ,
239
241
linker_script : "flex_layout.ld" ,
240
242
} ,
243
+ "apex_p" => Device {
244
+ name : DeviceName :: ApexP ,
245
+ c_sdk : match env:: var ( "LEDGER_SDK_PATH" ) . or_else ( |_| env:: var ( "APEX_P_SDK" ) ) {
246
+ Ok ( path) => PathBuf :: from ( path) ,
247
+ Err ( _) => return Err ( SDKBuildError :: MissingSDKPath ) ,
248
+ } ,
249
+ target : "thumbv8m.main-none-eabi" ,
250
+ defines : header2define ( "c_sdk_build_apex_p.defines" ) ,
251
+ cflags : {
252
+ let mut m_path = String :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
253
+ m_path. push_str ( "/c_sdk_build_apex_p.cflags" ) ;
254
+ let f = File :: open ( m_path)
255
+ . expect ( "Failed to open c_sdk_build_apex_p.cflags file" ) ;
256
+ let reader = BufReader :: new ( f) ;
257
+ reader. lines ( ) . filter_map ( |line| line. ok ( ) ) . collect :: < Vec < String > > ( )
258
+ } ,
259
+ glyphs_folders : Vec :: new ( ) ,
260
+ arm_libs : Default :: default ( ) ,
261
+ linker_script : "apex_p_layout.ld" ,
262
+ } ,
241
263
_ => {
242
264
return Err ( SDKBuildError :: UnsupportedDevice ) ;
243
265
}
@@ -267,6 +289,17 @@ impl SDKBuilder<'_> {
267
289
. glyphs_folders
268
290
. push ( self . device . c_sdk . join ( "lib_nbgl/glyphs/32px" ) ) ;
269
291
}
292
+ DeviceName :: ApexP => {
293
+ self . device
294
+ . glyphs_folders
295
+ . push ( self . device . c_sdk . join ( "lib_nbgl/glyphs/wallet" ) ) ;
296
+ self . device
297
+ . glyphs_folders
298
+ . push ( self . device . c_sdk . join ( "lib_nbgl/glyphs/48px" ) ) ;
299
+ self . device
300
+ . glyphs_folders
301
+ . push ( self . device . c_sdk . join ( "lib_nbgl/glyphs/24px" ) ) ;
302
+ }
270
303
_ => {
271
304
self . device
272
305
. glyphs_folders
@@ -281,7 +314,7 @@ impl SDKBuilder<'_> {
281
314
path. push_str ( "/arch/st33/lib" ) ;
282
315
path
283
316
}
284
- DeviceName :: NanoSPlus | DeviceName :: Flex | DeviceName :: Stax => {
317
+ DeviceName :: NanoSPlus | DeviceName :: Flex | DeviceName :: Stax | DeviceName :: ApexP => {
285
318
let mut path = self . device . c_sdk . display ( ) . to_string ( ) ;
286
319
path. push_str ( "/arch/st33k1/lib" ) ;
287
320
path
@@ -355,8 +388,6 @@ impl SDKBuilder<'_> {
355
388
. files ( & AUX_C_FILES )
356
389
. files ( str2path ( & self . device . c_sdk , & SDK_C_FILES ) ) ;
357
390
358
- //command
359
- // .file(c_sdk.join("lib_standard_app/main.c"))
360
391
361
392
let glyphs_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) . join ( "glyphs" ) ;
362
393
@@ -468,6 +499,7 @@ impl SDKBuilder<'_> {
468
499
DeviceName :: NanoX => String :: from ( "c_sdk_build_nanox.defines" ) ,
469
500
DeviceName :: Stax => String :: from ( "c_sdk_build_stax.defines" ) ,
470
501
DeviceName :: Flex => String :: from ( "c_sdk_build_flex.defines" ) ,
502
+ DeviceName :: ApexP => String :: from ( "c_sdk_build_apex_p.defines" ) ,
471
503
} ;
472
504
473
505
bindings = bindings. clang_arg ( format ! ( "-I{bsdk}/target/{csdk_target_name}/include/" ) ) ;
@@ -483,6 +515,7 @@ impl SDKBuilder<'_> {
483
515
&& env:: var_os ( "CARGO_FEATURE_NANO_NBGL" ) . is_some ( ) )
484
516
|| self . device . name == DeviceName :: Stax
485
517
|| self . device . name == DeviceName :: Flex
518
+ || self . device . name == DeviceName :: ApexP
486
519
{
487
520
let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
488
521
let mut include_path = "-I" . to_string ( ) ;
@@ -501,12 +534,21 @@ impl SDKBuilder<'_> {
501
534
. join ( "lib_nbgl/include/nbgl_use_case.h" )
502
535
. to_str ( )
503
536
. unwrap ( ) ,
537
+ )
538
+ . header (
539
+ self . device
540
+ . c_sdk
541
+ . join ( "lib_ux_nbgl/ux_nbgl.h" )
542
+ . to_str ( )
543
+ . unwrap ( ) ,
504
544
) ;
545
+ } else {
546
+ bindings = bindings. clang_arg ( "-DHAVE_UX_FLOW" ) ;
505
547
}
506
548
507
549
// BLE bindings
508
550
match self . device . name {
509
- DeviceName :: NanoX | DeviceName :: Flex | DeviceName :: Stax => {
551
+ DeviceName :: NanoX | DeviceName :: Flex | DeviceName :: Stax | DeviceName :: ApexP => {
510
552
bindings = bindings. header (
511
553
self . device
512
554
. c_sdk
@@ -807,19 +849,23 @@ fn clone_sdk(devicename: &DeviceName) -> PathBuf {
807
849
let ( repo_url, sdk_branch) = match devicename {
808
850
DeviceName :: NanoX => (
809
851
Path :: new ( "https://github.com/LedgerHQ/ledger-secure-sdk" ) ,
810
- "API_LEVEL_22 " ,
852
+ "API_LEVEL_24 " ,
811
853
) ,
812
854
DeviceName :: NanoSPlus => (
813
855
Path :: new ( "https://github.com/LedgerHQ/ledger-secure-sdk" ) ,
814
- "API_LEVEL_22 " ,
856
+ "API_LEVEL_24 " ,
815
857
) ,
816
858
DeviceName :: Stax => (
817
859
Path :: new ( "https://github.com/LedgerHQ/ledger-secure-sdk" ) ,
818
- "API_LEVEL_22 " ,
860
+ "API_LEVEL_24 " ,
819
861
) ,
820
862
DeviceName :: Flex => (
821
863
Path :: new ( "https://github.com/LedgerHQ/ledger-secure-sdk" ) ,
822
- "API_LEVEL_22" ,
864
+ "API_LEVEL_24" ,
865
+ ) ,
866
+ DeviceName :: ApexP => (
867
+ Path :: new ( "https://github.com/LedgerHQ/ledger-secure-sdk" ) ,
868
+ "API_LEVEL_25" ,
823
869
) ,
824
870
} ;
825
871
0 commit comments