progress
This commit is contained in:
parent
126c98e5af
commit
128733e51f
7 changed files with 633 additions and 983 deletions
|
|
@ -4,6 +4,13 @@ runner = "espflash flash --monitor"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "xtensa-esp32-none-elf"
|
target = "xtensa-esp32-none-elf"
|
||||||
|
rustflags = [
|
||||||
|
"-C", "link-arg=-Wl,-Tlinkall.x",
|
||||||
|
"-C", "link-arg=-nostartfiles",
|
||||||
|
]
|
||||||
|
|
||||||
|
[unstable]
|
||||||
|
build-std = ["core", "alloc", "compiler_builtins"]
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
DEFMT_LOG = "debug"
|
DEFMT_LOG = "debug"
|
||||||
|
|
|
||||||
1397
esp32/Cargo.lock
generated
1397
esp32/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,12 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pico"
|
name = "esp32"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
debug-assertions = true
|
||||||
|
lto = "fat"
|
||||||
|
codegen-units = 1
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
[target.'cfg(target_arch = "xtensa")'.dependencies]
|
||||||
|
arrayvec = { version = "0.7.6", default-features = false }
|
||||||
|
embedded-io = "0.7.1"
|
||||||
|
esp-hal = { version = "1.0.0", features = ["esp32", "rt"] }
|
||||||
|
|
||||||
|
[target.'cfg(target_arch = "arm")'.dependencies]
|
||||||
embedded-hal-compat = "0.13.0"
|
embedded-hal-compat = "0.13.0"
|
||||||
embassy-usb-logger = "0.5.1"
|
|
||||||
ufmt = "0.2.0"
|
ufmt = "0.2.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
ag-lcd={ version = "0.3", features = ["ufmt"]}
|
ag-lcd={ version = "0.3", features = ["ufmt"]}
|
||||||
|
|
@ -16,7 +27,6 @@ embedded-io-async = "0.7.0"
|
||||||
embedded-io = "0.7.1"
|
embedded-io = "0.7.1"
|
||||||
owned_str = "0.1.2"
|
owned_str = "0.1.2"
|
||||||
embassy-sync = "0.8.0"
|
embassy-sync = "0.8.0"
|
||||||
arrayvec = { version = "0.7.6", default-features = false }
|
|
||||||
embassy-net = { version = "0.9.1",features = ["defmt", "icmp", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet", "dns", "proto-ipv4", "proto-ipv6", "multicast"]}
|
embassy-net = { version = "0.9.1",features = ["defmt", "icmp", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet", "dns", "proto-ipv4", "proto-ipv6", "multicast"]}
|
||||||
embassy-executor = { version = "0.10.0", features = [
|
embassy-executor = { version = "0.10.0", features = [
|
||||||
"platform-cortex-m",
|
"platform-cortex-m",
|
||||||
|
|
@ -24,29 +34,15 @@ embassy-executor = { version = "0.10.0", features = [
|
||||||
"executor-interrupt",
|
"executor-interrupt",
|
||||||
"defmt",
|
"defmt",
|
||||||
] }
|
] }
|
||||||
embassy-rp = { version = "0.10.0", features = [
|
|
||||||
"defmt",
|
|
||||||
"unstable-pac",
|
|
||||||
"time-driver",
|
|
||||||
"critical-section-impl",
|
|
||||||
"rp2040",
|
|
||||||
] }
|
|
||||||
embassy-time = { version = "0.5.1", features = [
|
embassy-time = { version = "0.5.1", features = [
|
||||||
"defmt",
|
"defmt",
|
||||||
"defmt-timestamp-uptime",
|
"defmt-timestamp-uptime",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
cortex-m = { version = "0.7.7", features = ["inline-asm"] }
|
|
||||||
cortex-m-rt = "0.7.5"
|
|
||||||
critical-section = "1.2.0"
|
critical-section = "1.2.0"
|
||||||
static_cell = "2.1.1"
|
static_cell = "2.1.1"
|
||||||
portable-atomic = { version = "1.13.1", features = ["critical-section"] }
|
portable-atomic = { version = "1.13.1", features = ["critical-section"] }
|
||||||
|
|
||||||
|
|
||||||
defmt = "1.0.1"
|
defmt = "1.0.1"
|
||||||
defmt-rtt = "1.1.0"
|
defmt-rtt = "1.1.0"
|
||||||
|
|
||||||
panic-probe = { version = "1.0.0", features = ["print-defmt"] }
|
panic-probe = { version = "1.0.0", features = ["print-defmt"] }
|
||||||
|
|
||||||
cyw43 = { version = "0.7.0", features = ["defmt", "firmware-logs"] }
|
|
||||||
cyw43-pio = { version = "0.10.0", features = ["defmt"] }
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,4 @@ fn main() {
|
||||||
// here, we ensure the build script is only re-run when
|
// here, we ensure the build script is only re-run when
|
||||||
// `memory.x` is changed.
|
// `memory.x` is changed.
|
||||||
println!("cargo:rerun-if-changed=memory.x");
|
println!("cargo:rerun-if-changed=memory.x");
|
||||||
|
|
||||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,24 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-parts_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1777988971,
|
||||||
|
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760038930,
|
"lastModified": 1760038930,
|
||||||
|
|
@ -68,33 +86,33 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs-lib_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1777383249,
|
"lastModified": 1777168982,
|
||||||
"narHash": "sha256-b6T90GXUr21iIu6Aw+KGy5uSiB/cVT/UecId1YSESys=",
|
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
|
||||||
"owner": "NixOS",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "61a7520db583d9b41be602b4c1e1b1b1b1faa1f4",
|
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs.lib",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1744536153,
|
"lastModified": 1777954456,
|
||||||
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
|
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
|
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixpkgs-unstable",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
@ -102,26 +120,8 @@
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"esp-rs": "esp-rs",
|
"esp-rs": "esp-rs",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"flake-parts": "flake-parts_2",
|
||||||
"rust-overlay": "rust-overlay"
|
"nixpkgs": "nixpkgs_2"
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-overlay": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs_3"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1777346187,
|
|
||||||
"narHash": "sha256-oVxyGjpiIsrXhWTJVUOs38fZQkLjd0nZGOY9K7Kfot8=",
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"rev": "146e7bf7569b8288f24d41d806b9f584f7cfd5b5",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,33 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
esp-rs.url = "github:leighleighleigh/esp-rs-nix";
|
esp-rs.url = "github:leighleighleigh/esp-rs-nix";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = inputs @ { flake-parts, esp-rs, ... }:
|
||||||
{
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
self,
|
systems = [ "x86_64-linux" ];
|
||||||
rust-overlay,
|
|
||||||
nixpkgs,
|
imports = [
|
||||||
esp-rs,
|
"${esp-rs}/package.nix"
|
||||||
}:
|
];
|
||||||
let
|
|
||||||
overlays = [ (import rust-overlay) ];
|
perSystem = { pkgs, self', ... }: {
|
||||||
pkgs = import nixpkgs {
|
devShells.default = pkgs.mkShell {
|
||||||
system = "x86_64-linux";
|
packages = [
|
||||||
inherit overlays;
|
self'.packages.esp-rs
|
||||||
};
|
pkgs.rust-analyzer
|
||||||
in
|
pkgs.rustup
|
||||||
{
|
pkgs.espflash
|
||||||
packages.x86_64-linux.elf2uf2-rs = pkgs.callPackage ./elf2uf2.nix { };
|
pkgs.pkg-config
|
||||||
devShell.x86_64-linux = pkgs.mkShell {
|
pkgs.stdenv.cc
|
||||||
buildInputs = with pkgs; [
|
];
|
||||||
espflash
|
|
||||||
esptool
|
shellHook = ''
|
||||||
esp-rs.packages.${system}.default
|
export RUSTUP_TOOLCHAIN=${self'.packages.esp-rs}
|
||||||
cargo-espmonitor
|
'';
|
||||||
# (pkgs.rust-bin.selectLatestNightlyWith (
|
};
|
||||||
# toolchain:
|
|
||||||
# toolchain.default.override {
|
|
||||||
# targets = [
|
|
||||||
# "thumbv6m-none-eabi"
|
|
||||||
# "xtensa-esp32-none-eabi"
|
|
||||||
# ];
|
|
||||||
# extensions = [ "rust-src" ];
|
|
||||||
# }
|
|
||||||
# ))
|
|
||||||
pkgs.rust-analyzer
|
|
||||||
pkgs.flip-link
|
|
||||||
pkgs.probe-rs-tools
|
|
||||||
self.packages.x86_64-linux.elf2uf2-rs
|
|
||||||
pkgs.rustfmt
|
|
||||||
# pkgs.picotool
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,31 @@
|
||||||
//! This example shows how to use USB (Universal Serial Bus) in the RP2040 chip.
|
|
||||||
//!
|
|
||||||
//! This creates the possibility to send log::info/warn/error/debug! to USB serial port.
|
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use embassy_executor::Spawner;
|
use arrayvec::ArrayString;
|
||||||
use embassy_rp::bind_interrupts;
|
use core::fmt::Write as _;
|
||||||
use embassy_rp::peripherals::USB;
|
use embedded_io::Write as _;
|
||||||
use embassy_rp::usb::{Driver, InterruptHandler};
|
use esp_hal::{clock::CpuClock, uart::Config, uart::Uart};
|
||||||
use embassy_time::Timer;
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
#[panic_handler]
|
||||||
USBCTRL_IRQ => InterruptHandler<USB>;
|
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||||
});
|
loop {}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
|
||||||
async fn logger_task(driver: Driver<'static, USB>) {
|
|
||||||
embassy_usb_logger::run!(1024, log::LevelFilter::Info, driver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[esp_hal::main]
|
||||||
async fn main(spawner: Spawner) {
|
fn main() -> ! {
|
||||||
let p = embassy_rp::init(Default::default());
|
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||||
let driver = Driver::new(p.USB, Irqs);
|
let peripherals = esp_hal::init(config);
|
||||||
spawner.spawn(logger_task(driver).unwrap());
|
|
||||||
|
|
||||||
let mut counter = 0;
|
let mut uart = Uart::new(peripherals.UART0, Config::default())
|
||||||
|
.unwrap()
|
||||||
|
.with_rx(peripherals.GPIO3)
|
||||||
|
.with_tx(peripherals.GPIO1);
|
||||||
|
|
||||||
|
let mut counter = 0u32;
|
||||||
loop {
|
loop {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
log::info!("Tick {}", counter);
|
let mut line = ArrayString::<32>::new();
|
||||||
Timer::after_secs(1).await;
|
write!(&mut line, "Tick {}\r\n", counter).unwrap();
|
||||||
|
uart.write(line.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue