Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move some linker scripts into esp-hal-common and update the build s…
…cript
  • Loading branch information
jessebraham committed Mar 7, 2023
commit 3b7ca2bbbb03f15cf474c99f61c8d3b3da120b17
14 changes: 14 additions & 0 deletions esp-hal-common/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{env, fs, path::PathBuf};

fn main() {
let esp32 = cfg!(feature = "esp32");
let esp32c2 = cfg!(feature = "esp32c2");
Expand Down Expand Up @@ -158,4 +160,16 @@ fn main() {
for symbol in symbols {
println!("cargo:rustc-cfg={symbol}");
}

// Place all linker scripts in `OUT_DIR`, and instruct Cargo how to find these
// files:
let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());

if esp32 || esp32s2 || esp32s3 {
fs::copy("ld/xtensa/hal-defaults.x", out.join("hal-defaults.x")).unwrap();
fs::copy("ld/xtensa/rom.x", out.join("alias.x")).unwrap();
} else {
fs::copy("ld/riscv/hal-defaults.x", out.join("hal-defaults.x")).unwrap();
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions esp32-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ fn main() {
.write_all(include_bytes!("ld/memory.x"))
.unwrap();

File::create(out.join("alias.x"))
.unwrap()
.write_all(include_bytes!("ld/rom.x"))
.unwrap();

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

File::create(out.join("rom-functions.x"))
.unwrap()
.write_all(include_bytes!("ld/rom-functions.x"))
Expand Down
5 changes: 0 additions & 5 deletions esp32c2-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ fn check_features() {
fn add_defaults() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

File::create(out.join("rom-functions.x"))
.unwrap()
.write_all(include_bytes!("ld/rom-functions.x"))
Expand Down
5 changes: 0 additions & 5 deletions esp32c3-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ fn main() {
fn add_defaults() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

File::create(out.join("rom-functions.x"))
.unwrap()
.write_all(include_bytes!("ld/rom-functions.x"))
Expand Down
33 changes: 0 additions & 33 deletions esp32c3-hal/ld/hal-defaults.x

This file was deleted.

5 changes: 0 additions & 5 deletions esp32c6-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ fn main() {
fn add_defaults() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

File::create(out.join("rom-functions.x"))
.unwrap()
.write_all(include_bytes!("ld/rom-functions.x"))
Expand Down
5 changes: 5 additions & 0 deletions esp32c6-hal/ld/bl-riscv-link.x
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ PROVIDE(MachineExternal = DefaultHandler);
PROVIDE(DefaultHandler = DefaultInterruptHandler);
PROVIDE(ExceptionHandler = DefaultExceptionHandler);

/* The ESP32-C2 and ESP32-C3 have interrupt IDs 1-31, while the ESP32-C6 has
IDs 0-31, so we much define the handler for the one additional interrupt
ID: */
PROVIDE(interrupt0 = DefaultHandler);

/* # Pre-initialization function */
/* If the user overrides this using the `#[pre_init]` attribute or by creating a `__pre_init` function,
then the function this points to will be called before the RAM is initialized. */
Expand Down
5 changes: 5 additions & 0 deletions esp32c6-hal/ld/db-riscv-link.x
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ PROVIDE(MachineExternal = DefaultHandler);
PROVIDE(DefaultHandler = DefaultInterruptHandler);
PROVIDE(ExceptionHandler = DefaultExceptionHandler);

/* The ESP32-C2 and ESP32-C3 have interrupt IDs 1-31, while the ESP32-C6 has
IDs 0-31, so we much define the handler for the one additional interrupt
ID: */
PROVIDE(interrupt0 = DefaultHandler);

/* # Pre-initialization function */
/* If the user overrides this using the `#[pre_init]` attribute or by creating a `__pre_init` function,
then the function this points to will be called before the RAM is initialized. */
Expand Down
34 changes: 0 additions & 34 deletions esp32c6-hal/ld/hal-defaults.x

This file was deleted.

10 changes: 0 additions & 10 deletions esp32s2-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ fn main() {
.write_all(include_bytes!("ld/memory.x"))
.unwrap();

File::create(out.join("alias.x"))
.unwrap()
.write_all(include_bytes!("ld/rom.x"))
.unwrap();

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

File::create(out.join("rom-functions.x"))
.unwrap()
.write_all(include_bytes!("ld/rom-functions.x"))
Expand Down
7 changes: 0 additions & 7 deletions esp32s2-hal/ld/hal-defaults.x

This file was deleted.

4 changes: 0 additions & 4 deletions esp32s2-hal/ld/rom.x

This file was deleted.

15 changes: 0 additions & 15 deletions esp32s3-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ fn main() {
.write_all(include_bytes!("ld/memory.x"))
.unwrap();

File::create(out.join("alias.x"))
.unwrap()
.write_all(include_bytes!("ld/rom.x"))
.unwrap();

File::create(out.join("esp32s3.x"))
.unwrap()
.write_all(include_bytes!("ld/esp32s3.x"))
Expand Down Expand Up @@ -42,11 +37,6 @@ fn main() {
.write_all(include_bytes!("ld/db-memory.x"))
.unwrap();

File::create(out.join("alias.x"))
.unwrap()
.write_all(include_bytes!("ld/rom.x"))
.unwrap();

File::create(out.join("esp32s3.x"))
.unwrap()
.write_all(include_bytes!("ld/db-esp32s3.x"))
Expand All @@ -69,11 +59,6 @@ fn main() {
fn add_defaults() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

File::create(out.join("rom-functions.x"))
.unwrap()
.write_all(include_bytes!("ld/rom-functions.x"))
Expand Down
7 changes: 0 additions & 7 deletions esp32s3-hal/ld/hal-defaults.x

This file was deleted.

1 change: 1 addition & 0 deletions esp32s3-hal/ld/rom-functions.x
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ PROVIDE(ets_update_cpu_frequency_rom = 0x40043164);
PROVIDE(rom_i2c_writeReg = 0x40005d60);
PROVIDE(rom_i2c_writeReg_Mask = 0x40005d6c);
PROVIDE(rtc_get_reset_reason = 0x4000057c);
PROVIDE( rom_config_instruction_cache_mode = 0x40001a1c );
6 changes: 0 additions & 6 deletions esp32s3-hal/ld/rom.x

This file was deleted.