如何修复 - 无法在 Esp32 中打开端口 '/dev/cu.SLAB_USBtoUART'

How to fix - could not open port '/dev/cu.SLAB_USBtoUART' in Esp32

我正在尝试使用 Platform.io 将我的 Esp32 项目上传到 ESPWROOM32。

我尝试使用 Arduino 上传一个简单的代码并成功上传,这意味着问题不是电缆或电路板。

但是当我切换到 Platform.io 并尝试上传时,出现了这个问题。

Uploading .pio\build\esp32doit-devkit-v1\firmware.bin
esptool.py v3.0
Serial port /dev/cu.SLAB_USBtoUART
Traceback (most recent call last):
  File "C:\Users\bbbb\.platformio\packages\tool-esptoolpy\esptool.py", line 3969, in <module>
    _main()
  File "C:\Users\bbbb\.platformio\packages\tool-esptoolpy\esptool.py", line 3962, in _main
    main()
  File "C:\Users\bbbb\.platformio\packages\tool-esptoolpy\esptool.py", line 3551, in main
    esp = chip_class(each_port, initial_baud, args.trace)
  File "C:\Users\bbbb\.platformio\packages\tool-esptoolpy\esptool.py", line 271, in __init__
    self._port = serial.serial_for_url(port)
  File "c:\users\bbbb\.platformio\penv\lib\site-packages\serial\__init__.py", line 90, in serial_for_url
    instance.open()
  File "c:\users\bbbb\.platformio\penv\lib\site-packages\serial\serialwin32.py", line 64, in open
    raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port '/dev/cu.SLAB_USBtoUART': FileNotFoundError(2, 'The system cannot find the path specified.', None, 3)

在您的 platformio.ini 文件中,将 upload_portmonitor_port 设置为 COM ESP32 连接到的端口。例如,

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = COM5
monitor_port = COM5
monitor_speed = 115200