diff options
| author | sander <[email protected]> | 2023-03-22 16:49:49 +0100 |
|---|---|---|
| committer | sander <[email protected]> | 2023-03-22 16:49:49 +0100 |
| commit | ba9afbc26d06ab38065cbff5b17a7f76db297ad4 (patch) | |
| tree | 4444e14e287d60d69a0153415d0186be05588e02 /embassy-boot/boot/src/lib.rs | |
| parent | aa77a06d58a02340b455888a113287d8cac05973 (diff) | |
embassy-boot: add default nightly feature, makes it possible to compile with the stable compiler
Diffstat (limited to 'embassy-boot/boot/src/lib.rs')
| -rw-r--r-- | embassy-boot/boot/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs index 0df44f36e..7ce0c664a 100644 --- a/embassy-boot/boot/src/lib.rs +++ b/embassy-boot/boot/src/lib.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #![feature(async_fn_in_trait)] | 1 | #![cfg_attr(feature = "nightly", feature(async_fn_in_trait))] |
| 2 | #![allow(incomplete_features)] | 2 | #![allow(incomplete_features)] |
| 3 | #![no_std] | 3 | #![no_std] |
| 4 | #![warn(missing_docs)] | 4 | #![warn(missing_docs)] |
| @@ -6,6 +6,8 @@ | |||
| 6 | mod fmt; | 6 | mod fmt; |
| 7 | 7 | ||
| 8 | use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash}; | 8 | use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash}; |
| 9 | |||
| 10 | #[cfg(feature = "nightly")] | ||
| 9 | use embedded_storage_async::nor_flash::NorFlash as AsyncNorFlash; | 11 | use embedded_storage_async::nor_flash::NorFlash as AsyncNorFlash; |
| 10 | 12 | ||
| 11 | const BOOT_MAGIC: u8 = 0xD0; | 13 | const BOOT_MAGIC: u8 = 0xD0; |
| @@ -647,6 +649,7 @@ impl FirmwareUpdater { | |||
| 647 | /// This is useful to check if the bootloader has just done a swap, in order | 649 | /// This is useful to check if the bootloader has just done a swap, in order |
| 648 | /// to do verifications and self-tests of the new image before calling | 650 | /// to do verifications and self-tests of the new image before calling |
| 649 | /// `mark_booted`. | 651 | /// `mark_booted`. |
| 652 | #[cfg(feature = "nightly")] | ||
| 650 | pub async fn get_state<F: AsyncNorFlash>( | 653 | pub async fn get_state<F: AsyncNorFlash>( |
| 651 | &mut self, | 654 | &mut self, |
| 652 | flash: &mut F, | 655 | flash: &mut F, |
| @@ -776,6 +779,7 @@ impl FirmwareUpdater { | |||
| 776 | /// | 779 | /// |
| 777 | /// The `aligned` buffer must have a size of F::WRITE_SIZE, and follow the alignment rules for the flash being written to. | 780 | /// The `aligned` buffer must have a size of F::WRITE_SIZE, and follow the alignment rules for the flash being written to. |
| 778 | #[cfg(not(feature = "_verify"))] | 781 | #[cfg(not(feature = "_verify"))] |
| 782 | #[cfg(feature = "nightly")] | ||
| 779 | pub async fn mark_updated<F: AsyncNorFlash>( | 783 | pub async fn mark_updated<F: AsyncNorFlash>( |
| 780 | &mut self, | 784 | &mut self, |
| 781 | flash: &mut F, | 785 | flash: &mut F, |
| @@ -790,6 +794,7 @@ impl FirmwareUpdater { | |||
| 790 | /// # Safety | 794 | /// # Safety |
| 791 | /// | 795 | /// |
| 792 | /// The `aligned` buffer must have a size of F::WRITE_SIZE, and follow the alignment rules for the flash being written to. | 796 | /// The `aligned` buffer must have a size of F::WRITE_SIZE, and follow the alignment rules for the flash being written to. |
| 797 | #[cfg(feature = "nightly")] | ||
| 793 | pub async fn mark_booted<F: AsyncNorFlash>( | 798 | pub async fn mark_booted<F: AsyncNorFlash>( |
| 794 | &mut self, | 799 | &mut self, |
| 795 | flash: &mut F, | 800 | flash: &mut F, |
| @@ -799,6 +804,7 @@ impl FirmwareUpdater { | |||
| 799 | self.set_magic(aligned, BOOT_MAGIC, flash).await | 804 | self.set_magic(aligned, BOOT_MAGIC, flash).await |
| 800 | } | 805 | } |
| 801 | 806 | ||
| 807 | #[cfg(feature = "nightly")] | ||
| 802 | async fn set_magic<F: AsyncNorFlash>( | 808 | async fn set_magic<F: AsyncNorFlash>( |
| 803 | &mut self, | 809 | &mut self, |
| 804 | aligned: &mut [u8], | 810 | aligned: &mut [u8], |
| @@ -826,6 +832,7 @@ impl FirmwareUpdater { | |||
| 826 | /// # Safety | 832 | /// # Safety |
| 827 | /// | 833 | /// |
| 828 | /// Failing to meet alignment and size requirements may result in a panic. | 834 | /// Failing to meet alignment and size requirements may result in a panic. |
| 835 | #[cfg(feature = "nightly")] | ||
| 829 | pub async fn write_firmware<F: AsyncNorFlash>( | 836 | pub async fn write_firmware<F: AsyncNorFlash>( |
| 830 | &mut self, | 837 | &mut self, |
| 831 | offset: usize, | 838 | offset: usize, |
| @@ -860,6 +867,7 @@ impl FirmwareUpdater { | |||
| 860 | /// | 867 | /// |
| 861 | /// Using this instead of `write_firmware` allows for an optimized API in | 868 | /// Using this instead of `write_firmware` allows for an optimized API in |
| 862 | /// exchange for added complexity. | 869 | /// exchange for added complexity. |
| 870 | #[cfg(feature = "nightly")] | ||
| 863 | pub async fn prepare_update<F: AsyncNorFlash>( | 871 | pub async fn prepare_update<F: AsyncNorFlash>( |
| 864 | &mut self, | 872 | &mut self, |
| 865 | flash: &mut F, | 873 | flash: &mut F, |
| @@ -1112,6 +1120,7 @@ impl FirmwareWriter { | |||
| 1112 | /// # Safety | 1120 | /// # Safety |
| 1113 | /// | 1121 | /// |
| 1114 | /// Failing to meet alignment and size requirements may result in a panic. | 1122 | /// Failing to meet alignment and size requirements may result in a panic. |
| 1123 | #[cfg(feature = "nightly")] | ||
| 1115 | pub async fn write_block<F: AsyncNorFlash>( | 1124 | pub async fn write_block<F: AsyncNorFlash>( |
| 1116 | &mut self, | 1125 | &mut self, |
| 1117 | offset: usize, | 1126 | offset: usize, |
