diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bd8f9a0..91c5d26 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,12 +10,21 @@ env: CARGO_TERM_COLOR: always jobs: - build: + ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install Deps run: sudo apt -y install libudev-dev - - name: ci + - name: CI run: ./ci.sh + ci-esp: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install Deps + run: sudo apt -y install libudev-dev + - name: CI + run: ./ci-esp.sh diff --git a/ci-esp.sh b/ci-esp.sh old mode 100644 new mode 100755 index 4b62fd9..62af45b --- a/ci-esp.sh +++ b/ci-esp.sh @@ -19,6 +19,7 @@ cd $test_dir # generation $cwd/target/release/cargo-embassy embassy init test-esp32c3 --chip esp32c3 +$cwd/target/release/cargo-embassy embassy init test-esp32s2 --chip esp32s2 $cwd/target/release/cargo-embassy embassy init test-esp32s3 --chip esp32s3 # esp toolchain @@ -32,9 +33,10 @@ fi . $HOME/export-esp.sh # compile -cd ../test-esp32c3; cargo build --release -cd ../test-esp32s3; cargo build --release +cd $test_dir/test-esp32c3; cargo build --release +cd $test_dir/test-esp32s2; cargo build --release +cd $test_dir/test-esp32s3; cargo build --release # clean up -cd ../.. -# rm -r ci +cd $cwd +# rm -r $test_dir/ci diff --git a/src/chip.rs b/src/chip.rs index 99a8a24..af015c9 100644 --- a/src/chip.rs +++ b/src/chip.rs @@ -52,6 +52,7 @@ impl FromStr for Chip { ("stm32wl", (STM, Thumbv7e)), // ESP32 ("esp32c3", (ESP(Variant::C3), Risc32Imc)), + ("esp32s2", (ESP(Variant::S2), XTensaS2)), ("esp32s3", (ESP(Variant::S3), XTensaS3)), ]; diff --git a/src/chip/family/esp.rs b/src/chip/family/esp.rs index 3a3f996..b5dd25e 100644 --- a/src/chip/family/esp.rs +++ b/src/chip/family/esp.rs @@ -3,6 +3,7 @@ use std::fmt::Display; #[derive(Clone, Debug)] pub enum Variant { C3, + S2, S3, } @@ -10,6 +11,7 @@ impl Display for Variant { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(match self { Self::C3 => "esp32c3", + Self::S2 => "esp32s2", Self::S3 => "esp32s3", }) } diff --git a/src/chip/target.rs b/src/chip/target.rs index 1943914..249be3d 100644 --- a/src/chip/target.rs +++ b/src/chip/target.rs @@ -7,6 +7,7 @@ pub enum Target { Thumbv7e, Thumbv7f, Thumbv8, + XTensaS2, XTensaS3, Risc32Imc, } @@ -19,6 +20,7 @@ impl Display for Target { Self::Thumbv7e => "thumbv7em-none-eabi", Self::Thumbv7f => "thumbv7em-none-eabihf", Self::Thumbv8 => "thumbv8m.main-none-eabihf", + Self::XTensaS2 => "xtensa-esp32s2-none-elf", Self::XTensaS3 => "xtensa-esp32s3-none-elf", Self::Risc32Imc => "riscv32imc-unknown-none-elf", }) diff --git a/src/init.rs b/src/init.rs index 02dd180..50a00f8 100644 --- a/src/init.rs +++ b/src/init.rs @@ -139,7 +139,8 @@ impl Init { target = chip.target, rustflags = match variant { Variant::C3 => "rustflags = [\n\"-C\", \"force-frame-pointers\",\n]", - Variant::S3 => "rustflags = [\n\"-C\", \"link-arg=-nostartfiles\",\n]", + Variant::S2 | Variant::S3 => + "rustflags = [\n\"-C\", \"link-arg=-nostartfiles\",\n]", } ), _ => format!( diff --git a/src/templates/config.toml.esp.template b/src/templates/config.toml.esp.template index f0fbd45..71c3fce 100644 --- a/src/templates/config.toml.esp.template +++ b/src/templates/config.toml.esp.template @@ -5,7 +5,7 @@ runner = "espflash flash --monitor" [env] -ESP_LOGLEVEL="INFO" +ESP_LOG="INFO" [build] {rustflags} diff --git a/src/templates/main.rs.esp.template b/src/templates/main.rs.esp.template index 4114f53..8031c5d 100644 --- a/src/templates/main.rs.esp.template +++ b/src/templates/main.rs.esp.template @@ -5,41 +5,29 @@ use embassy_executor::Spawner; use embassy_time::Timer; use esp_backtrace as _; use esp_hal::{ - clock::ClockControl, - gpio::{Io, Level, Output}, - peripherals::Peripherals, - prelude::*, - system::SystemControl, - timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, + self, + clock::CpuClock, + gpio::{Level, Output}, + timer::timg::TimerGroup, }; +use esp_hal_embassy::main; use esp_println::println; -use static_cell::StaticCell; #[main] async fn main(_spawner: Spawner) { - let peripherals = Peripherals::take(); - let system = SystemControl::new(peripherals.SYSTEM); - - let clocks = ClockControl::max(system.clock_control).freeze(); - esp_println::logger::init_logger_from_env(); - let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks, None); - - let timer = { - static TIMER: StaticCell<[OneShotTimer; 1]> = StaticCell::new(); - - TIMER.init([OneShotTimer::new(timg0.timer0.into())]) - }; - - esp_hal_embassy::init(&clocks, timer); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let mut config = esp_hal::Config::default(); + config.cpu_clock = CpuClock::max(); + let peripherals = esp_hal::init(config); - let mut led = Output::new(io.pins.gpio17, Level::Low); + let timg0 = TimerGroup::new(peripherals.TIMG0); + esp_hal_embassy::init(timg0.timer0); + let mut led = Output::new(peripherals.GPIO17, Level::High); loop { println!("Hello, World!"); led.toggle(); Timer::after_millis(1_000).await; } -} +} \ No newline at end of file