diff --git a/.cargo/config.toml b/.cargo/config.toml index d204407..defe440 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,7 +3,7 @@ runner = "espflash flash --monitor" [env] -ESP_LOGLEVEL="INFO" +ESP_LOG="info" [build] rustflags = [ diff --git a/Cargo.toml b/Cargo.toml index dfe54a8..b10d4c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,21 +6,21 @@ edition = "2021" license = "MIT OR Apache-2.0" [dependencies] -esp-backtrace = { version = "0.14.0", features = [ +esp-backtrace = { version = "0.14.2", features = [ "{{ mcu }}", "exception-handler", "panic-handler", "println", ] } -esp-hal = { version = "0.20.1", features = [ "{{ mcu }}" ] } -esp-println = { version = "0.11.0", features = ["{{ mcu }}", "log"] } -log = { version = "0.4.21" } +esp-hal = { version = "0.21.0", features = [ "{{ mcu }}" ] } +esp-println = { version = "0.12.0", features = ["{{ mcu }}", "log"] } +log = { version = "0.4.22" } {% if alloc -%} -esp-alloc = { version = "0.4.0" } +esp-alloc = { version = "0.5.0" } {% endif -%} {% if wifi -%} embedded-io = "0.6.1" -esp-wifi = { version = "0.8.0", features = [ +esp-wifi = { version = "0.10.1", features = [ "{{ mcu }}", "phy-enable-usb", "utils", diff --git a/pre-script.rhai b/pre-script.rhai index d557ad0..2d29da1 100644 --- a/pre-script.rhai +++ b/pre-script.rhai @@ -84,15 +84,16 @@ variable::set("alloc_snippet", extern crate alloc; use core::mem::MaybeUninit; -#[global_allocator] -static ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty(); - fn init_heap() { const HEAP_SIZE: usize = 32 * 1024; static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit(); unsafe { - ALLOCATOR.init(HEAP.as_mut_ptr() as *mut u8, HEAP_SIZE); + esp_alloc::HEAP.add_region(esp_alloc::HeapRegion::new( + HEAP.as_mut_ptr() as *mut u8, + HEAP_SIZE, + esp_alloc::MemoryCapability::Internal.into(), + )); } } `); @@ -100,13 +101,12 @@ fn init_heap() { // depends on: `peripherals` being in scope variable::set("esp_wifi_snippet", ` -let timg0 = esp_hal::timer::timg::TimerGroup::new(peripherals.TIMG0, &clocks); -let _init = esp_wifi::initialize( +let timg0 = esp_hal::timer::timg::TimerGroup::new(peripherals.TIMG0); +let _init = esp_wifi::init( esp_wifi::EspWifiInitFor::${meta.esp_wifi_init}, timg0.timer0, esp_hal::rng::Rng::new(peripherals.RNG), peripherals.RADIO_CLK, - &clocks, ) .unwrap(); ` diff --git a/src/main.rs b/src/main.rs index 815ee62..73044fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,7 @@ #![no_main] use esp_backtrace as _; -use esp_hal::{ - clock::ClockControl, delay::Delay, peripherals::Peripherals, prelude::*, system::SystemControl, -}; +use esp_hal::{delay::Delay, prelude::*}; {% if alloc -%} {{ alloc_snippet }} @@ -12,11 +10,9 @@ use esp_hal::{ #[entry] fn main() -> ! { - let peripherals = Peripherals::take(); - let system = SystemControl::new(peripherals.SYSTEM); - - let clocks = ClockControl::max(system.clock_control).freeze(); - let delay = Delay::new(&clocks); + #[allow(unused)] + let peripherals = esp_hal::init(esp_hal::Config::default()); + let delay = Delay::new(); {%- if alloc %} init_heap();