30
30
#include "supervisor/flash.h"
31
31
#endif
32
32
33
- //| """DUALBANK Module
33
+ //| """Dualbank Module
34
34
//|
35
- //| The `dualbank` module adds ability to update and switch
36
- //| between the two app partitions.
35
+ //| The `dualbank` module adds ability to update and switch between the
36
+ //| two identical app partitions, which can contain different firmware versions .
37
37
//|
38
- //| There are two identical partitions, these contain different
39
- //| firmware versions.
40
38
//| Having two partitions enables rollback functionality.
41
39
//|
42
- //| The two partitions are defined as boot partition and
43
- //| next-update partition. Calling `dualbank.flash()` writes
44
- //| the next-update partition.
40
+ //| The two partitions are defined as the boot partition and the next-update partition.
41
+ //| Calling `dualbank.flash()` writes the next-update partition.
45
42
//|
46
- //| After the next-update partition is written a validation
47
- //| check is performed and on a successful validation this
48
- //| partition is set as the boot partition. On next reset,
49
- //| firmware will be loaded from this partition.
43
+ //| After the next-update partition is written a validation check is performed
44
+ //| and on a successful validation this partition is set as the boot partition.
45
+ //| On next reset, firmware will be loaded from this partition.
50
46
//|
51
- //| Here is the sequence of commands to follow:
47
+ //| Use cases:
48
+ //| * Can be used for ``OTA`` Over-The-Air updates.
49
+ //| * Can be used for ``dual-boot`` of different firmware versions or platforms.
50
+ //|
51
+ //| .. note::
52
+ //|
53
+ //| Boards with flash ``=2MB``:
54
+ //| This module is unavailable as the flash is only large enough for one app partition.
55
+ //|
56
+ //| Boards with flash ``>2MB``:
57
+ //| This module is enabled/disabled at runtime based on whether the ``CIRCUITPY`` drive
58
+ //| is extended or not. See `storage.erase_filesystem()` for more information.
52
59
//|
53
60
//| .. code-block:: python
54
61
//|
@@ -68,10 +75,12 @@ STATIC void raise_error_if_storage_extended(void) {
68
75
#endif
69
76
70
77
//| def flash(buffer: ReadableBuffer, offset: int = 0) -> None:
71
- //| """Writes one of two app partitions at the given offset.
78
+ //| """Writes one of the two app partitions at the given offset.
79
+ //|
80
+ //| This can be called multiple times when flashing the firmware in smaller chunks.
72
81
//|
73
- //| This can be called multiple times when flashing the firmware
74
- //| in small chunks .
82
+ //| :param ReadableBuffer buffer: The entire firmware or a partial chunk.
83
+ //| :param int offset: Start writing at this offset in the app partition .
75
84
//| """
76
85
//| ...
77
86
//|
@@ -102,10 +111,9 @@ STATIC mp_obj_t dualbank_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t
102
111
STATIC MP_DEFINE_CONST_FUN_OBJ_KW (dualbank_flash_obj , 0 , dualbank_flash );
103
112
104
113
//| def switch() -> None:
105
- //| """Switches the boot partition.
114
+ //| """Switches to the next-update partition.
106
115
//|
107
- //| On next reset, firmware will be loaded from the partition
108
- //| just switched over to.
116
+ //| On next reset, firmware will be loaded from the partition just switched over to.
109
117
//| """
110
118
//| ...
111
119
//|
0 commit comments