aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-03-08 01:26:45 +0000
committerGitHub <[email protected]>2023-03-08 01:26:45 +0000
commit969e85150c06a1bbd03de06db5ab3c917b2a1529 (patch)
treebfb2cb72fda7291fb5c024ace353db19512a1210
parentbd4c4209af3738e3b2d6b059670f9ed76e2f32ff (diff)
parent18646c579c09147d9cea1dfddb39f9803485ea14 (diff)
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 <[email protected]>
-rw-r--r--embassy-boot/boot/Cargo.toml2
-rw-r--r--embassy-boot/boot/src/lib.rs69
-rw-r--r--embassy-boot/nrf/Cargo.toml2
-rw-r--r--embassy-boot/rp/Cargo.toml2
-rw-r--r--embassy-boot/stm32/Cargo.toml2
-rw-r--r--embassy-embedded-hal/Cargo.toml2
-rw-r--r--embassy-embedded-hal/src/adapter.rs19
-rw-r--r--embassy-nrf/Cargo.toml2
-rw-r--r--embassy-nrf/src/qspi.rs25
-rw-r--r--examples/boot/bootloader/rp/Cargo.toml2
-rw-r--r--examples/boot/bootloader/stm32/Cargo.toml2
11 files changed, 54 insertions, 75 deletions
diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml
index 0b0c77b1e..3312c2f9f 100644
--- a/embassy-boot/boot/Cargo.toml
+++ b/embassy-boot/boot/Cargo.toml
@@ -28,7 +28,7 @@ log = { version = "0.4", optional = true }
28ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true } 28ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true }
29embassy-sync = { version = "0.1.0", path = "../../embassy-sync" } 29embassy-sync = { version = "0.1.0", path = "../../embassy-sync" }
30embedded-storage = "0.3.0" 30embedded-storage = "0.3.0"
31embedded-storage-async = "0.3.0" 31embedded-storage-async = "0.4.0"
32salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true } 32salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true }
33signature = { version = "1.6.4", default-features = false } 33signature = { version = "1.6.4", default-features = false }
34 34
diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs
index be254e9d7..0df44f36e 100644
--- a/embassy-boot/boot/src/lib.rs
+++ b/embassy-boot/boot/src/lib.rs
@@ -1,11 +1,12 @@
1#![feature(type_alias_impl_trait)] 1#![feature(async_fn_in_trait)]
2#![allow(incomplete_features)]
2#![no_std] 3#![no_std]
3#![warn(missing_docs)] 4#![warn(missing_docs)]
4#![doc = include_str!("../README.md")] 5#![doc = include_str!("../README.md")]
5mod fmt; 6mod fmt;
6 7
7use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash}; 8use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash};
8use embedded_storage_async::nor_flash::AsyncNorFlash; 9use embedded_storage_async::nor_flash::NorFlash as AsyncNorFlash;
9 10
10const BOOT_MAGIC: u8 = 0xD0; 11const BOOT_MAGIC: u8 = 0xD0;
11const SWAP_MAGIC: u8 = 0xF0; 12const SWAP_MAGIC: u8 = 0xF0;
@@ -1196,10 +1197,9 @@ impl FirmwareWriter {
1196#[cfg(test)] 1197#[cfg(test)]
1197mod tests { 1198mod tests {
1198 use core::convert::Infallible; 1199 use core::convert::Infallible;
1199 use core::future::Future;
1200 1200
1201 use embedded_storage::nor_flash::ErrorType; 1201 use embedded_storage::nor_flash::ErrorType;
1202 use embedded_storage_async::nor_flash::AsyncReadNorFlash; 1202 use embedded_storage_async::nor_flash::ReadNorFlash as AsyncReadNorFlash;
1203 use futures::executor::block_on; 1203 use futures::executor::block_on;
1204 1204
1205 use super::*; 1205 use super::*;
@@ -1535,13 +1535,10 @@ mod tests {
1535 { 1535 {
1536 const READ_SIZE: usize = 1; 1536 const READ_SIZE: usize = 1;
1537 1537
1538 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a; 1538 async fn read(&mut self, offset: u32, buf: &mut [u8]) -> Result<(), Self::Error> {
1539 fn read<'a>(&'a mut self, offset: u32, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { 1539 let len = buf.len();
1540 async move { 1540 buf[..].copy_from_slice(&self.0[offset as usize..offset as usize + len]);
1541 let len = buf.len(); 1541 Ok(())
1542 buf[..].copy_from_slice(&self.0[offset as usize..offset as usize + len]);
1543 Ok(())
1544 }
1545 } 1542 }
1546 1543
1547 fn capacity(&self) -> usize { 1544 fn capacity(&self) -> usize {
@@ -1555,38 +1552,32 @@ mod tests {
1555 const WRITE_SIZE: usize = WRITE_SIZE; 1552 const WRITE_SIZE: usize = WRITE_SIZE;
1556 const ERASE_SIZE: usize = ERASE_SIZE; 1553 const ERASE_SIZE: usize = ERASE_SIZE;
1557 1554
1558 type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a; 1555 async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
1559 fn erase(&mut self, from: u32, to: u32) -> Self::EraseFuture<'_> { 1556 let from = from as usize;
1560 async move { 1557 let to = to as usize;
1561 let from = from as usize; 1558 assert!(from % ERASE_SIZE == 0);
1562 let to = to as usize; 1559 assert!(to % ERASE_SIZE == 0);
1563 assert!(from % ERASE_SIZE == 0); 1560 for i in from..to {
1564 assert!(to % ERASE_SIZE == 0); 1561 self.0[i] = 0xFF;
1565 for i in from..to {
1566 self.0[i] = 0xFF;
1567 }
1568 Ok(())
1569 } 1562 }
1563 Ok(())
1570 } 1564 }
1571 1565
1572 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a; 1566 async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
1573 fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> {
1574 info!("Writing {} bytes to 0x{:x}", data.len(), offset); 1567 info!("Writing {} bytes to 0x{:x}", data.len(), offset);
1575 async move { 1568 assert!(data.len() % WRITE_SIZE == 0);
1576 assert!(data.len() % WRITE_SIZE == 0); 1569 assert!(offset as usize % WRITE_SIZE == 0);
1577 assert!(offset as usize % WRITE_SIZE == 0); 1570 assert!(
1578 assert!( 1571 offset as usize + data.len() <= SIZE,
1579 offset as usize + data.len() <= SIZE, 1572 "OFFSET: {}, LEN: {}, FLASH SIZE: {}",
1580 "OFFSET: {}, LEN: {}, FLASH SIZE: {}", 1573 offset,
1581 offset, 1574 data.len(),
1582 data.len(), 1575 SIZE
1583 SIZE 1576 );
1584 ); 1577
1585 1578 self.0[offset as usize..offset as usize + data.len()].copy_from_slice(data);
1586 self.0[offset as usize..offset as usize + data.len()].copy_from_slice(data); 1579
1587 1580 Ok(())
1588 Ok(())
1589 }
1590 } 1581 }
1591 } 1582 }
1592} 1583}
diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml
index c6af70144..c1a127518 100644
--- a/embassy-boot/nrf/Cargo.toml
+++ b/embassy-boot/nrf/Cargo.toml
@@ -22,7 +22,7 @@ embassy-boot = { path = "../boot", default-features = false }
22cortex-m = { version = "0.7.6" } 22cortex-m = { version = "0.7.6" }
23cortex-m-rt = { version = "0.7" } 23cortex-m-rt = { version = "0.7" }
24embedded-storage = "0.3.0" 24embedded-storage = "0.3.0"
25embedded-storage-async = "0.3.0" 25embedded-storage-async = "0.4.0"
26cfg-if = "1.0.0" 26cfg-if = "1.0.0"
27 27
28nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true } 28nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true }
diff --git a/embassy-boot/rp/Cargo.toml b/embassy-boot/rp/Cargo.toml
index ffc36a4e0..96024cdda 100644
--- a/embassy-boot/rp/Cargo.toml
+++ b/embassy-boot/rp/Cargo.toml
@@ -25,7 +25,7 @@ embassy-time = { path = "../../embassy-time", features = ["nightly"] }
25cortex-m = { version = "0.7.6" } 25cortex-m = { version = "0.7.6" }
26cortex-m-rt = { version = "0.7" } 26cortex-m-rt = { version = "0.7" }
27embedded-storage = "0.3.0" 27embedded-storage = "0.3.0"
28embedded-storage-async = "0.3.0" 28embedded-storage-async = "0.4.0"
29cfg-if = "1.0.0" 29cfg-if = "1.0.0"
30 30
31[features] 31[features]
diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml
index 2fc169b32..7061063bb 100644
--- a/embassy-boot/stm32/Cargo.toml
+++ b/embassy-boot/stm32/Cargo.toml
@@ -24,7 +24,7 @@ embassy-boot = { path = "../boot", default-features = false }
24cortex-m = { version = "0.7.6" } 24cortex-m = { version = "0.7.6" }
25cortex-m-rt = { version = "0.7" } 25cortex-m-rt = { version = "0.7" }
26embedded-storage = "0.3.0" 26embedded-storage = "0.3.0"
27embedded-storage-async = "0.3.0" 27embedded-storage-async = "0.4.0"
28cfg-if = "1.0.0" 28cfg-if = "1.0.0"
29 29
30[features] 30[features]
diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml
index fa74be8c4..45eb0d43d 100644
--- a/embassy-embedded-hal/Cargo.toml
+++ b/embassy-embedded-hal/Cargo.toml
@@ -22,7 +22,7 @@ embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["un
22embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" } 22embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
23embedded-hal-async = { version = "=0.2.0-alpha.0", optional = true } 23embedded-hal-async = { version = "=0.2.0-alpha.0", optional = true }
24embedded-storage = "0.3.0" 24embedded-storage = "0.3.0"
25embedded-storage-async = { version = "0.3.0", optional = true } 25embedded-storage-async = { version = "0.4.0", optional = true }
26nb = "1.0.0" 26nb = "1.0.0"
27 27
28defmt = { version = "0.3", optional = true } 28defmt = { version = "0.3", optional = true }
diff --git a/embassy-embedded-hal/src/adapter.rs b/embassy-embedded-hal/src/adapter.rs
index 3680984f1..a49f8df4b 100644
--- a/embassy-embedded-hal/src/adapter.rs
+++ b/embassy-embedded-hal/src/adapter.rs
@@ -1,7 +1,5 @@
1//! Adapters between embedded-hal traits. 1//! Adapters between embedded-hal traits.
2 2
3use core::future::Future;
4
5use embedded_hal_02::{blocking, serial}; 3use embedded_hal_02::{blocking, serial};
6 4
7/// Wrapper that implements async traits using blocking implementations. 5/// Wrapper that implements async traits using blocking implementations.
@@ -182,7 +180,7 @@ where
182 180
183/// NOR flash wrapper 181/// NOR flash wrapper
184use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; 182use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
185use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash}; 183use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
186 184
187impl<T> ErrorType for BlockingAsync<T> 185impl<T> ErrorType for BlockingAsync<T>
188where 186where
@@ -198,14 +196,12 @@ where
198 const WRITE_SIZE: usize = <T as NorFlash>::WRITE_SIZE; 196 const WRITE_SIZE: usize = <T as NorFlash>::WRITE_SIZE;
199 const ERASE_SIZE: usize = <T as NorFlash>::ERASE_SIZE; 197 const ERASE_SIZE: usize = <T as NorFlash>::ERASE_SIZE;
200 198
201 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 199 async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
202 fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> { 200 self.wrapped.write(offset, data)
203 async move { self.wrapped.write(offset, data) }
204 } 201 }
205 202
206 type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 203 async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
207 fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { 204 self.wrapped.erase(from, to)
208 async move { self.wrapped.erase(from, to) }
209 } 205 }
210} 206}
211 207
@@ -214,9 +210,8 @@ where
214 T: ReadNorFlash, 210 T: ReadNorFlash,
215{ 211{
216 const READ_SIZE: usize = <T as ReadNorFlash>::READ_SIZE; 212 const READ_SIZE: usize = <T as ReadNorFlash>::READ_SIZE;
217 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 213 async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> {
218 fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> { 214 self.wrapped.read(address, data)
219 async move { self.wrapped.read(address, data) }
220 } 215 }
221 216
222 fn capacity(&self) -> usize { 217 fn capacity(&self) -> usize {
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index c31ce199b..4e62ca89e 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -100,7 +100,7 @@ critical-section = "1.1"
100rand_core = "0.6.3" 100rand_core = "0.6.3"
101fixed = "1.10.0" 101fixed = "1.10.0"
102embedded-storage = "0.3.0" 102embedded-storage = "0.3.0"
103embedded-storage-async = { version = "0.3.0", optional = true } 103embedded-storage-async = { version = "0.4.0", optional = true }
104cfg-if = "1.0.0" 104cfg-if = "1.0.0"
105 105
106nrf52805-pac = { version = "0.12.0", optional = true, features = [ "rt" ] } 106nrf52805-pac = { version = "0.12.0", optional = true, features = [ "rt" ] }
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index 7f004b9fc..2e16c2ff5 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -587,9 +587,7 @@ impl<'d, T: Instance> NorFlash for Qspi<'d, T> {
587 587
588#[cfg(feature = "nightly")] 588#[cfg(feature = "nightly")]
589mod _eh1 { 589mod _eh1 {
590 use core::future::Future; 590 use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
591
592 use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash};
593 591
594 use super::*; 592 use super::*;
595 593
@@ -597,27 +595,22 @@ mod _eh1 {
597 const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE; 595 const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE;
598 const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE; 596 const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE;
599 597
600 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 598 async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
601 fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> { 599 self.write(offset, data).await
602 async move { self.write(offset, data).await }
603 } 600 }
604 601
605 type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 602 async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
606 fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { 603 for address in (from..to).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) {
607 async move { 604 self.erase(address).await?
608 for address in (from..to).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) {
609 self.erase(address).await?
610 }
611 Ok(())
612 } 605 }
606 Ok(())
613 } 607 }
614 } 608 }
615 609
616 impl<'d, T: Instance> AsyncReadNorFlash for Qspi<'d, T> { 610 impl<'d, T: Instance> AsyncReadNorFlash for Qspi<'d, T> {
617 const READ_SIZE: usize = 4; 611 const READ_SIZE: usize = 4;
618 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 612 async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> {
619 fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> { 613 self.read(address, data).await
620 async move { self.read(address, data).await }
621 } 614 }
622 615
623 fn capacity(&self) -> usize { 616 fn capacity(&self) -> usize {
diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml
index c0b576cff..a16cebe31 100644
--- a/examples/boot/bootloader/rp/Cargo.toml
+++ b/examples/boot/bootloader/rp/Cargo.toml
@@ -16,7 +16,7 @@ embassy-time = { path = "../../../../embassy-time", features = ["nightly"] }
16cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } 16cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
17cortex-m-rt = { version = "0.7" } 17cortex-m-rt = { version = "0.7" }
18embedded-storage = "0.3.0" 18embedded-storage = "0.3.0"
19embedded-storage-async = "0.3.0" 19embedded-storage-async = "0.4.0"
20cfg-if = "1.0.0" 20cfg-if = "1.0.0"
21 21
22[features] 22[features]
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml
index be659e02a..b1791620f 100644
--- a/examples/boot/bootloader/stm32/Cargo.toml
+++ b/examples/boot/bootloader/stm32/Cargo.toml
@@ -14,7 +14,7 @@ embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features
14cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } 14cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
15cortex-m-rt = { version = "0.7" } 15cortex-m-rt = { version = "0.7" }
16embedded-storage = "0.3.0" 16embedded-storage = "0.3.0"
17embedded-storage-async = "0.3.0" 17embedded-storage-async = "0.4.0"
18cfg-if = "1.0.0" 18cfg-if = "1.0.0"
19 19
20[features] 20[features]