| Dobrica Pavlinušić's random unstructured stuff micropython: Revision 9 esptool and raspberry piI found out that older versions of esptool (like the ones deliveved by debian packages) don't work well on raspberry pi 2 and raspberry pi 4 root@pihdmi:/home/pi/linux-gpio-pinout# esptool -p /dev/ttyUSB0 read_mac esptool.py v2.5.1 Serial port /dev/ttyUSB0 Connecting........_____....._____....._____....._____....._____....._____....._____ A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header root@pihdmi:/home/pi/linux-gpio-pinout# /nuc/esp32/esptool/esptool.py --port /dev/ttyUSB0 read_mac esptool.py v3.2-dev Serial port /dev/ttyUSB0 Connecting........_____....._____.....___ Detecting chip type... ESP32 Chip is ESP32-D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: a4:cf:12:55:c5:60 Uploading stub... Running stub... Stub running... MAC: a4:cf:12:55:c5:60 Hard resetting via RTS pin... esp-idf versiondpavlin@nuc:/nuc/esp32/esp-idf$ git remote -v origin https://github.com/espressif/esp-idf.git (fetch) origin https://github.com/espressif/esp-idf.git (push) dpavlin@nuc:/nuc/esp32/esp-idf$ git checkout -b v3.3-upy 9e70825d1e1cbf7988cf36981774300066580ea7 dpavlin@nuc:/nuc/esp32/esp-idf$ git submodule update --init --recursive For latest micropython v4.3 leaves too little memory available for esp32ecp/ecp5 v4.2.2
( 'gc', gc.isenabled(), 'alloc', gc.mem_alloc(), 'free', gc.mem_free() ) enough memory, but 50% packet loss for ping to remote ppp ip enviromentdpavlin@nuc:/nuc/upy/micropython/ports/esp32$ cat env.sh export PATH=/nuc/esp32/xtensa-esp32-elf/bin/:$PATH export ESPIDF=/nuc/esp32/esp-idf/ IP_FORWARD enable in lwip
dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ git diff
diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile
index 756bc8f89..aa03a6370 100644
--- a/ports/esp32/Makefile
+++ b/ports/esp32/Makefile
@@ -494,7 +494,7 @@ ESPIDF_SPI_FLASH_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/spi_flash/*.c))
 ESPIDF_ULP_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/ulp/*.c))
-$(BUILD)/$(ESPCOMP)/lwip/%.o: CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable
+$(BUILD)/$(ESPCOMP)/lwip/%.o: CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable -DIP_FORWARD=1
 ESPIDF_LWIP_O = $(patsubst %.c,%.o,\
        $(wildcard $(ESPCOMP)/lwip/apps/dhcpserver/*.c) \
        $(wildcard $(ESPCOMP)/lwip/lwip/src/api/*.c) \
builddpavlin@nuc:/nuc/upy/micropython/ports/esp32$ make V=1 ... xtensa-esp32-elf-size build-GENERIC/application.elf text data bss dec hex filename 1100148 275360 37372 1412880 158f10 build-GENERIC/application.elf Create build-GENERIC/application.bin /nuc/esp32/esp-idf//components/esptool_py/esptool/esptool.py --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB build-GENERIC/application.elf esptool.py v2.8 Create build-GENERIC/firmware.bin python3 makeimg.py build-GENERIC/bootloader.bin build-GENERIC/partitions.bin build-GENERIC/application.bin build-GENERIC/firmware.bin bootloader 21360 partitions 3072 application 1375648 total 1441184 deploy to esp32 using esptool ttyUSB4dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ make V=1 PORT=/dev/ttyUSB4 deploy Building with ESP IDF v3 python3 ../../py/makeversionhdr.py build-GENERIC/genhdr/mpversion.h python3 ../../tools/makemanifest.py -o build-GENERIC/frozen_content.c -v "MPY_DIR=../.." -v "MPY_LIB_DIR=../../../micropython-lib" -v "PORT_DIR=/nuc/upy/micropython/ports/esp32" -v "BOARD_DIR=boards/GENERIC" -b "build-GENERIC" -f"-march=xtensawin" boards/manifest.py Writing build-GENERIC/firmware.bin to the board /nuc/esp32/esp-idf//components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB4 --baud 460800 write_flash -z --flash_mode dio --flash_freq 40m 0x1000 build-GENERIC/firmware.bin esptool.py v2.8 Serial port /dev/ttyUSB4 Connecting........_____....._____....._____... Chip is ESP32D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: 24:0a:c4:31:d6:38 Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Auto-detected Flash size: 4MB Compressed 1437088 bytes to 921637... Wrote 1437088 bytes (921637 compressed) at 0x00001000 in 21.5 seconds (effective 535.8 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... serial
dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ microcom -p /dev/ttyUSB4
connected to /dev/ttyUSB4
Escape character: Ctrl-\
Type the escape character to get to the prompt.
>>>
MPY: soft reboot
AP config:  ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
network config: ('192.168.3.208', '255.255.255.0', '192.168.3.1', '192.168.3.1')
FTP server started on 192.168.4.1:21
FTP server started on 192.168.3.208:21
 esp32 mac: 24:0a:c4:31:d6:38 esp32upy
MicroPython v1.14-dirty on 2021-07-25; ESP32 module with ESP32
Type "help()" for more information.
>>> import machine
>>> machine.reset()
ets Jun  8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4972
load:0x40078000,len:10600
load:0x40080400,len:5684
entry 0x400806bc
AP config:  ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
network config: ('192.168.3.208', '255.255.255.0', '192.168.3.1', '192.168.3.1')
FTP server started on 192.168.4.1:21
FTP server started on 192.168.3.208:21
 esp32 mac: 24:0a:c4:31:d6:38 esp32upy
MicroPython v1.14-dirty on 2021-07-25; ESP32 module with ESP32
Type "help()" for more information.
webrepl
 ulx3s ppp |