环境运维

idf.py flash 烧录失败解决

 

esptool.py --chip esp32 -p /dev/cu.usbmodem562B0116711 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x1000 bootloader/bootloader.bin 0x10000 hello_world.bin 0x8000 partition_table/partition-table.bin

esptool.py vv4.8.dev1

Serial port /dev/cu.usbmodem562B0116711

Connecting.....

Chip is ESP32-D0WD-V3 (revision v3.0)

Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None

Crystal is 40MHz

MAC: c0:49:ef:68:47:48

Uploading stub...

 

Note: If issues persist, try installing the WCH USB-to-Serial MacOS driver.

 

A fatal error occurred: Failed to write to target RAM (result was 01070000: Operation timed out)

CMake Error at run_serial_tool.cmake:66 (message):

  

  /Users/wangyuqiang/.espressif/python_env/idf4.3_py3.9_env/bin/python;;/Users/wangyuqiang/esp/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32

  failed.

 

 

 

make[3]: *** [CMakeFiles/flash] Error 1

make[2]: *** [CMakeFiles/flash.dir/all] Error 2

make[1]: *** [CMakeFiles/flash.dir/rule] Error 2

make: *** [flash] Error 2

make failed with exit code 2, output of the command is in the /Users/wangyuqiang/esp/hello_world/build/log/idf_py_stderr_output_16692 and /Users/wangyuqiang/esp/hello_world/build/log/idf_py_stdout_output_16692

 

出现以上错误是因为 usb转串口的驱动未安装

https://www.wch.cn/downloads/CH34XSER_MAC_ZIP.html 通过该网址下载驱动安装包

 

再次执行idf.py flash

烧录成功

[100%] Built target __idf_main

[100%] Built target __ldgen_output_sections.ld

[100%] Built target hello_world.elf

[100%] Built target gen_project_binary

hello_world.bin binary size 0x2b8d0 bytes. Smallest app partition is 0x100000 bytes. 0xd4730 bytes (83%) free.

[100%] Built target app_check_size

[100%] Built target app

esptool.py --chip esp32 -p /dev/cu.wchusbserial562B0116711 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x1000 bootloader/bootloader.bin 0x10000 hello_world.bin 0x8000 partition_table/partition-table.bin

esptool.py vv4.8.dev1

Serial port /dev/cu.wchusbserial562B0116711

Connecting.....

Chip is ESP32-D0WD-V3 (revision v3.0)

Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None

Crystal is 40MHz

MAC: c0:49:ef:68:47:48

Uploading stub...

Running stub...

Stub running...

Changing baud rate to 460800

Changed.

Configuring flash size...

Flash will be erased from 0x00001000 to 0x00007fff...

Flash will be erased from 0x00010000 to 0x0003bfff...

Flash will be erased from 0x00008000 to 0x00008fff...

Compressed 26736 bytes to 16374...

Writing at 0x00001000... (100 %)

Wrote 26736 bytes (16374 compressed) at 0x00001000 in 0.7 seconds (effective 323.6 kbit/s)...

Hash of data verified.

Compressed 178384 bytes to 95592...

Writing at 0x000360d6... (100 %)

Wrote 178384 bytes (95592 compressed) at 0x00010000 in 2.5 seconds (effective 571.8 kbit/s)...

Hash of data verified.

Compressed 3072 bytes to 103...

Writing at 0x00008000... (100 %)

Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 506.2 kbit/s)...

Hash of data verified.

 

Leaving...

Hard resetting via RTS pin...

[100%] Built target flash

Done

=====================================这是分割线======================================

以下是遇到相同问题的网友

https://swf.com.tw/?p=1848

ESP32和ESP8266開發板大都採用CH340這個USB轉TTL訊號的序列通訊IC,Windows系統會自動上網搜尋並安裝USB裝置的驅動程式,macOS需要手動安裝。macOS版的CH340驅動程式可在晶片開發商(南京沁恒微电子公司)的這個網頁下載。

安裝CH340驅動程式

底下是在macOS Ventura系統安裝驅動程式的過程:

CH340驅動程式

按下「繼續」後,系統會出現這樣的訊息:

阻擋系統延伸功能

按下「好」,再點擊底下畫面中的“Install”鈕,開始安裝驅動程式。

安章驅動程式

安裝過程會出現另一個訊息,請點擊『打開「系統設定」』:

阻擋系統延伸功能

在「隱私權與安全性」設定畫面中,點擊「允許」此驅動程式的按鈕。

隱私權與安全性

這樣就安裝完成了。

安裝完成

把ESP32或ESP8266開發板接上Mac,然後開啟終端機,輸入底下的命令列舉tty.wch開頭的所有序列通訊裝置試試:

ls  /dev/tty.wch*

應該會顯示一個“/dev/tty.wchusbserial○○○”裝置,代表驅動程式安裝並啟用成功。

終端機

實際連接Arduino IDE也沒問題,這是IDE 2.0的序列埠監控視窗面板,按右下角的圖示,可開啟或收合面板。

序列埠監控視窗

用MacBook Air接Arduino開發板的小小問題

MacBook Air只有兩個USB Type-C插槽,但多數開發板仍採用Micro USB介面,轉接線也多是Type-A型式,連接Mac時,我通常都是用下圖這種附帶HDMI介面的Type-C轉接器,簡潔的MacBook周遭馬上變得紊亂。此外,MacBook Air的兩個Type-C都集中在左側,而我的桌上型顯示器和電源插孔都在右側,所以接線都得繞到另一邊。

MacBook Air接Type-C轉接器

某些PC廠商的輕薄型筆電也只有兩個Type-C,但是分別位於機體兩側,像Dell的XPS 13,更方便使用,但是對硬體DIY來說,最實用的還是具備USB Type-A、Type-C、HDMI、有線網路⋯⋯等多種介面的電腦。

有一種專爲MacBook設計的Type-C轉接/集線器,可無縫插接在MacBook外殼側邊,但上面這種帶線的「通用型」款式,也可連接任天堂Switch和其他手機平板。

為了方便插拔開發板的USB接線,我採用具備磁吸式轉接頭的USB線材:

磁吸式轉接頭的USB線材

某次實驗時,插拔USB的次數較為頻繁,我已經斷開板子和電腦的USB連線,Arduino IDE仍呈現「連線」狀態;接回USB,IDE卻無法和開發板連線。原本以為是Type-C集線器或者USB線材的問題,換了USB線並直連MacBook、重新啟動電腦,操作一陣子之後,問題依舊且會無故斷線⋯⋯也許是驅動程式的bug。