Skip to content

Commit c68b6dc

Browse files
committed
Add RTT, PAGE_BUFFER
1 parent d8daf02 commit c68b6dc

16 files changed

Lines changed: 351 additions & 45 deletions

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ edition = "2018"
66

77
[dependencies]
88
panic-never = "0.1.0"
9-
ufmt = { version = "0.1.0", optional = true }
9+
ufmt = "0.1.0"
1010
cfg-if = "1.0"
1111

1212
[features]
13-
log = ["ufmt"]
14-
1513
# targets
1614
esp32 = []
1715
esp32s2 = []

ld/esp32.x

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MEMORY {
2-
/* Middle of SRAM0 */
3-
IRAM : ORIGIN = 0x40090000, LENGTH = 0x10000
4-
RWDATA : ORIGIN = 0x3FFC0000, LENGTH = 0x20000
2+
/* SRAM1 */
3+
IRAM : ORIGIN = 0x400A0000, LENGTH = 0x8000
4+
RWDATA : ORIGIN = 0x3FFE0000, LENGTH = 0x18000
55
}
66

77
INCLUDE "loader.x"

ld/esp32s2.x

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
MEMORY {
22
/* SRAM1 + 0x4000 cache + 0x400 vectors */
3-
IRAM : ORIGIN = 0x4002C400, LENGTH = 0x10000
4-
RWDATA : ORIGIN = 0x3FFBE000, LENGTH = 0x21000
3+
IRAM : ORIGIN = 0x40028000 + 0x4000 + 0x400, LENGTH = 0x10000
4+
/* SRAM1 over the data bus, after IRAM */
5+
RWDATA : ORIGIN = 0x3FFB8000 + 0x4000 + 0x400 + 0x10000, LENGTH = 0x20000
56
}
67

78
INCLUDE "loader.x"

ld/esp32s3.x

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
MEMORY {
2-
/* SRAM2 + 0x8400 */
3-
IRAM : ORIGIN = 0x40380400, LENGTH = 0x10000
4-
RWDATA : ORIGIN = 0x3FCB0000, LENGTH = 0x20000
2+
/* Use SRAM1 (+0x8400) which is accessible via both instruction and data busses */
3+
IRAM : ORIGIN = 0x40380400, LENGTH = 0x40388000 - 0x40380400
4+
/* SRAM1 over the data bus, after IRAM */
5+
RWDATA : ORIGIN = 0x3FC98000, LENGTH = 0x20000
56
}
67

78
INCLUDE "loader.x"

src/chip/esp32.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,27 @@ pub fn major_chip_version() -> u8 {
9494
pub fn minor_chip_version() -> u8 {
9595
read_field::<0, 184, 2>()
9696
}
97+
98+
/// Ensures that data (e.g. constants) are accessed through the data bus.
99+
pub unsafe fn read_via_data_bus(s: &u8) -> u8 {
100+
// SRAM1
101+
const DBUS_START: usize = 0x3FFE_0000;
102+
const DBUS_END: usize = 0x4000_0000;
103+
104+
let addr = s as *const u8 as usize;
105+
if addr >= DBUS_START && addr < DBUS_END {
106+
*s
107+
} else {
108+
let byte_in_word = addr & 0x3;
109+
let addr = addr - byte_in_word;
110+
111+
let word: u32;
112+
core::arch::asm!(
113+
"l32i {0}, {1}, 0",
114+
out(reg) word,
115+
in(reg) addr,
116+
);
117+
118+
(word >> (byte_in_word * 8)) as u8
119+
}
120+
}

src/chip/esp32c2.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ pub fn major_chip_version() -> u8 {
9393
pub fn minor_chip_version() -> u8 {
9494
read_field::<2, 48, 4>()
9595
}
96+
97+
/// Ensures that data (e.g. constants) are accessed through the data bus.
98+
pub unsafe fn read_via_data_bus(s: &u8) -> u8 {
99+
unsafe { core::ptr::read(s as *const u8) }
100+
}

src/chip/esp32c3.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,8 @@ pub fn minor_chip_version() -> u8 {
103103

104104
hi << 3 | lo
105105
}
106+
107+
/// Ensures that data (e.g. constants) are accessed through the data bus.
108+
pub unsafe fn read_via_data_bus(s: &u8) -> u8 {
109+
unsafe { core::ptr::read(s as *const u8) }
110+
}

src/chip/esp32c5.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ pub fn major_chip_version() -> u8 {
6262
pub fn minor_chip_version() -> u8 {
6363
read_field::<1, 64, 4>()
6464
}
65+
66+
/// Ensures that data (e.g. constants) are accessed through the data bus.
67+
pub unsafe fn read_via_data_bus(s: &u8) -> u8 {
68+
unsafe { core::ptr::read(s as *const u8) }
69+
}

src/chip/esp32c6.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@ pub fn major_chip_version() -> u8 {
7272
pub fn minor_chip_version() -> u8 {
7373
read_field::<1, 114, 4>()
7474
}
75+
76+
/// Ensures that data (e.g. constants) are accessed through the data bus.
77+
pub unsafe fn read_via_data_bus(s: &u8) -> u8 {
78+
unsafe { core::ptr::read(s as *const u8) }
79+
}

src/chip/esp32c61.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ pub fn major_chip_version() -> u8 {
6262
pub fn minor_chip_version() -> u8 {
6363
read_field::<1, 64, 4>()
6464
}
65+
66+
/// Ensures that data (e.g. constants) are accessed through the data bus.
67+
pub unsafe fn read_via_data_bus(s: &u8) -> u8 {
68+
unsafe { core::ptr::read(s as *const u8) }
69+
}

0 commit comments

Comments
 (0)