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]
|
||||
target = "xtensa-esp32-none-elf"
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Wl,-Tlinkall.x",
|
||||
"-C", "link-arg=-nostartfiles",
|
||||
]
|
||||
|
||||
[unstable]
|
||||
build-std = ["core", "alloc", "compiler_builtins"]
|
||||
|
||||
[env]
|
||||
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]
|
||||
name = "pico"
|
||||
name = "esp32"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
debug-assertions = true
|
||||
lto = "fat"
|
||||
codegen-units = 1
|
||||
|
||||
|
||||
[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"
|
||||
embassy-usb-logger = "0.5.1"
|
||||
ufmt = "0.2.0"
|
||||
log = "0.4"
|
||||
ag-lcd={ version = "0.3", features = ["ufmt"]}
|
||||
|
|
@ -16,7 +27,6 @@ embedded-io-async = "0.7.0"
|
|||
embedded-io = "0.7.1"
|
||||
owned_str = "0.1.2"
|
||||
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-executor = { version = "0.10.0", features = [
|
||||
"platform-cortex-m",
|
||||
|
|
@ -24,29 +34,15 @@ embassy-executor = { version = "0.10.0", features = [
|
|||
"executor-interrupt",
|
||||
"defmt",
|
||||
] }
|
||||
embassy-rp = { version = "0.10.0", features = [
|
||||
"defmt",
|
||||
"unstable-pac",
|
||||
"time-driver",
|
||||
"critical-section-impl",
|
||||
"rp2040",
|
||||
] }
|
||||
embassy-time = { version = "0.5.1", features = [
|
||||
"defmt",
|
||||
"defmt-timestamp-uptime",
|
||||
] }
|
||||
|
||||
cortex-m = { version = "0.7.7", features = ["inline-asm"] }
|
||||
cortex-m-rt = "0.7.5"
|
||||
critical-section = "1.2.0"
|
||||
static_cell = "2.1.1"
|
||||
portable-atomic = { version = "1.13.1", features = ["critical-section"] }
|
||||
|
||||
|
||||
defmt = "1.0.1"
|
||||
defmt-rtt = "1.1.0"
|
||||
|
||||
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
|
||||
// `memory.x` is changed.
|
||||
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"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1760038930,
|
||||
|
|
@ -68,33 +86,33 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"nixpkgs-lib_2": {
|
||||
"locked": {
|
||||
"lastModified": 1777383249,
|
||||
"narHash": "sha256-b6T90GXUr21iIu6Aw+KGy5uSiB/cVT/UecId1YSESys=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "61a7520db583d9b41be602b4c1e1b1b1b1faa1f4",
|
||||
"lastModified": 1777168982,
|
||||
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1744536153,
|
||||
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
|
||||
"lastModified": 1777954456,
|
||||
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
|
||||
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
|
@ -102,26 +120,8 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"esp-rs": "esp-rs",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
"flake-parts": "flake-parts_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,49 +1,33 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
esp-rs.url = "github:leighleighleigh/esp-rs-nix";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
rust-overlay,
|
||||
nixpkgs,
|
||||
esp-rs,
|
||||
}:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
inherit overlays;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.x86_64-linux.elf2uf2-rs = pkgs.callPackage ./elf2uf2.nix { };
|
||||
devShell.x86_64-linux = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
espflash
|
||||
esptool
|
||||
esp-rs.packages.${system}.default
|
||||
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
|
||||
];
|
||||
outputs = inputs @ { flake-parts, esp-rs, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
||||
imports = [
|
||||
"${esp-rs}/package.nix"
|
||||
];
|
||||
|
||||
perSystem = { pkgs, self', ... }: {
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
self'.packages.esp-rs
|
||||
pkgs.rust-analyzer
|
||||
pkgs.rustup
|
||||
pkgs.espflash
|
||||
pkgs.pkg-config
|
||||
pkgs.stdenv.cc
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export RUSTUP_TOOLCHAIN=${self'.packages.esp-rs}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_main]
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_rp::bind_interrupts;
|
||||
use embassy_rp::peripherals::USB;
|
||||
use embassy_rp::usb::{Driver, InterruptHandler};
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
use arrayvec::ArrayString;
|
||||
use core::fmt::Write as _;
|
||||
use embedded_io::Write as _;
|
||||
use esp_hal::{clock::CpuClock, uart::Config, uart::Uart};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
USBCTRL_IRQ => InterruptHandler<USB>;
|
||||
});
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn logger_task(driver: Driver<'static, USB>) {
|
||||
embassy_usb_logger::run!(1024, log::LevelFilter::Info, driver);
|
||||
#[panic_handler]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
let p = embassy_rp::init(Default::default());
|
||||
let driver = Driver::new(p.USB, Irqs);
|
||||
spawner.spawn(logger_task(driver).unwrap());
|
||||
#[esp_hal::main]
|
||||
fn main() -> ! {
|
||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||
let peripherals = esp_hal::init(config);
|
||||
|
||||
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 {
|
||||
counter += 1;
|
||||
log::info!("Tick {}", counter);
|
||||
Timer::after_secs(1).await;
|
||||
let mut line = ArrayString::<32>::new();
|
||||
write!(&mut line, "Tick {}\r\n", counter).unwrap();
|
||||
uart.write(line.as_bytes()).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue