Skip to content

Commit dd29ef1

Browse files
committed
fix: esp32 build
feat: mark ota valid after more operations
1 parent ff7ee41 commit dd29ef1

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/board.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ impl Board {
6060
pub fn init(peripherals: Peripherals) -> Result<Board> {
6161
use embedded_hal::digital::OutputPin;
6262

63-
esp_alloc::heap_allocator!(size: 120 * 1024);
64-
6563
let timg0 = TimerGroup::new(peripherals.TIMG0);
6664
let timg1 = TimerGroup::new(peripherals.TIMG1);
6765
let rng = Rng::new(peripherals.RNG);

src/main.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,9 @@ async fn main(spawner: Spawner) {
6767
config
6868
});
6969

70-
set_brownout_detection(false);
71-
let board = Board::init(peripherals).expect("Board init error");
72-
{
73-
if let Ok(mut ota) = esp_hal_ota::Ota::new(FlashStorage::new()) {
74-
let res = ota.ota_mark_app_valid();
75-
if let Err(e) = res {
76-
log::error!("Ota mark app valid failed: {e:?}");
77-
}
78-
}
79-
}
70+
#[cfg(not(feature = "esp32"))]
71+
esp_alloc::heap_allocator!(size: 120 * 1024);
8072

81-
// second heap init
8273
{
8374
#[cfg(feature = "esp32")]
8475
const HEAP_SIZE: usize = 90 * 1024;
@@ -100,6 +91,9 @@ async fn main(spawner: Spawner) {
10091
}
10192
}
10293

94+
set_brownout_detection(false);
95+
let board = Board::init(peripherals).expect("Board init error");
96+
10397
FkmLogger::set_logger();
10498
esp_hal_embassy::init(board.timg1.timer0);
10599

@@ -110,6 +104,16 @@ async fn main(spawner: Spawner) {
110104
let global_state = Rc::new(GlobalStateInner::new(&nvs));
111105
let wifi_setup_sig = Rc::new(Signal::new());
112106

107+
// mark ota as valid
108+
{
109+
if let Ok(mut ota) = esp_hal_ota::Ota::new(FlashStorage::new()) {
110+
let res = ota.ota_mark_app_valid();
111+
if let Err(e) = res {
112+
log::error!("Ota mark app valid failed: {e:?}");
113+
}
114+
}
115+
}
116+
113117
_ = spawner.spawn(lcd::lcd_task(
114118
board.lcd,
115119
global_state.clone(),

0 commit comments

Comments
 (0)