diff --git a/pico/.cargo/config.toml b/pico/.cargo/config.toml index ebaa5b1..9740544 100644 --- a/pico/.cargo/config.toml +++ b/pico/.cargo/config.toml @@ -2,8 +2,11 @@ # runner = "probe-rs run --chip RP2040" runner = "sudo picotool load -u -v -x -t elf" +[target.xtensa-esp32-none-elf] +runner = "espflash flash --monitor" + [build] -target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+ +target = "xtensa-esp32-none-elf" [env] DEFMT_LOG = "debug" diff --git a/pico/flake.nix b/pico/flake.nix index dabad3d..ba232f7 100644 --- a/pico/flake.nix +++ b/pico/flake.nix @@ -2,6 +2,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; rust-overlay.url = "github:oxalica/rust-overlay"; + esp-rs.url = "github:leighleighleigh/esp-rs-nix"; }; outputs = @@ -9,6 +10,7 @@ self, rust-overlay, nixpkgs, + esp-rs, }: let overlays = [ (import rust-overlay) ]; @@ -20,11 +22,16 @@ { packages.x86_64-linux.elf2uf2-rs = pkgs.callPackage ./elf2uf2.nix { }; devShell.x86_64-linux = pkgs.mkShell { - buildInputs = [ + buildInputs = with pkgs; [ + espflash + esptool (pkgs.rust-bin.selectLatestNightlyWith ( toolchain: toolchain.default.override { - targets = [ "thumbv6m-none-eabi" ]; + targets = [ + "thumbv6m-none-eabi" + "xtensa-esp32-none-eabi" + ]; extensions = [ "rust-src" ]; } )) diff --git a/pico/src/bin/scan.rs b/pico/src/bin/scan.rs index 6c992bc..d9917a3 100644 --- a/pico/src/bin/scan.rs +++ b/pico/src/bin/scan.rs @@ -37,11 +37,19 @@ async fn logger_task(usb: embassy_rp::Peri<'static, embassy_rp::peripherals::USB embassy_usb_logger::run!(1024, log::LevelFilter::Info, driver); } +#[embassy_executor::task] +async fn periodic_log() { + loop { + info!("periodic log"); + Timer::after_millis(1000).await; + } +} #[embassy_executor::main] async fn main(spawner: Spawner) { let p = embassy_rp::init(Default::default()); spawner.spawn(unwrap!(logger_task(p.USB))); + spawner.spawn(unwrap!(periodic_log())); info!("Hello World!");