Skip to content

Commit 92098ca

Browse files
committed
update docs, implement suggested changes
1 parent 08e94e6 commit 92098ca

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

shared-bindings/ota/__init__.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,24 @@
4141
//| After the next-update partition is written a validation
4242
//| check is performed and on a successful validation this
4343
//| partition is set as the boot partition. On next reset,
44-
//| firmware will be loaded from this partition"""
44+
//| firmware will be loaded from this partition.
45+
//|
46+
//| Here is the sequence of commands to follow:
47+
//|
48+
//| .. code-block:: python
49+
//|
50+
//| import ota
51+
//|
52+
//| ota.flash(buffer, offset)
53+
//| ota.finish()
54+
//| """
55+
//| ...
4556
//|
4657

4758
//| def switch() -> None:
48-
//| """Switches the boot partition."""
59+
//| """Switches the boot partition. On next reset,
60+
//| firmware will be loaded from the partition
61+
//| just switched over to."""
4962
//| ...
5063
//|
5164
STATIC mp_obj_t ota_switch(void) {
@@ -56,7 +69,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_switch_obj, ota_switch);
5669

5770
//| def finish() -> None:
5871
//| """Validates flashed firmware, sets next boot partition.
59-
//| **Must be called after** `ota.flash()`"""
72+
//| **Must be called** after the firmware has been
73+
//| completely written into the flash using `ota.flash()`.
74+
//|
75+
//| This is to be called only once per update."""
6076
//| ...
6177
//|
6278
STATIC mp_obj_t ota_finish(void) {
@@ -65,11 +81,14 @@ STATIC mp_obj_t ota_finish(void) {
6581
}
6682
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_finish_obj, ota_finish);
6783

68-
//| def flash(*buffer: WriteableBuffer, offset: int=0) -> None:
84+
//| def flash(*buffer: ReadableBuffer, offset: int=0) -> None:
6985
//| """Writes one of two OTA partitions at the given offset.
7086
//|
7187
//| The default offset is 0. It is necessary to provide the
72-
//| offset when writing in discontinous chunks."""
88+
//| offset when writing in discontinous chunks.
89+
//|
90+
//| This can be called multiple times when flashing the firmware
91+
//| in small chunks."""
7392
//| ...
7493
//|
7594
STATIC mp_obj_t ota_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

0 commit comments

Comments
 (0)