implement ota module
This commit is contained in:
parent
054eafd42f
commit
fc23a0cc8a
31
ports/esp32s2/common-hal/ota/__init__.c
Normal file
31
ports/esp32s2/common-hal/ota/__init__.c
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 microDev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/ota/__init__.h"
|
||||
|
||||
void common_hal_ota_flash(const void *buf, const size_t len) {
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ CIRCUITPY_FREQUENCYIO = 1
|
||||
CIRCUITPY_I2CPERIPHERAL = 0
|
||||
CIRCUITPY_ROTARYIO = 1
|
||||
CIRCUITPY_NVM = 1
|
||||
CIRCUITPY_OTA = 1
|
||||
# We don't have enough endpoints to include MIDI.
|
||||
CIRCUITPY_USB_MIDI = 0
|
||||
CIRCUITPY_WIFI = 1
|
||||
|
@ -205,6 +205,9 @@ endif
|
||||
ifeq ($(CIRCUITPY_OS),1)
|
||||
SRC_PATTERNS += os/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_OTA),1)
|
||||
SRC_PATTERNS += ota/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PIXELBUF),1)
|
||||
SRC_PATTERNS += _pixelbuf/%
|
||||
endif
|
||||
@ -347,6 +350,7 @@ SRC_COMMON_HAL_ALL = \
|
||||
nvm/ByteArray.c \
|
||||
nvm/__init__.c \
|
||||
os/__init__.c \
|
||||
ota/__init__.c \
|
||||
ps2io/Ps2.c \
|
||||
ps2io/__init__.c \
|
||||
pulseio/PulseIn.c \
|
||||
|
@ -539,6 +539,13 @@ extern const struct _mp_obj_module_t os_module;
|
||||
#define OS_MODULE_ALT_NAME
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_OTA
|
||||
extern const struct _mp_obj_module_t ota_module;
|
||||
#define OTA_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ota), (mp_obj_t)&ota_module },
|
||||
#else
|
||||
#define OTA_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PEW
|
||||
extern const struct _mp_obj_module_t pew_module;
|
||||
#define PEW_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__pew),(mp_obj_t)&pew_module },
|
||||
@ -827,6 +834,7 @@ extern const struct _mp_obj_module_t wifi_module;
|
||||
NETWORK_MODULE \
|
||||
SOCKET_MODULE \
|
||||
WIZNET_MODULE \
|
||||
OTA_MODULE \
|
||||
PEW_MODULE \
|
||||
PIXELBUF_MODULE \
|
||||
PS2IO_MODULE \
|
||||
|
@ -179,6 +179,9 @@ CFLAGS += -DCIRCUITPY_NVM=$(CIRCUITPY_NVM)
|
||||
CIRCUITPY_OS ?= 1
|
||||
CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
|
||||
|
||||
CIRCUITPY_OTA ?= 0
|
||||
CFLAGS += -DCIRCUITPY_OTA=$(CIRCUITPY_OTA)
|
||||
|
||||
CIRCUITPY_PIXELBUF ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_PIXELBUF=$(CIRCUITPY_PIXELBUF)
|
||||
|
||||
|
51
shared-bindings/ota/__init__.c
Normal file
51
shared-bindings/ota/__init__.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 microDev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/ota/__init__.h"
|
||||
|
||||
//| """ota module
|
||||
//|
|
||||
//| The `ota` module implements over-the-air update."""
|
||||
|
||||
STATIC mp_obj_t ota_flash(mp_obj_t program_binary_in) {
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(program_binary_in, &bufinfo, MP_BUFFER_READ);
|
||||
|
||||
common_hal_ota_flash(bufinfo.buf, bufinfo.len);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(ota_flash_obj, ota_flash);
|
||||
|
||||
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_flash), MP_ROM_PTR(&ota_flash_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(ota_module_globals, ota_module_globals_table);
|
||||
|
||||
const mp_obj_module_t ota_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&ota_module_globals,
|
||||
};
|
34
shared-bindings/ota/__init__.h
Normal file
34
shared-bindings/ota/__init__.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 microDev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_OTA___INIT___H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_OTA___INIT___H
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
extern void common_hal_ota_flash(const void *buf, const size_t len);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_OTA___INIT___H
|
Loading…
x
Reference in New Issue
Block a user