Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 1f628e3

Browse files
authored
Add support for the ESP32-P4 (#61)
* Add support for the ESP32-P4 * Update the CI workflow to check the ESP32-P4
1 parent 48514c0 commit 1f628e3

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
{ chip: "esp32c3", target: "riscv32imc-unknown-none-elf" },
2929
{ chip: "esp32c6", target: "riscv32imac-unknown-none-elf" },
3030
{ chip: "esp32h2", target: "riscv32imac-unknown-none-elf" },
31+
{ chip: "esp32p4", target: "riscv32imafc-unknown-none-elf" },
3132
]
3233

3334
steps:

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ esp32c2 = []
3131
esp32c3 = []
3232
esp32c6 = []
3333
esp32h2 = []
34+
esp32p4 = []
3435
esp32s2 = []
3536
esp32s3 = []
3637
esp8266 = []
3738

3839
# You must enable exactly 1 of the below features to enable to intended
3940
# communication method (note that "uart" is enabled by default):
4041
uart = []
41-
jtag-serial = ["portable-atomic"] # C3, C6, H2, and S3 only!
42+
jtag-serial = ["portable-atomic"] # C3, C6, H2, P4, and S3 only!
4243
no-op = []
4344

4445
# Enables a `defmt` backend usable with espflash. We force rzcobs encoding to simplify implementation

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn main() {
66
cfg!(feature = "esp32c3"),
77
cfg!(feature = "esp32c6"),
88
cfg!(feature = "esp32h2"),
9+
cfg!(feature = "esp32p4"),
910
cfg!(feature = "esp32s2"),
1011
cfg!(feature = "esp32s3"),
1112
cfg!(feature = "esp8266"),
@@ -33,6 +34,7 @@ fn main() {
3334
&& !(cfg!(feature = "esp32c3")
3435
|| cfg!(feature = "esp32c6")
3536
|| cfg!(feature = "esp32h2")
37+
|| cfg!(feature = "esp32p4")
3638
|| cfg!(feature = "esp32s3"))
3739
{
3840
panic!(

src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl Printer {
9090
feature = "esp32c3",
9191
feature = "esp32c6",
9292
feature = "esp32h2",
93+
feature = "esp32p4",
9394
feature = "esp32s3"
9495
)
9596
))]
@@ -106,6 +107,11 @@ mod serial_jtag_printer {
106107
#[cfg(any(feature = "esp32c6", feature = "esp32h2"))]
107108
const SERIAL_JTAG_CONF_REG: usize = 0x6000_F004;
108109

110+
#[cfg(feature = "esp32p4")]
111+
const SERIAL_JTAG_FIFO_REG: usize = 0x500D_2000;
112+
#[cfg(feature = "esp32p4")]
113+
const SERIAL_JTAG_CONF_REG: usize = 0x500D_2004;
114+
109115
#[cfg(feature = "esp32s3")]
110116
const SERIAL_JTAG_FIFO_REG: usize = 0x6003_8000;
111117
#[cfg(feature = "esp32s3")]
@@ -329,6 +335,23 @@ mod uart_printer {
329335
}
330336
}
331337

338+
#[cfg(feature = "esp32p4")]
339+
impl Functions for Device {
340+
const TX_ONE_CHAR: usize = 0x4FC0_0054;
341+
342+
fn flush() {
343+
unsafe {
344+
const TX_FLUSH: usize = 0x4FC0_0074;
345+
const GET_CHANNEL: usize = 0x4FC0_0038;
346+
347+
let tx_flush: unsafe extern "C" fn(u8) = core::mem::transmute(TX_FLUSH);
348+
let get_channel: unsafe extern "C" fn() -> u8 = core::mem::transmute(GET_CHANNEL);
349+
350+
tx_flush(get_channel());
351+
}
352+
}
353+
}
354+
332355
impl super::Printer {
333356
pub fn write_bytes_assume_cs(&mut self, bytes: &[u8]) {
334357
for chunk in bytes.chunks(Device::CHUNK_SIZE) {

0 commit comments

Comments
 (0)