diff --git a/.github/workflows/check_csdk_build_parameters.yml b/.github/workflows/check_csdk_build_parameters.yml new file mode 100644 index 00000000..96e187d2 --- /dev/null +++ b/.github/workflows/check_csdk_build_parameters.yml @@ -0,0 +1,43 @@ +name: Build C Boilerplate application and check if C SDK build parameters are still correct +permissions: + contents: read + +on: + pull_request: + workflow_dispatch: + schedule: + # * is a special character in YAML so you have to quote this string + - cron: '0 12 * * *' + +jobs: + check_csdk_build_parameters: + runs-on: ubuntu-latest + container: + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest + strategy: + matrix: + target: ["nanox", "nanosplus", "stax", "flex", "apex_p"] + steps: + - name: Checkout C BP + uses: actions/checkout@v4 + with: + repository: LedgerHQ/app-boilerplate + path: c_boilerplate + - name: Checkout C SDK Build Parameters Extractor + uses: actions/checkout@v4 + with: + repository: LedgerHQ/csdk_build_parameters_extractor + path: c_sdk_build_params_x + - name: Build C SDK Build Parameters Extractor + run: | + cd c_sdk_build_params_x + cargo build --release + - name: Run C SDK Build Parameters Extractor + run: | + cd c_sdk_build_params_x + ./target/release/cbpx --app-path ../c_boilerplate \ + --device ${{ matrix.target }} + if [ $? -ne 0 ]; then + echo "C SDK build parameters do not match with ref ones for target ${{ matrix.target }}" + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/reusable_build_all_apps.yml b/.github/workflows/reusable_build_all_apps.yml index 465d4256..4dca28ef 100644 --- a/.github/workflows/reusable_build_all_apps.yml +++ b/.github/workflows/reusable_build_all_apps.yml @@ -93,6 +93,11 @@ jobs: cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) cd $build_directory + # Required as patch has a different version from what is locked in Cargo.lock + cargo update include_gif + cargo update ledger_secure_sdk_sys + cargo update ledger_device_sdk + workspace_root=$(cargo metadata --no-deps --format-version 1 | jq -r '.workspace_root') cargo_toml_path="$workspace_root/Cargo.toml" @@ -121,6 +126,9 @@ jobs: echo "Cargo.toml:" cat $cargo_toml_path + cargo update include_gif + cargo update ledger_secure_sdk_sys + cargo update ledger_device_sdk - name: Build run: | # Clone C SDK if provided @@ -134,10 +142,7 @@ jobs: cd ${{ matrix.app-name }} build_directory=$(ledger-manifest --output-build-directory ledger_app.toml) cd $build_directory - # Use last published versions of the Rust SDK - cargo update include_gif - cargo update ledger_secure_sdk_sys - cargo update ledger_device_sdk + echo "Building app for ${{ matrix.device }}" device=$(echo ${{ matrix.device }} | sed 's/+/plus/') echo "Build for "$device cargo ledger build $device diff --git a/Cargo.lock b/Cargo.lock index b717cdef..e72a7c93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -184,12 +184,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.60.2", ] [[package]] @@ -264,11 +264,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -309,9 +309,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lazycell" @@ -327,7 +327,7 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "ledger_device_sdk" -version = "1.23.0" +version = "1.24.0" dependencies = [ "const-zero", "include_gif", @@ -342,7 +342,7 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.9.0" +version = "1.10.0" dependencies = [ "bindgen", "cc", @@ -353,9 +353,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libloading" @@ -364,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -375,9 +375,9 @@ checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "lock_api" @@ -444,9 +444,9 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "peeking_take_while" @@ -567,15 +567,15 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -676,78 +676,158 @@ dependencies = [ "rustix", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "zeroize" diff --git a/ledger_device_sdk/Cargo.toml b/ledger_device_sdk/Cargo.toml index 33e900b1..5f570a14 100644 --- a/ledger_device_sdk/Cargo.toml +++ b/ledger_device_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_device_sdk" -version = "1.23.0" +version = "1.24.0" authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"] edition = "2021" license.workspace = true @@ -21,16 +21,17 @@ 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.9.0" } +ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.10.0" } [features] debug = [] speculos = [] heap = [ "ledger_secure_sdk_sys/heap" ] nano_nbgl = [ "ledger_secure_sdk_sys/nano_nbgl" ] +debug_csdk = [ "ledger_secure_sdk_sys/debug_csdk" ] default = [ "heap" ] [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = ['cfg(target_os, values("stax", "flex", "nanox", "nanosplus"))'] +check-cfg = ['cfg(target_os, values("apex_p", "stax", "flex", "nanox", "nanosplus"))'] diff --git a/ledger_device_sdk/icons/Important_Circle_64px.png b/ledger_device_sdk/icons/Important_Circle_64px.png deleted file mode 100755 index 40e9c22f..00000000 Binary files a/ledger_device_sdk/icons/Important_Circle_64px.png and /dev/null differ diff --git a/ledger_device_sdk/icons/Warning_64px.gif b/ledger_device_sdk/icons/Warning_64px.gif deleted file mode 100644 index 7eb50308..00000000 Binary files a/ledger_device_sdk/icons/Warning_64px.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/badge_back.gif b/ledger_device_sdk/icons/badge_back.gif deleted file mode 100644 index a2a7e6d4..00000000 Binary files a/ledger_device_sdk/icons/badge_back.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_back.gif b/ledger_device_sdk/icons/icon_back.gif deleted file mode 100644 index a2a7e6d4..00000000 Binary files a/ledger_device_sdk/icons/icon_back.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_back_x.gif b/ledger_device_sdk/icons/icon_back_x.gif deleted file mode 100644 index ff043615..00000000 Binary files a/ledger_device_sdk/icons/icon_back_x.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_certificate.gif b/ledger_device_sdk/icons/icon_certificate.gif deleted file mode 100644 index 89b529f7..00000000 Binary files a/ledger_device_sdk/icons/icon_certificate.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_coggle.gif b/ledger_device_sdk/icons/icon_coggle.gif deleted file mode 100644 index 01c43b28..00000000 Binary files a/ledger_device_sdk/icons/icon_coggle.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_crossmark.gif b/ledger_device_sdk/icons/icon_crossmark.gif deleted file mode 100644 index 2dcf9d9e..00000000 Binary files a/ledger_device_sdk/icons/icon_crossmark.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_dashboard.gif b/ledger_device_sdk/icons/icon_dashboard.gif deleted file mode 100644 index 5c305517..00000000 Binary files a/ledger_device_sdk/icons/icon_dashboard.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_dashboard_x.gif b/ledger_device_sdk/icons/icon_dashboard_x.gif deleted file mode 100644 index 33d9b0a7..00000000 Binary files a/ledger_device_sdk/icons/icon_dashboard_x.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_down.gif b/ledger_device_sdk/icons/icon_down.gif deleted file mode 100644 index 4f4e39ee..00000000 Binary files a/ledger_device_sdk/icons/icon_down.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_eye.gif b/ledger_device_sdk/icons/icon_eye.gif deleted file mode 100644 index df4bb829..00000000 Binary files a/ledger_device_sdk/icons/icon_eye.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_left.gif b/ledger_device_sdk/icons/icon_left.gif deleted file mode 100644 index 524226ba..00000000 Binary files a/ledger_device_sdk/icons/icon_left.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_processing.gif b/ledger_device_sdk/icons/icon_processing.gif deleted file mode 100644 index 8fe937fa..00000000 Binary files a/ledger_device_sdk/icons/icon_processing.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_right.gif b/ledger_device_sdk/icons/icon_right.gif deleted file mode 100644 index 15ff3cf5..00000000 Binary files a/ledger_device_sdk/icons/icon_right.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_up.gif b/ledger_device_sdk/icons/icon_up.gif deleted file mode 100644 index 4e13c064..00000000 Binary files a/ledger_device_sdk/icons/icon_up.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_validate_14.gif b/ledger_device_sdk/icons/icon_validate_14.gif deleted file mode 100644 index ccb5cabe..00000000 Binary files a/ledger_device_sdk/icons/icon_validate_14.gif and /dev/null differ diff --git a/ledger_device_sdk/icons/icon_warning.gif b/ledger_device_sdk/icons/icon_warning.gif deleted file mode 100644 index 08bd4a73..00000000 Binary files a/ledger_device_sdk/icons/icon_warning.gif and /dev/null differ diff --git a/ledger_device_sdk/src/io.rs b/ledger_device_sdk/src/io.rs index 5017a38e..683520b5 100644 --- a/ledger_device_sdk/src/io.rs +++ b/ledger_device_sdk/src/io.rs @@ -1,17 +1,27 @@ -#[cfg(not(any(target_os = "stax", target_os = "flex")))] +#[cfg(any(target_os = "nanosplus", target_os = "nanox"))] use ledger_secure_sdk_sys::buttons::{get_button_event, ButtonEvent, ButtonsState}; use ledger_secure_sdk_sys::seph as sys_seph; use ledger_secure_sdk_sys::*; use crate::seph; -#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] +#[cfg(any( + target_os = "nanox", + target_os = "stax", + target_os = "flex", + target_os = "apex_p" +))] use crate::seph::ItcUxEvent; use core::convert::{Infallible, TryFrom}; use core::ops::{Index, IndexMut}; -#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] +#[cfg(any( + target_os = "nanox", + target_os = "stax", + target_os = "flex", + target_os = "apex_p" +))] unsafe extern "C" { pub unsafe static mut G_ux_params: bolos_ux_params_t; } @@ -96,9 +106,9 @@ pub enum Event { /// APDU event Command(T), /// Button press or release event - #[cfg(not(any(target_os = "stax", target_os = "flex")))] + #[cfg(any(target_os = "nanosplus", target_os = "nanox"))] Button(ButtonEvent), - #[cfg(any(target_os = "stax", target_os = "flex"))] + #[cfg(any(target_os = "stax", target_os = "flex", target_os = "apex_p"))] TouchEvent, /// Ticker Ticker, @@ -111,7 +121,7 @@ pub struct Comm { pub rx: usize, pub tx: usize, pub event_pending: bool, - #[cfg(not(any(target_os = "stax", target_os = "flex")))] + #[cfg(any(target_os = "nanosplus", target_os = "nanox"))] buttons: ButtonsState, /// Expected value for the APDU CLA byte. /// If defined, [`Comm`] will automatically reply with [`StatusWords::BadCla`] when an APDU @@ -152,7 +162,7 @@ impl Comm { rx: 0, tx: 0, event_pending: false, - #[cfg(not(any(target_os = "stax", target_os = "flex")))] + #[cfg(any(target_os = "nanosplus", target_os = "nanox"))] buttons: ButtonsState::new(), expected_cla: None, apdu_type: seph::PacketTypes::PacketTypeNone as u8, @@ -185,7 +195,12 @@ impl Comm { // This is private. Users should call reply to set the satus word and // transmit the response. fn apdu_send(&mut self) { - #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + #[cfg(any( + target_os = "stax", + target_os = "flex", + target_os = "apex_p", + feature = "nano_nbgl" + ))] { let mut buffer: [u8; 273] = [0; 273]; let status = sys_seph::io_rx(&mut buffer, false); @@ -343,7 +358,7 @@ impl Comm { match seph::Events::from(tag) { // BUTTON PUSH EVENT - #[cfg(not(any(target_os = "stax", target_os = "flex")))] + #[cfg(any(target_os = "nanosplus", target_os = "nanox"))] seph::Events::ButtonPushEvent => { #[cfg(feature = "nano_nbgl")] unsafe { @@ -356,7 +371,7 @@ impl Comm { } // SCREEN TOUCH EVENT - #[cfg(any(target_os = "stax", target_os = "flex"))] + #[cfg(any(target_os = "stax", target_os = "flex", target_os = "apex_p"))] seph::Events::ScreenTouchEvent => unsafe { ux_process_finger_event(seph_buffer.as_mut_ptr()); return Some(Event::TouchEvent); @@ -364,7 +379,12 @@ impl Comm { // TICKER EVENT seph::Events::TickerEvent => { - #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + #[cfg(any( + target_os = "stax", + target_os = "flex", + target_os = "apex_p", + feature = "nano_nbgl" + ))] unsafe { ux_process_ticker_event(); } @@ -373,7 +393,12 @@ impl Comm { // ITC EVENT seph::Events::ItcEvent => { - #[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))] + #[cfg(any( + target_os = "nanox", + target_os = "stax", + target_os = "flex", + target_os = "apex_p" + ))] match ItcUxEvent::from(seph_buffer[3]) { seph::ItcUxEvent::AskBlePairing => unsafe { G_ux_params.ux_id = BOLOS_UX_ASYNCHMODAL_PAIRING_REQUEST; @@ -397,7 +422,12 @@ impl Comm { }, seph::ItcUxEvent::Redisplay => { - #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + #[cfg(any( + target_os = "stax", + target_os = "flex", + target_os = "apex_p", + feature = "nano_nbgl" + ))] unsafe { nbgl_objAllowDrawing(true); nbgl_screenRedraw(); @@ -412,7 +442,12 @@ impl Comm { // DEFAULT EVENT _ => { - #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + #[cfg(any( + target_os = "stax", + target_os = "flex", + target_os = "apex_p", + feature = "nano_nbgl" + ))] unsafe { ux_process_default_event(); } diff --git a/ledger_device_sdk/src/lib.rs b/ledger_device_sdk/src/lib.rs index b325066a..0edcd550 100644 --- a/ledger_device_sdk/src/lib.rs +++ b/ledger_device_sdk/src/lib.rs @@ -19,9 +19,17 @@ pub mod seph; pub mod testing; -#[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] +#[cfg(any( + target_os = "stax", + target_os = "flex", + target_os = "apex_p", + feature = "nano_nbgl" +))] pub mod nbgl; -#[cfg(not(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl")))] +#[cfg(all( + any(target_os = "nanosplus", target_os = "nanox"), + not(feature = "nano_nbgl") +))] pub mod ui; pub mod uxapp; diff --git a/ledger_device_sdk/src/libcall/swap.rs b/ledger_device_sdk/src/libcall/swap.rs index 45a54a5f..fd77a3cd 100644 --- a/ledger_device_sdk/src/libcall/swap.rs +++ b/ledger_device_sdk/src/libcall/swap.rs @@ -1,4 +1,9 @@ -#[cfg(any(target_os = "stax", target_os = "flex"))] +#[cfg(any( + target_os = "stax", + target_os = "flex", + target_os = "apex_p", + feature = "nano_nbgl" +))] use crate::nbgl::NbglSpinner; use crate::testing::debug_print; use ledger_secure_sdk_sys::{ @@ -298,7 +303,12 @@ pub fn sign_tx_params NbglHomeAndSettings { }; SWITCH_ARRAY[i].initState = state; SWITCH_ARRAY[i].token = (FIRST_USER_TOKEN + i as u32) as u8; - #[cfg(any(target_os = "stax", target_os = "flex"))] + #[cfg(any(target_os = "stax", target_os = "flex", target_os = "apex_p"))] { SWITCH_ARRAY[i].tuneId = TuneIndex::TapCasual as u8; } @@ -275,7 +275,7 @@ impl<'a> NbglHomeAndSettings { }; SWITCH_ARRAY[i].initState = state; SWITCH_ARRAY[i].token = (FIRST_USER_TOKEN + i as u32) as u8; - #[cfg(any(target_os = "stax", target_os = "flex"))] + #[cfg(any(target_os = "stax", target_os = "flex", target_os = "apex_p"))] { SWITCH_ARRAY[i].tuneId = TuneIndex::TapCasual as u8; } diff --git a/ledger_device_sdk/src/nvm.rs b/ledger_device_sdk/src/nvm.rs index de0caa24..e3d00574 100644 --- a/ledger_device_sdk/src/nvm.rs +++ b/ledger_device_sdk/src/nvm.rs @@ -186,7 +186,12 @@ macro_rules! atomic_storage { #[cfg(target_os = "nanox")] atomic_storage!(256); -#[cfg(any(target_os = "nanosplus", target_os = "stax", target_os = "flex"))] +#[cfg(any( + target_os = "nanosplus", + target_os = "stax", + target_os = "flex", + target_os = "apex_p" +))] atomic_storage!(512); pub enum AtomicStorageElem { diff --git a/ledger_device_sdk/src/seph.rs b/ledger_device_sdk/src/seph.rs index 107c97c5..d1ee23d2 100644 --- a/ledger_device_sdk/src/seph.rs +++ b/ledger_device_sdk/src/seph.rs @@ -93,7 +93,12 @@ pub fn handle_event(_apdu_buffer: &mut [u8], spi_buffer: &[u8]) { let _len = u16::from_be_bytes([spi_buffer[1], spi_buffer[2]]); match Events::from(spi_buffer[0]) { Events::TickerEvent => { - #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + #[cfg(any( + target_os = "apex_p", + target_os = "stax", + target_os = "flex", + feature = "nano_nbgl" + ))] unsafe { ux_process_ticker_event(); } diff --git a/ledger_device_sdk/src/ui/bagls.rs b/ledger_device_sdk/src/ui/bagls.rs index 830f52c2..c5cf9822 100644 --- a/ledger_device_sdk/src/ui/bagls.rs +++ b/ledger_device_sdk/src/ui/bagls.rs @@ -35,6 +35,7 @@ const fn middle_y(glyph: &Glyph) -> i16 { ((crate::ui::SCREEN_HEIGHT as u32 - glyph.height) / 2) as i16 } +#[derive(Clone, Copy)] pub struct Icon<'a> { pub icon: &'a Glyph<'a>, pub pos: (i16, i16), @@ -95,25 +96,27 @@ use crate::ui::bitmaps; pub const OUTER_PADDING: usize = 2; pub const SCREENW: i16 = (crate::ui::SCREEN_WIDTH - OUTER_PADDING) as i16; -pub const DOWN_ARROW: Icon = +pub static DOWN_ARROW: Icon = Icon::from(&bitmaps::DOWN_ARROW).set_x(SCREENW - bitmaps::DOWN_ARROW.width as i16); -pub const LEFT_ARROW: Icon = Icon::from(&bitmaps::LEFT_ARROW).set_x(OUTER_PADDING as i16); -pub const RIGHT_ARROW: Icon = +pub static LEFT_ARROW: Icon = Icon::from(&bitmaps::LEFT_ARROW).set_x(OUTER_PADDING as i16); +pub static RIGHT_ARROW: Icon = Icon::from(&bitmaps::RIGHT_ARROW).set_x(SCREENW - bitmaps::RIGHT_ARROW.width as i16); -pub const UP_ARROW: Icon = Icon::from(&bitmaps::UP_ARROW).set_x(OUTER_PADDING as i16); -pub const DOWN_S_ARROW: Icon = DOWN_ARROW.shift_v(4); -pub const LEFT_S_ARROW: Icon = LEFT_ARROW.shift_h(4); -pub const RIGHT_S_ARROW: Icon = RIGHT_ARROW.shift_h(-4); -pub const UP_S_ARROW: Icon = UP_ARROW.shift_v(-4); +pub static UP_ARROW: Icon = Icon::from(&bitmaps::UP_ARROW).set_x(OUTER_PADDING as i16); +pub static DOWN_S_ARROW: Icon = DOWN_ARROW.shift_v(4); +pub static LEFT_S_ARROW: Icon = LEFT_ARROW.shift_h(4); +pub static RIGHT_S_ARROW: Icon = RIGHT_ARROW.shift_h(-4); +pub static UP_S_ARROW: Icon = UP_ARROW.shift_v(-4); -pub const CHECKMARK_ICON: Icon = Icon::from(&bitmaps::CHECKMARK); -pub const CROSS_ICON: Icon = Icon::from(&bitmaps::CROSS); -pub const COGGLE_ICON: Icon = Icon::from(&bitmaps::COGGLE); -pub const CERTIFICATE_ICON: Icon = Icon::from(&bitmaps::CERTIFICATE); -pub const CROSSMARK_ICON: Icon = Icon::from(&bitmaps::CROSSMARK); -pub const DASHBOARD_ICON: Icon = Icon::from(&bitmaps::DASHBOARD); -pub const DASHBOARD_X_ICON: Icon = Icon::from(&bitmaps::DASHBOARD_X); -pub const EYE_ICON: Icon = Icon::from(&bitmaps::EYE); -pub const PROCESSING_ICON: Icon = Icon::from(&bitmaps::PROCESSING); -pub const VALIDATE_14_ICON: Icon = Icon::from(&bitmaps::VALIDATE_14); -pub const WARNING_ICON: Icon = Icon::from(&bitmaps::WARNING); +//pub static BACK_ICON: Icon = Icon::from(&bitmaps::BACK); +pub static BACK_X_ICON: Icon = Icon::from(&bitmaps::BACK_X); +pub static COGGLE_ICON: Icon = Icon::from(&bitmaps::COGGLE); +pub static PROCESSING_ICON: Icon = Icon::from(&bitmaps::PROCESSING); +pub static CERTIFICATE_ICON: Icon = Icon::from(&bitmaps::CERTIFICATE); +pub static CROSSMARK_ICON: Icon = Icon::from(&bitmaps::CROSSMARK); +pub static DASHBOARD_ICON: Icon = Icon::from(&bitmaps::DASHBOARD); +pub static DASHBOARD_X_ICON: Icon = Icon::from(&bitmaps::DASHBOARD_X); +pub static EYE_ICON: Icon = Icon::from(&bitmaps::EYE); +pub static VALIDATE_14_ICON: Icon = Icon::from(&bitmaps::VALIDATE_14); +pub static WARNING_ICON: Icon = Icon::from(&bitmaps::WARNING); +pub static CHECKMARK_ICON: Icon = Icon::from(&bitmaps::CHECKMARK); +pub static CROSS_ICON: Icon = Icon::from(&bitmaps::CROSS); diff --git a/ledger_device_sdk/src/ui/bitmaps.rs b/ledger_device_sdk/src/ui/bitmaps.rs index c7924f19..aaf95f81 100644 --- a/ledger_device_sdk/src/ui/bitmaps.rs +++ b/ledger_device_sdk/src/ui/bitmaps.rs @@ -57,19 +57,157 @@ use include_gif::include_gif; pub const BLANK: [u8; 1024] = [0u8; 1024]; -pub const BACK: Glyph = Glyph::from_include(include_gif!("icons/badge_back.gif")); -pub const CHECKMARK: Glyph = Glyph::from_include(include_gif!("icons/badge_check.gif")); -pub const COGGLE: Glyph = Glyph::from_include(include_gif!("icons/icon_coggle.gif")); +extern "C" { + /// The bitmap for the back icon. + pub static C_icon_back_bitmap: [u8; 25]; +} +pub static BACK: Glyph = Glyph { + bitmap: unsafe { &C_icon_back_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_back_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_back_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the back_x icon. + pub static C_icon_back_x_bitmap: [u8; 25]; +} +pub static BACK_X: Glyph = Glyph { + bitmap: unsafe { &C_icon_back_x_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_back_x_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_back_x_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the coggle icon. + pub static C_icon_coggle_bitmap: [u8; 25]; +} +pub static COGGLE: Glyph = Glyph { + bitmap: unsafe { &C_icon_coggle_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_coggle_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_coggle_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the processing icon. + pub static C_icon_down_bitmap: [u8; 25]; +} +pub static DOWN_ARROW: Glyph = Glyph { + bitmap: unsafe { &C_icon_down_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_down_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_down_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the left arrow icon. + pub static C_icon_left_bitmap: [u8; 25]; +} +pub static LEFT_ARROW: Glyph = Glyph { + bitmap: unsafe { &C_icon_left_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_left_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_left_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the right arrow icon. + pub static C_icon_right_bitmap: [u8; 25]; +} +pub static RIGHT_ARROW: Glyph = Glyph { + bitmap: unsafe { &C_icon_right_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_right_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_right_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the up arrow icon. + pub static C_icon_up_bitmap: [u8; 25]; +} +pub static UP_ARROW: Glyph = Glyph { + bitmap: unsafe { &C_icon_up_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_up_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_up_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the certificate icon. + pub static C_icon_certificate_bitmap: [u8; 25]; +} +pub static CERTIFICATE: Glyph = Glyph { + bitmap: unsafe { &C_icon_certificate_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_certificate_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_certificate_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the crossmark icon. + pub static C_icon_crossmark_bitmap: [u8; 25]; +} +pub static CROSSMARK: Glyph = Glyph { + bitmap: unsafe { &C_icon_crossmark_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_crossmark_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_crossmark_HEIGHT, + inverted: false, +}; +// This is a special case for the cross icon, which is a GIF (used by client apps) pub const CROSS: Glyph = Glyph::from_include(include_gif!("icons/icon_cross_badge.gif")); -pub const DOWN_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_down.gif")); -pub const LEFT_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_left.gif")); -pub const RIGHT_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_right.gif")); -pub const UP_ARROW: Glyph = Glyph::from_include(include_gif!("icons/icon_up.gif")); -pub const CERTIFICATE: Glyph = Glyph::from_include(include_gif!("icons/icon_certificate.gif")); -pub const CROSSMARK: Glyph = Glyph::from_include(include_gif!("icons/icon_crossmark.gif")); -pub const DASHBOARD: Glyph = Glyph::from_include(include_gif!("icons/icon_dashboard.gif")); -pub const DASHBOARD_X: Glyph = Glyph::from_include(include_gif!("icons/icon_dashboard_x.gif")); -pub const EYE: Glyph = Glyph::from_include(include_gif!("icons/icon_eye.gif")); -pub const PROCESSING: Glyph = Glyph::from_include(include_gif!("icons/icon_processing.gif")); -pub const VALIDATE_14: Glyph = Glyph::from_include(include_gif!("icons/icon_validate_14.gif")); -pub const WARNING: Glyph = Glyph::from_include(include_gif!("icons/icon_warning.gif")); +extern "C" { + /// The bitmap for the dashboard icon. + pub static C_icon_dashboard_bitmap: [u8; 25]; +} +pub static DASHBOARD: Glyph = Glyph { + bitmap: unsafe { &C_icon_dashboard_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_dashboard_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_dashboard_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the dashboard x icon. + pub static C_icon_dashboard_x_bitmap: [u8; 25]; +} +pub static DASHBOARD_X: Glyph = Glyph { + bitmap: unsafe { &C_icon_dashboard_x_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_dashboard_x_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_dashboard_x_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the eye icon. + pub static C_icon_eye_bitmap: [u8; 25]; +} +pub static EYE: Glyph = Glyph { + bitmap: unsafe { &C_icon_eye_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_eye_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_eye_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the processing icon. + pub static C_icon_processing_bitmap: [u8; 25]; +} +pub static PROCESSING: Glyph = Glyph { + bitmap: unsafe { &C_icon_processing_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_processing_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_processing_HEIGHT, + inverted: false, +}; +extern "C" { + /// The bitmap for the validate icon. + pub static C_icon_validate_14_bitmap: [u8; 25]; +} +pub static VALIDATE_14: Glyph = Glyph { + bitmap: unsafe { &C_icon_validate_14_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_validate_14_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_validate_14_HEIGHT, + inverted: false, +}; +// This is a special case for the checkmark icon, which is a GIF (used by client apps) +pub const CHECKMARK: Glyph = Glyph::from_include(include_gif!("icons/badge_check.gif")); +extern "C" { + /// The bitmap for the warning icon. + pub static C_icon_warning_bitmap: [u8; 25]; +} +pub static WARNING: Glyph = Glyph { + bitmap: unsafe { &C_icon_warning_bitmap }, + width: ledger_secure_sdk_sys::GLYPH_icon_warning_WIDTH, + height: ledger_secure_sdk_sys::GLYPH_icon_warning_HEIGHT, + inverted: false, +}; diff --git a/ledger_device_sdk/src/ui/gadgets.rs b/ledger_device_sdk/src/ui/gadgets.rs index faccf122..3bc6fe5f 100644 --- a/ledger_device_sdk/src/ui/gadgets.rs +++ b/ledger_device_sdk/src/ui/gadgets.rs @@ -228,10 +228,10 @@ impl<'a> MessageValidator<'a> { let draw = |page: usize| { clear_screen(); if page == page_count - 2 { - draw_icon_and_text(CHECKMARK_ICON, self.confirm); + draw_icon_and_text(VALIDATE_14_ICON, self.confirm); RIGHT_ARROW.display(); } else if page == page_count - 1 { - draw_icon_and_text(CROSS_ICON, self.cancel); + draw_icon_and_text(CROSSMARK_ICON, self.cancel); } else { self.message[page].place(Location::Middle, Layout::Centered, false); RIGHT_ARROW.display(); diff --git a/ledger_device_sdk/src/uxapp.rs b/ledger_device_sdk/src/uxapp.rs index 4ba807cf..6a1a79e6 100644 --- a/ledger_device_sdk/src/uxapp.rs +++ b/ledger_device_sdk/src/uxapp.rs @@ -42,7 +42,12 @@ impl UxEvent { Self::ValidatePIN as u8 } Self::DelayLock => { - #[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))] + #[cfg(any( + target_os = "apex_p", + target_os = "stax", + target_os = "flex", + feature = "nano_nbgl" + ))] { G_ux_params.u.lock_delay.delay_ms = 10000; } diff --git a/ledger_secure_sdk_sys/Cargo.toml b/ledger_secure_sdk_sys/Cargo.toml index 16bba9e9..70f61cc5 100644 --- a/ledger_secure_sdk_sys/Cargo.toml +++ b/ledger_secure_sdk_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ledger_secure_sdk_sys" -version = "1.9.0" +version = "1.10.0" authors = ["yhql", "agrojean-ledger", "yogh333"] edition = "2021" license.workspace = true @@ -19,7 +19,8 @@ critical-section = { version = "1.1.2", optional = true } [features] heap = ["dep:embedded-alloc", "dep:critical-section"] nano_nbgl = [] +debug_csdk = [] [lints.rust.unexpected_cfgs] level = "warn" -check-cfg = ['cfg(target_os, values("stax", "flex", "nanox", "nanosplus"))'] +check-cfg = ['cfg(target_os, values("apex_p", "stax", "flex", "nanox", "nanosplus"))'] diff --git a/ledger_secure_sdk_sys/build.rs b/ledger_secure_sdk_sys/build.rs index 06c60c5f..de0ad4a8 100644 --- a/ledger_secure_sdk_sys/build.rs +++ b/ledger_secure_sdk_sys/build.rs @@ -4,7 +4,7 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; use std::time::Instant; -use std::{env, fs::File, io::BufRead, io::BufReader, io::Read}; +use std::{env, fs::File, io::BufRead, io::BufReader, io::Read, io::Write}; const AUX_C_FILES: [&str; 2] = ["./src/c/src.c", "./src/c/sjlj.s"]; @@ -24,56 +24,6 @@ const SDK_C_FILES: [&str; 13] = [ "io/src/os_io_seph_ux.c", ]; -const CFLAGS_NANOSPLUS: [&str; 22] = [ - "-Oz", - "-g0", - "-fomit-frame-pointer", - "-momit-leaf-frame-pointer", - "-fno-common", - "-mlittle-endian", - "-std=gnu99", - "-fdata-sections", - "-ffunction-sections", - "-funsigned-char", - "-fshort-enums", - "-mno-unaligned-access", - "-fropi", - "-fno-jump-tables", - "-nostdlib", - "-nodefaultlibs", - "-frwpi", - "--target=armv8m-none-eabi", - "-mcpu=cortex-m35p+nodsp", - "-mthumb", - "-msoft-float", - "-Wno-unused-command-line-argument", -]; -const CFLAGS_STAX: [&str; 22] = CFLAGS_NANOSPLUS; -const CFLAGS_FLEX: [&str; 22] = CFLAGS_NANOSPLUS; -const CFLAGS_NANOX: [&str; 21] = [ - "-Oz", - "-g0", - "-fomit-frame-pointer", - "-momit-leaf-frame-pointer", - "-fno-common", - "-mlittle-endian", - "-std=gnu99", - "-fdata-sections", - "-ffunction-sections", - "-funsigned-char", - "-fshort-enums", - "-mno-unaligned-access", - "-fropi", - "-fno-jump-tables", - "-nostdlib", - "-nodefaultlibs", - "-frwpi", - "-mthumb", - "--target=armv6m-none-eabi", - "-mcpu=cortex-m0plus", - "-Wno-unused-command-line-argument", -]; - #[derive(Debug, Default, PartialEq)] enum DeviceName { #[default] @@ -81,6 +31,7 @@ enum DeviceName { NanoX, Stax, Flex, + ApexP, } #[derive(Debug, Default)] @@ -89,10 +40,10 @@ struct Device<'a> { pub c_sdk: PathBuf, pub target: &'a str, pub defines: Vec<(String, Option)>, - pub cflags: Vec<&'a str>, + pub cflags: Vec, pub glyphs_folders: Vec, pub arm_libs: String, - pub linker_script: &'a str, + pub linker_script: String, } impl std::fmt::Display for DeviceName { @@ -102,6 +53,7 @@ impl std::fmt::Display for DeviceName { DeviceName::NanoX => write!(f, "nanox"), DeviceName::Stax => write!(f, "stax"), DeviceName::Flex => write!(f, "flex"), + DeviceName::ApexP => write!(f, "apex_p"), } } } @@ -188,7 +140,13 @@ impl SDKBuilder<'_> { }, target: "thumbv8m.main-none-eabi", defines: { - let mut v = header2define("csdk_nanos2.h"); + let mut v = header2define( + format!( + "{}/devices/nanosplus/c_sdk_build_nanosplus.defines", + env!("CARGO_MANIFEST_DIR") + ) + .as_str(), + ); if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() { println!("cargo:warning=NBGL is built"); v.push((String::from("HAVE_NBGL"), None)); @@ -198,13 +156,29 @@ impl SDKBuilder<'_> { println!("cargo:warning=BAGL is built"); println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "bagl"); v.push((String::from("HAVE_BAGL"), None)); + v.push((String::from("HAVE_UX_FLOW"), None)); } v }, - cflags: Vec::from(CFLAGS_NANOSPLUS), + cflags: { + let m_path = format!( + "{}/devices/nanosplus/c_sdk_build_nanosplus.cflags", + env!("CARGO_MANIFEST_DIR") + ); + let f = File::open(m_path) + .expect("Failed to open c_sdk_build_nanosplus.cflags file"); + let reader = BufReader::new(f); + reader + .lines() + .filter_map(|line| line.ok()) + .collect::>() + }, glyphs_folders: Vec::new(), arm_libs: Default::default(), - linker_script: "nanosplus_layout.ld", + linker_script: format!( + "{}/devices/nanosplus/nanosplus_layout.ld", + env!("CARGO_MANIFEST_DIR") + ), }, "nanox" => Device { name: DeviceName::NanoX, @@ -214,7 +188,13 @@ impl SDKBuilder<'_> { }, target: "thumbv6m-none-eabi", defines: { - let mut v = header2define("csdk_nanox.h"); + let mut v = header2define( + format!( + "{}/devices/nanox/c_sdk_build_nanox.defines", + env!("CARGO_MANIFEST_DIR") + ) + .as_str(), + ); if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() { println!("cargo:warning=NBGL is built"); v.push((String::from("HAVE_NBGL"), None)); @@ -224,13 +204,29 @@ impl SDKBuilder<'_> { println!("cargo:warning=BAGL is built"); println!("cargo:rustc-env=C_SDK_GRAPHICS={}", "bagl"); v.push((String::from("HAVE_BAGL"), None)); + v.push((String::from("HAVE_UX_FLOW"), None)); } v }, - cflags: Vec::from(CFLAGS_NANOX), + cflags: { + let m_path = format!( + "{}/devices/nanox/c_sdk_build_nanox.cflags", + env!("CARGO_MANIFEST_DIR") + ); + let f = + File::open(m_path).expect("Failed to open c_sdk_build_nanox.cflags file"); + let reader = BufReader::new(f); + reader + .lines() + .filter_map(|line| line.ok()) + .collect::>() + }, glyphs_folders: Vec::new(), arm_libs: Default::default(), - linker_script: "nanox_layout.ld", + linker_script: format!( + "{}/devices/nanox/nanox_layout.ld", + env!("CARGO_MANIFEST_DIR") + ), }, "stax" => Device { name: DeviceName::Stax, @@ -239,11 +235,32 @@ impl SDKBuilder<'_> { Err(_) => return Err(SDKBuildError::MissingSDKPath), }, target: "thumbv8m.main-none-eabi", - defines: header2define("csdk_stax.h"), - cflags: Vec::from(CFLAGS_STAX), + defines: header2define( + format!( + "{}/devices/stax/c_sdk_build_stax.defines", + env!("CARGO_MANIFEST_DIR") + ) + .as_str(), + ), + cflags: { + let m_path = format!( + "{}/devices/stax/c_sdk_build_stax.cflags", + env!("CARGO_MANIFEST_DIR") + ); + let f = + File::open(m_path).expect("Failed to open c_sdk_build_stax.cflags file"); + let reader = BufReader::new(f); + reader + .lines() + .filter_map(|line| line.ok()) + .collect::>() + }, glyphs_folders: Vec::new(), arm_libs: Default::default(), - linker_script: "stax_layout.ld", + linker_script: format!( + "{}/devices/stax/stax_layout.ld", + env!("CARGO_MANIFEST_DIR") + ), }, "flex" => Device { name: DeviceName::Flex, @@ -252,11 +269,66 @@ impl SDKBuilder<'_> { Err(_) => return Err(SDKBuildError::MissingSDKPath), }, target: "thumbv8m.main-none-eabi", - defines: header2define("csdk_flex.h"), - cflags: Vec::from(CFLAGS_FLEX), + defines: header2define( + format!( + "{}/devices/flex/c_sdk_build_flex.defines", + env!("CARGO_MANIFEST_DIR") + ) + .as_str(), + ), + cflags: { + let m_path = format!( + "{}/devices/flex/c_sdk_build_flex.cflags", + env!("CARGO_MANIFEST_DIR") + ); + let f = + File::open(m_path).expect("Failed to open c_sdk_build_flex.cflags file"); + let reader = BufReader::new(f); + reader + .lines() + .filter_map(|line| line.ok()) + .collect::>() + }, + glyphs_folders: Vec::new(), + arm_libs: Default::default(), + linker_script: format!( + "{}/devices/flex/flex_layout.ld", + env!("CARGO_MANIFEST_DIR") + ), + }, + "apex_p" => Device { + name: DeviceName::ApexP, + c_sdk: match env::var("LEDGER_SDK_PATH").or_else(|_| env::var("APEX_P_SDK")) { + Ok(path) => PathBuf::from(path), + Err(_) => return Err(SDKBuildError::MissingSDKPath), + }, + target: "thumbv8m.main-none-eabi", + defines: header2define( + format!( + "{}/devices/apex_p/c_sdk_build_apex_p.defines", + env!("CARGO_MANIFEST_DIR") + ) + .as_str(), + ), + cflags: { + let m_path = format!( + "{}/devices/apex_p/c_sdk_build_apex_p.cflags", + env!("CARGO_MANIFEST_DIR") + ); + let f = + File::open(m_path).expect("Failed to open c_sdk_build_apex_p.cflags file"); + let reader = BufReader::new(f); + reader + .lines() + .filter_map(|line| line.ok()) + .collect::>() + }, glyphs_folders: Vec::new(), arm_libs: Default::default(), - linker_script: "flex_layout.ld", + linker_script: format!( + "{}/devices/apex_p/apex_p_layout.ld", + env!("CARGO_MANIFEST_DIR") + ), }, _ => { return Err(SDKBuildError::UnsupportedDevice); @@ -287,10 +359,27 @@ impl SDKBuilder<'_> { .glyphs_folders .push(self.device.c_sdk.join("lib_nbgl/glyphs/32px")); } - _ => { + DeviceName::ApexP => { + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/wallet")); self.device .glyphs_folders - .push(self.device.c_sdk.join("lib_nbgl/glyphs/nano")); + .push(self.device.c_sdk.join("lib_nbgl/glyphs/48px")); + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/24px")); + } + DeviceName::NanoSPlus | DeviceName::NanoX => { + if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() { + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_nbgl/glyphs/nano")); + } else { + self.device + .glyphs_folders + .push(self.device.c_sdk.join("lib_ux/glyphs")); + } } } @@ -301,7 +390,7 @@ impl SDKBuilder<'_> { path.push_str("/arch/st33/lib"); path } - DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax => { + DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax | DeviceName::ApexP => { let mut path = self.device.c_sdk.display().to_string(); path.push_str("/arch/st33k1/lib"); path @@ -375,9 +464,6 @@ impl SDKBuilder<'_> { .files(&AUX_C_FILES) .files(str2path(&self.device.c_sdk, &SDK_C_FILES)); - //command - // .file(c_sdk.join("lib_standard_app/main.c")) - let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); command = command @@ -401,6 +487,12 @@ impl SDKBuilder<'_> { command.define(define.as_str(), value.as_deref()); } + // If the debug_csdk feature is enabled, add PRINTF defines + if env::var_os("CARGO_FEATURE_DEBUG_CSDK").is_some() { + command.define("HAVE_PRINTF", None); + command.define("PRINTF", Some("mcu_usb_printf")); + } + // Set the CFLAGS for cflag in &self.device.cflags { command.flag(cflag); @@ -423,6 +515,12 @@ impl SDKBuilder<'_> { if s.0 == "HAVE_NBGL" { configure_lib_nbgl(&mut command, &self.device.c_sdk); } + if s.0 == "HAVE_BAGL" { + let glyphs_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphs"); + command + .include(&glyphs_path) + .file(glyphs_path.join("glyphs.c")); + } } // Add the defines found in the Makefile.conf.cx to our build command. @@ -460,10 +558,8 @@ impl SDKBuilder<'_> { &[ "lib_cxng/include/libcxng.h", /* cxlib */ "include/os.h", /* syscalls */ - "include/os_screen.h", "include/syscalls.h", "include/os_ux.h", - "include/ox.h", /* crypto-related syscalls */ "lib_standard_app/swap_lib_calls.h", ], ); @@ -477,7 +573,15 @@ impl SDKBuilder<'_> { // Target specific files let csdk_target_name = self.device.name.to_string(); - let header = format!("csdk_{csdk_target_name}.h"); + let header = match self.device.name { + DeviceName::NanoSPlus => { + String::from("devices/nanosplus/c_sdk_build_nanosplus.defines") + } + DeviceName::NanoX => String::from("devices/nanox/c_sdk_build_nanox.defines"), + DeviceName::Stax => String::from("devices/stax/c_sdk_build_stax.defines"), + DeviceName::Flex => String::from("devices/flex/c_sdk_build_flex.defines"), + DeviceName::ApexP => String::from("devices/apex_p/c_sdk_build_apex_p.defines"), + }; bindings = bindings.clang_arg(format!("-I{bsdk}/target/{csdk_target_name}/include/")); bindings = bindings.header(header); @@ -488,50 +592,37 @@ impl SDKBuilder<'_> { } // BAGL or NBGL bindings + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let mut include_path = "-I".to_string(); + let glyphs = out_path.join("glyphs"); + include_path += glyphs.to_str().unwrap(); + bindings = bindings.clang_args([include_path.as_str()]); if ((self.device.name == DeviceName::NanoX || self.device.name == DeviceName::NanoSPlus) && env::var_os("CARGO_FEATURE_NANO_NBGL").is_some()) || self.device.name == DeviceName::Stax || self.device.name == DeviceName::Flex + || self.device.name == DeviceName::ApexP { - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - let mut include_path = "-I".to_string(); - let glyphs = out_path.join("glyphs"); - include_path += glyphs.to_str().unwrap(); - bindings = bindings.clang_args([include_path.as_str()]); - bindings = bindings.clang_args([ format!("-I{bsdk}/lib_nbgl/include/").as_str(), format!("-I{bsdk}/lib_ux_nbgl/").as_str(), ]); - bindings = bindings - .header( - self.device - .c_sdk - .join("lib_nbgl/include/nbgl_use_case.h") - .to_str() - .unwrap(), - ) - .header( - self.device - .c_sdk - .join("lib_ux_nbgl/ux_nbgl.h") - .to_str() - .unwrap(), - ); - } - - // BLE bindings - match self.device.name { - DeviceName::NanoX | DeviceName::Flex | DeviceName::Stax => { - bindings = bindings.header( - self.device - .c_sdk - .join("lib_blewbxx_impl/include/ledger_ble.h") - .to_str() - .unwrap(), - ) + bindings = bindings.header( + self.device + .c_sdk + .join("lib_nbgl/include/nbgl_use_case.h") + .to_str() + .unwrap(), + ); + if self.device.name == DeviceName::NanoSPlus || self.device.name == DeviceName::NanoX { + bindings = bindings.clang_args(["-DHAVE_NBGL", "-DNBGL_STEP", "-DNBGL_USE_CASE"]); } - _ => (), + } else { + bindings = bindings.clang_args([ + format!("-I{bsdk}/lib_bagl/include/").as_str(), + format!("-I{bsdk}/lib_ux/include/").as_str(), + ]); + bindings = bindings.clang_args(["-DHAVE_BAGL", "-DHAVE_UX_FLOW"]); } for define in &self.cxdefines { @@ -580,8 +671,8 @@ impl SDKBuilder<'_> { println!("cargo:rustc-link-search={}", out_dir.display()); // copy std::fs::copy( - self.device.linker_script, - out_dir.join(self.device.linker_script), + self.device.linker_script.as_str(), + out_dir.join(self.device.linker_script.split("/").last().unwrap()), ) .unwrap(); std::fs::copy("link.ld", out_dir.join("link.ld")).unwrap(); @@ -823,19 +914,23 @@ fn clone_sdk(devicename: &DeviceName) -> PathBuf { let (repo_url, sdk_branch) = match devicename { DeviceName::NanoX => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", + "API_LEVEL_24", ), DeviceName::NanoSPlus => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", + "API_LEVEL_24", ), DeviceName::Stax => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", + "API_LEVEL_24", ), DeviceName::Flex => ( Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), - "API_LEVEL_22", + "API_LEVEL_24", + ), + DeviceName::ApexP => ( + Path::new("https://github.com/LedgerHQ/ledger-secure-sdk"), + "API_LEVEL_25", ), }; @@ -855,32 +950,74 @@ fn clone_sdk(devicename: &DeviceName) -> PathBuf { } fn generate_glyphs(device: &Device) { - let icon2glyph = device.c_sdk.join("lib_nbgl/tools/icon2glyph.py"); - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let dest_path = out_path.join("glyphs"); if !dest_path.exists() { fs::create_dir_all(&dest_path).ok(); } - let mut cmd = Command::new(icon2glyph.as_os_str()); - cmd.arg("--glyphcheader") - .arg(dest_path.join("glyphs.h").as_os_str()) - .arg("--glyphcfile") - .arg(dest_path.join("glyphs.c").as_os_str()); + // NBGL Glyphs + if ((device.name == DeviceName::NanoSPlus || device.name == DeviceName::NanoX) + && env::var_os("CARGO_FEATURE_NANO_NBGL").is_some()) + || device.name == DeviceName::Stax + || device.name == DeviceName::Flex + || device.name == DeviceName::ApexP + { + println!("cargo:warning=NBGL glyphs are generated"); + let icon2glyph = device.c_sdk.join("lib_nbgl/tools/icon2glyph.py"); + + let mut cmd = Command::new(icon2glyph.as_os_str()); + cmd.arg("--glyphcheader") + .arg(dest_path.join("glyphs.h").as_os_str()) + .arg("--glyphcfile") + .arg(dest_path.join("glyphs.c").as_os_str()); - if device.name == DeviceName::NanoSPlus || device.name == DeviceName::NanoX { - cmd.arg("--reverse"); - } + if device.name == DeviceName::NanoSPlus || device.name == DeviceName::NanoX { + cmd.arg("--reverse"); + } - for folder in device.glyphs_folders.iter() { - for file in std::fs::read_dir(folder).unwrap() { - let path = file.unwrap().path(); - let path_str = path.to_str().unwrap().to_string(); - cmd.arg(path_str); + for folder in device.glyphs_folders.iter() { + for file in std::fs::read_dir(folder).unwrap() { + let path = file.unwrap().path(); + let path_str = path.to_str().unwrap().to_string(); + cmd.arg(path_str); + } + } + let _ = cmd.output(); + } + // BAGL Glyphs + else { + println!("cargo:warning=BAGL glyphs are generated"); + let icon2glyph = device.c_sdk.join("icon3.py"); + + let mut cmd1 = Command::new("python3"); + cmd1.arg(icon2glyph.as_os_str()); + cmd1.arg("--glyphcheader"); + let mut cmd2 = Command::new("python3"); + cmd2.arg(icon2glyph.as_os_str()); + cmd2.arg("--glyphcfile").arg("--factorize"); + + for folder in device.glyphs_folders.iter() { + for file in std::fs::read_dir(folder).unwrap() { + let path = file.unwrap().path(); + let path_str = path.to_str().unwrap().to_string(); + cmd1.arg(&path_str); + cmd2.arg(&path_str); + } } + let output1 = cmd1.output().unwrap(); + let output2 = cmd2.output().unwrap(); + + let mut glyphs_header: File = File::create(dest_path.join("glyphs.h")).unwrap(); + glyphs_header + .write_all(&output1.stdout) + .expect("Failed to write glyphs.h"); + + let mut glyphs_cfile = File::create(dest_path.join("glyphs.c")).unwrap(); + glyphs_cfile + .write_all(&output2.stdout) + .expect("Failed to write glyphs.c"); } - let _ = cmd.output(); } /// Helper function to concatenate all paths in pathlist to c_sdk's path diff --git a/ledger_secure_sdk_sys/c_sdk_build_flex.cflags b/ledger_secure_sdk_sys/c_sdk_build_flex.cflags deleted file mode 100644 index 519cb514..00000000 --- a/ledger_secure_sdk_sys/c_sdk_build_flex.cflags +++ /dev/null @@ -1,34 +0,0 @@ ---sysroot="/usr/arm-none-eabi" --Oz --g0 --fomit-frame-pointer --momit-leaf-frame-pointer --fno-common --mlittle-endian --std=gnu99 --Wall --Wextra --Wno-main --Werror=int-to-pointer-cast --Wno-error=int-conversion --Wimplicit-fallthrough --Wvla --Wundef --Wshadow --Wformat=2 --Wformat-security --Wwrite-strings --fdata-sections --ffunction-sections --funsigned-char --fshort-enums --mno-unaligned-access --fropi --fno-jump-tables --nostdlib --nodefaultlibs --frwpi --mthumb ---target=armv8m-none-eabi --mcpu=cortex-m35p+nodsp --msoft-float \ No newline at end of file diff --git a/ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags b/ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags deleted file mode 100644 index 519cb514..00000000 --- a/ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags +++ /dev/null @@ -1,34 +0,0 @@ ---sysroot="/usr/arm-none-eabi" --Oz --g0 --fomit-frame-pointer --momit-leaf-frame-pointer --fno-common --mlittle-endian --std=gnu99 --Wall --Wextra --Wno-main --Werror=int-to-pointer-cast --Wno-error=int-conversion --Wimplicit-fallthrough --Wvla --Wundef --Wshadow --Wformat=2 --Wformat-security --Wwrite-strings --fdata-sections --ffunction-sections --funsigned-char --fshort-enums --mno-unaligned-access --fropi --fno-jump-tables --nostdlib --nodefaultlibs --frwpi --mthumb ---target=armv8m-none-eabi --mcpu=cortex-m35p+nodsp --msoft-float \ No newline at end of file diff --git a/ledger_secure_sdk_sys/c_sdk_build_nanox.cflags b/ledger_secure_sdk_sys/c_sdk_build_nanox.cflags deleted file mode 100644 index db9a2818..00000000 --- a/ledger_secure_sdk_sys/c_sdk_build_nanox.cflags +++ /dev/null @@ -1,34 +0,0 @@ ---sysroot="/usr/arm-none-eabi" --Oz --g0 --fomit-frame-pointer --momit-leaf-frame-pointer --fno-common --mlittle-endian --std=gnu99 --Wall --Wextra --Wno-main --Werror=int-to-pointer-cast --Wno-error=int-conversion --Wimplicit-fallthrough --Wvla --Wundef --Wshadow --Wformat=2 --Wformat-security --Wwrite-strings --fdata-sections --ffunction-sections --funsigned-char --fshort-enums --mno-unaligned-access --fropi --fno-jump-tables --nostdlib --nodefaultlibs --frwpi --mthumb ---target=armv6m-none-eabi --mcpu=cortex-m0plus - diff --git a/ledger_secure_sdk_sys/c_sdk_build_stax.cflags b/ledger_secure_sdk_sys/c_sdk_build_stax.cflags deleted file mode 100644 index 519cb514..00000000 --- a/ledger_secure_sdk_sys/c_sdk_build_stax.cflags +++ /dev/null @@ -1,34 +0,0 @@ ---sysroot="/usr/arm-none-eabi" --Oz --g0 --fomit-frame-pointer --momit-leaf-frame-pointer --fno-common --mlittle-endian --std=gnu99 --Wall --Wextra --Wno-main --Werror=int-to-pointer-cast --Wno-error=int-conversion --Wimplicit-fallthrough --Wvla --Wundef --Wshadow --Wformat=2 --Wformat-security --Wwrite-strings --fdata-sections --ffunction-sections --funsigned-char --fshort-enums --mno-unaligned-access --fropi --fno-jump-tables --nostdlib --nodefaultlibs --frwpi --mthumb ---target=armv8m-none-eabi --mcpu=cortex-m35p+nodsp --msoft-float \ No newline at end of file diff --git a/ledger_secure_sdk_sys/csdk_flex.h b/ledger_secure_sdk_sys/csdk_flex.h deleted file mode 100644 index a8643398..00000000 --- a/ledger_secure_sdk_sys/csdk_flex.h +++ /dev/null @@ -1,66 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.standard_app -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// BLUETOOTH -#define HAVE_BLE -#define HAVE_BLE_APDU -#define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 -// NFC SUPPORT (feature dependent) -//#define HAVE_NFC -//#define HAVE_NFC_READER -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE -// IO SEPROXY BUFFER SIZE -#define OS_IO_SEPH_BUFFER_SIZE 272 -// NBGL QRCODE (feature dependent) -#define NBGL_QRCODE -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD -// STANDARD DEFINES -#define IO_HID_EP_LENGTH 64 -#define HAVE_SPRINTF -#define HAVE_SNPRINTF_FORMAT_U -#define HAVE_IO_USB -#define HAVE_L4_USBLIB -#define IO_USB_MAX_ENDPOINTS 4 -#define HAVE_USB_APDU -#define USB_SEGMENT_SIZE 64 -#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL -#define HAVE_IO_U2F -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.defines -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define gcc -#define __IO volatile -// Flex -#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 HAVE_HW_TOUCH_SWIPE -#define NBGL_PAGE -#define NBGL_USE_CASE -#define SCREEN_SIZE_WALLET -#define HAVE_FAST_HOLD_TO_APPROVE - -#define HAVE_LEDGER_PKI - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Misc -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_LOCAL_APDU_BUFFER - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// DEBUG C SDK -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_PRINTF -//#define PRINTF mcu_usb_printf \ No newline at end of file diff --git a/ledger_secure_sdk_sys/csdk_nanos2.h b/ledger_secure_sdk_sys/csdk_nanos2.h deleted file mode 100644 index a2187004..00000000 --- a/ledger_secure_sdk_sys/csdk_nanos2.h +++ /dev/null @@ -1,57 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.standard_app -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE -// IO SEPROXY BUFFER SIZE -#define OS_IO_SEPH_BUFFER_SIZE 272 -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD -// STANDARD DEFINES -#define IO_HID_EP_LENGTH 64 -#define HAVE_SPRINTF -#define HAVE_SNPRINTF_FORMAT_U -#define HAVE_IO_USB -#define HAVE_L4_USBLIB -#define IO_USB_MAX_ENDPOINTS 4 -#define HAVE_USB_APDU -#define USB_SEGMENT_SIZE 64 -#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL -#define HAVE_IO_U2F -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.defines -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define gcc -#define __IO volatile - -#define BAGL_HEIGHT 64 -#define BAGL_WIDTH 128 -#define HAVE_BAGL_ELLIPSIS -#define HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX -#define HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX -#define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX -#define SCREEN_SIZE_NANO -#define HAVE_UX_FLOW - -#define HAVE_SE_BUTTON -#define HAVE_SE_SCREEN -#define HAVE_FONTS -#define HAVE_INAPP_BLE_PAIRING -#define HAVE_BATTERY - -#define HAVE_LEDGER_PKI - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Misc -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_LOCAL_APDU_BUFFER - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// DEBUG C SDK -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_PRINTF -//#define PRINTF mcu_usb_printf diff --git a/ledger_secure_sdk_sys/csdk_nanox.h b/ledger_secure_sdk_sys/csdk_nanox.h deleted file mode 100644 index 50d403f3..00000000 --- a/ledger_secure_sdk_sys/csdk_nanox.h +++ /dev/null @@ -1,64 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.standard_app -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// BLUETOOTH -#define HAVE_BLE -#define HAVE_BLE_APDU -#define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE -// IO SEPROXY BUFFER SIZE -#define OS_IO_SEPH_BUFFER_SIZE 272 -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD -// STANDARD DEFINES -#define IO_HID_EP_LENGTH 64 -#define HAVE_SPRINTF -#define HAVE_SNPRINTF_FORMAT_U -#define HAVE_IO_USB -#define HAVE_L4_USBLIB -#define IO_USB_MAX_ENDPOINTS 4 -#define HAVE_USB_APDU -#define USB_SEGMENT_SIZE 64 -#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL -#define HAVE_IO_U2F -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.defines -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define gcc -#define __IO volatile - -#define BAGL_HEIGHT 64 -#define BAGL_WIDTH 128 -#define HAVE_BAGL_ELLIPSIS -#define HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX -#define HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX -#define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX -#define SCREEN_SIZE_NANO -#define HAVE_UX_FLOW - -#define HAVE_SE_BUTTON -#define HAVE_SE_SCREEN -#define HAVE_FONTS -#define HAVE_INAPP_BLE_PAIRING -#define HAVE_BATTERY - -#define HAVE_LEDGER_PKI - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Misc -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_LOCAL_APDU_BUFFER -#define HAVE_SEPROXYHAL_MCU -#define HAVE_MCU_PROTECT - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// DEBUG C SDK -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_PRINTF -//#define PRINTF mcu_usb_printf \ No newline at end of file diff --git a/ledger_secure_sdk_sys/csdk_stax.h b/ledger_secure_sdk_sys/csdk_stax.h deleted file mode 100644 index 08ba196d..00000000 --- a/ledger_secure_sdk_sys/csdk_stax.h +++ /dev/null @@ -1,64 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.standard_app -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// BLUETOOTH -#define HAVE_BLE -#define HAVE_BLE_APDU -#define BLE_COMMAND_TIMEOUT_MS 2000 -#define BLE_SEGMENT_SIZE 32 -// NFC SUPPORT (feature dependent) -//#define HAVE_NFC -//#define HAVE_NFC_READER -// APP STORAGE (feature dependent) -//#define HAVE_APP_STORAGE -// IO SEPROXY BUFFER SIZE -#define OS_IO_SEPH_BUFFER_SIZE 272 -// NBGL QRCODE (feature dependent) -#define NBGL_QRCODE -// NBGL KEYBOARD (feature dependent) -//#define NBGL_KEYBOARD -// NBGL KEYPAD (feature dependent) -//#define NBGL_KEYPAD -// STANDARD DEFINES -#define IO_HID_EP_LENGTH 64 -#define HAVE_SPRINTF -#define HAVE_SNPRINTF_FORMAT_U -#define HAVE_IO_USB -#define HAVE_L4_USBLIB -#define IO_USB_MAX_ENDPOINTS 4 -#define HAVE_USB_APDU -#define USB_SEGMENT_SIZE 64 -#define HAVE_WEBUSB -//#define WEBUSB_URL_SIZE_B -//#define WEBUSB_URL -#define HAVE_IO_U2F -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Makefile.defines -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define gcc -#define __IO volatile -// Stax -#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_LEDGER_PKI - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Misc -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_LOCAL_APDU_BUFFER - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// DEBUG C SDK -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define HAVE_PRINTF -//#define PRINTF mcu_usb_printf \ No newline at end of file diff --git a/ledger_secure_sdk_sys/devices/apex_p/apex_p.json b/ledger_secure_sdk_sys/devices/apex_p/apex_p.json new file mode 100644 index 00000000..f4931197 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/apex_p/apex_p.json @@ -0,0 +1,29 @@ +{ + "abi": "eabi", + "arch": "arm", + "c-enum-min-bits": 8, + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "emit-debug-gdb-scripts": false, + "executables": true, + "frame-pointer": "always", + "linker": "link_wrap.sh", + "linker-flavor": "ld.lld", + "llvm-target": "thumbv8m.main-none-eabi", + "max-atomic-width": 32, + "panic-strategy": "abort", + "pre-link-args": { + "ld.lld": [ + "-Tapex_p_layout.ld", + "-Tlink.ld" + ], + "ld": [ + "-Tapex_p_layout.ld", + "-Tlink.ld" + ] + }, + "relocation-model": "ropi-rwpi", + "singlethread": true, + "target-pointer-width": "32", + "os": "apex_p", + "target-family": [ "bolos" ] +} diff --git a/ledger_secure_sdk_sys/devices/apex_p/apex_p_layout.ld b/ledger_secure_sdk_sys/devices/apex_p/apex_p_layout.ld new file mode 100644 index 00000000..3cc9c1e8 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/apex_p/apex_p_layout.ld @@ -0,0 +1,10 @@ +MEMORY +{ + FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K + DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 40K +} + +PAGE_SIZE = 512; +STACK_SIZE = 1500; +END_STACK = ORIGIN(SRAM) + LENGTH(SRAM); \ No newline at end of file diff --git a/ledger_secure_sdk_sys/devices/apex_p/c_sdk_build_apex_p.cflags b/ledger_secure_sdk_sys/devices/apex_p/c_sdk_build_apex_p.cflags new file mode 100644 index 00000000..85792e01 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/apex_p/c_sdk_build_apex_p.cflags @@ -0,0 +1,21 @@ +--sysroot="/usr/lib/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-std=gnu99 +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-msoft-float +-frwpi +--target=arm-none-eabi +-mcpu=cortex-m35p+nodsp +-mlittle-endian +-mthumb +-Wno-unused-command-line-argument diff --git a/ledger_secure_sdk_sys/devices/apex_p/c_sdk_build_apex_p.defines b/ledger_secure_sdk_sys/devices/apex_p/c_sdk_build_apex_p.defines new file mode 100644 index 00000000..fd84320b --- /dev/null +++ b/ledger_secure_sdk_sys/devices/apex_p/c_sdk_build_apex_p.defines @@ -0,0 +1,36 @@ +#define HAVE_BLE +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define HAVE_BLE_APDU +#define NBGL_QRCODE +#define USE_OS_IO_STACK +#define IO_HID_EP_LENGTH 64 +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U +#define HAVE_IO_USB +#define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 +#define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define HAVE_WEBUSB +#define WEBUSB_URL_SIZE_B 0 +#define WEBUSB_URL +#define HAVE_IO_U2F +#define OS_IO_SEPROXYHAL +#define STANDARD_APP_SYNC_RAPDU +#define REVAMPED_IO +#define gcc +#define __IO volatile +#define NDEBUG +#define HAVE_BAGL_FONT_NANOTEXT_MEDIUM_18PX +#define HAVE_BAGL_FONT_NANOTEXT_BOLD_18PX +#define HAVE_BAGL_FONT_NANODISPLAY_SEMIBOLD_24PX +#define HAVE_NBGL +#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_INAPP_BLE_PAIRING +#define OS_IO_SEPH_BUFFER_SIZE 272 +#define HAVE_LEDGER_PKI diff --git a/ledger_secure_sdk_sys/devices/flex/c_sdk_build_flex.cflags b/ledger_secure_sdk_sys/devices/flex/c_sdk_build_flex.cflags new file mode 100644 index 00000000..f38a0fdc --- /dev/null +++ b/ledger_secure_sdk_sys/devices/flex/c_sdk_build_flex.cflags @@ -0,0 +1,21 @@ +--sysroot="/usr/lib/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-std=gnu99 +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-msoft-float +-frwpi +--target=arm-none-eabi +-mcpu=cortex-m35p+nodsp +-mlittle-endian +-mthumb +-Wno-unused-command-line-argument \ No newline at end of file diff --git a/ledger_secure_sdk_sys/devices/flex/c_sdk_build_flex.defines b/ledger_secure_sdk_sys/devices/flex/c_sdk_build_flex.defines new file mode 100644 index 00000000..a1d80627 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/flex/c_sdk_build_flex.defines @@ -0,0 +1,37 @@ +#define HAVE_BLE +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define HAVE_BLE_APDU +#define NBGL_QRCODE +#define USE_OS_IO_STACK +#define IO_HID_EP_LENGTH 64 +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U +#define HAVE_IO_USB +#define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 +#define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define HAVE_WEBUSB +#define WEBUSB_URL_SIZE_B 0 +#define WEBUSB_URL +#define HAVE_IO_U2F +#define OS_IO_SEPROXYHAL +#define STANDARD_APP_SYNC_RAPDU +#define REVAMPED_IO +#define gcc +#define __IO volatile +#define NDEBUG +#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 OS_IO_SEPH_BUFFER_SIZE 272 +#define HAVE_LEDGER_PKI \ No newline at end of file diff --git a/ledger_secure_sdk_sys/flex.json b/ledger_secure_sdk_sys/devices/flex/flex.json similarity index 100% rename from ledger_secure_sdk_sys/flex.json rename to ledger_secure_sdk_sys/devices/flex/flex.json diff --git a/ledger_secure_sdk_sys/flex_layout.ld b/ledger_secure_sdk_sys/devices/flex/flex_layout.ld similarity index 79% rename from ledger_secure_sdk_sys/flex_layout.ld rename to ledger_secure_sdk_sys/devices/flex/flex_layout.ld index 9418ef65..8dc74d6e 100644 --- a/ledger_secure_sdk_sys/flex_layout.ld +++ b/ledger_secure_sdk_sys/devices/flex/flex_layout.ld @@ -2,7 +2,7 @@ MEMORY { FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 36K } PAGE_SIZE = 512; diff --git a/ledger_secure_sdk_sys/devices/nanosplus/c_sdk_build_nanosplus.cflags b/ledger_secure_sdk_sys/devices/nanosplus/c_sdk_build_nanosplus.cflags new file mode 100644 index 00000000..85792e01 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/nanosplus/c_sdk_build_nanosplus.cflags @@ -0,0 +1,21 @@ +--sysroot="/usr/lib/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-std=gnu99 +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-msoft-float +-frwpi +--target=arm-none-eabi +-mcpu=cortex-m35p+nodsp +-mlittle-endian +-mthumb +-Wno-unused-command-line-argument diff --git a/ledger_secure_sdk_sys/devices/nanosplus/c_sdk_build_nanosplus.defines b/ledger_secure_sdk_sys/devices/nanosplus/c_sdk_build_nanosplus.defines new file mode 100644 index 00000000..f6c3cc1c --- /dev/null +++ b/ledger_secure_sdk_sys/devices/nanosplus/c_sdk_build_nanosplus.defines @@ -0,0 +1,32 @@ +#define USE_OS_IO_STACK +#define IO_HID_EP_LENGTH 64 +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U +#define HAVE_IO_USB +#define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 +#define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define HAVE_WEBUSB +#define WEBUSB_URL_SIZE_B 0 +#define WEBUSB_URL +#define OS_IO_SEPROXYHAL +#define STANDARD_APP_SYNC_RAPDU +#define REVAMPED_IO +#define gcc +#define __IO volatile +#define NDEBUG +#define BAGL_HEIGHT 64 +#define BAGL_WIDTH 128 +#define HAVE_BAGL_ELLIPSIS +#define HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX +#define SCREEN_SIZE_NANO +#define OS_IO_SEPH_BUFFER_SIZE 272 +#define HAVE_SE_SCREEN +#define HAVE_SE_BUTTON +#define HAVE_FONTS +#define HAVE_INAPP_BLE_PAIRING +#define HAVE_BATTERY +#define HAVE_LEDGER_PKI diff --git a/ledger_secure_sdk_sys/nanosplus.json b/ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json similarity index 100% rename from ledger_secure_sdk_sys/nanosplus.json rename to ledger_secure_sdk_sys/devices/nanosplus/nanosplus.json diff --git a/ledger_secure_sdk_sys/nanosplus_layout.ld b/ledger_secure_sdk_sys/devices/nanosplus/nanosplus_layout.ld similarity index 79% rename from ledger_secure_sdk_sys/nanosplus_layout.ld rename to ledger_secure_sdk_sys/devices/nanosplus/nanosplus_layout.ld index 9418ef65..3cc9c1e8 100644 --- a/ledger_secure_sdk_sys/nanosplus_layout.ld +++ b/ledger_secure_sdk_sys/devices/nanosplus/nanosplus_layout.ld @@ -2,7 +2,7 @@ MEMORY { FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 40K } PAGE_SIZE = 512; diff --git a/ledger_secure_sdk_sys/devices/nanox/c_sdk_build_nanox.cflags b/ledger_secure_sdk_sys/devices/nanox/c_sdk_build_nanox.cflags new file mode 100644 index 00000000..bde3d665 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/nanox/c_sdk_build_nanox.cflags @@ -0,0 +1,20 @@ +--sysroot="/usr/lib/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-std=gnu99 +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-frwpi +--target=arm-none-eabi +-mcpu=cortex-m0plus +-mlittle-endian +-mthumb +-Wno-unused-command-line-argument diff --git a/ledger_secure_sdk_sys/devices/nanox/c_sdk_build_nanox.defines b/ledger_secure_sdk_sys/devices/nanox/c_sdk_build_nanox.defines new file mode 100644 index 00000000..88919ff0 --- /dev/null +++ b/ledger_secure_sdk_sys/devices/nanox/c_sdk_build_nanox.defines @@ -0,0 +1,36 @@ +#define HAVE_BLE +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define HAVE_BLE_APDU +#define USE_OS_IO_STACK +#define IO_HID_EP_LENGTH 64 +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U +#define HAVE_IO_USB +#define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 +#define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define HAVE_WEBUSB +#define WEBUSB_URL_SIZE_B 0 +#define WEBUSB_URL +#define HAVE_IO_U2F +#define OS_IO_SEPROXYHAL +#define STANDARD_APP_SYNC_RAPDU +#define REVAMPED_IO +#define gcc +#define __IO volatile +#define NDEBUG +#define BAGL_HEIGHT 64 +#define BAGL_WIDTH 128 +#define HAVE_BAGL_ELLIPSIS +#define HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX +#define HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX +#define SCREEN_SIZE_NANO +#define OS_IO_SEPH_BUFFER_SIZE 272 +#define HAVE_SE_SCREEN +#define HAVE_SE_BUTTON +#define HAVE_FONTS +#define HAVE_INAPP_BLE_PAIRING +#define HAVE_BATTERY +#define HAVE_LEDGER_PKI \ No newline at end of file diff --git a/ledger_secure_sdk_sys/nanox.json b/ledger_secure_sdk_sys/devices/nanox/nanox.json similarity index 100% rename from ledger_secure_sdk_sys/nanox.json rename to ledger_secure_sdk_sys/devices/nanox/nanox.json diff --git a/ledger_secure_sdk_sys/nanox_layout.ld b/ledger_secure_sdk_sys/devices/nanox/nanox_layout.ld similarity index 100% rename from ledger_secure_sdk_sys/nanox_layout.ld rename to ledger_secure_sdk_sys/devices/nanox/nanox_layout.ld diff --git a/ledger_secure_sdk_sys/devices/stax/c_sdk_build_stax.cflags b/ledger_secure_sdk_sys/devices/stax/c_sdk_build_stax.cflags new file mode 100644 index 00000000..f38a0fdc --- /dev/null +++ b/ledger_secure_sdk_sys/devices/stax/c_sdk_build_stax.cflags @@ -0,0 +1,21 @@ +--sysroot="/usr/lib/arm-none-eabi" +-Oz +-g0 +-fomit-frame-pointer +-momit-leaf-frame-pointer +-fno-common +-std=gnu99 +-fdata-sections +-ffunction-sections +-funsigned-char +-fshort-enums +-mno-unaligned-access +-fropi +-fno-jump-tables +-msoft-float +-frwpi +--target=arm-none-eabi +-mcpu=cortex-m35p+nodsp +-mlittle-endian +-mthumb +-Wno-unused-command-line-argument \ No newline at end of file diff --git a/ledger_secure_sdk_sys/devices/stax/c_sdk_build_stax.defines b/ledger_secure_sdk_sys/devices/stax/c_sdk_build_stax.defines new file mode 100644 index 00000000..f366093a --- /dev/null +++ b/ledger_secure_sdk_sys/devices/stax/c_sdk_build_stax.defines @@ -0,0 +1,36 @@ +#define HAVE_BLE +#define BLE_COMMAND_TIMEOUT_MS 2000 +#define HAVE_BLE_APDU +#define NBGL_QRCODE +#define USE_OS_IO_STACK +#define IO_HID_EP_LENGTH 64 +#define HAVE_SPRINTF +#define HAVE_SNPRINTF_FORMAT_U +#define HAVE_IO_USB +#define HAVE_L4_USBLIB +#define IO_USB_MAX_ENDPOINTS 4 +#define HAVE_USB_APDU +#define USB_SEGMENT_SIZE 64 +#define HAVE_WEBUSB +#define WEBUSB_URL_SIZE_B 0 +#define WEBUSB_URL +#define HAVE_IO_U2F +#define OS_IO_SEPROXYHAL +#define STANDARD_APP_SYNC_RAPDU +#define REVAMPED_IO +#define gcc +#define __IO volatile +#define NDEBUG +#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 OS_IO_SEPH_BUFFER_SIZE 272 +#define HAVE_LEDGER_PKI \ No newline at end of file diff --git a/ledger_secure_sdk_sys/stax.json b/ledger_secure_sdk_sys/devices/stax/stax.json similarity index 100% rename from ledger_secure_sdk_sys/stax.json rename to ledger_secure_sdk_sys/devices/stax/stax.json diff --git a/ledger_secure_sdk_sys/stax_layout.ld b/ledger_secure_sdk_sys/devices/stax/stax_layout.ld similarity index 79% rename from ledger_secure_sdk_sys/stax_layout.ld rename to ledger_secure_sdk_sys/devices/stax/stax_layout.ld index 9418ef65..8dc74d6e 100644 --- a/ledger_secure_sdk_sys/stax_layout.ld +++ b/ledger_secure_sdk_sys/devices/stax/stax_layout.ld @@ -2,7 +2,7 @@ MEMORY { FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 36K } PAGE_SIZE = 512; diff --git a/ledger_secure_sdk_sys/src/c/src.c b/ledger_secure_sdk_sys/src/c/src.c index a95b8f0e..ee2518cd 100644 --- a/ledger_secure_sdk_sys/src/c/src.c +++ b/ledger_secure_sdk_sys/src/c/src.c @@ -58,7 +58,7 @@ void printhex_c(char* str, uint32_t m); "movt %[result], #:upper16:" #SYM "(sbrel)\n\t" \ "add %[result], r9, %[result]" \ : [result] "=r" (DST)) -#elif defined(TARGET_NANOX) || defined(TARGET_STAX) || defined(TARGET_FLEX) +#elif defined(TARGET_NANOX) || defined(TARGET_STAX) || defined(TARGET_FLEX) || defined(TARGET_APEX_P) # define SYMBOL_SBREL_ADDRESS(DST, SYM) \ __asm volatile( \ "ldr %[result], =" #SYM "(sbrel)\n\t" \