Skip to content

Instantly share code, notes, and snippets.

@dberlin
Created March 20, 2023 13:38
Show Gist options
  • Save dberlin/acbc1a1dbb9d12dbf44ec6a1fc3ce56c to your computer and use it in GitHub Desktop.
Save dberlin/acbc1a1dbb9d12dbf44ec6a1fc3ce56c to your computer and use it in GitHub Desktop.
Crashing example
#![feature(asm_experimental_arch)]
#![feature(naked_functions)]
#![feature(type_alias_impl_trait)]
#![no_std]
#![no_main]
use arr_macro::arr;
use esp32s3_hal::{
clock::{ClockControl, CpuClock},
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rng, Rtc,
};
use esp_backtrace as _;
use embedded_storage::ReadStorage;
use esp_println::println;
#[entry]
fn main() -> ! {
esp_wifi::init_heap();
esp_println::println!("Init!");
esp_println::logger::init_logger(log::LevelFilter::Debug);
let peripherals = Peripherals::take();
let system = peripherals.SYSTEM.split();
let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze();
let mut rtc = Rtc::new(peripherals.RTC_CNTL);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;
// Disable watchdog timers
rtc.swd.disable();
rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();
esp_wifi::initialize(timer_group1.timer0, Rng::new(peripherals.RNG), &clocks).unwrap();
println!("About to init storage");
let mut storage = esp_storage::FlashStorage::new();
println!("About to loop reading storage");
let mut result_bytes: [u8; 32] = arr![0;32];
for offset in (0..3072).step_by(32) {
println!("About to read storage");
storage
.read(0x8000 + offset as u32, &mut result_bytes)
.unwrap();
}
loop {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment