Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View MabezDev's full-sized avatar
🦀

Scott Mabin MabezDev

🦀
View GitHub Profile
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>

To find the substitute path for the from section:

find $(rustc --print sysroot) -maxdepth 2 -mindepth 2  -type f -name "libstd-*" -exec strings {} \; | grep -o '^/rustc/[^/]\+/' | uniq

which produces something like /rustc/9a90d03ad171856dc016c2dcc19292ec49a8a26f/

Next install rust-src component if you haven't already. Then combine the output of rustc --print sysroot with /lib/rustlib/src/rust to find your downloaded sources.

/// Feed the WDT watchdog
pub fn feed_wdt() {
const RTC_WDT_BASE: u32 = 0x3ff48000;
const RTC_WDT_WPROTECT: u32 = RTC_WDT_BASE + 0xa4;
const RTC_WDT_FEED: u32 = RTC_WDT_BASE + 0xa0;
unsafe {
core::ptr::write_volatile(RTC_WDT_WPROTECT as *mut _, 0); // disable write protection
{
core::ptr::write_volatile(RTC_WDT_FEED as *mut _, 0x1); // feed the watch dog