10000 Merge pull request #7503 from MicroDev1/dualbank · adafruit/circuitpython@2f71f61 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f71f61

Browse files
authored
Merge pull request #7503 from MicroDev1/dualbank
Improve dualbank and storage extension docs
2 parents 438d3e9 + 4ef363a commit 2f71f61

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

shared-bindings/dualbank/__init__.c

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,32 @@
3030
#include "supervisor/flash.h"
3131
#endif
3232

33-
//| """DUALBANK Module
33+
//| """Dualbank Module
3434
//|
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.
3737
//|
38-
//| There are two identical partitions, these contain different
39-
//| firmware versions.
4038
//| Having two partitions enables rollback functionality.
4139
//|
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.
4542
//|
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.
5046
//|
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.
5259
//|
5360
//| .. code-block:: python
5461
//|
@@ -68,10 +75,12 @@ STATIC void raise_error_if_storage_extended(void) {
6875
#endif
6976

7077
//| 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.
7281
//|
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.
7584
//| """
7685
//| ...
7786
//|
@@ -102,10 +111,9 @@ STATIC mp_obj_t dualbank_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t
102111
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dualbank_flash_obj, 0, dualbank_flash);
103112

104113
//| def switch() -> None:
105-
//| """Switches the boot partition.
114+
//| """Switches to the next-update partition.
106115
//|
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.
109117
//| """
110118
//| ...
111119
//|

shared-bindings/storage/__init__.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);
166166
//| extended by setting this to `True`. If this isn't provided or
167167
//| set to `None` (default), the existing configuration will be used.
168168
//|
169+
//| .. note:: New firmware starts with storage extended. In case of an existing
170+
//| filesystem (e.g. uf2 load), the existing extension setting is preserved.
171+
//|
169172
//| .. warning:: All the data on ``CIRCUITPY`` will be lost, and
170-
//| CircuitPython will restart on certain boards."""
173+
//| CircuitPython will restart on certain boards."""
171174
//| ...
172175
//|
173176

0 commit comments

Comments
 (0)
0