stuff
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::format;
|
||||
use edge_http::io::server::Connection;
|
||||
use edge_http::Method;
|
||||
use embedded_io_async::{Read, Write};
|
||||
@@ -31,6 +29,9 @@ where
|
||||
Method::Post => {
|
||||
let mut offset = 0_usize;
|
||||
let mut chunk = 0;
|
||||
|
||||
// Erase only a single 4K block right before writing into it.
|
||||
// The first block will be erased when offset == 0 below.
|
||||
loop {
|
||||
let mut buf = [0_u8; 1024];
|
||||
let to_write = conn.read(&mut buf).await?;
|
||||
@@ -42,6 +43,11 @@ where
|
||||
} else {
|
||||
let mut board = BOARD_ACCESS.get().await.lock().await;
|
||||
board.board_hal.progress(chunk as u32).await;
|
||||
// Erase next block if we are at a 4K boundary (including the first block at offset 0)
|
||||
if offset % 4096 >= offset+to_write % 4096 {
|
||||
info!("erasing block {} during write between {} with size {}", offset / 4096, offset, to_write);
|
||||
board.board_hal.get_esp().ota_erase(offset as u32).await?;
|
||||
}
|
||||
board
|
||||
.board_hal
|
||||
.get_esp()
|
||||
|
Reference in New Issue
Block a user