Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tools:micropython [2020/08/08 05:23] – created darron | tools:micropython [2020/08/17 11:35] (current) – [ESP32] darron | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ==== Micropython ==== | ||
+ | |||
+ | Python for microcontrollers. | ||
+ | |||
+ | === Setup === | ||
+ | |||
+ | Install [[: | ||
+ | === ESP32 === | ||
+ | |||
+ | To reset the device for access by esptool, hold IO0 and tap EN. Release IO0. | ||
+ | |||
+ | Erase flash chip | ||
+ | |||
< | < | ||
+ | esptool.py --chip esp32 --port / | ||
+ | esptool.py v3.0-dev | ||
+ | Serial port / | ||
+ | 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: | ||
+ | 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 | ||
- | build mpycross | + | < |
+ | wget " | ||
+ | </ | ||
+ | Write flash chip | ||
+ | < | ||
+ | esptool.py --chip esp32 --port / | ||
+ | esptool.py v3.0-dev | ||
+ | Serial port / | ||
+ | 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: | ||
+ | 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. | ||
- | git submodule update --init | + | Leaving... |
+ | Hard resetting via RTS pin... | ||
+ | </ | ||
+ | Verify flash | ||
+ | < | ||
+ | esptool.py --chip esp32 --port / | ||
+ | esptool.py v3.0-dev | ||
+ | Serial port / | ||
+ | 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: | ||
+ | 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 / | ||
+ | picocom v3.1 | ||
+ | |||
+ | port is : / | ||
+ | flowcontrol | ||
+ | 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, | ||
+ | logfile is : none | ||
+ | initstring | ||
+ | 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 " | ||
+ | >>> | ||
+ | __main__ | ||
+ | _boot | ||
+ | _onewire | ||
+ | _thread | ||
+ | _uasyncio | ||
+ | _webrepl | ||
+ | apa106 | ||
+ | btree | ||
+ | builtins | ||
+ | cmath | ||
+ | dht | ||
+ | ds18x20 | ||
+ | esp | ||
+ | esp32 | ||
+ | flashbdev | ||
+ | framebuf | ||
+ | Plus any modules on the filesystem | ||
+ | </ | ||
+ | |||
+ | ===ESP8266=== | ||
+ | |||
+ | Install | ||
+ | < | ||
+ | esp8266-20191220-v1.12.bin | ||
+ | </ | ||
+ | |||
+ | Run | ||
+ | |||
+ | < | ||
+ | picocom -b 115200 / | ||
+ | picocom v1.7 | ||
+ | |||
+ | port is : / | ||
+ | flowcontrol | ||
+ | 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, | ||
+ | |||
+ | Terminal ready | ||
+ | |||
+ | MPY: soft reboot | ||
+ | MicroPython v1.12 on 2019-12-20; ESP module with ESP8266 | ||
+ | Type " | ||
+ | </ | ||
+ | |||
+ | ===STM32=== | ||
+ | |||
+ | Probe | ||
+ | |||
+ | < | ||
+ | st-info --probe | ||
+ | Found 1 stlink programmers | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | Install [[tools: | ||
+ | |||
+ | 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/ | ||
+ | st-flash 1.6.1-86-gf162a5d | ||
+ | 2020-08-16T06: | ||
+ | file build-NUCLEO_F411RE/ | ||
+ | 2020-08-16T06: | ||
+ | EraseFlash - Sector:0x0 Size:0x4000 2020-08-16T06: | ||
+ | 2020-08-16T06: | ||
+ | 2020-08-16T06: | ||
+ | 2020-08-16T06: | ||
+ | enabling 32-bit flash writes | ||
+ | size: 14780 | ||
+ | 2020-08-16T06: | ||
+ | 2020-08-16T06: | ||
+ | Writing build-NUCLEO_F411RE/ | ||
+ | st-flash 1.6.1-86-gf162a5d | ||
+ | 2020-08-16T06: | ||
+ | file build-NUCLEO_F411RE/ | ||
+ | 2020-08-16T06: | ||
+ | EraseFlash - Sector:0x5 Size: | ||
+ | EraseFlash - Sector:0x6 Size: | ||
+ | EraseFlash - Sector:0x7 Size: | ||
+ | 2020-08-16T06: | ||
+ | 2020-08-16T06: | ||
+ | 2020-08-16T06: | ||
+ | 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: | ||
+ | 2020-08-16T07: | ||
+ | </ | ||
+ | |||
+ | Run | ||
+ | |||
+ | < | ||
+ | picocom -b 115200 / | ||
+ | picocom v3.1 | ||
+ | |||
+ | port is : / | ||
+ | flowcontrol | ||
+ | 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, | ||
+ | logfile is : none | ||
+ | initstring | ||
+ | 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 " | ||
+ | </ | ||
+ | === Resources === | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ |