Add feature to reserve Bluetooth RAM for ESP32 (#63)

This commit is contained in:
Björn Quentin 2022-05-20 11:38:39 +02:00 committed by GitHub
parent a55c9d77ec
commit 76a2067339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 10 deletions

View File

@ -45,3 +45,4 @@ smart-leds = "0.3"
default = ["rt"]
rt = ["xtensa-lx-rt/esp32"]
ufmt = ["esp-hal-common/ufmt"]
bluetooth = []

View File

@ -23,9 +23,38 @@ fn main() {
.write_all(include_bytes!("ld/linkall.x"))
.unwrap();
let memory_extras = generate_memory_extras();
File::create(out.join("memory_extras.x"))
.unwrap()
.write_all(&memory_extras)
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// Only re-run the build script when memory.x is changed,
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=memory.x");
}
fn generate_memory_extras() -> Vec<u8> {
let reserve_dram = if cfg!(feature = "bluetooth") {
"0x10000"
} else {
"0x0"
};
format!(
"
/* reserved at the start of DRAM for e.g. the BT stack */
RESERVE_DRAM = {reserve_dram};
/* reserved at the start of the RTC memories for use by the ULP processor */
RESERVE_RTC_FAST = 0;
RESERVE_RTC_SLOW = 0;
/* define stack size for both cores */
STACK_SIZE = 8k;"
)
.as_bytes()
.to_vec()
}

View File

@ -8,15 +8,7 @@
/* override entry point */
ENTRY(ESP32Reset)
/* reserved at the start of DRAM for e.g. teh BT stack */
RESERVE_DRAM = 0;
/* reserved at the start of the RTC memories for use by the ULP processor */
RESERVE_RTC_FAST = 0;
RESERVE_RTC_SLOW = 0;
/* define stack size for both cores */
STACK_SIZE = 8k;
INCLUDE "memory_extras.x"
/* Specify main memory areas */
MEMORY

View File

@ -9,8 +9,8 @@ pub use esp_hal_common::{
pulse_control,
ram,
spi,
utils,
usb_serial_jtag,
utils,
Cpu,
Delay,
PulseControl,