硬件需求:
nodemcu / WeMosD1 (esp8266ex)
软件:
系统:windows/mac/linux,本人用ubuntu
软件:python3.4+,本人3.8
pip install adafruit-ampy
esptool
VSCode with "RT-Thread MicroPython" plugin
pip install esptool
- esptool.py --port /dev/ttyUSB1 erase_flash
- esptool.py v4.3
- Serial port /dev/ttyUSB1
- Connecting....
- Detecting chip type... Unsupported detection protocol, switching and trying again...
- Connecting....
- Detecting chip type... ESP8266
- Chip is ESP8266EX
- Features: WiFi
- Crystal is 26MHz
- MAC: e0:98:06:12:37:a8
- Uploading stub...
- Running stub...
- Stub running...
- Erasing flash (this may take a while)...
- Chip erase completed successfully in 11.7s
- Hard resetting via RTS pin...
MicroPython - Python for microcontrollers
下载最新的固件
刷写:
- esptool.py --port /dev/ttyUSB1 --baud 460800 write_flash --flash_size=detect 0 esp8266-20220618-v1.19.1.bin
- esptool.py v4.3
- Serial port /dev/ttyUSB1
- Connecting....
- Detecting chip type... Unsupported detection protocol, switching and trying again...
- Connecting....
- Detecting chip type... ESP8266
- Chip is ESP8266EX
- Features: WiFi
- Crystal is 26MHz
- MAC: e0:98:06:12:37:a8
- Uploading stub...
- Running stub...
- Stub running...
- Changing baud rate to 460800
- Changed.
- Configuring flash size...
- Auto-detected Flash size: 4MB
- Flash will be erased from 0x00000000 to 0x0009afff...
- Flash params set to 0x0040
- Compressed 634844 bytes to 419808...
- Wrote 634844 bytes (419808 compressed) at 0x00000000 in 9.5 seconds (effective 532.2 kbit/s)...
- Hash of data verified.
-
- Leaving...
- Hard resetting via RTS pin...
使用ampy上传下载程序
ampy -p /dev/ttyUSB0 ls
/boot.py
ampy支持的命令:
运行一个示例
(base) ping@ping:~/.vscode/extensions/rt-thread.rt-thread-micropython-1.0.11/microExamples/examples/03.board/3.esp8266$ ampy -p /dev/ttyUSB0 put blink.py
(base) ping@ping:~/.vscode/extensions/rt-thread.rt-thread-micropython-1.0.11/microExamples/examples/03.board/3.esp8266$ ampy -p /dev/ttyUSB0 run blink.py
因为RT-thread 插件无法找到串口,所以用ampy上传和运行了。