Skip to content

Commit abb39ba

Browse files
Update heap allocation (#252)
* feat: Update heap allocation * docs: Update changelog
1 parent 4ec8dde commit abb39ba

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Changed
1313

1414
- Updated `embedded-test` dependency to 0.7.0 (#251)
15+
- Use `esp_hal::ram(reclaimed)` attribute for heap allocator (#252)
1516

1617
### Fixed
1718

1819
- Add App Descriptor macro to tests (#251)
20+
- ESP32 `dram2` size (#252)
1921

2022
### Removed
2123

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn main() -> Result<()> {
231231
// based on esp32 linker scripts
232232
// TODO: add this to esp-metadata
233233
let max_dram2 = match chip {
234-
Chip::Esp32 => 98767,
234+
Chip::Esp32 => 98768,
235235
Chip::Esp32c2 => 66416, // 0x3fcdeb70 -0x3fcce800
236236
Chip::Esp32c3 => 66320, // 0x3fcde710 - 3fcce400
237237
Chip::Esp32c6 => 65536, // 0x4087e610 - 0x4086e610

src/tui.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use esp_generate::{
88
};
99
use esp_metadata::Chip;
1010
use ratatui::crossterm::{
11-
event::{self, Event, KeyCode, KeyEventKind},
12-
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
1311
ExecutableCommand,
12+
event::{self, Event, KeyCode, KeyEventKind},
13+
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
1414
};
1515
use ratatui::{prelude::*, style::palette::tailwind, widgets::*};
1616

@@ -290,7 +290,7 @@ impl App<'_> {
290290
match key.code {
291291
Char('q') => self.confirm_quit = true,
292292
Char('s') | Char('S') => {
293-
return Ok(Some(self.repository.config.selected.clone()))
293+
return Ok(Some(self.repository.config.selected.clone()));
294294
}
295295
Esc => {
296296
if self.state.len() == 1 {

template/src/bin/async_main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async fn main(spawner: Spawner) -> ! {
7777

7878
//IF option("alloc")
7979
//REPLACE 65536 max-dram2-uninit
80-
esp_alloc::heap_allocator!(#[unsafe(link_section = ".dram2_uninit")] size: 65536);
80+
esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 65536);
8181
//IF option("wifi") && (option("ble-bleps") || option("ble-trouble"))
8282
// COEX needs more RAM - so we've added some more
8383
esp_alloc::heap_allocator!(size: 64 * 1024);
@@ -88,9 +88,10 @@ async fn main(spawner: Spawner) -> ! {
8888
//IF option("esp32") || option("esp32s2") || option("esp32s3")
8989
esp_rtos::start(timg0.timer0);
9090
//ELSE
91-
let sw_interrupt = esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
91+
let sw_interrupt =
92+
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
9293
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
93-
//ENDIF
94+
//ENDIF
9495

9596
//IF option("defmt") || option("log")
9697
info!("Embassy initialized!");
@@ -99,12 +100,12 @@ async fn main(spawner: Spawner) -> ! {
99100
//ENDIF
100101

101102
//IF option("ble-trouble") || option("ble-bleps") || option("wifi")
102-
let radio_init = esp_radio::init()
103-
.expect("Failed to initialize Wi-Fi/BLE controller");
103+
let radio_init = esp_radio::init().expect("Failed to initialize Wi-Fi/BLE controller");
104104
//ENDIF
105105
//IF option("wifi")
106-
let (mut _wifi_controller, _interfaces) = esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
107-
.expect("Failed to initialize Wi-Fi controller");
106+
let (mut _wifi_controller, _interfaces) =
107+
esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
108+
.expect("Failed to initialize Wi-Fi controller");
108109
//ENDIF
109110
//IF option("ble-trouble")
110111
// find more examples https://github.com/embassy-rs/trouble/tree/main/examples/esp32

template/src/bin/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() -> ! {
7373

7474
//IF option("alloc")
7575
//REPLACE 65536 max-dram2-uninit
76-
esp_alloc::heap_allocator!(#[unsafe(link_section = ".dram2_uninit")] size: 65536);
76+
esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 65536);
7777
//IF option("wifi") && (option("ble-bleps") || option("ble-trouble"))
7878
// COEX needs more RAM - so we've added some more
7979
esp_alloc::heap_allocator!(size: 64 * 1024);
@@ -85,15 +85,16 @@ fn main() -> ! {
8585
//IF option("esp32") || option("esp32s2") || option("esp32s3")
8686
esp_rtos::start(timg0.timer0);
8787
//ELSE
88-
let sw_interrupt = esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
88+
let sw_interrupt =
89+
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
8990
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
90-
//ENDIF
91-
let radio_init = esp_radio::init()
92-
.expect("Failed to initialize Wi-Fi/BLE controller");
91+
//ENDIF
92+
let radio_init = esp_radio::init().expect("Failed to initialize Wi-Fi/BLE controller");
9393
//ENDIF
9494
//IF option("wifi")
95-
let (mut _wifi_controller, _interfaces) = esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
96-
.expect("Failed to initialize Wi-Fi controller");
95+
let (mut _wifi_controller, _interfaces) =
96+
esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
97+
.expect("Failed to initialize Wi-Fi controller");
9798
//ENDIF
9899
//IF option("ble-bleps")
99100
let _connector = BleConnector::new(&radio_init, peripherals.BT, Default::default());

xtask/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::{
44
process::{Command, Stdio},
55
};
66

7-
use anyhow::{bail, Result};
7+
use anyhow::{Result, bail};
88
use clap::{Parser, Subcommand};
99
use esp_generate::{
10-
config::{find_option, ActiveConfiguration},
10+
config::{ActiveConfiguration, find_option},
1111
template::{GeneratorOptionCategory, GeneratorOptionItem, Template},
1212
};
1313
use esp_metadata::Chip;

0 commit comments

Comments
 (0)