aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-boot/src')
-rw-r--r--embassy-boot/src/boot_loader.rs33
-rw-r--r--embassy-boot/src/firmware_updater/blocking.rs32
2 files changed, 63 insertions, 2 deletions
diff --git a/embassy-boot/src/boot_loader.rs b/embassy-boot/src/boot_loader.rs
index c433ce439..2a5f024f6 100644
--- a/embassy-boot/src/boot_loader.rs
+++ b/embassy-boot/src/boot_loader.rs
@@ -56,7 +56,38 @@ impl<'a, ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>
56 BlockingPartition<'a, NoopRawMutex, STATE>, 56 BlockingPartition<'a, NoopRawMutex, STATE>,
57 > 57 >
58{ 58{
59 /// Create a bootloader config from the flash and address symbols defined in the linkerfile 59 /// Constructs a `BootLoaderConfig` instance from flash memory and address symbols defined in the linker file.
60 ///
61 /// This method initializes `BlockingPartition` instances for the active, DFU (Device Firmware Update),
62 /// and state partitions, leveraging start and end addresses specified by the linker. These partitions
63 /// are critical for managing firmware updates, application state, and boot operations within the bootloader.
64 ///
65 /// # Parameters
66 /// - `active_flash`: A reference to a mutex-protected `RefCell` for the active partition's flash interface.
67 /// - `dfu_flash`: A reference to a mutex-protected `RefCell` for the DFU partition's flash interface.
68 /// - `state_flash`: A reference to a mutex-protected `RefCell` for the state partition's flash interface.
69 ///
70 /// # Safety
71 /// The method contains `unsafe` blocks for dereferencing raw pointers that represent the start and end addresses
72 /// of the bootloader's partitions in flash memory. It is crucial that these addresses are accurately defined
73 /// in the memory.x file to prevent undefined behavior.
74 ///
75 /// The caller must ensure that the memory regions defined by these symbols are valid and that the flash memory
76 /// interfaces provided are compatible with these regions.
77 ///
78 /// # Returns
79 /// A `BootLoaderConfig` instance with `BlockingPartition` instances for the active, DFU, and state partitions.
80 ///
81 /// # Example
82 /// ```no_run
83 /// // Assume `active_flash`, `dfu_flash`, and `state_flash` all share the same flash memory interface.
84 /// let layout = Flash::new_blocking(p.FLASH).into_blocking_regions();
85 /// let flash = Mutex::new(RefCell::new(layout.bank1_region));
86 ///
87 /// let config = BootLoaderConfig::from_linkerfile_blocking(&flash, &flash, &flash);
88 /// // `config` can now be used to create a `BootLoader` instance for managing boot operations.
89 /// ```
90 /// Working examples can be found in the bootloader examples folder.
60 // #[cfg(target_os = "none")] 91 // #[cfg(target_os = "none")]
61 pub fn from_linkerfile_blocking( 92 pub fn from_linkerfile_blocking(
62 active_flash: &'a Mutex<NoopRawMutex, RefCell<ACTIVE>>, 93 active_flash: &'a Mutex<NoopRawMutex, RefCell<ACTIVE>>,
diff --git a/embassy-boot/src/firmware_updater/blocking.rs b/embassy-boot/src/firmware_updater/blocking.rs
index cf850fce3..a29efabf0 100644
--- a/embassy-boot/src/firmware_updater/blocking.rs
+++ b/embassy-boot/src/firmware_updater/blocking.rs
@@ -19,7 +19,37 @@ pub struct BlockingFirmwareUpdater<'d, DFU: NorFlash, STATE: NorFlash> {
19impl<'a, DFU: NorFlash, STATE: NorFlash> 19impl<'a, DFU: NorFlash, STATE: NorFlash>
20 FirmwareUpdaterConfig<BlockingPartition<'a, NoopRawMutex, DFU>, BlockingPartition<'a, NoopRawMutex, STATE>> 20 FirmwareUpdaterConfig<BlockingPartition<'a, NoopRawMutex, DFU>, BlockingPartition<'a, NoopRawMutex, STATE>>
21{ 21{
22 /// Create a firmware updater config from the flash and address symbols defined in the linkerfile 22 /// Constructs a `FirmwareUpdaterConfig` instance from flash memory and address symbols defined in the linker file.
23 ///
24 /// This method initializes `BlockingPartition` instances for the DFU (Device Firmware Update), and state
25 /// partitions, leveraging start and end addresses specified by the linker. These partitions are critical
26 /// for managing firmware updates, application state, and boot operations within the bootloader.
27 ///
28 /// # Parameters
29 /// - `dfu_flash`: A reference to a mutex-protected `RefCell` for the DFU partition's flash interface.
30 /// - `state_flash`: A reference to a mutex-protected `RefCell` for the state partition's flash interface.
31 ///
32 /// # Safety
33 /// The method contains `unsafe` blocks for dereferencing raw pointers that represent the start and end addresses
34 /// of the bootloader's partitions in flash memory. It is crucial that these addresses are accurately defined
35 /// in the memory.x file to prevent undefined behavior.
36 ///
37 /// The caller must ensure that the memory regions defined by these symbols are valid and that the flash memory
38 /// interfaces provided are compatible with these regions.
39 ///
40 /// # Returns
41 /// A `FirmwareUpdaterConfig` instance with `BlockingPartition` instances for the DFU, and state partitions.
42 ///
43 /// # Example
44 /// ```no_run
45 /// // Assume `dfu_flash`, and `state_flash` share the same flash memory interface.
46 /// let layout = Flash::new_blocking(p.FLASH).into_blocking_regions();
47 /// let flash = Mutex::new(RefCell::new(layout.bank1_region));
48 ///
49 /// let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash, &flash);
50 /// // `config` can now be used to create a `FirmwareUpdater` instance for managing boot operations.
51 /// ```
52 /// Working examples can be found in the bootloader examples folder.
23 pub fn from_linkerfile_blocking( 53 pub fn from_linkerfile_blocking(
24 dfu_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<DFU>>, 54 dfu_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<DFU>>,
25 state_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<STATE>>, 55 state_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<STATE>>,