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

Various cleanups & extension of timer features in preparation of WiFi #47

Merged
merged 8 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions examples/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> ! {
let mut timg0 = dp.TIMG0;
let mut timg1 = dp.TIMG1;

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

// (https://github.com/espressif/openocd-esp32/blob/97ba3a6bb9eaa898d91df923bbedddfeaaaf28c9/src/target/esp32.c#L431)
// openocd disables the watchdog timer on halt
Expand Down Expand Up @@ -50,7 +50,6 @@ fn main() -> ! {
},
Config::default(),
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn main() -> ! {
// we will do it manually on startup
disable_timg_wdts(&mut timg0, &mut timg1);

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

// setup clocks & watchdog
let mut clock_control = ClockControl::new(
Expand Down Expand Up @@ -132,7 +132,6 @@ fn main() -> ! {
},
Config::default(),
clock_control_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static GPIO: CriticalSectionSpinLockMutex<
fn main() -> ! {
let dp = target::Peripherals::take().unwrap();

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

let clkcntrl = esp32_hal::clock_control::ClockControl::new(
dp.RTCCNTL,
Expand Down Expand Up @@ -73,7 +73,6 @@ fn main() -> ! {
},
Config::default().baudrate(115_200.Hz()),
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/hall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> ! {
let mut timg0 = dp.TIMG0;
let mut timg1 = dp.TIMG1;

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

// (https://github.com/espressif/openocd-esp32/blob/97ba3a6bb9eaa898d91df923bbedddfeaaaf28c9/src/target/esp32.c#L431)
// openocd disables the watchdog timer on halt
Expand Down Expand Up @@ -50,7 +50,6 @@ fn main() -> ! {
},
Config::default(),
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() -> ! {
// we will do it manually on startup
disable_timg_wdts(&mut timg0, &mut timg1);

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

// setup clocks & watchdog
let mut clock_control = ClockControl::new(
Expand Down Expand Up @@ -71,7 +71,6 @@ fn main() -> ! {
},
Config::default(),
clock_control_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> ! {
// we will do it manually on startup
disable_timg_wdts(&mut timg0, &mut timg1);

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

// setup clocks & watchdog
let clock_control = ClockControl::new(
Expand All @@ -53,7 +53,6 @@ fn main() -> ! {
},
Config::default(),
clock_control_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/rtccntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> ! {
// we will do it manually on startup
disable_timg_wdts(&mut timg0, &mut timg1);

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

// setup clocks & watchdog
let mut clock_control = ClockControl::new(
Expand Down Expand Up @@ -65,7 +65,6 @@ fn main() -> ! {
},
Config::default(),
clock_control_config,
&mut dport,
)
.unwrap();
uart0.change_baudrate(115200).unwrap();
Expand Down
3 changes: 1 addition & 2 deletions examples/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const BLINK_HZ: Hertz = Hertz(2);
fn main() -> ! {
let dp = target::Peripherals::take().expect("Failed to obtain Peripherals");

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

let clkcntrl = ClockControl::new(
dp.RTCCNTL,
Expand Down Expand Up @@ -56,7 +56,6 @@ fn main() -> ! {
..Config::default()
},
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand Down
4 changes: 1 addition & 3 deletions examples/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<
fn main() -> ! {
let dp = target::Peripherals::take().expect("Failed to obtain Peripherals");

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

let clkcntrl = ClockControl::new(
dp.RTCCNTL,
Expand Down Expand Up @@ -123,7 +123,6 @@ fn main() -> ! {
..serial::config::Config::default()
},
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand All @@ -145,7 +144,6 @@ fn main() -> ! {
data_mode: spi::config::MODE_0,
},
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static TX: CriticalSectionSpinLockMutex<Option<esp32_hal::serial::Tx<esp32::UART
fn main() -> ! {
let dp = target::Peripherals::take().unwrap();

let (mut dport, dport_clock_control) = dp.DPORT.split();
let (_, dport_clock_control) = dp.DPORT.split();

let clkcntrl = esp32_hal::clock_control::ClockControl::new(
dp.RTCCNTL,
Expand Down Expand Up @@ -93,7 +93,6 @@ fn main() -> ! {
},
config,
clkcntrl_config,
&mut dport,
)
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions flash
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ then
then
printf "\n\n"
# get gen_esp32part.py and create binary partition table
curl -s -S -f --max-time 2 -L $GENPART_SOURCE --output target/gen_esp32part.py_new
curl -s -S -f --max-time 5 -L $GENPART_SOURCE --output target/gen_esp32part.py_new

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

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

if [ $? -ne 0 ]; then
if [ -f target/bootloader.bin ]; then
Expand Down
22 changes: 21 additions & 1 deletion memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,23 @@ SECTIONS {
_external_heap_start = ABSOLUTE(.);
} > psram_seg

}

/* wifi data */

.rwtext.wifi :
{
. = ALIGN(4);
*( .wifi0iram .wifi0iram.*)
*( .wifirxiram .wifirxiram.*)
*( .iram1 .iram1.*)
} > RWTEXT AT > RODATA

.data.wifi :
{
. = ALIGN(4);
*( .dram1 .dram1.*)
} > RWDATA AT > RODATA
}

_external_ram_start = ABSOLUTE(ORIGIN(psram_seg));
_external_ram_end = ABSOLUTE(ORIGIN(psram_seg)+LENGTH(psram_seg));
Expand All @@ -176,4 +192,8 @@ _stack_start_cpu0 = _stack_end_cpu1;
_stack_end_cpu0 = _stack_start_cpu0 + STACK_SIZE;

EXTERN(DefaultHandler);

EXTERN(WIFI_EVENT); /* Force inclusion of WiFi libraries */

INCLUDE "device.x"

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

const DEFAULT_EXTERNAL_THRESHOLD: usize = 32 * 1024;
const DEFAULT_USE_IRAM: bool = true;
const DEFAULT_USE_IRAM: bool = false;

/// Default allocator using a mix of memories.
///
Expand Down
13 changes: 7 additions & 6 deletions src/clock_control/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ impl super::ClockControl {
///
/// The second core will start running with the function `entry`.
pub fn start_app_core(&mut self, entry: fn() -> !) -> Result<(), Error> {
if self
.dport_control
.appcpu_ctrl_b()
.read()
.appcpu_clkgate_en()
.bit_is_set()
if !xtensa_lx6::is_debugger_attached()
&& self
.dport_control
.appcpu_ctrl_b()
.read()
.appcpu_clkgate_en()
.bit_is_set()
{
return Err(Error::CoreAlreadyRunning);
}
Expand Down
Loading