add docs, update translation & fix ota.flash()
This commit is contained in:
parent
6a4f74946f
commit
cb35abfd04
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2020-12-08 10:30+0530\n"
|
"POT-Creation-Date: 2020-12-10 16:56+0530\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -1907,6 +1907,10 @@ msgstr ""
|
|||||||
msgid "Unable to read color palette data"
|
msgid "Unable to read color palette data"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: ports/esp32s2/common-hal/ota/__init__.c
|
||||||
|
msgid "Unable to switch boot partition"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: shared-bindings/nvm/ByteArray.c
|
#: shared-bindings/nvm/ByteArray.c
|
||||||
msgid "Unable to write to nvm."
|
msgid "Unable to write to nvm."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -3198,6 +3202,10 @@ msgstr ""
|
|||||||
msgid "offset is too large"
|
msgid "offset is too large"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: shared-bindings/ota/__init__.c
|
||||||
|
msgid "offset must be >= 0"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: py/objstr.c py/objstrunicode.c
|
#: py/objstr.c py/objstrunicode.c
|
||||||
msgid "offset out of bounds"
|
msgid "offset out of bounds"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -145,6 +145,6 @@ void common_hal_ota_finish(void) {
|
|||||||
|
|
||||||
void common_hal_ota_switch(void) {
|
void common_hal_ota_switch(void) {
|
||||||
if (esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL)) != ESP_OK) {
|
if (esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL)) != ESP_OK) {
|
||||||
mp_raise_RuntimeError(translate("Unable to switch partition"));
|
mp_raise_RuntimeError(translate("Unable to switch boot partition"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,39 +30,52 @@
|
|||||||
//|
|
//|
|
||||||
//| The `ota` module implements over-the-air update."""
|
//| The `ota` module implements over-the-air update."""
|
||||||
|
|
||||||
|
//| def switch() -> None:
|
||||||
|
//| """Switches the boot partition.
|
||||||
|
//| ...
|
||||||
|
//|
|
||||||
STATIC mp_obj_t ota_switch(void) {
|
STATIC mp_obj_t ota_switch(void) {
|
||||||
common_hal_ota_switch();
|
common_hal_ota_switch();
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_switch_obj, ota_switch);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_switch_obj, ota_switch);
|
||||||
|
|
||||||
|
//| def finish() -> None:
|
||||||
|
//| """Validates flashed firmware, sets next boot partition.
|
||||||
|
//| **Must be called after** `ota.flash()`
|
||||||
|
//| ...
|
||||||
|
//|
|
||||||
STATIC mp_obj_t ota_finish(void) {
|
STATIC mp_obj_t ota_finish(void) {
|
||||||
common_hal_ota_finish();
|
common_hal_ota_finish();
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_finish_obj, ota_finish);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ota_finish_obj, ota_finish);
|
||||||
|
|
||||||
|
//| def flash(*buffer: WriteableBuffer, offset: int=0) -> None:
|
||||||
|
//| """Writes one of two OTA partition at the given offset.
|
||||||
|
//| ...
|
||||||
|
//|
|
||||||
STATIC mp_obj_t ota_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
STATIC mp_obj_t ota_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
enum { ARG_binary, ARG_offset };
|
enum { ARG_buffer, ARG_offset };
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_binary, MP_ARG_OBJ | MP_ARG_REQUIRED },
|
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED },
|
||||||
{ MP_QSTR_offset, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} },
|
{ MP_QSTR_offset, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} },
|
||||||
};
|
};
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
if (args[ARG_offset].u_int < -1) {
|
if (args[ARG_offset].u_int < -1) {
|
||||||
mp_raise_ValueError(translate("offset must be >= 0"));
|
mp_raise_ValueError(translate("offset must be >= 0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(args[ARG_binary].u_obj, &bufinfo, MP_BUFFER_READ);
|
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ);
|
||||||
|
|
||||||
common_hal_ota_flash(bufinfo.buf, bufinfo.len, args[ARG_offset].u_int);
|
common_hal_ota_flash(bufinfo.buf, bufinfo.len, args[ARG_offset].u_int);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ota_flash_obj, 1, ota_flash);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ota_flash_obj, 0, ota_flash);
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t ota_module_globals_table[] = {
|
STATIC const mp_rom_map_elem_t ota_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ota) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ota) },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user