Skip to content

Commit cb35abf

Browse files
committed
add docs, update translation & fix ota.flash()
1 parent 6a4f749 commit cb35abf

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

locale/circuitpython.pot

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-12-08 10:30+0530\n"
11+
"POT-Creation-Date: 2020-12-10 16:56+0530\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -1907,6 +1907,10 @@ msgstr ""
19071907
msgid "Unable to read color palette data"
19081908
msgstr ""
19091909

1910+
#: ports/esp32s2/common-hal/ota/__init__.c
1911+
msgid "Unable to switch boot partition"
1912+
msgstr ""
1913+
19101914
#: shared-bindings/nvm/ByteArray.c
19111915
msgid "Unable to write to nvm."
19121916
msgstr ""
@@ -3198,6 +3202,10 @@ msgstr ""
31983202
msgid "offset is too large"
31993203
msgstr ""
32003204

3205+
#: shared-bindings/ota/__init__.c
3206+
msgid "offset must be >= 0"
3207+
msgstr ""
3208+
32013209
#: py/objstr.c py/objstrunicode.c
32023210
msgid "offset out of bounds"
32033211
msgstr ""

ports/esp32s2/common-hal/ota/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ void common_hal_ota_finish(void) {
145145

146146
void common_hal_ota_switch(void) {
147147
if (esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL)) != ESP_OK) {
148-
mp_raise_RuntimeError(translate("Unable to switch partition"));
148+
mp_raise_RuntimeError(translate("Unable to switch boot partition"));
149149
}
150150
}

shared-bindings/ota/__init__.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,52 @@
3030
//|
3131
//| The `ota` module implements over-the-air update."""
3232

33+
//| def switch() -> None:
34+
//| """Switches the boot partition.
35+
//| ...
36+
//|
3337
STATIC mp_obj_t ota_switch(void) {
3438
common_hal_ota_switch();
3539
return mp_const_none;
3640
}
3741
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_switch_obj, ota_switch);
3842

43+
//| def finish() -> None:
44+
//| """Validates flashed firmware, sets next boot partition.
45+
//| **Must be called after** `ota.flash()`
46+
//| ...
47+
//|
3948
STATIC mp_obj_t ota_finish(void) {
4049
common_hal_ota_finish();
4150
return mp_const_none;
4251
}
4352
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_finish_obj, ota_finish);
4453

54+
//| def flash(*buffer: WriteableBuffer, offset: int=0) -> None:
55+
//| """Writes one of two OTA partition at the given offset.
56+
//| ...
57+
//|
4558
STATIC mp_obj_t ota_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
46-
enum { ARG_binary, ARG_offset };
59+
enum { ARG_buffer, ARG_offset };
4760
static const mp_arg_t allowed_args[] = {
48-
{ MP_QSTR_binary, MP_ARG_OBJ | MP_ARG_REQUIRED },
61+
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED },
4962
{ MP_QSTR_offset, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} },
5063
};
5164

5265
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
53-
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
66+
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
5467

5568
if (args[ARG_offset].u_int < -1) {
5669
mp_raise_ValueError(translate("offset must be >= 0"));
5770
}
5871

5972
mp_buffer_info_t bufinfo;
60-
mp_get_buffer_raise(args[ARG_binary].u_obj, &bufinfo, MP_BUFFER_READ);
73+
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ);
6174

6275
common_hal_ota_flash(bufinfo.buf, bufinfo.len, args[ARG_offset].u_int);
6376
return mp_const_none;
6477
}
65-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ota_flash_obj, 1, ota_flash);
78+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ota_flash_obj, 0, ota_flash);
6679

6780
STATIC const mp_rom_map_elem_t ota_module_globals_table[] = {
6881
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ota) },

0 commit comments

Comments
 (0)