8000 Super enhancement for ESP8266: software-initiated MicroPython base firmware update from image file on LFS2 file-system and dynamic frozen modules by xuancong84 · Pull Request #12429 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Super enhancement for ESP8266: software-initiated MicroPython base firmware update from image file on LFS2 file-system and dynamic frozen modules #12429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a07543f
esp8266: Add OTA firmware update from file and dynamic frozen modules.
xuancong84 Sep 22, 2023
c3a5ff0
Merge branch 'micropython:master' into master
xuancong84 Oct 1, 2023
85359d4
fix bug: forgot to erase sector before flash_mpy_to_rom()
xuancong84 Oct 4, 2023
25f239e
Merge branch 'micropython:master' into master
xuancong84 Oct 5, 2023
57f9838
Merge branch 'micropython:master' into master
xuancong84 Oct 15, 2023
a462dda
Merge branch 'micropython:master' into master
xuancong84 Oct 18, 2023
4c5437a
adjusted for updates in upstream/master.
xuancong84 Oct 21, 2023
68b82ba
Merge branch 'micropython:master' into master
xuancong84 Oct 21, 2023
3f5de4b
Merge remote-tracking branch 'upstream/master'
xuancong84 Nov 22, 2023
ad9d71b
after merge
xuancong84 Nov 22, 2023
8ac2c85
Merge branch 'micropython:master' into master
xuancong84 Nov 22, 2023
63f52c2
Merge branch 'micropython:master' into master
xuancong84 Dec 3, 2023
9f9c6e8
Merge branch 'micropython:master' into master
xuancong84 Dec 10, 2023
3b9c631
Merge branch 'micropython:master' into master
xuancong84 Dec 12, 2023
ce120da
Merge branch 'micropython:master' into master
xuancong84 Dec 20, 2023
5d05a8f
extended ESP32 WDT timeout for OpenSmartHome
xuancong84 Dec 20, 2023
4b4f601
rp2/rp2_flash: Lockout second core only when doing flash erase/write.
dpgeorge Jan 1, 2024
61b8361
rp2/mutex_extra: Implement additional mutex functions.
dpgeorge Jan 2, 2024
ac5e0b9
rp2/mpthreadport: Fix race with IRQ when entering atomic section.
dpgeorge Jan 1, 2024
9b8c64c
all: Bump version to 1.22.1.
dpgeorge Jan 5, 2024
681d094
Merge branch 'micropython:master' into master
xuancong84 Jan 17, 2024
9dd264e
Merge branch 'micropython:master' into master
xuancong84 Feb 14, 2024
d5f3fcd
rp2/rp2_dma: Fix fetching 'write' buffers for writing not reading.
nickovs Jan 6, 2024
068aa28
rp2/machine_uart: Fix event wait in uart.flush() and uart.read().
robert-hh Jan 7, 2024
4c7d955
renesas-ra/ra: Fix SysTick clock source.
iabdalkader Jan 12, 2024
1e8cc6c
renesas-ra/boards/ARDUINO_PORTENTA_C33: Fix the RTC clock source.
iabdalkader Jan 17, 2024
a2e9ab3
extmod/asyncio: Support gather of tasks that finish early.
dpgeorge Jan 18, 2024
8b6e89a
mimxrt/modmachine: Fix deepsleep wakeup pin ifdef.
kwagyeman Jan 22, 2024
2531a15
extmod/modssl_mbedtls: Fix cipher iteration in SSLContext.get_ciphers.
dpgeorge Jan 29, 2024
f53ee9f
rp2: Change machine.I2S and rp2.DMA to use shared DMA IRQ handlers.
dpgeorge Jan 30, 2024
b979c5a
py/compile: Fix potential Py-stack overflow in try-finally with return.
dpgeorge Jan 31, 2024
cc7cfc7
renesas-ra/ra/ra_i2c: Fix 1 byte and 2 bytes read issue.
TakeoTakahashi2020 Jan 29, 2024
e7ff724
extmod/btstack: Reset pending_value_handle before calling write-done cb.
dpgeorge Feb 8, 2024
02df2b0
extmod/btstack: Reset pending_value_handle before calling read-done cb.
dpgeorge Feb 11, 2024
e72d038
esp32/mpnimbleport: Release the GIL while doing NimBLE port deinit.
dpgeorge Feb 14, 2024
ee3c9cc
esp32: Increase NimBLE task stack size and overflow detection headroom.
dpgeorge Feb 15, 2024
8cd1582
all: Bump version to 1.22.2.
dpgeorge Feb 20, 2024
f7e7f27
Merge tag 'v1.22.2' of github.com:micropython/micropython
xuancong84 May 17, 2024
515de5e
Merge tag 'v1.23.0' of https://github.com/micropython/micropython
xuancong84 Jul 3, 2024
141a55d
esp8266 and esp32 build working after merge
xuancong84 Jul 3, 2024
529dfd9
Merge branch 'master' of https://github.com/micropython/micropython
xuancong84 Jul 4, 2024
dad4f6c
Merge to include Disable hardware stack protection for esp32c3
xuancong84 Sep 13, 2024
f231bf8
workaround the deadlock due to "Fix uneven GIL allocation between Pyt…
xuancong84 Sep 17, 2024
5c7ac55
tools/mpremote: Fix UnboundLocalError in Transport.fs_writefile().
glenn20 Oct 26, 2024
785c92d
esp32/machine_pwm: Use IDF functions to calculate resolution correctly.
pi-anl Oct 27, 2024
c0afff8
pic16bit: Make it build with recent XC16 versions.
agatti Sep 12, 2024
a7d3bc2
py/objdeque: Fix buffer overflow in deque_subscr.
jansturm92 Oct 29, 2024
6f32768
extmod/modlwip: Fix IGMP address type when IPv6 is enabled.
dpgeorge Oct 31, 2024
164c549
esp32/machine_pwm: Restore PWM support for ESP-IDF v5.0.x and v5.1.x.
projectgus Nov 1, 2024
72799f9
esp32: Workaround native code execution crash on ESP32-S2.
projectgus Nov 6, 2024
c1a85bb
tools/mpremote: Make sure stdout and stderr output appear in order.
dpgeorge Nov 6, 2024
159b54b
tools/mpremote: Add test for forced copy.
dpgeorge Nov 6, 2024
4e78c61
tools/mpremote: Support trailing slash on dest for non-recursive copy.
dpgeorge Nov 6, 2024
0c580f7
esp32/modsocket: Fix getaddrinfo hints to set AI_CANONNAME.
dpgeorge Nov 11, 2024
20a6d82
extmod/vfs_blockdev: Support bool return from Python read/write blocks.
dpgeorge Nov 13, 2024
67f8938
extmod/network_cyw43: Fix isconnected() result on AP interface.
projectgus Nov 13, 2024
4f4d683
extmod/network_cyw43: Fix uninitialised variable in status('stations').
dpgeorge Nov 19, 2024
49b83ed
extmod/network_cyw43: Allow configuring active AP interface.
projectgus Nov 13, 2024
03bc561
esp32: Fix setting WLAN channel in AP mode.
projectgus Nov 12, 2024
eb0027b
esp32: Use hardware version for touchpad macro defines.
projectgus Nov 6, 2024
33f50d4
esp32: Fix machine.TouchPad startup on ESP32-S2 and S3.
projectgus Nov 6, 2024
948863c
extmod/modframebuf: Fix 0 radius bug in FrameBuffer.ellipse.
corranwebster Nov 14, 2024
7118942
nrf/drivers/ticker: Reset slow ticker callback count on soft reboot.
robert-hh Nov 27, 2024
564ef28
py/objfloat: Workaround non-constant NAN definition on Windows MSVC.
projectgus Nov 20, 2024
ecfdd5d
all: Bump version to 1.24.1.
dpgeorge Nov 29, 2024
1c61594
Merge branch 'last-stable'
xuancong84 Mar 15, 2025
f0031ae
esp32 working after merge
xuancong84 Mar 16, 2025
83877c0
added functions for controlling interrupt masks on esp32
xuancong84 Apr 8, 2025
8b88a14
added micropython.kbd_intr_enable(bool) to allow enable/disable keybo…
xuancong84 Apr 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ user.props

# MacOS desktop metadata files
.DS_Store
ports/esp8266/modules/*.py
4 changes: 4 additions & 0 deletions extmod/modframebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ static mp_obj_t framebuf_ellipse(size_t n_args, const mp_obj_t *args_in) {
} else {
mask |= ELLIPSE_MASK_ALL;
}
if (args[2] == 0 && args[3] == 0) {
setpixel_checked(self, args[0], args[1], args[4], mask & ELLIPSE_MASK_ALL);
return mp_const_none;
}
mp_int_t two_asquare = 2 * args[2] * args[2];
mp_int_t two_bsquare = 2 * args[3] * args[3];
mp_int_t x = args[2];
Expand Down
2 changes: 1 addition & 1 deletion extmod/modlwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ static mp_obj_t lwip_socket_setsockopt(size_t n_args, const mp_obj_t *args) {
case IP_DROP_MEMBERSHIP: {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ);
if (bufinfo.len != sizeof(ip_addr_t) * 2) {
if (bufinfo.len != sizeof(MP_IGMP_IP_ADDR_TYPE) * 2) {
mp_raise_ValueError(NULL);
}

Expand Down
5 changes: 2 additions & 3 deletions extmod/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,15 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_deepsleep_obj, 0, 1, machine_deepsle
#endif

#if MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ

static mp_obj_t machine_disable_irq(void) {
uint32_t state = MICROPY_BEGIN_ATOMIC_SECTION();
return mp_obj_new_int(state);
}
static MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);

static mp_obj_t machine_enable_irq(mp_obj_t state_in) {
uint32_t state = mp_obj_get_int(state_in);
MICROPY_END_ATOMIC_SECTION(state);
uint32_t irq_state = mp_obj_get_int(state_in);
MICROPY_END_ATOMIC_SECTION(irq_state);
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);
Expand Down
50 changes: 43 additions & 7 deletions extmod/network_cyw43.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ typedef struct _network_cyw43_obj_t {
static const network_cyw43_obj_t network_cyw43_wl_sta = { { &mp_network_cyw43_type }, &cyw43_state, CYW43_ITF_STA };
static const network_cyw43_obj_t network_cyw43_wl_ap = { { &mp_network_cyw43_type }, &cyw43_state, CYW43_ITF_AP };

// Avoid race conditions with callbacks by tracking the last up or down request
// we have made for each interface.
static bool if_active[2];

static void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
struct netif *netif = &self->cyw->netif[self->itf];
Expand Down Expand Up @@ -122,6 +126,10 @@ static MP_DEFINE_CONST_FUN_OBJ_3(network_cyw43_ioctl_obj, network_cyw43_ioctl);
/*******************************************************************************/
// network API

static uint32_t get_country_code(void) {
return CYW43_COUNTRY(mod_network_country_code[0], mod_network_country_code[1], 0);
}

static mp_obj_t network_cyw43_deinit(mp_obj_t self_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
cyw43_deinit(self->cyw);
Expand All @@ -132,10 +140,11 @@ static MP_DEFINE_CONST_FUN_OBJ_1(network_cyw43_deinit_obj, network_cyw43_deinit)
static mp_obj_t network_cyw43_active(size_t n_args, const mp_obj_t *args) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(args[0]);
if (n_args == 1) {
return mp_obj_new_bool(cyw43_tcpip_link_status(self->cyw, self->itf));
return mp_obj_new_bool(if_active[self->itf]);
} else {
uint32_t country = CYW43_COUNTRY(mod_network_country_code[0], mod_network_country_code[1], 0);
cyw43_wifi_set_up(self->cyw, self->itf, mp_obj_is_true(args[1]), country);
bool value = mp_obj_is_true(args[1]);
cyw43_wifi_set_up(self->cyw, self->itf, value, get_country_code());
if_active[self->itf] = value;
return mp_const_none;
}
}
Expand Down Expand Up @@ -311,7 +320,17 @@ static MP_DEFINE_CONST_FUN_OBJ_1(network_cyw43_disconnect_obj, network_cyw43_dis

static mp_obj_t network_cyw43_isconnected(mp_obj_t self_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
return mp_obj_new_bool(cyw43_tcpip_link_status(self->cyw, self->itf) == 3);
bool result = (cyw43_tcpip_link_status(self->cyw, self->itf) == CYW43_LINK_UP);

if (result && self->itf == CYW43_ITF_AP) {
// For AP we need to not only know if the link is up, but also if any stations
// have associated.
uint8_t mac_buf[6];
int num_stas = 1;
cyw43_wifi_ap_get_stas(self->cyw, &num_stas, mac_buf);
result = num_stas > 0;
}
return mp_obj_new_bool(result);
}
static MP_DEFINE_CONST_FUN_OBJ_1(network_cyw43_isconnected_obj, network_cyw43_isconnected);

Expand Down Expand Up @@ -351,13 +370,15 @@ static mp_obj_t network_cyw43_status(size_t n_args, const mp_obj_t *args) {
if (self->itf != CYW43_ITF_AP) {
mp_raise_ValueError(MP_ERROR_TEXT("AP required"));
}
int num_stas;
uint8_t macs[32 * 6];
static const unsigned mac_len = 6;
static const unsigned max_stas = 32;
int num_stas = max_stas;
uint8_t macs[max_stas * mac_len];
cyw43_wifi_ap_get_stas(self->cyw, &num_stas, macs);
mp_obj_t list = mp_obj_new_list(num_stas, NULL);
for (int i = 0; i < num_stas; ++i) {
mp_obj_t tuple[1] = {
mp_obj_new_bytes(&macs[i * 6], 6),
mp_obj_new_bytes(&macs[i * mac_len], mac_len),
};
((mp_obj_list_t *)MP_OBJ_TO_PTR(list))->items[i] = mp_obj_new_tuple(1, tuple);
}
Expand Down Expand Up @@ -445,6 +466,10 @@ static mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map
mp_raise_TypeError(MP_ERROR_TEXT("can't specify pos and kw args"));
}

// A number of these options only update buffers in memory, and
// won't do anything until the interface is cycled down and back up
bool cycle_active = false;

for (size_t i = 0; i < kwargs->alloc; ++i) {
if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
mp_map_elem_t *e = &kwargs->table[i];
Expand All @@ -457,13 +482,15 @@ static mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map
}
case MP_QSTR_channel: {
cyw43_wifi_ap_set_channel(self->cyw, mp_obj_get_int(e->value));
cycle_active = true;
break;
}
case MP_QSTR_ssid:
case MP_QSTR_essid: {
size_t len;
const char *str = mp_obj_str_get_data(e->value, &len);
cyw43_wifi_ap_set_ssid(self->cyw, len, (const uint8_t *)str);
cycle_active = true;
break;
}
case MP_QSTR_monitor: {
Expand All @@ -483,13 +510,15 @@ static mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map
}
case MP_QSTR_security: {
cyw43_wifi_ap_set_auth(self->cyw, mp_obj_get_int(e->value));
cycle_active = true;
break;
}
case MP_QSTR_key:
case MP_QSTR_password: {
size_t len;
const char *str = mp_obj_str_get_data(e->value, &len);
cyw43_wifi_ap_set_password(self->cyw, len, (const uint8_t *)str);
cycle_active = true;
break;
}
case MP_QSTR_pm: {
Expand Down Expand Up @@ -519,6 +548,13 @@ static mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map
}
}

// If the interface is already active, cycle it down and up
if (cycle_active && if_active[self->itf]) {
uint32_t country = get_country_code();
cyw43_wifi_set_up(self->cyw, self->itf, false, country);
cyw43_wifi_set_up(self->cyw, self->itf, true, country);
}

return mp_const_none;
}
}
Expand Down
7 changes: 7 additions & 0 deletions extmod/vfs_blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ static int mp_vfs_blockdev_call_rw(mp_obj_t *args, size_t block_num, size_t bloc
if (ret == mp_const_none) {
return 0;
} else {
// Some block devices return a bool indicating success, so
// convert those to an errno integer code.
if (ret == mp_const_true) {
return 0;
} else if (ret == mp_const_false) {
return -MP_EIO;
}
// Block device functions are expected to return 0 on success
// and negative integer on errors. Check for positive integer
// results as some callers (i.e. littlefs) will produce corrupt
Expand Down
1 change: 1 addition & 0 deletions extmod/vfs_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void mp_reader_new_file(mp_reader_t *reader, qstr filename) {
reader->data = rf;
reader->readbyte = mp_reader_vfs_readbyte;
reader->close = mp_reader_vfs_close;
reader->readbytes = NULL;
}

#endif // MICROPY_READER_VFS
2 changes: 1 addition & 1 deletion lib/libmetal
Submodule libmetal updated 56 files
+2 −2 .github/actions/build_ci/Dockerfile
+37 −27 .github/actions/build_ci/entrypoint.sh
+1 −1 README.md
+1 −1 VERSION
+1 −1 cmake/syscheck.cmake
+5 −1 lib/atomic.h
+1 −1 lib/compiler.h
+93 −0 lib/compiler/armcc/errno.h
+2 −0 lib/config.h
+6 −0 lib/cpu.h
+17 −21 lib/device.h
+1 −1 lib/errno.h
+18 −0 lib/list.h
+9 −9 lib/log.h
+13 −1 lib/processor/CMakeLists.txt
+0 −3 lib/processor/aarch64/CMakeLists.txt
+0 −15 lib/processor/aarch64/atomic.h
+0 −3 lib/processor/arm/CMakeLists.txt
+0 −15 lib/processor/arm/atomic.h
+0 −17 lib/processor/arm/cpu.h
+0 −2 lib/processor/ceva/CMakeLists.txt
+0 −2 lib/processor/csky/CMakeLists.txt
+0 −17 lib/processor/csky/cpu.h
+15 −0 lib/processor/generic/atomic.h
+17 −0 lib/processor/generic/cpu.h
+22 −0 lib/processor/hosted/cpu.h
+0 −3 lib/processor/microblaze/CMakeLists.txt
+0 −15 lib/processor/microblaze/atomic.h
+0 −20 lib/processor/microblaze/cpu.h
+0 −2 lib/processor/riscv/CMakeLists.txt
+0 −17 lib/processor/riscv/cpu.h
+0 −3 lib/processor/x86/CMakeLists.txt
+0 −16 lib/processor/x86/atomic.h
+0 −3 lib/processor/x86_64/CMakeLists.txt
+0 −16 lib/processor/x86_64/atomic.h
+0 −2 lib/processor/xtensa/CMakeLists.txt
+0 −15 lib/processor/xtensa/atomic.h
+3 −3 lib/shmem.h
+1 −2 lib/softirq.c
+4 −4 lib/sys.h
+2 −2 lib/system/freertos/cache.h
+54 −1 lib/system/freertos/xlnx/sys.c
+2 −2 lib/system/generic/cache.h
+5 −1 lib/system/generic/xlnx/CMakeLists.txt
+54 −1 lib/system/generic/xlnx/sys.c
+5 −0 lib/system/generic/xlnx/sys.h
+25 −0 lib/system/generic/xlnx/sys_devicetree.h
+17 −17 lib/system/linux/sys.h
+23 −2 lib/system/nuttx/io.c
+2 −2 lib/system/zephyr/alloc.c
+2 −2 lib/system/zephyr/alloc.h
+2 −2 lib/system/zephyr/sys.c
+6 −0 lib/system/zephyr/sys.h
+2 −2 lib/utilities.h
+4 −4 lib/version.h
+2 −1 test/metal-test.h
Loading
0