File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,12 +6,10 @@ edition = "2018"
66
77[dependencies ]
88panic-never = " 0.1.0"
9- ufmt = { version = " 0.1.0" , optional = true }
9+ ufmt = " 0.1.0"
1010cfg-if = " 1.0"
1111
1212[features ]
13- log = [" ufmt" ]
14-
1513# targets
1614esp32 = []
1715esp32s2 = []
Original file line number Diff line number Diff line change 11MEMORY {
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
77INCLUDE "loader.x"
Original file line number Diff line number Diff line change 11MEMORY {
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
78INCLUDE "loader.x"
Original file line number Diff line number Diff line change 11MEMORY {
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
78INCLUDE "loader.x"
Original file line number Diff line number Diff line change @@ -94,3 +94,27 @@ pub fn major_chip_version() -> u8 {
9494pub 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+ }
Original file line number Diff line number Diff line change @@ -93,3 +93,8 @@ pub fn major_chip_version() -> u8 {
9393pub 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+ }
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff line change @@ -62,3 +62,8 @@ pub fn major_chip_version() -> u8 {
6262pub 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+ }
Original file line number Diff line number Diff line change @@ -72,3 +72,8 @@ pub fn major_chip_version() -> u8 {
7272pub 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+ }
Original file line number Diff line number Diff line change @@ -62,3 +62,8 @@ pub fn major_chip_version() -> u8 {
6262pub 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+ }
You can’t perform that action at this time.
0 commit comments