==== Micropython ==== Python for microcontrollers. === Setup === Install [[:tools:esptool|ESPTool]] for ESP8266 and ESP32. Install [[:tools:stlink|STLink]] for STM32. === ESP32 === To reset the device for access by esptool, hold IO0 and tap EN. Release IO0. Erase flash chip esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash esptool.py v3.0-dev Serial port /dev/ttyUSB0 Connecting........_____. Chip is ESP32-D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: 30:ae:a4:fe:03:80 Uploading stub... Running stub... Stub running... Erasing flash (this may take a while)... Chip erase completed successfully in 6.4s Hard resetting via RTS pin... Fetch firmware wget "http://micropython.org/resources/firmware/esp32-idf3-20200816-unstable-v1.12-665-g60f5b941e.bin" Write flash chip esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-idf3-20200816-unstable-v1.12-665-g60f5b941e.bin esptool.py v3.0-dev Serial port /dev/ttyUSB0 Connecting........_ Chip is ESP32-D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: 30:ae:a4:fe:03:80 Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Auto-detected Flash size: 4MB Compressed 1448240 bytes to 925586... Wrote 1448240 bytes (925586 compressed) at 0x00001000 in 23.4 seconds (effective 495.0 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... Verify flash esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 verify_flash 0x1000 esp32-idf3-20200816-unstable-v1.12-665-g60f5b941e.bin esptool.py v3.0-dev Serial port /dev/ttyUSB0 Connecting........_____....._____....._ Chip is ESP32-D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: 30:ae:a4:fe:03:80 Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Auto-detected Flash size: 4MB Verifying 0x161930 (1448240) bytes @ 0x00001000 in flash against esp32-idf3-20200816-unstable-v1.12-665-g60f5b941e.bin... -- verify OK (digest matched) Hard resetting via RTS pin... Run picocom -b 115200 /dev/ttyUSB0 picocom v3.1 port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no Type [C-a] [C-h] to see available commands Terminal ready MPY: soft reboot MicroPython v1.12-665-g60f5b941e on 2020-08-16; ESP32 module with ESP32 Type "help()" for more information. >>> help("modules") __main__ gc uasyncio/stream upip_utarfile _boot inisetup ubinascii upysh _onewire machine ubluetooth urandom _thread math ucollections ure _uasyncio micropython ucryptolib urequests _webrepl neopixel uctypes uselect apa106 network uerrno usocket btree ntptime uhashlib ussl builtins onewire uhashlib ustruct cmath sys uheapq utime dht uarray uio utimeq ds18x20 uasyncio/__init__ ujson uwebsocket esp uasyncio/core umqtt/robust uzlib esp32 uasyncio/event umqtt/simple webrepl flashbdev uasyncio/funcs uos webrepl_setup framebuf uasyncio/lock upip websocket_helper Plus any modules on the filesystem ===ESP8266=== Install esp8266-20191220-v1.12.bin Run picocom -b 115200 /dev/ttyUSB0 picocom v1.7 port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 escape is : C-a local echo is : no noinit is : no noreset is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv imap is : omap is : emap is : crcrlf,delbs, Terminal ready MPY: soft reboot MicroPython v1.12 on 2019-12-20; ESP module with ESP8266 Type "help()" for more information. ===STM32=== Probe st-info --probe Found 1 stlink programmers serial: 303636444646353135343536373037303637313733313437 hla-serial: "\x30\x36\x36\x44\x46\x46\x35\x31\x35\x34\x35\x36\x37\x30\x37\x30\x36\x37\x31\x37\x33\x31\x34\x37" flash: 524288 (pagesize: 16384) sram: 131072 chipid: 0x0431 descr: stm32f411re Install [[tools:gccarm|gccarm]] Checkout micropython and build mpy-cross. In ports directory, build stm32. Eg. make BOARD=NUCLEO_F411RE deploy-stlink Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. Writing build-NUCLEO_F411RE/firmware0.bin to the board via ST-LINK st-flash 1.6.1-86-gf162a5d 2020-08-16T06:59:50 INFO common.c: stm32f411re: 128 KiB SRAM, 512 KiB flash in at least 16 KiB pages. file build-NUCLEO_F411RE/firmware0.bin md5 checksum: 1d81eee6e92c41643d7b3ae71cd4f, stlink checksum: 0x001867ec 2020-08-16T06:59:50 INFO common.c: Attempting to write 14780 (0x39bc) bytes to stm32 address: 134217728 (0x8000000) EraseFlash - Sector:0x0 Size:0x4000 2020-08-16T06:59:51 INFO common.c: Flash page at addr: 0x08000000 erased 2020-08-16T06:59:51 INFO common.c: Finished erasing 1 pages of 16384 (0x4000) bytes 2020-08-16T06:59:51 INFO common.c: Starting Flash write for F2/F4/F7/L4 2020-08-16T06:59:51 INFO flash_loader.c: Successfully loaded flash loader in sram enabling 32-bit flash writes size: 14780 2020-08-16T06:59:51 INFO common.c: Starting verification of write complete 2020-08-16T06:59:51 INFO common.c: Flash written and verified! jolly good! Writing build-NUCLEO_F411RE/firmware1.bin to the board via ST-LINK st-flash 1.6.1-86-gf162a5d 2020-08-16T06:59:51 INFO common.c: stm32f411re: 128 KiB SRAM, 512 KiB flash in at least 16 KiB pages. file build-NUCLEO_F411RE/firmware1.bin md5 checksum: 15c0323c6561a0651eed6d4a34ff33a1, stlink checksum: 0x019ebca3 2020-08-16T06:59:51 INFO common.c: Attempting to write 284128 (0x455e0) bytes to stm32 address: 134348800 (0x8020000) EraseFlash - Sector:0x5 Size:0x20000 2020-08-16T06:59:53 INFO common.c: Flash page at addr: 0x08020000 erased EraseFlash - Sector:0x6 Size:0x20000 2020-08-16T06:59:55 INFO common.c: Flash page at addr: 0x08040000 erased EraseFlash - Sector:0x7 Size:0x20000 2020-08-16T06:59:57 INFO common.c: Flash page at addr: 0x08060000 erased 2020-08-16T06:59:57 INFO common.c: Finished erasing 3 pages of 131072 (0x20000) bytes 2020-08-16T06:59:57 INFO common.c: Starting Flash write for F2/F4/F7/L4 2020-08-16T06:59:57 INFO flash_loader.c: Successfully loaded flash loader in sram enabling 32-bit flash writes size: 32768 size: 32768 size: 32768 size: 32768 size: 32768 size: 32768 size: 32768 size: 32768 size: 21984 2020-08-16T07:00:04 INFO common.c: Starting verification of write complete 2020-08-16T07:00:07 INFO common.c: Flash written and verified! jolly good! Run picocom -b 115200 /dev/ttyACM0 picocom v3.1 port is : /dev/ttyACM0 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no Type [C-a] [C-h] to see available commands Terminal ready MPY: sync filesystems MPY: soft reboot MicroPython v1.12-663-g9883d8e81 on 2020-08-16; NUCLEO-F411RE with STM32F411xE Type "help()" for more information. === Resources === [[http://micropython.org/download/esp8266/|ESP8266 firmware]] [[http://micropython.org/download/esp32/|ESP32 firmware]] [[http://micropython.org/download/stm32/|STM32 firmware]]