安装micropython到esp8266

硬件需求:

nodemcu / WeMosD1    (esp8266ex)

软件:

系统:windows/mac/linux,本人用ubuntu

软件:python3.4+,本人3.8

pip install adafruit-ampy

esptool

VSCode with "RT-Thread MicroPython" plugin

安装esptool:

pip install esptool

擦除flash

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支持的命令:

  • get  从开发版下载文件ampy -p /dev/ttyUSB0 get boot.py
  • ls  list所有开发板文件
  • mkdir 在开发板创建文件夹
  • reset 开发板软件重置
  • rmdir 删除文件夹
  • run 运行脚本并输出

运行一个示例

(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上传和运行了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值