diff --git a/Cargo.toml b/Cargo.toml index a0db8faee..5703a0812 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,6 @@ members = [ "esp-hal-common", "esp32-hal", "esp32c3-hal", + "esp32s2-hal", + "esp32s3-hal", ] diff --git a/esp32s2-hal/.cargo/config.toml b/esp32s2-hal/.cargo/config.toml new file mode 100644 index 000000000..e1b5c081e --- /dev/null +++ b/esp32s2-hal/.cargo/config.toml @@ -0,0 +1,12 @@ +[target.xtensa-esp32s2-none-elf] +runner = "xtensa-esp32s2-elf-gdb -q -x xtensa.gdb" + +[build] +rustflags = [ + "-C", "link-arg=-nostartfiles", + "-C", "link-arg=-Wl,-Tlink.x", +] +target = "xtensa-esp32s2-none-elf" + +[unstable] +build-std = ["core"] diff --git a/esp32s2-hal/Cargo.toml b/esp32s2-hal/Cargo.toml new file mode 100644 index 000000000..be3305d39 --- /dev/null +++ b/esp32s2-hal/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "esp32s2-hal" +version = "0.1.0" +edition = "2018" + +[dependencies] +bare-metal = "1.0" +embedded-hal = { version = "0.2", features = ["unproven"] } +nb = "1.0" +void = { version = "1.0", default-features = false } +xtensa-lx = { version = "0.4", features = ["lx6"] } # FIXME + +[dependencies.esp32s2] +path = "../../esp-pacs/esp32s2" + +[dependencies.esp-hal-common] +path = "../esp-hal-common" +features = ["32s2"] + +[dependencies.xtensa-lx-rt] +git = "https://github.com/esp-rs/xtensa-lx-rt/" +branch = "unify-xtensa-asm" +features = ["lx6"] +optional = true + +[dev-dependencies] +panic-halt = "0.2" + +[features] +default = ["rt"] +rt = ["esp32s2/rt", "xtensa-lx-rt"] diff --git a/esp32s2-hal/README.md b/esp32s2-hal/README.md new file mode 100644 index 000000000..799d64b45 --- /dev/null +++ b/esp32s2-hal/README.md @@ -0,0 +1 @@ +# esp32s2-hal diff --git a/esp32s2-hal/build.rs b/esp32s2-hal/build.rs new file mode 100644 index 000000000..bd5affeec --- /dev/null +++ b/esp32s2-hal/build.rs @@ -0,0 +1,21 @@ +use std::{env, fs::File, io::Write, path::PathBuf}; + +fn main() { + // Put the linker script somewhere the linker can find it + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + + File::create(out.join("alias.x")) + .unwrap() + .write_all(include_bytes!("rom.x")) + .unwrap(); + + println!("cargo:rustc-link-search={}", out.display()); + + // 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=memory.x"); +} diff --git a/esp32s2-hal/rust-toolchain.toml b/esp32s2-hal/rust-toolchain.toml new file mode 100644 index 000000000..292fa818b --- /dev/null +++ b/esp32s2-hal/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "esp" +components = ["rustfmt", "rustc-dev"] +targets = ["xtensa-esp32s2-none-elf"] diff --git a/esp32s2-hal/src/lib.rs b/esp32s2-hal/src/lib.rs new file mode 100644 index 000000000..91f936c33 --- /dev/null +++ b/esp32s2-hal/src/lib.rs @@ -0,0 +1,8 @@ +#![no_std] + +pub use embedded_hal as ehal; +pub use esp32s2 as pac; +pub use esp_hal_common::{prelude, Serial, Timer}; + +#[no_mangle] +extern "C" fn DefaultHandler(_level: u32, _interrupt: pac::Interrupt) {} diff --git a/esp32s3-hal/.cargo/config.toml b/esp32s3-hal/.cargo/config.toml new file mode 100644 index 000000000..6dae2c109 --- /dev/null +++ b/esp32s3-hal/.cargo/config.toml @@ -0,0 +1,12 @@ +[target.xtensa-esp32s3-none-elf] +runner = "xtensa-esp32s3-elf-gdb -q -x xtensa.gdb" + +[build] +rustflags = [ + "-C", "link-arg=-nostartfiles", + "-C", "link-arg=-Wl,-Tlink.x", +] +target = "xtensa-esp32s3-none-elf" + +[unstable] +build-std = ["core"] diff --git a/esp32s3-hal/Cargo.toml b/esp32s3-hal/Cargo.toml new file mode 100644 index 000000000..6aa73841c --- /dev/null +++ b/esp32s3-hal/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "esp32s3-hal" +version = "0.1.0" +edition = "2018" + +[dependencies] +bare-metal = "1.0" +embedded-hal = { version = "0.2", features = ["unproven"] } +nb = "1.0" +void = { version = "1.0", default-features = false } +xtensa-lx = { version = "0.4", features = ["lx6"] } # FIXME + +[dependencies.esp32s3] +path = "../../esp-pacs/esp32s3" + +[dependencies.esp-hal-common] +path = "../esp-hal-common" +features = ["32s3"] + +[dependencies.xtensa-lx-rt] +git = "https://github.com/esp-rs/xtensa-lx-rt/" +branch = "unify-xtensa-asm" +features = ["lx6"] +optional = true + +[dev-dependencies] +panic-halt = "0.2" + +[features] +default = ["rt"] +rt = ["esp32s3/rt", "xtensa-lx-rt"] diff --git a/esp32s3-hal/README.md b/esp32s3-hal/README.md new file mode 100644 index 000000000..75d4c72a8 --- /dev/null +++ b/esp32s3-hal/README.md @@ -0,0 +1 @@ +# esp32s3-hal diff --git a/esp32s3-hal/build.rs b/esp32s3-hal/build.rs new file mode 100644 index 000000000..d1b07bcc1 --- /dev/null +++ b/esp32s3-hal/build.rs @@ -0,0 +1,16 @@ +use std::{env, fs::File, io::Write, path::PathBuf}; + +fn main() { + // Put the linker script somewhere the linker can find it + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + + println!("cargo:rustc-link-search={}", out.display()); + + // 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=memory.x"); +} diff --git a/esp32s3-hal/rust-toolchain.toml b/esp32s3-hal/rust-toolchain.toml new file mode 100644 index 000000000..de5cd8048 --- /dev/null +++ b/esp32s3-hal/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "esp" +components = ["rustfmt", "rustc-dev"] +targets = ["xtensa-esp32s3-none-elf"] diff --git a/esp32s3-hal/src/lib.rs b/esp32s3-hal/src/lib.rs new file mode 100644 index 000000000..a9b9366c7 --- /dev/null +++ b/esp32s3-hal/src/lib.rs @@ -0,0 +1,5 @@ +#![no_std] + +pub use embedded_hal as ehal; +pub use esp32s3 as pac; +pub use esp_hal_common::{prelude, Serial, Timer};