Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit 8463b83

Browse files
authored
Merge pull request #47 from arjanmels/feature-wifi
Various cleanups & extension of timer features in preparation of WiFi
2 parents 04cfe50 + 0a82f20 commit 8463b83

File tree

19 files changed

+478
-173
lines changed

19 files changed

+478
-173
lines changed

examples/adc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() -> ! {
2020
let mut timg0 = dp.TIMG0;
2121
let mut timg1 = dp.TIMG1;
2222

23-
let (mut dport, dport_clock_control) = dp.DPORT.split();
23+
let (_, dport_clock_control) = dp.DPORT.split();
2424

2525
// (https://github.com/espressif/openocd-esp32/blob/97ba3a6bb9eaa898d91df923bbedddfeaaaf28c9/src/target/esp32.c#L431)
2626
// openocd disables the watchdog timer on halt
@@ -50,7 +50,6 @@ fn main() -> ! {
5050
},
5151
Config::default(),
5252
clkcntrl_config,
53-
&mut dport,
5453
)
5554
.unwrap();
5655

examples/exception.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn main() -> ! {
100100
// we will do it manually on startup
101101
disable_timg_wdts(&mut timg0, &mut timg1);
102102

103-
let (mut dport, dport_clock_control) = dp.DPORT.split();
103+
let (_, dport_clock_control) = dp.DPORT.split();
104104

105105
// setup clocks & watchdog
106106
let mut clock_control = ClockControl::new(
@@ -132,7 +132,6 @@ fn main() -> ! {
132132
},
133133
Config::default(),
134134
clock_control_config,
135-
&mut dport,
136135
)
137136
.unwrap();
138137

examples/gpio.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static GPIO: CriticalSectionSpinLockMutex<
3434
fn main() -> ! {
3535
let dp = target::Peripherals::take().unwrap();
3636

37-
let (mut dport, dport_clock_control) = dp.DPORT.split();
37+
let (_, dport_clock_control) = dp.DPORT.split();
3838

3939
let clkcntrl = esp32_hal::clock_control::ClockControl::new(
4040
dp.RTCCNTL,
@@ -73,7 +73,6 @@ fn main() -> ! {
7373
},
7474
Config::default().baudrate(115_200.Hz()),
7575
clkcntrl_config,
76-
&mut dport,
7776
)
7877
.unwrap();
7978

examples/hall.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() -> ! {
2020
let mut timg0 = dp.TIMG0;
2121
let mut timg1 = dp.TIMG1;
2222

23-
let (mut dport, dport_clock_control) = dp.DPORT.split();
23+
let (_, dport_clock_control) = dp.DPORT.split();
2424

2525
// (https://github.com/espressif/openocd-esp32/blob/97ba3a6bb9eaa898d91df923bbedddfeaaaf28c9/src/target/esp32.c#L431)
2626
// openocd disables the watchdog timer on halt
@@ -50,7 +50,6 @@ fn main() -> ! {
5050
},
5151
Config::default(),
5252
clkcntrl_config,
53-
&mut dport,
5453
)
5554
.unwrap();
5655

examples/multicore.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() -> ! {
3232
// we will do it manually on startup
3333
disable_timg_wdts(&mut timg0, &mut timg1);
3434

35-
let (mut dport, dport_clock_control) = dp.DPORT.split();
35+
let (_, dport_clock_control) = dp.DPORT.split();
3636

3737
// setup clocks & watchdog
3838
let mut clock_control = ClockControl::new(
@@ -71,7 +71,6 @@ fn main() -> ! {
7171
},
7272
Config::default(),
7373
clock_control_config,
74-
&mut dport,
7574
)
7675
.unwrap();
7776

examples/ram.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() -> ! {
2626
// we will do it manually on startup
2727
disable_timg_wdts(&mut timg0, &mut timg1);
2828

29-
let (mut dport, dport_clock_control) = dp.DPORT.split();
29+
let (_, dport_clock_control) = dp.DPORT.split();
3030

3131
// setup clocks & watchdog
3232
let clock_control = ClockControl::new(
@@ -53,7 +53,6 @@ fn main() -> ! {
5353
},
5454
Config::default(),
5555
clock_control_config,
56-
&mut dport,
5756
)
5857
.unwrap();
5958

examples/rtccntl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() -> ! {
2626
// we will do it manually on startup
2727
disable_timg_wdts(&mut timg0, &mut timg1);
2828

29-
let (mut dport, dport_clock_control) = dp.DPORT.split();
29+
let (_, dport_clock_control) = dp.DPORT.split();
3030

3131
// setup clocks & watchdog
3232
let mut clock_control = ClockControl::new(
@@ -65,7 +65,6 @@ fn main() -> ! {
6565
},
6666
Config::default(),
6767
clock_control_config,
68-
&mut dport,
6968
)
7069
.unwrap();
7170
uart0.change_baudrate(115200).unwrap();

examples/serial.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const BLINK_HZ: Hertz = Hertz(2);
1919
fn main() -> ! {
2020
let dp = target::Peripherals::take().expect("Failed to obtain Peripherals");
2121

22-
let (mut dport, dport_clock_control) = dp.DPORT.split();
22+
let (_, dport_clock_control) = dp.DPORT.split();
2323

2424
let clkcntrl = ClockControl::new(
2525
dp.RTCCNTL,
@@ -56,7 +56,6 @@ fn main() -> ! {
5656
..Config::default()
5757
},
5858
clkcntrl_config,
59-
&mut dport,
6059
)
6160
.unwrap();
6261

examples/spi.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<
8888
fn main() -> ! {
8989
let dp = target::Peripherals::take().expect("Failed to obtain Peripherals");
9090

91-
let (mut dport, dport_clock_control) = dp.DPORT.split();
91+
let (_, dport_clock_control) = dp.DPORT.split();
9292

9393
let clkcntrl = ClockControl::new(
9494
dp.RTCCNTL,
@@ -123,7 +123,6 @@ fn main() -> ! {
123123
..serial::config::Config::default()
124124
},
125125
clkcntrl_config,
126-
&mut dport,
127126
)
128127
.unwrap();
129128

@@ -145,7 +144,6 @@ fn main() -> ! {
145144
data_mode: spi::config::MODE_0,
146145
},
147146
clkcntrl_config,
148-
&mut dport,
149147
)
150148
.unwrap();
151149

examples/timer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static TX: CriticalSectionSpinLockMutex<Option<esp32_hal::serial::Tx<esp32::UART
4141
fn main() -> ! {
4242
let dp = target::Peripherals::take().unwrap();
4343

44-
let (mut dport, dport_clock_control) = dp.DPORT.split();
44+
let (_, dport_clock_control) = dp.DPORT.split();
4545

4646
let clkcntrl = esp32_hal::clock_control::ClockControl::new(
4747
dp.RTCCNTL,
@@ -93,7 +93,6 @@ fn main() -> ! {
9393
},
9494
config,
9595
clkcntrl_config,
96-
&mut dport,
9796
)
9897
.unwrap();
9998

flash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ then
243243
then
244244
printf "\n\n"
245245
# get gen_esp32part.py and create binary partition table
246-
curl -s -S -f --max-time 2 -L $GENPART_SOURCE --output target/gen_esp32part.py_new
246+
curl -s -S -f --max-time 5 -L $GENPART_SOURCE --output target/gen_esp32part.py_new
247247

248248
if [ $? -ne 0 ]; then
249249
if [ -f target/gen_esp32part.py ]; then
@@ -269,7 +269,7 @@ then
269269

270270
# get bootloader.bin file
271271
# (different variants exist, but only difference is flash settings which are overriden by esptool)
272-
curl -s -S -f --max-time 2 -L $BOOTLOADER_SOURCE --output target/bootloader.bin_new
272+
curl -s -S -f --max-time 5 -L $BOOTLOADER_SOURCE --output target/bootloader.bin_new
273273

274274
if [ $? -ne 0 ]; then
275275
if [ -f target/bootloader.bin ]; then

memory.x

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,23 @@ SECTIONS {
161161
_external_heap_start = ABSOLUTE(.);
162162
} > psram_seg
163163

164-
}
164+
165+
/* wifi data */
166+
167+
.rwtext.wifi :
168+
{
169+
. = ALIGN(4);
170+
*( .wifi0iram .wifi0iram.*)
171+
*( .wifirxiram .wifirxiram.*)
172+
*( .iram1 .iram1.*)
173+
} > RWTEXT AT > RODATA
174+
175+
.data.wifi :
176+
{
177+
. = ALIGN(4);
178+
*( .dram1 .dram1.*)
179+
} > RWDATA AT > RODATA
180+
}
165181

166182
_external_ram_start = ABSOLUTE(ORIGIN(psram_seg));
167183
_external_ram_end = ABSOLUTE(ORIGIN(psram_seg)+LENGTH(psram_seg));
@@ -176,4 +192,8 @@ _stack_start_cpu0 = _stack_end_cpu1;
176192
_stack_end_cpu0 = _stack_start_cpu0 + STACK_SIZE;
177193

178194
EXTERN(DefaultHandler);
195+
196+
EXTERN(WIFI_EVENT); /* Force inclusion of WiFi libraries */
197+
179198
INCLUDE "device.x"
199+

src/alloc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
//! The allocators can be safely used in a mixed fashion. (Including multiple GeneralAllocators
66
//! with different thresholds)
77
//!
8+
//! **NOTE: iram can only be accessed by aligned 32-bit accesses, as structures can indicate
9+
//! alignment >= 4 even when members are smaller, it cannot be used for general rust allocations.
10+
//! (Unless a load/store exception handler is used, but this will be very slow.)
11+
//!
812
//! **NOTE: the default implementations of memcpy, memset etc. which are used behind the scenes use
913
//! unaligned accesses.** This causes exceptions when used together with IRAM.
1014
//! The replacements in the mem module do handle alignment properly. They can be enable by
@@ -27,7 +31,7 @@ use core::ptr::NonNull;
2731
use linked_list_allocator::Heap;
2832

2933
const DEFAULT_EXTERNAL_THRESHOLD: usize = 32 * 1024;
30-
const DEFAULT_USE_IRAM: bool = true;
34+
const DEFAULT_USE_IRAM: bool = false;
3135

3236
/// Default allocator using a mix of memories.
3337
///

src/clock_control/cpu.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ impl super::ClockControl {
136136
///
137137
/// The second core will start running with the function `entry`.
138138
pub fn start_app_core(&mut self, entry: fn() -> !) -> Result<(), Error> {
139-
if self
140-
.dport_control
141-
.appcpu_ctrl_b()
142-
.read()
143-
.appcpu_clkgate_en()
144-
.bit_is_set()
139+
if !xtensa_lx6::is_debugger_attached()
140+
&& self
141+
.dport_control
142+
.appcpu_ctrl_b()
143+
.read()
144+
.appcpu_clkgate_en()
145+
.bit_is_set()
145146
{
146147
return Err(Error::CoreAlreadyRunning);
147148
}

0 commit comments

Comments
 (0)