Initial commit

Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
This commit is contained in:
Thomas Klaehn 2025-02-12 05:32:06 +01:00
commit 03a3c8732f
19 changed files with 2941 additions and 0 deletions

11
.cargo/config.toml Normal file
View File

@ -0,0 +1,11 @@
[alias]
esp32c6 = "build --release --features=esp32c6 --target riscv32imac-unknown-none-elf"
[build]
target = "riscv32imac-unknown-none-elf"
[target.'cfg(target_arch = "riscv32")']
runner = "espflash flash --monitor"
[unstable]
build-std = ["core"]

79
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,79 @@
# Base image
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
# Arguments
ARG CONTAINER_USER=esp
ARG CONTAINER_GROUP=esp
ARG NIGHTLY_VERSION=nightly-2024-06-30
ARG ESP_IDF_VERSION=v5.2.2
ARG ESP_BOARD=esp32c6
# Install dependencies
RUN apt-get update \
&& apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv \
cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 \
llvm-dev libclang-dev clang pkg-config unzip libusb-1.0-0 \
libpython3-all-dev python3-virtualenv curl \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# Set users
RUN adduser --disabled-password --gecos "" ${CONTAINER_USER}
RUN adduser ${CONTAINER_USER} root
USER ${CONTAINER_USER}
WORKDIR /home/${CONTAINER_USER}
# Install rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
--default-toolchain ${NIGHTLY_VERSION} -y --profile minimal \
--component rust-src,clippy,rustfmt
# Update envs
ENV PATH=${PATH}:$HOME/.cargo/bin
# Install extra crates
RUN ARCH=$($HOME/.cargo/bin/rustup show | grep "Default host" | sed -e 's/.* //') && \
curl -L "https://github.com/esp-rs/espflash/releases/latest/download/cargo-espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/cargo-espflash.zip" && \
unzip "${HOME}/.cargo/bin/cargo-espflash.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/cargo-espflash.zip" && \
chmod u+x "${HOME}/.cargo/bin/cargo-espflash" && \
curl -L "https://github.com/esp-rs/espflash/releases/latest/download/espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/espflash.zip" && \
unzip "${HOME}/.cargo/bin/espflash.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/espflash.zip" && \
chmod u+x "${HOME}/.cargo/bin/espflash" && \
curl -L "https://github.com/esp-rs/esp-web-flash-server/releases/latest/download/web-flash-${ARCH}.zip" -o "${HOME}/.cargo/bin/web-flash.zip" && \
unzip "${HOME}/.cargo/bin/web-flash.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/web-flash.zip" && \
chmod u+x "${HOME}/.cargo/bin/web-flash" && \
curl -L "https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-${ARCH}.zip" -o "${HOME}/.cargo/bin/ldproxy.zip" && \
unzip "${HOME}/.cargo/bin/ldproxy.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/ldproxy.zip" && \
chmod u+x "${HOME}/.cargo/bin/ldproxy" && \
GENERATE_VERSION=$(git ls-remote --refs --sort="version:refname" --tags "https://github.com/cargo-generate/cargo-generate" | cut -d/ -f3- | tail -n1) && \
GENERATE_URL="https://github.com/cargo-generate/cargo-generate/releases/latest/download/cargo-generate-${GENERATE_VERSION}-${ARCH}.tar.gz" && \
curl -L "${GENERATE_URL}" -o "${HOME}/.cargo/bin/cargo-generate.tar.gz" && \
tar xf "${HOME}/.cargo/bin/cargo-generate.tar.gz" -C "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/cargo-generate.tar.gz" && \
chmod u+x "${HOME}/.cargo/bin/cargo-generate"
# Install esp-idf
RUN mkdir -p ${HOME}/.espressif/frameworks/ \
&& git clone --branch ${ESP_IDF_VERSION} -q --depth 1 --shallow-submodules \
--recursive https://github.com/espressif/esp-idf.git \
${HOME}/.espressif/frameworks/esp-idf \
&& python3 ${HOME}/.espressif/frameworks/esp-idf/tools/idf_tools.py install cmake \
&& ${HOME}/.espressif/frameworks/esp-idf/install.sh ${ESP_BOARD} \
&& rm -rf .espressif/dist \
&& rm -rf .espressif/frameworks/esp-idf/docs \
&& rm -rf .espressif/frameworks/esp-idf/examples \
&& rm -rf .espressif/frameworks/esp-idf/tools/esp_app_trace \
&& rm -rf .espressif/frameworks/esp-idf/tools/test_idf_size
# Activate ESP environment
ENV IDF_TOOLS_PATH=${HOME}/.espressif
RUN echo "source ${HOME}/.espressif/frameworks/esp-idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
CMD "/bin/bash"

46
.devcontainer/devcontainer.json Executable file
View File

@ -0,0 +1,46 @@
{
"name": "esp32-dev",
"build": {
"dockerfile": "Dockerfile",
"args": {
"NIGHTLY_VERSION": "nightly-2025-01-01"
}
},
// Privileged container in order to access /dev
"privileged": true,
// Mount USB devices (debug probes, UART interfaces, ...)
"mounts": [
"source=/dev/bus/usb/,target=/dev/bus/usb/,type=bind"
],
"runArgs": [
"--device=/dev/ttyACM0"
],
"customizations": {
"vscode": {
"settings": {
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.formatOnType": true,
"lldb.executable": "/usr/bin/lldb",
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
},
"extensions": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"yzhang.markdown-all-in-one"
]
}
},
"remoteUser": "esp",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace"
}

50
.devcontainer/test.sh Normal file
View File

@ -0,0 +1,50 @@
#!/bin/sh
set -ef
echo "Compiling $1"
cd /home/esp/workspace/$1
if [ -f cfg.toml.example ]; then
# Rename file to cfg.toml
cp cfg.toml.example cfg.toml
# Replace defaults
sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "Wokwi-GUEST"/g' cfg.toml
sed -i 's/wifi_psk = "hunter2"/wifi_psk = ""/g' cfg.toml
sed -i 's/mqtt_user = "horse"/mqtt_user = "user"/g' cfg.toml
sed -i 's/mqtt_pass = "CorrectHorseBatteryStaple"/mqtt_pass = "pass"/g' cfg.toml
sed -i 's/mqtt_host = "yourpc.local"/mqtt_host = "host"/g' cfg.toml
fi
$HOME/.cargo/bin/cargo clean
$HOME/.cargo/bin/cargo build
# Check examples
if [[ "$1" == advanced/button-interrupt ]]; then
$HOME/.cargo/bin/cargo build --example solution
$HOME/.cargo/bin/cargo build --example solution_led
# Simulate with Wokwi
sed -i 's/^[[:space:]]*firmware[[:space:]]*=[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']\([[:space:]]*\)$/\nfirmware = "target\/riscv32imc-esp-espidf\/debug\/examples\/solution"/' wokwi.toml
fi
if [[ "$1" == advanced/i2c-sensor-reading ]]; then
$HOME/.cargo/bin/cargo build --example part_1
$HOME/.cargo/bin/cargo build --example part_2
fi
if [[ "$1" == intro/http-client ]]; then
$HOME/.cargo/bin/cargo build --example http_client
$HOME/.cargo/bin/cargo build --example https_client
# Simulate with Wokwi
sed -i 's/^[[:space:]]*firmware[[:space:]]*=[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']\([[:space:]]*\)$/\nfirmware = "target\/riscv32imc-esp-espidf\/debug\/examples\/http_client"/' wokwi.toml
fi
if [[ "$1" == intro/http-server ]]; then
$HOME/.cargo/bin/cargo build --example http_server
fi
if [[ "$1" == intro/mqtt/exercise ]]; then
$HOME/.cargo/bin/cargo build --example solution_publ_rcv
$HOME/.cargo/bin/cargo build --example solution_publ
fi

17
.gitignore vendored Normal file
View File

@ -0,0 +1,17 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

22
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Cortex Debug",
"cwd": "${workspaceFolder}",
"executable": "./std-training/intro/hardware-check/target/riscv32imc-esp-espidf/debug/",
"request": "launch",
"type": "cortex-debug",
"runToEntryPoint": "main",
"gdbPath": "gdb-multiarch",
"servertype": "openocd",
"configFiles": [
"interface/stlink.cfg",
"target/stm32g0x.cfg"
]
}
]
}

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"rust-analyzer.cargo.allTargets": false,
"rust-analyzer.cargo.target": "riscv32imac-unknown-none-elf",
}

48
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,48 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"args": [
"-p",
"lp-core",
"--release"
],
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build"
},
"label": "rust: cargo build lp-core"
},
{
"type": "cargo",
"command": "check",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo check"
},
{
"type": "cargo",
"command": "clean",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo clean"
},
{
"type": "cargo",
"command": "run",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo run"
}
]
}

2282
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

5
Cargo.toml Normal file
View File

@ -0,0 +1,5 @@
cargo-features = ["profile-rustflags"]
[workspace]
members = ["hp-core", "lp-core"]
resolver = "2"

41
Readme.md Normal file
View File

@ -0,0 +1,41 @@
# ESP32-C6
Template firmware for both, low-performance and high performance core of the
esp32-c6 riscv processor.
## hp-core
Firmware for the high performance core.
### Build
```shell
cargo build --package hp-core --release
```
## lp-core
Firmware for the low performance core.
### Build
```shell
cargo build --package lp-core --release
```
## Execution
```shell
cargo run --package hp-core --release
```
### Preconditions
In order to execute/flash the project some conditions must be fulfilled:
* hardware target is connected with USB before the devcontainer is launched
* the belonging tty device is named `ttyACM0` (otherwise rename it in
`.devcontainer/devcontainer.json`)
* the belonging tty device (`ttyACM0`) is member of the `root` group because
the devcontainer user (`esp`) is in this group too. If this changes it must
be adoptet in `.devcontainer/Dockerfile`

79
hp-core/Cargo.toml Normal file
View File

@ -0,0 +1,79 @@
[package]
name = "hp-core"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
publish = false
[dependencies]
aligned = { version = "0.4.2", optional = true }
bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [ "macros", "async"] }
blocking-network-stack = { git = "https://github.com/bjoernQ/blocking-network-stack.git", rev = "b3ecefc222d8806edd221f266999ca339c52d34e" }
bt-hci = "0.2.0"
cfg-if = "1.0.0"
critical-section = "1.1.3"
embassy-executor = { version = "0.7.0", features = ["task-arena-size-20480"] }
embassy-futures = "0.1.1"
embassy-net = { version = "0.6.0", features = [ "tcp", "udp", "dhcpv4", "medium-ethernet"] }
embassy-sync = "0.6.0"
embassy-time = "0.4.0"
embassy-usb = { version = "0.2.0", default-features = false }
embedded-can = "0.4.1"
embedded-hal-async = "1.0.0"
embedded-io = { version = "0.6.1", default-features = false }
embedded-io-async = "0.6.1"
embedded-storage = "0.3.1"
esp-alloc = "0.6.0"
esp-backtrace = { version = "0.15.0", features = ["esp32c6", "exception-handler", "panic-handler", "println"] }
esp-hal = { version = "0.23.1", features = ["log"] }
esp-hal-embassy = { version = "0.6.0", optional = true }
esp-ieee802154 = { version = "0.5.0", optional = true }
esp-println = { version = "0.13.0", features = ["log"] }
esp-storage = { version = "0.4.0", optional = true }
esp-wifi = { version = "0.12.0", features = ["log"], optional = true }
heapless = "0.8.0"
hmac = { version = "0.12.1", default-features = false }
ieee80211 = { version = "0.4.0", default-features = false }
ieee802154 = "0.6.1"
log = "0.4.22"
nb = "1.1.0"
portable-atomic = { version = "1.9.0", default-features = false }
sha2 = { version = "0.10.8", default-features = false }
smoltcp = { version = "0.12.0", default-features = false, features = [ "medium-ethernet", "socket-raw"] }
embedded-time = "=0.12.1"
static_cell = { version = "2.1.0", features = ["nightly"] }
usb-device = "0.3.2"
usbd-serial = "0.2.2"
edge-dhcp = { version = "0.5.0" }
edge-raw = { version = "0.5.0" }
edge-nal = { version = "0.5.0" }
edge-nal-embassy = { version = "0.5.0" }
[features]
default=["esp32c6"]
esp32 = ["esp-hal/esp32", "esp-backtrace/esp32", "esp-hal-embassy?/esp32", "esp-println/esp32", "esp-storage?/esp32", "esp-wifi?/esp32"]
esp32c2 = ["esp-hal/esp32c2", "esp-backtrace/esp32c2", "esp-hal-embassy?/esp32c2", "esp-println/esp32c2", "esp-storage?/esp32c2", "esp-wifi?/esp32c2", ]
esp32c3 = ["esp-hal/esp32c3", "esp-backtrace/esp32c3", "esp-hal-embassy?/esp32c3", "esp-println/esp32c3", "esp-storage?/esp32c3", "esp-wifi?/esp32c3"]
esp32c6 = ["esp-hal/esp32c6", "esp-backtrace/esp32c6", "esp-hal-embassy?/esp32c6", "esp-println/esp32c6", "esp-storage?/esp32c6", "esp-wifi?/esp32c6", "esp-ieee802154?/esp32c6"]
esp32h2 = ["esp-hal/esp32h2", "esp-backtrace/esp32h2", "esp-hal-embassy?/esp32h2", "esp-println/esp32h2", "esp-storage?/esp32h2", "esp-wifi?/esp32h2", "esp-ieee802154?/esp32h2"]
esp32s2 = ["esp-hal/esp32s2", "esp-backtrace/esp32s2", "esp-hal-embassy?/esp32s2", "esp-println/esp32s2", "esp-storage?/esp32s2", "esp-wifi?/esp32s2"]
esp32s3 = ["esp-hal/esp32s3", "esp-backtrace/esp32s3", "esp-hal-embassy?/esp32s3", "esp-println/esp32s3", "esp-storage?/esp32s3", "esp-wifi?/esp32s3"]
esp-wifi = ["dep:esp-wifi"]
embassy = ["dep:esp-hal-embassy"]
[profile.release]
codegen-units = 1
debug = 2
debug-assertions = true
incremental = false
opt-level = 3
lto = 'fat'
overflow-checks = false
[build]
rustflags = [
"-C", "force-frame-pointers",
]

19
hp-core/build.rs Normal file
View File

@ -0,0 +1,19 @@
use std::error::Error;
// use esp_build::assert_unique_used_features;
fn main() -> Result<(), Box<dyn Error>> {
// assert_unique_used_features!("esp32c6");
// NOTE: update when adding new device support!
// Determine the name of the configured device:
let device_name = "esp32c6";
// Define all necessary configuration symbols for the configured device:
println!("cargo:rustc-cfg={}", device_name);
println!("cargo:rustc-link-arg=-Tlinkall.x");
// // Done!
Ok(())
}

52
hp-core/src/main.rs Normal file
View File

@ -0,0 +1,52 @@
//! This shows a very basic example of running code on the LP core.
//!
//! Code on LP core increments a counter and continuously toggles LED. The
//! current value is printed by the HP core.
//!
//! Make sure to first compile the `esp-lp-hal/examples/blinky.rs` example
//!
//! The following wiring is assumed:
//! - LED => GPIO1
//% CHIPS: esp32c6
//% FEATURES: esp-hal/unstable
#![no_std]
#![no_main]
use esp_backtrace as _;
use esp_hal::{
gpio::lp_io::LowPowerOutput,
load_lp_code,
lp_core::{LpCore, LpCoreWakeupSource},
main,
};
use esp_println::{print, println};
#[main]
fn main() -> ! {
let peripherals = esp_hal::init(esp_hal::Config::default());
// configure GPIO 1 as LP output pin
let lp_pin = LowPowerOutput::new(peripherals.GPIO1);
let mut lp_core = LpCore::new(peripherals.LP_CORE);
lp_core.stop();
println!("lp core stopped");
// load code to LP core
let lp_core_code =
load_lp_code!("./target/riscv32imac-unknown-none-elf/release/lp-core");
// start LP core
lp_core_code.run(&mut lp_core, LpCoreWakeupSource::HpCpu, lp_pin);
println!("lpcore run");
let data = (0x5000_2000) as *mut u32;
loop {
print!("Current {:x} \u{000d}", unsafe {
data.read_volatile()
});
}
}

45
lp-core/Cargo.toml Normal file
View File

@ -0,0 +1,45 @@
[package]
name = "lp-core"
version = "0.1.0"
edition = "2021"
rust-version = "1.84.0"
description = "Firmware for esp32-c6's low power core"
keywords = ["embedded", "embedded-hal", "esp32", "espressif", "hal"]
categories = ["embedded", "hardware-support", "no-std"]
license = "MIT OR Apache-2.0"
[dependencies]
cfg-if = "1.0.0"
document-features = "0.2.10"
esp-lp-hal = { version = "0.1.0", features = ["esp32c6"] }
embedded-hal = { version = "1.0.0" }
embedded-hal-nb = { version = "1.0.0", optional = true }
embedded-io = { version = "0.6.1", optional = true }
esp32c6-lp = { version = "0.3.0", features = ["critical-section"], optional = true }
nb = { version = "1.1.0", optional = true }
procmacros = { version = "0.16.0", package = "esp-hal-procmacros" }
riscv = { version = "0.11.1", features = ["critical-section-single-hart"] }
panic-halt = "0.2.0"
[build-dependencies]
esp-build = { version = "0.2.0" }
[features]
default = ["esp32c6"]
## Enable debug features in the HAL (used for development).
debug = [
"esp32c6-lp?/impl-register-debug",
]
# Chip Support Feature Flags
# Target the ESP32-C6.
esp32c6 = ["dep:esp32c6-lp", "procmacros/is-lp-core", "dep:nb"]
# embedded-hal = ["dep:embedded-hal"]
#! ### Trait Implementation Feature Flags
## Implement the traits defined in the `1.0.0` releases of `embedded-hal` and
## `embedded-hal-nb` for the relevant peripherals.
# embedded-hal = ["dep:embedded-hal", "dep:embedded-hal-nb"]
## Implement the traits defined in `embedded-io` for the relevant peripherals.
# embedded-io = ["dep:embedded-io"]

27
lp-core/build.rs Normal file
View File

@ -0,0 +1,27 @@
use std::error::Error;
use esp_build::assert_unique_used_features;
fn main() -> Result<(), Box<dyn Error>> {
assert_unique_used_features!("esp32c6");
// NOTE: update when adding new device support!
// Determine the name of the configured device:
let device_name = "esp32c6";
// Define all necessary configuration symbols for the configured device:
println!("cargo:rustc-cfg={}", device_name);
// Put the linker script somewhere the linker can find it:
// let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
// println!("cargo:rustc-link-search={}", out.display());
// Copy the required linker script to the `out` directory:
// fs::copy("lp-core/ld/link.x", out.join("link.x"))?;
// println!("cargo:rerun-if-changed=lp-core/ld/link.x");
println!("cargo:rustc-link-arg=-Tlp-core/ld/link.x");
// // Done!
Ok(())
}

67
lp-core/ld/link.x Normal file
View File

@ -0,0 +1,67 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
ENTRY(reset_vector)
VECTOR_TABLE_LENGTH = 0x80;
CONFIG_ULP_COPROC_RESERVE_MEM = 1024 * 16;
CONFIG_ULP_SHARED_MEM = 0;
RAM_LENGTH = CONFIG_ULP_COPROC_RESERVE_MEM - VECTOR_TABLE_LENGTH - CONFIG_ULP_SHARED_MEM;
MEMORY
{
/*first 128byte for exception/interrupt vectors*/
vector_table(RX) : ORIGIN = 0x50000000, LENGTH = VECTOR_TABLE_LENGTH
ram(RWX) : ORIGIN = 0x50000080, LENGTH = RAM_LENGTH
}
SECTIONS
{
.vector.text :
{
/* Exception/interrupt vectors */
__mtvec_base = .;
KEEP (*(.init.vector))
__mtvec_end = .;
} > vector_table
. = ORIGIN(ram);
.text ALIGN(4):
{
*(.text.vectors) /* Default reset vector must link to offset 0x80 */
KEEP(*(.init));
KEEP(*(.init.rust));
*(.text)
*(.text*)
} > ram
.rodata ALIGN(4):
{
*(.rodata)
*(.rodata*)
} > ram
.data ALIGN(4):
{
*(.data)
*(.data*)
*(.sdata)
*(.sdata*)
} > ram
.bss ALIGN(4) :
{
*(.bss)
*(.bss*)
*(.sbss)
*(.sbss*)
PROVIDE(end = .);
} > ram
__stack_top = ORIGIN(ram) + LENGTH(ram);
}

35
lp-core/src/main.rs Normal file
View File

@ -0,0 +1,35 @@
//! Counts a 32 bit value at a known point in memory, and blink GPIO1.
//!
//! When using the ESP32-C6's LP core, this address in memory is `0x5000_2000`.
//!
//! Make sure the LP RAM is cleared before loading the code.
#![no_std]
#![no_main]
use embedded_hal::{delay::DelayNs, digital::OutputPin};
use esp_lp_hal::{delay::Delay, gpio::Output, prelude::*};
use panic_halt as _;
const ADDRESS: u32 = 0x5000_2000;
#[entry]
fn main(mut gpio1: Output<1>) -> ! {
let mut i: u32 = 0;
let ptr = ADDRESS as *mut u32;
loop {
i = i.wrapping_add(1u32);
unsafe {
ptr.write_volatile(i);
}
gpio1.set_high().unwrap();
Delay.delay_ms(500);
gpio1.set_low().unwrap();
Delay.delay_ms(500);
}
}

12
workspace.code-workspace Normal file
View File

@ -0,0 +1,12 @@
{
"folders": [
{
"path": ".",
"name": "ESP32-C6"
},
// { "path": "/usr/src/libperiCORE", "name":"libperiCORE" },
// { "path": "/usr/src/seve", "name":"sève" },
// { "path": "/usr/src/periCORE-buildsystem", "name":"periCORE-buildsystem" },
// { "path": "/usr/src/", "name": "/usr/src" }
]
}