Skip to content

Commit f0a2b82

Browse files
committed
Move linker script in Device
1 parent 80a8e2e commit f0a2b82

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

ledger_secure_sdk_sys/build.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct Device<'a> {
112112
pub cflags: Vec<&'a str>,
113113
pub glyphs_folders: Vec<PathBuf>,
114114
pub arm_libs: String,
115+
pub linker_script: &'a str,
115116
}
116117

117118
impl std::fmt::Display for DeviceName {
@@ -207,6 +208,7 @@ impl SDKBuilder<'_> {
207208
cflags: Vec::from(CFLAGS_NANOS),
208209
glyphs_folders: Vec::new(),
209210
arm_libs: Default::default(),
211+
linker_script: "nanos_layout.ld",
210212
},
211213
"nanosplus" => Device {
212214
name: DeviceName::NanoSPlus,
@@ -228,6 +230,7 @@ impl SDKBuilder<'_> {
228230
cflags: Vec::from(CFLAGS_NANOSPLUS),
229231
glyphs_folders: Vec::new(),
230232
arm_libs: Default::default(),
233+
linker_script: "nanosplus_layout.ld",
231234
},
232235
"nanox" => Device {
233236
name: DeviceName::NanoX,
@@ -249,6 +252,7 @@ impl SDKBuilder<'_> {
249252
cflags: Vec::from(CFLAGS_NANOX),
250253
glyphs_folders: Vec::new(),
251254
arm_libs: Default::default(),
255+
linker_script: "nanox_layout.ld",
252256
},
253257
"stax" => Device {
254258
name: DeviceName::Stax,
@@ -258,6 +262,7 @@ impl SDKBuilder<'_> {
258262
cflags: Vec::from(CFLAGS_STAX),
259263
glyphs_folders: Vec::new(),
260264
arm_libs: Default::default(),
265+
linker_script: "stax_layout.ld",
261266
},
262267
"flex" => Device {
263268
name: DeviceName::Flex,
@@ -267,6 +272,7 @@ impl SDKBuilder<'_> {
267272
cflags: Vec::from(CFLAGS_FLEX),
268273
glyphs_folders: Vec::new(),
269274
arm_libs: Default::default(),
275+
linker_script: "flex_layout.ld",
270276
},
271277
_ => {
272278
return Err(SDKBuildError::UnsupportedDevice);
@@ -613,14 +619,11 @@ impl SDKBuilder<'_> {
613619
// extend the library search path
614620
println!("cargo:rustc-link-search={}", out_dir.display());
615621
// copy
616-
let linkerscript = match self.device.name {
617-
DeviceName::NanoS => "nanos_layout.ld",
618-
DeviceName::NanoX => "nanox_layout.ld",
619-
DeviceName::NanoSPlus => "nanosplus_layout.ld",
620-
DeviceName::Stax => "stax_flex_layout.ld",
621-
DeviceName::Flex => "stax_flex_layout.ld",
622-
};
623-
std::fs::copy(linkerscript, out_dir.join(linkerscript)).unwrap();
622+
std::fs::copy(
623+
self.device.linker_script,
624+
out_dir.join(self.device.linker_script),
625+
)
626+
.unwrap();
624627
std::fs::copy("link.ld", out_dir.join("link.ld")).unwrap();
625628
Ok(())
626629
}

ledger_secure_sdk_sys/stax_layout.ld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K
4+
DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K
5+
SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K
6+
}
7+
8+
PAGE_SIZE = 512;
9+
STACK_SIZE = 1500;
10+
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);

0 commit comments

Comments
 (0)