1. 串口通信问题
================================================================================================
================================================================================================
最近升级了下esp32的编译环境,使用了官方的最新的编译开发环境,msys32 + eclipse IDE方式,发现无法打开串口和ESP32通信,
eclipse IDE提示通信失败 serial.serialutil.SerialException: could not open port '/??/COM7', 输出如下:
File "D:\15.Esp32Projects\msys32\mingw32\lib\python2.7\site-packages/serial/__init__.py", line 88, in serial_for_url instance.open() File "D:\15.Esp32Projects\msys32\mingw32\lib\python2.7\site-packages/serial/serialwin32.py", line 62, in open raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) serial.serialutil.SerialException: could not open port '/??/COM7': WindowsError(3, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc2\xb7\xbe\xb6\xa1\xa3') make: *** [/d/15.Esp32Projects/esp/esp-idf/components/esptool_py/Makefile.projbuild:78: erase_flash] Error 1 Building component project variables list D:/15.Esp32Projects/esp/app/build/app_trace/component_project_vars.mk make[1]: Leaving directory 'D:/15.Esp32Projects/esp/app/build/app_trace' including D:/15.Esp32Projects/esp/esp-idf/components/bootloader/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/bootloader_support/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/coap/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/esp32/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/mbedtls/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/nghttp/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/partition_table/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/ulp/Makefile.projbuild... Erasing entire flash... python D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyS6" --baud 115200 --before "default_reset" --after "hard_reset" erase_flash esptool.py v2.5.0 Serial port D:/15.Esp32Projects/msys32/ 16:36:43 Build Failed. 1 errors, 0 warnings. (took 32s.24ms)
同样通过msys32 命令行方式 也提示通信失败serial.serialutil.SerialException: could not open port '/??/COM7',输出如下:
31253@LAPTOP-31253 MINGW32 ~/esp/app $ make erase_flash Erasing entire flash... esptool.py v2.5.0 Serial port /??/COM7 Traceback (most recent call last): File "D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/esptool/esptool.py ", line 2849, in <module> _main() File "D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/esptool/esptool.py ", line 2842, in _main main() File "D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/esptool/esptool.py ", line 2549, in main esp = chip_class(each_port, initial_baud, args.trace) File "D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/esptool/esptool.py ", line 213, in __init__ self._port = serial.serial_for_url(port) File "D:/15.Esp32Projects/msys32/mingw32/lib/python2.7/site-packages/serial/__ init__.py", line 88, in serial_for_url instance.open() File "D:/15.Esp32Projects/msys32/mingw32/lib/python2.7/site-packages/serial/se rialwin32.py", line 62, in open raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) serial.serialutil.SerialException: could not open port '/??/COM7': WindowsError( 3, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc2\xb7\xbe \xb6\xa1\xa3') make: *** [/d/15.Esp32Projects/esp/esp-idf/components/esptool_py/Makefile.projbu ild:78:erase_flash] 错误 1 31253@LAPTOP-31253 MINGW32 ~/esp/app $
msys32 命令行查询得到的串口编号为ttyS6(windows10 下的为COM7),输出如下
31253@LAPTOP-31253 MINGW32 ~ $ cd msys32 31253@LAPTOP-31253 MINGW32 ~/msys32 $ ls /dev/tty* /dev/tty /dev/ttyS6 31253@LAPTOP-31253 MINGW32 ~/msys32 $
sdkconfig中也是设置的/dev/ttyS6, 按照此设置以前使用的平台通信没有问题的(更新前使用的编译环境为cygwin + eclipse IDE)
2. 解决方案如下:
===============================================================================================
===============================================================================================
skdconfig中直接使用COM7作为串口号即可解决通信问题,设置如下图:
按照上面的设置更新menuconfig后,
eclipse IDE界面通信成功,输出如下:
including D:/15.Esp32Projects/esp/esp-idf/components/bootloader_support/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/coap/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/esp32/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/mbedtls/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/nghttp/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/partition_table/Makefile.projbuild... including D:/15.Esp32Projects/esp/esp-idf/components/ulp/Makefile.projbuild... Erasing entire flash... python D:/15.Esp32Projects/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "COM7" --baud 115200 --before "default_reset" --after "hard_reset" erase_flash esptool.py v2.5.0 Serial port COM7 Connecting...... Chip is ESP32D0WDQ6 (revision 0) Features: WiFi, BT, Dual Core MAC: 24:0a:c4:04:94:f8 Uploading stub... Running stub... Stub running... Erasing flash (this may take a while)... Chip erase completed successfully in 2.7s Hard resetting via RTS pin... 16:24:14 Build Finished. 0 errors, 0 warnings. (took 9s.197ms)
31253@LAPTOP-31253 MINGW32 ~/esp/app $ make erase_flash Erasing entire flash... esptool.py v2.5.0 Serial port COM7 Connecting.... Chip is ESP32D0WDQ6 (revision 0) Features: WiFi, BT, Dual Core MAC: 24:0a:c4:04:94:f8 Uploading stub... Running stub... Stub running... Erasing flash (this may take a while)... Chip erase completed successfully in 0.8s Hard resetting via RTS pin...
工具版本信息如下:
msys32打包工具链:
esp32_win32_msys2_environment_and_toolchain-20181001
esp-idf版本3.1
MINGW32版本:
GNU bash,版本 4.4.19(3)-release (i686-pc-msys)
eclipse IDE版本: