NodeMCU ESP8266 无法上传草图 - 超时错误
NodeMCU ESP8266 cannot upload sketch - timeout error
使用 arduino-cli、arduino-ide,或直接使用 esptool.py(来自 https://github.com/espressif/esptool),我在上传简单(正确)草图时遇到以下错误。
x@y:~/blink$ ~/tools/arduino-cli upload -p /dev/ttyUSB0 --fqbn esp8266:esp8266:nodemcuv2
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/upload.py", line 66, in <module>
esptool.main(cmdline)
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 4074, in main
esp = esp or get_default_connected_device(ser_list, port=args.port, connect_attempts=args.connect_attempts,
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 121, in get_default_connected_device
_esp.connect(before, connect_attempts)
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 639, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
Error during Upload: Failed uploading: uploading error: exit status 1
esptool.py v3.1
问题是我上次 apt upgrade
将内核从 5.4.0-86-generic 更新为 5.4.0-88-generic(我检查了 /var/log/apt/history.log.1.gz
中的更新)。 5.4.0-88驱动CH341无法正常使用(我用的ESP需要CH340G驱动)。解决方案是回到 5.4.0-86 驱动程序,下面我列出我所做的。
- 断开连接到任何 USB 的任何 ESP 或电路板。然后测试是否加载了 CH341 模块(允许与 EPS 进行串行通信)。您可以使用此代码在步骤 2、3.
中测试模块的正确 unload/load
x@y:~$ lsmod | egrep serial
usbserial 53248 2 cp210x,ch341
- 这里是当前 (5.4.0-88) 和以前 (5.4.0-86) 内核模块所在的位置
x@y:~$ ls -larh /lib/modules/
total 164K
drwxr-xr-x 6 root root 4,0K set 29 09:19 5.4.0-88-generic
drwxr-xr-x 6 root root 4,0K set 23 09:45 5.4.0-86-generic
[...]
- 卸载电流(5.4.0-88)CH341模块用命令
sudo rmmod /lib/modules/5.4.0-88-generic/kernel/drivers/usb/serial/ch341.ko
- 使用命令加载以前的(5.4.0-86)CH341模块
sudo insmod /lib/modules/5.4.0-86-generic/kernel/drivers/usb/serial/ch341.ko
就是这样 :) 您现在应该可以将新草图上传到您的 ESP8266。
使用 arduino-cli、arduino-ide,或直接使用 esptool.py(来自 https://github.com/espressif/esptool),我在上传简单(正确)草图时遇到以下错误。
x@y:~/blink$ ~/tools/arduino-cli upload -p /dev/ttyUSB0 --fqbn esp8266:esp8266:nodemcuv2
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/upload.py", line 66, in <module>
esptool.main(cmdline)
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 4074, in main
esp = esp or get_default_connected_device(ser_list, port=args.port, connect_attempts=args.connect_attempts,
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 121, in get_default_connected_device
_esp.connect(before, connect_attempts)
File "/home/x/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 639, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
Error during Upload: Failed uploading: uploading error: exit status 1
esptool.py v3.1
问题是我上次 apt upgrade
将内核从 5.4.0-86-generic 更新为 5.4.0-88-generic(我检查了 /var/log/apt/history.log.1.gz
中的更新)。 5.4.0-88驱动CH341无法正常使用(我用的ESP需要CH340G驱动)。解决方案是回到 5.4.0-86 驱动程序,下面我列出我所做的。
- 断开连接到任何 USB 的任何 ESP 或电路板。然后测试是否加载了 CH341 模块(允许与 EPS 进行串行通信)。您可以使用此代码在步骤 2、3. 中测试模块的正确 unload/load
x@y:~$ lsmod | egrep serial
usbserial 53248 2 cp210x,ch341
- 这里是当前 (5.4.0-88) 和以前 (5.4.0-86) 内核模块所在的位置
x@y:~$ ls -larh /lib/modules/
total 164K
drwxr-xr-x 6 root root 4,0K set 29 09:19 5.4.0-88-generic
drwxr-xr-x 6 root root 4,0K set 23 09:45 5.4.0-86-generic
[...]
- 卸载电流(5.4.0-88)CH341模块用命令
sudo rmmod /lib/modules/5.4.0-88-generic/kernel/drivers/usb/serial/ch341.ko
- 使用命令加载以前的(5.4.0-86)CH341模块
sudo insmod /lib/modules/5.4.0-86-generic/kernel/drivers/usb/serial/ch341.ko
就是这样 :) 您现在应该可以将新草图上传到您的 ESP8266。