Allocate ekv buffer in PSRAM

This commit is contained in:
Jakub Hlusička 2026-02-28 01:52:38 +01:00
parent 76ed47d687
commit e0b0aded7b

View file

@ -16,6 +16,8 @@ use esp_hal::rng::Trng;
use esp_storage::FlashStorage;
use log::{debug, info};
use crate::ram::PSRAM_ALLOCATOR;
pub type PartitionAcid =
Partition<'static, CriticalSectionRawMutex, BlockingAsync<FlashStorage<'static>>>;
@ -25,7 +27,7 @@ struct AlignedBuf<const N: usize>(pub [u8; N]);
pub struct EkvFlash<T> {
flash: T,
buffer: Box<AlignedBuf<{ ekv::config::PAGE_SIZE }>>,
buffer: Box<AlignedBuf<{ ekv::config::PAGE_SIZE }>, &'static esp_alloc::EspHeap>,
}
impl<T> EkvFlash<T> {
@ -34,7 +36,7 @@ impl<T> EkvFlash<T> {
flash,
buffer: {
// Allocate the buffer directly on the heap.
let buffer = Box::new_zeroed();
let buffer = Box::new_zeroed_in(&PSRAM_ALLOCATOR);
unsafe { buffer.assume_init() }
},
}