Skip to content

Instantly share code, notes, and snippets.

View MabezDev's full-sized avatar
🦀
I may be slow to respond.

Scott Mabin MabezDev

🦀
I may be slow to respond.
View GitHub Profile
//! DHCP Example
//!
//!
//! Set SSID and PASSWORD env variable before running this example.
//!
//! This gets an ip address via DHCP then performs an HTTP get request to some "random" server
//% FEATURES: esp-wifi esp-wifi/wifi-default esp-wifi/wifi esp-wifi/utils
//% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6
{
"arch": "xtensa",
"cpu": "generic",
"crt-objects-fallback": "false",
"data-layout": "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32",
"emit-debug-gdb-scripts": false,
"is-builtin": false,
"linker": "xtensa-esp32-elf-gcc",
"linker-flavor": "gnu-cc",
"llvm-target": "xtensa-none-elf",
mabez at mGentoo ➜ blink git:(master) RUST_LOG="info" probe-rs run --chip esp32c6 build/blink.elf
INFO probe_rs::config::target: Using sequence Riscv(ESP32C6 { inner: EspFlashSizeDetector { stack_pointer: 1082195968, spiflash_peripheral: 1610625024, attach_fn: 1073742300, load_address: 0 } })
INFO probe_rs::probe::espusbjtag::protocol: Found ESP USB JTAG adapter, base speed is 24000kHz. Available dividers: (1..255)
INFO probe_rs::probe::espusbjtag: Setting scan chain to [ScanChainElement { name: Some("main"), ir_len: Some(5) }]
INFO probe_rs::probe::common: Found bypass TAP
INFO probe_rs::probe::common: Found bypass TAP
INFO probe_rs::probe::common: Found bypass TAP
INFO probe_rs::probe::common: Found bypass TAP
INFO probe_rs::probe::common: Found bypass TAP
INFO probe_rs::probe::common: Found bypass TAP
This file has been truncated, but you can view the full file.
{"timestamp":"2024-01-15T13:35:56.042203Z","level":"INFO","fields":{"message":"Writing log to \"test.log\""},"target":"probe_rs","filename":"probe-rs/src/bin/probe-rs/main.rs","line_number":328}
{"timestamp":"2024-01-15T13:35:56.045845Z","level":"DEBUG","fields":{"message":"Searching registry for chip with name esp32p4"},"target":"probe_rs::config::registry","filename":"probe-rs/src/config/registry.rs","line_number":174}
{"timestamp":"2024-01-15T13:35:56.045855Z","level":"DEBUG","fields":{"message":"Exact match for chip name: esp32p4"},"target":"probe_rs::config::registry","filename":"probe-rs/src/config/registry.rs","line_number":185}
{"timestamp":"2024-01-15T13:35:56.045930Z","level":"INFO","fields":{"message":"Using sequence Riscv(ESP32P4)"},"target":"probe_rs::config::target","filename":"probe-rs/src/config/target.rs","line_number":196}
{"timestamp":"2024-01-15T13:35:56.045948Z","level":"INFO","fields":{"message":"new"},"target":"probe_rs::probe::cmsisdap::tools","filename":"probe-rs/src/probe/cmsisdap/to
//! embassy wait
//!
//! This is an example of asynchronously `Wait`ing for a pin state to change.
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use embassy_executor::Executor;
use embassy_time::{Duration, Timer};
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x420182d6
0x420182d6 - _ZN14esp_hal_common7embassy11time_driver12EmbassyTimer3now17hdd745a8ad9f1c59cE
at ??:??
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x16ec
0x3fcd5820 - _stack_start
  1. Clone https://github.com/esp-rs/rust
  2. Ensure deps are met before starting the installation process, see the README.
  3. Run ./configure --experimental-targets=Xtensa --release-channel=nightly --enable-extended --tools=clippy,cargo,rustfmt
  4. Start the build with ./x.py build --stage 2
  5. Link the custom toolchain to rustup:
       rustup toolchain link esp build/$HOST/stage2
    

Where $HOST is your machines triple, i.e x86_64-unknown-linux-gnu

#[naked]
#[no_mangle]
#[link_section = ".rwtext"]
unsafe extern "C" fn save_context() {
asm!(
"
s32i a2, sp, +XT_STK_A2
s32i a3, sp, +XT_STK_A3
s32i a4, sp, +XT_STK_A4
s32i a5, sp, +XT_STK_A5
use rtfm::Mutex; // or mutex_trait
pub enum Operation<T: Mutex<T = ...> {
FileSystem(T) // Note: can't use impl Mutex<T = Filesystem> here, so we have to introduce the T type param
// ...
}
// If the `Operation` enum is buried deep within a type, it poisens that type with the same type parameter
pub struct Server<T: Mutex<T = ...> {
op: Operation<T>