From d82d6109b4023fd34ebf300cc4090dc4a943db79 Mon Sep 17 00:00:00 2001 From: Alexis Grojean Date: Mon, 27 May 2024 10:34:18 +0200 Subject: [PATCH] Custom memory layout for Stax and Flex (44k ram compared to 30k for nano s plus) --- ledger_device_sdk/build.rs | 3 ++- ledger_device_sdk/flex.json | 4 ++-- ledger_device_sdk/stax.json | 4 ++-- ledger_device_sdk/stax_flex_layout.ld | 10 ++++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 ledger_device_sdk/stax_flex_layout.ld diff --git a/ledger_device_sdk/build.rs b/ledger_device_sdk/build.rs index 5476b72c..1c4d50d4 100644 --- a/ledger_device_sdk/build.rs +++ b/ledger_device_sdk/build.rs @@ -34,7 +34,8 @@ fn main() -> Result<(), Box> { let linkerscript = match device { NanoS => "nanos_layout.ld", NanoX => "nanox_layout.ld", - NanoSPlus | Stax | Flex => "nanosplus_layout.ld", + NanoSPlus => "nanosplus_layout.ld", + Stax | Flex => "stax_flex_layout.ld", }; std::fs::copy(linkerscript, out_dir.join(linkerscript))?; std::fs::copy("link.ld", out_dir.join("link.ld"))?; diff --git a/ledger_device_sdk/flex.json b/ledger_device_sdk/flex.json index 8d928c30..bfcb5914 100644 --- a/ledger_device_sdk/flex.json +++ b/ledger_device_sdk/flex.json @@ -13,11 +13,11 @@ "panic-strategy": "abort", "pre-link-args": { "ld.lld": [ - "-Tnanosplus_layout.ld", + "-Tstax_flex_layout.ld", "-Tlink.ld" ], "ld": [ - "-Tnanosplus_layout.ld", + "-Tstax_flex_layout.ld", "-Tlink.ld" ] }, diff --git a/ledger_device_sdk/stax.json b/ledger_device_sdk/stax.json index 89a87877..a566b638 100644 --- a/ledger_device_sdk/stax.json +++ b/ledger_device_sdk/stax.json @@ -13,11 +13,11 @@ "panic-strategy": "abort", "pre-link-args": { "ld.lld": [ - "-Tnanosplus_layout.ld", + "-Tstax_flex_layout.ld", "-Tlink.ld" ], "ld": [ - "-Tnanosplus_layout.ld", + "-Tstax_flex_layout.ld", "-Tlink.ld" ] }, diff --git a/ledger_device_sdk/stax_flex_layout.ld b/ledger_device_sdk/stax_flex_layout.ld new file mode 100644 index 00000000..9418ef65 --- /dev/null +++ b/ledger_device_sdk/stax_flex_layout.ld @@ -0,0 +1,10 @@ +MEMORY +{ + FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K + DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K +} + +PAGE_SIZE = 512; +STACK_SIZE = 1500; +END_STACK = ORIGIN(SRAM) + LENGTH(SRAM); \ No newline at end of file