Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move remaining device-specific linker scripts into esp-hal-common #963

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions esp-hal-common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rustc-link-search={}", out.display());

if cfg!(feature = "esp32") || cfg!(feature = "esp32s2") || cfg!(feature = "esp32s3") {
fs::copy("ld/xtensa/hal-defaults.x", out.join("hal-defaults.x")).unwrap();
fs::copy("ld/xtensa/hal-defaults.x", out.join("hal-defaults.x"))?;

let (irtc, drtc) = if cfg!(feature = "esp32s3") {
("rtc_fast_seg", "rtc_fast_seg")
} else {
("rtc_fast_iram_seg", "rtc_fast_dram_seg")
};

let alias = format!(
r#"
REGION_ALIAS("ROTEXT", irom_seg);
Expand All @@ -221,14 +223,16 @@ fn main() -> Result<(), Box<dyn Error>> {
"#,
irtc, drtc
);
fs::write(out.join("alias.x"), alias).unwrap();

fs::write(out.join("alias.x"), alias)?;
} else {
fs::copy("ld/riscv/hal-defaults.x", out.join("hal-defaults.x"))?;
fs::copy("ld/riscv/asserts.x", out.join("asserts.x"))?;
fs::copy("ld/riscv/debug.x", out.join("debug.x"))?;
}

copy_dir_all("ld/sections", &out)?;
copy_dir_all(format!("ld/{device_name}"), &out)?;

// Generate the eFuse table from the selected device's CSV file:
gen_efuse_table(device_name, out)?;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions esp32-hal/ld/linkall.x → esp-hal-common/ld/esp32/linkall.x
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INCLUDE "memory.x"
INCLUDE "alias.x"
INCLUDE "link-esp32.x"
INCLUDE "esp32.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
INCLUDE "rom-functions.x"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ REGION_ALIAS("RODATA", DROM);
REGION_ALIAS("RWDATA", DRAM);
REGION_ALIAS("RWTEXT", IRAM);

INCLUDE "bl-riscv-link.x"
INCLUDE "esp32c2.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ REGION_ALIAS("RWTEXT", IRAM);
REGION_ALIAS("RTC_FAST_RWTEXT", RTC_FAST);
REGION_ALIAS("RTC_FAST_RWDATA", RTC_FAST);

INCLUDE "bl-riscv-link.x"
INCLUDE "esp32c3.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ REGION_ALIAS("RWDATA", RAM);
REGION_ALIAS("RTC_FAST_RWTEXT", RTC_FAST);
REGION_ALIAS("RTC_FAST_RWDATA", RTC_FAST);

INCLUDE "bl-riscv-link.x"
INCLUDE "esp32c6.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ REGION_ALIAS("RWDATA", RAM);
REGION_ALIAS("RTC_FAST_RWTEXT", RTC_FAST);
REGION_ALIAS("RTC_FAST_RWDATA", RTC_FAST);

INCLUDE "bl-riscv-link.x"
INCLUDE "esp32h2.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INCLUDE "memory.x"
INCLUDE "alias.x"
INCLUDE "link-esp32s2.x"
INCLUDE "esp32s2.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
INCLUDE "rom-functions.x"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INCLUDE "memory.x"
INCLUDE "alias.x"
INCLUDE "link-esp32s3.x"
INCLUDE "esp32s3.x"
INCLUDE "hal-defaults.x"
INCLUDE "rom-functions.x"
INCLUDE "rom-functions.x"
File renamed without changes.
14 changes: 1 addition & 13 deletions esp32-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
use std::{
env,
error::Error,
fs::{self, File},
io::Write,
path::PathBuf,
};
use std::{env, error::Error, fs::File, io::Write, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/memory.x", out.join("memory.x"))?;
fs::copy("ld/link-esp32.x", out.join("link-esp32.x"))?;
fs::copy("ld/linkall.x", out.join("linkall.x"))?;

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

let memory_extras = generate_memory_extras();
File::create(out.join("memory_extras.x"))?.write_all(&memory_extras)?;

Expand Down
8 changes: 1 addition & 7 deletions esp32c2-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, error::Error, fs, path::PathBuf};
use std::{env, error::Error, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
check_features();
Expand All @@ -7,12 +7,6 @@ fn main() -> Result<(), Box<dyn Error>> {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/bl-esp32c2-memory.x", out.join("memory.x")).unwrap();
fs::copy("ld/bl-riscv-link.x", out.join("bl-riscv-link.x")).unwrap();
fs::copy("ld/bl-linkall.x", out.join("linkall.x")).unwrap();

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");
Expand Down
8 changes: 1 addition & 7 deletions esp32c3-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use std::{env, error::Error, fs, path::PathBuf};
use std::{env, error::Error, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/bl-esp32c3-memory.x", out.join("memory.x"))?;
fs::copy("ld/bl-riscv-link.x", out.join("bl-riscv-link.x"))?;
fs::copy("ld/bl-linkall.x", out.join("linkall.x"))?;

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");
Expand Down
8 changes: 1 addition & 7 deletions esp32c6-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use std::{env, error::Error, fs, path::PathBuf};
use std::{env, error::Error, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/bl-esp32c6-memory.x", out.join("memory.x"))?;
fs::copy("ld/bl-riscv-link.x", out.join("bl-riscv-link.x"))?;
fs::copy("ld/bl-linkall.x", out.join("linkall.x"))?;

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");
Expand Down
8 changes: 1 addition & 7 deletions esp32h2-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use std::{env, error::Error, fs, path::PathBuf};
use std::{env, error::Error, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/bl-esp32h2-memory.x", out.join("memory.x"))?;
fs::copy("ld/bl-riscv-link.x", out.join("bl-riscv-link.x"))?;
fs::copy("ld/bl-linkall.x", out.join("linkall.x"))?;

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");
Expand Down
14 changes: 1 addition & 13 deletions esp32s2-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
use std::{
env,
error::Error,
fs::{self, File},
io::Write,
path::PathBuf,
};
use std::{env, error::Error, fs::File, io::Write, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/memory.x", out.join("memory.x"))?;
fs::copy("ld/link-esp32s2.x", out.join("link-esp32s2.x"))?;
fs::copy("ld/linkall.x", out.join("linkall.x"))?;

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

let memory_extras = generate_memory_extras();
File::create(out.join("memory_extras.x"))?.write_all(&memory_extras)?;

Expand Down
8 changes: 1 addition & 7 deletions esp32s3-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use std::{env, error::Error, fs, path::PathBuf};
use std::{env, error::Error, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

fs::copy("ld/memory.x", out.join("memory.x"))?;
fs::copy("ld/link-esp32s3.x", out.join("link-esp32s3.x"))?;
fs::copy("ld/linkall.x", out.join("linkall.x"))?;

fs::copy("ld/rom-functions.x", out.join("rom-functions.x"))?;

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");
Expand Down