Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a571bf6
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
a2c6145
Teach `esp-hal-common` about the ESP32-C6
jessebraham Jan 6, 2023
f358cad
Get a number of peripheral drivers building for the ESP32-C6
jessebraham Jan 6, 2023
fc65b3f
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
bea1242
Simplify and fix the linker script
bjoernQ Jan 20, 2023
5f8e2d1
C6: add I2S
JurajSadel Jan 25, 2023
6db490d
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
a38ced1
Teach `esp-hal-common` about the ESP32-C6
jessebraham Jan 6, 2023
730f57f
Get a number of peripheral drivers building for the ESP32-C6
jessebraham Jan 6, 2023
3cec8bb
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
1e5ef3c
C6: update
JurajSadel Jan 20, 2023
e6df68d
Simplify and fix the linker script
bjoernQ Jan 20, 2023
d2b0734
update
JurajSadel Jan 24, 2023
bde4bb5
C6: add I2S
JurajSadel Jan 25, 2023
6351eee
update
JurajSadel Jan 24, 2023
51cb4c0
C6 Interrupts
bjoernQ Jan 25, 2023
753414a
C6: Update build.rs, linker scripts and initial examples
JurajSadel Jan 27, 2023
dece8b4
C6: RMT
JurajSadel Jan 27, 2023
3ad20aa
Fix interrupt handling
bjoernQ Jan 26, 2023
731f1cb
Fix `ClockControl::configure`
bjoernQ Jan 27, 2023
b0e7a59
C6: revert to I2S0 instead of just I2S
JurajSadel Jan 30, 2023
ae4e4b5
C6: rebase and update
JurajSadel Feb 1, 2023
a4edc46
RTC not buildable
JurajSadel Feb 2, 2023
988b1d0
Implement RWDT and SWD disable
bjoernQ Feb 2, 2023
ac4c447
C6: working LEDC
JurajSadel Feb 3, 2023
8ddaf7e
C6: working RMT
JurajSadel Feb 3, 2023
2b7fd7d
C6: add aes
JurajSadel Feb 7, 2023
b100cb2
C6: add mcpwm
JurajSadel Feb 7, 2023
9968157
C6: add rtc_cntln - not finished
JurajSadel Feb 7, 2023
cfb8445
C6: update and formatting
JurajSadel Feb 7, 2023
f9b7e19
C6: add pcnt
JurajSadel Feb 7, 2023
a7e14a9
C6: add examples and format
JurajSadel Feb 7, 2023
b7f0316
Remove inline assembly, fix interrupts and linker scripts
jessebraham Feb 7, 2023
a2e4c93
Remove unused features, update cargo config for atomic emu, misc cleanup
jessebraham Feb 7, 2023
8217147
Get ADC building and example "working" (as much as it ever does)
jessebraham Feb 7, 2023
a933093
Remove a bunch of unused constants which were copied from ESP-IDF
jessebraham Feb 7, 2023
93f926f
The `mcpwm` example now works correctly
jessebraham Feb 7, 2023
59a599d
Get `TWAI` peripheral driver building for C6
jessebraham Feb 8, 2023
46487eb
Clean up the `rtc_cntl` module and get all the other HALs building again
jessebraham Feb 8, 2023
4f97342
Add the C6 to our CI workflow
jessebraham Feb 8, 2023
403c640
Fix various things that have been missed when rebasing
jessebraham Feb 8, 2023
08f6f19
C6: Small updates in wdt (#1)
JurajSadel Feb 9, 2023
730b6b3
Update `esp-println` dependency to fix build errors
jessebraham Feb 9, 2023
e903e90
Fix formatting issues causing pre-commit hook to fail
jessebraham Feb 9, 2023
3622bc1
Get some more examples working
jessebraham Feb 9, 2023
9747426
Working `ram` example
jessebraham Feb 10, 2023
e41ecdd
Sync with changes in `main` after rebasing
jessebraham Feb 10, 2023
28ece39
Working `embassy_spi` example
jessebraham Feb 10, 2023
dd7f469
Use a git dependency for the PAC until we publish a release
jessebraham Feb 10, 2023
7dd27e5
Fix I2S for ESP32-C6
bjoernQ Feb 14, 2023
39444ba
Fix esp32c6 direct boot (#4)
MabezDev Feb 22, 2023
d16cab7
Update RWDT and refactor RTC (#3)
JurajSadel Feb 23, 2023
87cf485
Make required changes to include new `RADIO` peripheral
jessebraham Feb 23, 2023
0d3fd81
Use published versions of PAC and `esp-println`
jessebraham Feb 23, 2023
a381487
Use the correct target extensions (`imac`)
jessebraham Feb 24, 2023
572e99d
Fix the super watchdog timer, plus a few more examples
jessebraham Feb 24, 2023
dc309ea
Fix UART clock configuration
jessebraham Feb 24, 2023
716163b
Make sure to sync UART registers when configuring AT cmd detection
bjoernQ Feb 27, 2023
2f5972b
Disable APM in direct-boot mode
bjoernQ Feb 27, 2023
3eb273a
Address a number of review comments
jessebraham Feb 27, 2023
6641a0d
Fix `SPI` clocks and `rtc_watchdog` example (#6)
JurajSadel Feb 27, 2023
9e5f298
README and example fixes/cleanup
jessebraham Feb 27, 2023
ed59cd9
Add I2C peripheral enable and reset
bjoernQ Feb 27, 2023
e678120
Fix `ApbSarAdc` configuration in `system.rs`
jessebraham Feb 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Create the esp32c6-hal package
  • Loading branch information
jessebraham committed Feb 23, 2023
commit a571bf6013ab135ec6cb45ebbc619ff344bc5ced
3 changes: 3 additions & 0 deletions esp-hal.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
{
"path": "esp32c3-hal"
},
{
"path": "esp32c6-hal"
},
{
"path": "esp32s2-hal"
},
Expand Down
20 changes: 20 additions & 0 deletions esp32c6-hal/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[target.riscv32imc-unknown-none-elf]
runner = "espflash --monitor"
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "force-frame-pointers",
]

# for testing: you can specify this target to see atomic emulation in action
[target.riscv32imac-unknown-none-elf]
runner = "espflash --monitor"
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "force-frame-pointers",
]

[build]
target = "riscv32imc-unknown-none-elf"

[unstable]
build-std = [ "core" ]
76 changes: 76 additions & 0 deletions esp32c6-hal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[package]
name = "esp32c6-hal"
version = "0.3.0"
authors = [
"Jesse Braham <[email protected]>",
"Björn Quentin <[email protected]>",
]
edition = "2021"
rust-version = "1.60.0"
description = "HAL for ESP32-C3 microcontrollers"
repository = "https://github.com/esp-rs/esp-hal"
license = "MIT OR Apache-2.0"

keywords = [
"embedded",
"embedded-hal",
"esp",
"esp32c3",
"no-std",
]
categories = [
"embedded",
"hardware-support",
"no-std",
]

[dependencies]
cfg-if = "1.0.0"
embassy-time = { version = "0.1.0", features = ["nightly"], optional = true }
embedded-hal = { version = "0.2.7", features = ["unproven"] }
embedded-hal-1 = { version = "=1.0.0-alpha.9", optional = true, package = "embedded-hal" }
embedded-hal-async = { version = "0.1.0-alpha.3", optional = true }
embedded-hal-nb = { version = "=1.0.0-alpha.1", optional = true }
esp-hal-common = { version = "0.4.0", features = ["esp32c6"], path = "../esp-hal-common" }
r0 = "1.0.0"
riscv = "0.10.0"
riscv-rt = { version = "0.10.0", optional = true }

[dev-dependencies]
critical-section = "1.1.1"
embassy-executor = { package = "embassy-executor", git = "https://github.com/embassy-rs/embassy/", rev = "eed34f9", features = ["nightly", "integrated-timers"] }
embedded-graphics = "0.7.1"
esp-backtrace = { git = "https://github.com/jessebraham/esp-backtrace", branch = "feature/chip-support", features = ["esp32c6", "panic-handler", "exception-handler", "print-uart"] }
esp-println = { git = "https://github.com/esp-rs/esp-println", rev = "fc4e9cf", features = ["esp32c6"] }
sha2 = { version = "0.10.6", default-features = false}
smart-leds = "0.3.0"
ssd1306 = "0.7.1"
static_cell = "1.0.0"

[features]
default = ["rt", "vectored"]
direct-boot = []
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb"]
rt = ["riscv-rt"]
smartled = ["esp-hal-common/smartled"]
ufmt = ["esp-hal-common/ufmt"]
vectored = ["esp-hal-common/vectored"]
async = ["esp-hal-common/async", "embedded-hal-async"]
embassy = ["esp-hal-common/embassy"]
embassy-time-systick = ["esp-hal-common/embassy-time-systick", "embassy-time/tick-hz-16_000_000"]

# [[example]]
# name = "hello_rgb"
# required-features = ["smartled"]

# [[example]]
# name = "spi_eh1_loopback"
# required-features = ["eh1"]

# [[example]]
# name = "spi_eh1_device_loopback"
# required-features = ["eh1"]

# [[example]]
# name = "embassy_hello_world"
# required-features = ["embassy"]
76 changes: 76 additions & 0 deletions esp32c6-hal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# esp32c6-hal

[![Crates.io](https://img.shields.io/crates/v/esp32c6-hal?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp32c6-hal)
[![docs.rs](https://img.shields.io/docsrs/esp32c6-hal?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.rs/esp32c6-hal)
![Crates.io](https://img.shields.io/crates/l/esp32c6-hal?labelColor=1C2C2E&style=flat-square)
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)

`no_std` HAL for the ESP32-C6 from Espressif. Implements a number of the traits defined by [embedded-hal](https://github.com/rust-embedded/embedded-hal).

This device uses the RISC-V ISA, which is officially supported by the Rust compiler via the `riscv32imc-unknown-none-elf` target. Refer to the [Getting Stared](#getting-started) section below for more information.

## [Documentation]

[documentation]: https://docs.rs/esp32c6-hal/

## Getting Started

### Installing the Rust Compiler Target

The compilation target for this device is officially supported via the `stable` release channel and can be installed via [rustup](https://rustup.rs/):

```shell
$ rustup target add riscv32imc-unknown-none-elf
```

### Supported boot methods

#### IDF Bootloader

The [IDF second stage bootloader](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-guides/startup.html#second-stage-bootloader) is the default bootloader solution.

By default, [espflash](https://github.com/esp-rs/espflash) fetches the required binaries (Bootloader and Partition Table) and flashes them onto the target device together with the Rust-based application firmware image.

#### Direct Boot

[Direct Boot](https://github.com/espressif/esp32c6-direct-boot-example#direct-boot-in-esp32-c6) allows an application stored in the External Flash to be executed directly, without being copied into Internal RAM.

##### Booting the Hello World example using Direct Boot

Build the Hello World example with support for Direct Boot:

```shell
cargo build --release --example hello_world --features direct-boot
```

Then proceed to generating the application binary and flashing it onto the target device:

```shell
cargo espflash --release --format direct-boot --features direct-boot --example hello_world --monitor
```

The ROM Bootloader will identify the firmware image built with Direct Boot support and load it appropriately from the External Flash:

```shell
ESP-ROM:esp32c6-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
Hello world!
Hello world!
Hello world!
```

## License

Licensed under either of:

- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without
any additional terms or conditions.
74 changes: 74 additions & 0 deletions esp32c6-hal/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
use std::{env, fs::File, io::Write, path::PathBuf};

#[cfg(feature = "direct-boot")]
fn main() {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("ld/db-esp32c6-memory.x"))
.unwrap();

File::create(out.join("esp32c6-link.x"))
.unwrap()
.write_all(include_bytes!("ld/db-esp32c6-link.x"))
.unwrap();

File::create(out.join("riscv-link.x"))
.unwrap()
.write_all(include_bytes!("ld/db-riscv-link.x"))
.unwrap();

File::create(out.join("linkall.x"))
.unwrap()
.write_all(include_bytes!("ld/db-linkall.x"))
.unwrap();

println!("cargo:rustc-link-search={}", out.display());

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");

add_defaults();
}

#[cfg(not(feature = "direct-boot"))]
fn main() {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("ld/bl-esp32c6-memory.x"))
.unwrap();

File::create(out.join("bl-riscv-link.x"))
.unwrap()
.write_all(include_bytes!("ld/bl-riscv-link.x"))
.unwrap();

File::create(out.join("linkall.x"))
.unwrap()
.write_all(include_bytes!("ld/bl-linkall.x"))
.unwrap();

println!("cargo:rustc-link-search={}", out.display());

// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=ld/memory.x");

add_defaults();
}

fn add_defaults() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out.join("hal-defaults.x"))
.unwrap()
.write_all(include_bytes!("ld/hal-defaults.x"))
.unwrap();

println!("cargo:rustc-link-search={}", out.display());
}
43 changes: 43 additions & 0 deletions esp32c6-hal/ld/bl-esp32c6-memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
MEMORY
{
/* MEMORY_MAP = [
[0x00000000, 0x00010000, "PADDING"],
[0x42800000, 0x43000000, "DROM"],
[0x40800000, 0x40880000, "DRAM"],
[0x40800000, 0x40880000, "BYTE_ACCESSIBLE"],
[0x4004AC00, 0x40050000, "DROM_MASK"],
[0x40000000, 0x4004AC00, "IROM_MASK"],
[0x42000000, 0x42800000, "IROM"],
[0x40800000, 0x40880000, "IRAM"],
[0x50000000, 0x50004000, "RTC_IRAM"],
[0x50000000, 0x50004000, "RTC_DRAM"],
[0x600FE000, 0x60100000, "MEM_INTERNAL2"],
] */

/* 512K of on soc RAM, 32K reserved for cache */
ICACHE : ORIGIN = 0x40800000, LENGTH = 32K
/* Instruction RAM */
IRAM : ORIGIN = 0x40800000 + 32K, LENGTH = 512K - 32K
/* Data RAM */
DRAM : ORIGIN = 0x40800000 + 32K, LENGTH = 512K - 32K

/* External flash */
/* Instruction ROM */
IROM : ORIGIN = 0x42000000 + 0x20, LENGTH = 0x400000 - 0x20
/* Data ROM */
DROM : ORIGIN = 0x42800000, LENGTH = 0x400000

/* RTC fast memory (executable). Persists over deep sleep. */
RTC_FAST : ORIGIN = 0x50000000, LENGTH = 16K /*- ESP_BOOTLOADER_RESERVE_RTC*/
}

REGION_ALIAS("REGION_TEXT", IROM);
REGION_ALIAS("REGION_RODATA", DROM);

REGION_ALIAS("REGION_DATA", DRAM);
REGION_ALIAS("REGION_BSS", DRAM);
REGION_ALIAS("REGION_HEAP", DRAM);
REGION_ALIAS("REGION_STACK", DRAM);

REGION_ALIAS("REGION_RWTEXT", IRAM);
REGION_ALIAS("REGION_RTC_FAST", RTC_FAST);
3 changes: 3 additions & 0 deletions esp32c6-hal/ld/bl-linkall.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INCLUDE "memory.x"
INCLUDE "bl-riscv-link.x"
INCLUDE "hal-defaults.x"
Loading