This is an old revision of the document!


Micropython

Python for microcontrollers.

Setup

Install ESPTool for ESP8266 and ESP32. Install 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.

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 gccarm

Checkout micropython and build mpy-cross.

In ports directory, build stm32.

Eg.

<code> make V=1 BOARD=NUCLEO_F411RE deploy-stlink <code>

Resources

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies