Merge #1262
1262: bump embedded-storage-async to 0.4 r=Dirbaio a=mehmetalianil I just haven't found a way to revert the altered stm-metapac contents due to building. Co-authored-by: Mehmet Ali Anil <mehmet@grusbv.com>
This commit is contained in:
commit
969e85150c
@ -28,7 +28,7 @@ log = { version = "0.4", optional = true }
|
|||||||
ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true }
|
ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true }
|
||||||
embassy-sync = { version = "0.1.0", path = "../../embassy-sync" }
|
embassy-sync = { version = "0.1.0", path = "../../embassy-sync" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.4.0"
|
||||||
salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true }
|
salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true }
|
||||||
signature = { version = "1.6.4", default-features = false }
|
signature = { version = "1.6.4", default-features = false }
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#![feature(type_alias_impl_trait)]
|
#![feature(async_fn_in_trait)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
mod fmt;
|
mod fmt;
|
||||||
|
|
||||||
use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash};
|
use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash};
|
||||||
use embedded_storage_async::nor_flash::AsyncNorFlash;
|
use embedded_storage_async::nor_flash::NorFlash as AsyncNorFlash;
|
||||||
|
|
||||||
const BOOT_MAGIC: u8 = 0xD0;
|
const BOOT_MAGIC: u8 = 0xD0;
|
||||||
const SWAP_MAGIC: u8 = 0xF0;
|
const SWAP_MAGIC: u8 = 0xF0;
|
||||||
@ -1196,10 +1197,9 @@ impl FirmwareWriter {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
use core::future::Future;
|
|
||||||
|
|
||||||
use embedded_storage::nor_flash::ErrorType;
|
use embedded_storage::nor_flash::ErrorType;
|
||||||
use embedded_storage_async::nor_flash::AsyncReadNorFlash;
|
use embedded_storage_async::nor_flash::ReadNorFlash as AsyncReadNorFlash;
|
||||||
use futures::executor::block_on;
|
use futures::executor::block_on;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -1535,13 +1535,10 @@ mod tests {
|
|||||||
{
|
{
|
||||||
const READ_SIZE: usize = 1;
|
const READ_SIZE: usize = 1;
|
||||||
|
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a;
|
async fn read(&mut self, offset: u32, buf: &mut [u8]) -> Result<(), Self::Error> {
|
||||||
fn read<'a>(&'a mut self, offset: u32, buf: &'a mut [u8]) -> Self::ReadFuture<'a> {
|
let len = buf.len();
|
||||||
async move {
|
buf[..].copy_from_slice(&self.0[offset as usize..offset as usize + len]);
|
||||||
let len = buf.len();
|
Ok(())
|
||||||
buf[..].copy_from_slice(&self.0[offset as usize..offset as usize + len]);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capacity(&self) -> usize {
|
fn capacity(&self) -> usize {
|
||||||
@ -1555,38 +1552,32 @@ mod tests {
|
|||||||
const WRITE_SIZE: usize = WRITE_SIZE;
|
const WRITE_SIZE: usize = WRITE_SIZE;
|
||||||
const ERASE_SIZE: usize = ERASE_SIZE;
|
const ERASE_SIZE: usize = ERASE_SIZE;
|
||||||
|
|
||||||
type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a;
|
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
|
||||||
fn erase(&mut self, from: u32, to: u32) -> Self::EraseFuture<'_> {
|
let from = from as usize;
|
||||||
async move {
|
let to = to as usize;
|
||||||
let from = from as usize;
|
assert!(from % ERASE_SIZE == 0);
|
||||||
let to = to as usize;
|
assert!(to % ERASE_SIZE == 0);
|
||||||
assert!(from % ERASE_SIZE == 0);
|
for i in from..to {
|
||||||
assert!(to % ERASE_SIZE == 0);
|
self.0[i] = 0xFF;
|
||||||
for i in from..to {
|
|
||||||
self.0[i] = 0xFF;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a;
|
async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
|
||||||
fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> {
|
|
||||||
info!("Writing {} bytes to 0x{:x}", data.len(), offset);
|
info!("Writing {} bytes to 0x{:x}", data.len(), offset);
|
||||||
async move {
|
assert!(data.len() % WRITE_SIZE == 0);
|
||||||
assert!(data.len() % WRITE_SIZE == 0);
|
assert!(offset as usize % WRITE_SIZE == 0);
|
||||||
assert!(offset as usize % WRITE_SIZE == 0);
|
assert!(
|
||||||
assert!(
|
offset as usize + data.len() <= SIZE,
|
||||||
offset as usize + data.len() <= SIZE,
|
"OFFSET: {}, LEN: {}, FLASH SIZE: {}",
|
||||||
"OFFSET: {}, LEN: {}, FLASH SIZE: {}",
|
offset,
|
||||||
offset,
|
data.len(),
|
||||||
data.len(),
|
SIZE
|
||||||
SIZE
|
);
|
||||||
);
|
|
||||||
|
|
||||||
self.0[offset as usize..offset as usize + data.len()].copy_from_slice(data);
|
self.0[offset as usize..offset as usize + data.len()].copy_from_slice(data);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ embassy-boot = { path = "../boot", default-features = false }
|
|||||||
cortex-m = { version = "0.7.6" }
|
cortex-m = { version = "0.7.6" }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.4.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true }
|
nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true }
|
||||||
|
@ -25,7 +25,7 @@ embassy-time = { path = "../../embassy-time", features = ["nightly"] }
|
|||||||
cortex-m = { version = "0.7.6" }
|
cortex-m = { version = "0.7.6" }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.4.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -24,7 +24,7 @@ embassy-boot = { path = "../boot", default-features = false }
|
|||||||
cortex-m = { version = "0.7.6" }
|
cortex-m = { version = "0.7.6" }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.4.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -22,7 +22,7 @@ embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["un
|
|||||||
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
|
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
|
||||||
embedded-hal-async = { version = "=0.2.0-alpha.0", optional = true }
|
embedded-hal-async = { version = "=0.2.0-alpha.0", optional = true }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = { version = "0.3.0", optional = true }
|
embedded-storage-async = { version = "0.4.0", optional = true }
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
|
|
||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
//! Adapters between embedded-hal traits.
|
//! Adapters between embedded-hal traits.
|
||||||
|
|
||||||
use core::future::Future;
|
|
||||||
|
|
||||||
use embedded_hal_02::{blocking, serial};
|
use embedded_hal_02::{blocking, serial};
|
||||||
|
|
||||||
/// Wrapper that implements async traits using blocking implementations.
|
/// Wrapper that implements async traits using blocking implementations.
|
||||||
@ -182,7 +180,7 @@ where
|
|||||||
|
|
||||||
/// NOR flash wrapper
|
/// NOR flash wrapper
|
||||||
use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
|
use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
|
||||||
use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash};
|
use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
|
||||||
|
|
||||||
impl<T> ErrorType for BlockingAsync<T>
|
impl<T> ErrorType for BlockingAsync<T>
|
||||||
where
|
where
|
||||||
@ -198,14 +196,12 @@ where
|
|||||||
const WRITE_SIZE: usize = <T as NorFlash>::WRITE_SIZE;
|
const WRITE_SIZE: usize = <T as NorFlash>::WRITE_SIZE;
|
||||||
const ERASE_SIZE: usize = <T as NorFlash>::ERASE_SIZE;
|
const ERASE_SIZE: usize = <T as NorFlash>::ERASE_SIZE;
|
||||||
|
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
|
||||||
fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> {
|
self.wrapped.write(offset, data)
|
||||||
async move { self.wrapped.write(offset, data) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
|
||||||
fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> {
|
self.wrapped.erase(from, to)
|
||||||
async move { self.wrapped.erase(from, to) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,9 +210,8 @@ where
|
|||||||
T: ReadNorFlash,
|
T: ReadNorFlash,
|
||||||
{
|
{
|
||||||
const READ_SIZE: usize = <T as ReadNorFlash>::READ_SIZE;
|
const READ_SIZE: usize = <T as ReadNorFlash>::READ_SIZE;
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> {
|
||||||
fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> {
|
self.wrapped.read(address, data)
|
||||||
async move { self.wrapped.read(address, data) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capacity(&self) -> usize {
|
fn capacity(&self) -> usize {
|
||||||
|
@ -100,7 +100,7 @@ critical-section = "1.1"
|
|||||||
rand_core = "0.6.3"
|
rand_core = "0.6.3"
|
||||||
fixed = "1.10.0"
|
fixed = "1.10.0"
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = { version = "0.3.0", optional = true }
|
embedded-storage-async = { version = "0.4.0", optional = true }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
nrf52805-pac = { version = "0.12.0", optional = true, features = [ "rt" ] }
|
nrf52805-pac = { version = "0.12.0", optional = true, features = [ "rt" ] }
|
||||||
|
@ -587,9 +587,7 @@ impl<'d, T: Instance> NorFlash for Qspi<'d, T> {
|
|||||||
|
|
||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
mod _eh1 {
|
mod _eh1 {
|
||||||
use core::future::Future;
|
use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
|
||||||
|
|
||||||
use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@ -597,27 +595,22 @@ mod _eh1 {
|
|||||||
const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE;
|
const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE;
|
||||||
const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE;
|
const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE;
|
||||||
|
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
|
||||||
fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> {
|
self.write(offset, data).await
|
||||||
async move { self.write(offset, data).await }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
|
||||||
fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> {
|
for address in (from..to).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) {
|
||||||
async move {
|
self.erase(address).await?
|
||||||
for address in (from..to).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) {
|
|
||||||
self.erase(address).await?
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Instance> AsyncReadNorFlash for Qspi<'d, T> {
|
impl<'d, T: Instance> AsyncReadNorFlash for Qspi<'d, T> {
|
||||||
const READ_SIZE: usize = 4;
|
const READ_SIZE: usize = 4;
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> {
|
||||||
fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> {
|
self.read(address, data).await
|
||||||
async move { self.read(address, data).await }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capacity(&self) -> usize {
|
fn capacity(&self) -> usize {
|
||||||
|
@ -16,7 +16,7 @@ embassy-time = { path = "../../../../embassy-time", features = ["nightly"] }
|
|||||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.4.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -14,7 +14,7 @@ embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features
|
|||||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.4.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
Loading…
Reference in New Issue
Block a user