2019年7月2日 星期二

關於 Arduino Web Editor 無法上傳問題 (not in sync)

上週買的 ESP32-CAM 開發板經我上網研究, 發現目前還沒有 MicroPython 的範例程式碼釋出, 因此得先用 Arduino IDE 去開發. 但我這台 Acer Swift5 今年初買來至今尚未做過 Arduino 實驗, 故需下載 Arduino IDE 才行. 但到官網卻赫然發現 Arduino 居然已經有雲端線上版本, 好處是不需下載永遠是最新版, 那就先註冊個帳號吧!

# Sign up an Arduino account




使用 email 註冊後收信, 按信中的確認連結完成註冊即可 :





接著在 Aduino 官網首頁右上角按 Sign in 登入帳號後, 點選 Software/Online Tools 再按左上角的 Arduino Web Editor  :






這時會出現下載 Arduino plugin 提示訊息, 點選超連結下載 plugin 後執行 Arduino create agent :




這樣就可以將 Arduino 板子連接 USB 埠開始使用了. 先選擇板子與 COM 埠, 我使用的是 Nano 與 COM7 :





然後從左邊 Example/Basics 選取 Blinks 範例, 再按向右鍵 (Upload) 上傳程式 :




但是, 過了很久還是一直顯示 Busy, 最後底下的訊息視窗顯示如下 "not in sync" 的錯誤訊息 :

/home/builder/opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware /home/builder/opt/arduino-builder/hardware -hardware /home/builder/.arduino15/packages -tools /home/builder/opt/arduino-builder/tools -tools /home/builder/.arduino15/packages -built-in-libraries /home/builder/opt/libraries/latest -logger humantags -fqbn arduino:avr:nano:cpu=atmega328 -build-cache /tmp -build-path /tmp/701031103/build -verbose -prefs runtime.tools.arduinoOTA.path=/home/builder/.arduino15/packages/arduino/tools/arduinoOTA/1.2.1 -prefs runtime.tools.arm-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-linux-gcc/4.9.3 -prefs runtime.tools.arm-none-eabi-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4 -prefs runtime.tools.arc-elf32.path=/home/builder/.arduino15/packages/Intel/tools/arc-elf32/1.6.9+1.0.1 -prefs runtime.tools.arduino101load.path=/home/builder/.arduino15/packages/Intel/tools/arduino101load/2.0.1 -prefs runtime.tools.i586-poky-linux-uclibc.path=/home/builder/.arduino15/packages/Intel/tools/i586-poky-linux-uclibc/1.6.2+1.0 -prefs runtime.tools.openocd.path=/home/builder/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7 -prefs runtime.tools.dfu-util.path=/home/builder/.arduino15/packages/arduino/tools/dfu-util/0.9.0-arduino1 -prefs runtime.tools.CMSIS-Atmel.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0 -prefs runtime.tools.bossac.path=/home/builder/.arduino15/packages/arduino/tools/bossac/1.7.0 -prefs runtime.tools.sketchUploader.path=/home/builder/.arduino15/packages/Intel/tools/sketchUploader/1.6.2+1.0 -prefs runtime.tools.CMSIS.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS/4.5.0 -prefs runtime.tools.x86-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/x86-linux-gcc/7.2.0 -prefs runtime.tools.linuxuploader.path=/home/builder/.arduino15/packages/arduino/tools/linuxuploader/1.5.1 -prefs runtime.tools.flashpack.path=/home/builder/.arduino15/packages/Intel/tools/flashpack/2.0.0 -prefs runtime.tools.avrdude.path=/home/builder/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14 -prefs runtime.tools.nrf5x-cl-tools.path=/home/builder/.arduino15/packages/arduino/tools/nrf5x-cl-tools/9.3.1 -prefs runtime.tools.avr-gcc.path=/home/builder/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 -prefs runtime.tools.core2-32-poky-linux.path=/home/builder/.arduino15/packages/Intel/tools/core2-32-poky-linux/1.6.2+1.0 -libraries /tmp/701031103/custom -libraries /tmp/701031103/pinned /tmp/701031103/Blink
Sketch uses 930 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
Programming with: Serial
Flashing with command:C:/Users/User/.arduino-create/arduino/avrdude/6.3.0-arduino14/bin/avrdude.exe -CC:/Users/User/.arduino-create/arduino/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -PCOM9 -b115200 -D -Uflash:w:C:/Users/User/AppData/Local/Temp/arduino-create-agent194799784/Blink.hex:i
avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:/Users/User/.arduino-create/arduino/avrdude/6.3.0-arduino14/etc/avrdude.conf"
Using Port : COM9
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x46
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x46
avrdude done. Thank you.

查詢網路有人說電腦重開機即可, 但我試過那不管用. 我用下載下來的 Arduino IDE 上傳就可以順利上傳.

後來在 Stack overflow 下面這篇的第 13 個回應找到解答, 原來我這塊 Nano 的 MPU 比較舊, 要選 "Atmega328P (Old Bootloader)" :

“avrdude: stk500_getsync(): not in sync: resp=0x00,” aka Some Dude Named Avr Won't Let Me Upload My Program

"Change Tools->Processor->Atmega 328P to Atmega 328P (Old Bootloader). Remind that the Processor option is only available when you select some specific Boards at Tools>Board.
This worked for my Arduino Nano with CH340, using Arduino IDE 1.8.5 under Linux Ubuntu 17.10. Besides, this will probably happen if you use IDE 1.8.9 or newer and you get an old or cloned Nano."

我更改板子為 Atmega328P (Old Bootloader) 後就解決上傳問題了 :




上傳成功的訊息如下 :

/home/builder/opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware /home/builder/opt/arduino-builder/hardware -hardware /home/builder/.arduino15/packages -tools /home/builder/opt/arduino-builder/tools -tools /home/builder/.arduino15/packages -built-in-libraries /home/builder/opt/libraries/latest -logger humantags -fqbn arduino:avr:nano:cpu=atmega328old -build-cache /tmp -build-path /tmp/690911048/build -verbose -prefs runtime.tools.arm-none-eabi-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4 -prefs runtime.tools.avr-gcc.path=/home/builder/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 -prefs runtime.tools.openocd.path=/home/builder/.arduino15/packages/Intel/tools/openocd/0.9.0+0.1 -prefs runtime.tools.x86-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/x86-linux-gcc/7.2.0 -prefs runtime.tools.arm-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-linux-gcc/4.9.3 -prefs runtime.tools.arc-elf32.path=/home/builder/.arduino15/packages/Intel/tools/arc-elf32/1.6.9+1.0.1 -prefs runtime.tools.arduinoOTA.path=/home/builder/.arduino15/packages/arduino/tools/arduinoOTA/1.2.1 -prefs runtime.tools.nrf5x-cl-tools.path=/home/builder/.arduino15/packages/arduino/tools/nrf5x-cl-tools/9.3.1 -prefs runtime.tools.flashpack.path=/home/builder/.arduino15/packages/Intel/tools/flashpack/2.0.0 -prefs runtime.tools.i586-poky-linux-uclibc.path=/home/builder/.arduino15/packages/Intel/tools/i586-poky-linux-uclibc/1.6.2+1.0 -prefs runtime.tools.sketchUploader.path=/home/builder/.arduino15/packages/Intel/tools/sketchUploader/1.6.2+1.0 -prefs runtime.tools.CMSIS.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS/4.5.0 -prefs runtime.tools.bossac.path=/home/builder/.arduino15/packages/industruino/tools/bossac/1.7.0-industruino -prefs runtime.tools.dfu-util.path=/home/builder/.arduino15/packages/arduino/tools/dfu-util/0.9.0-arduino1 -prefs runtime.tools.avrdude.path=/home/builder/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14 -prefs runtime.tools.arduino101load.path=/home/builder/.arduino15/packages/Intel/tools/arduino101load/2.0.1 -prefs runtime.tools.core2-32-poky-linux.path=/home/builder/.arduino15/packages/Intel/tools/core2-32-poky-linux/1.6.2+1.0 -prefs runtime.tools.CMSIS-Atmel.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0 -prefs runtime.tools.linuxuploader.path=/home/builder/.arduino15/packages/arduino/tools/linuxuploader/1.5.1 -libraries /tmp/690911048/custom -libraries /tmp/690911048/pinned /tmp/690911048/Blink
Sketch uses 930 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
Programming with: Serial
Flashing with command:C:/Users/User/.arduino-create/arduino/avrdude/6.3.0-arduino14/bin/avrdude.exe -CC:/Users/User/.arduino-create/arduino/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -PCOM9 -b57600 -D -Uflash:w:C:/Users/User/AppData/Local/Temp/arduino-create-agent680988764/Blink.hex:i
avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:/Users/User/.arduino-create/arduino/avrdude/6.3.0-arduino14/etc/avrdude.conf"
Using Port : COM9
Using Programmer : arduino
Overriding Baud Rate : 57600  (較低的速率才可以)
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.16
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "C:/Users/User/AppData/Local/Temp/arduino-create-agent680988764/Blink.hex"
avrdude: writing flash (930 bytes):
Writing | ################################################## | 100% 0.29s
avrdude: 930 bytes of flash written
avrdude: verifying flash memory against C:/Users/User/AppData/Local/Temp/arduino-create-agent680988764/Blink.hex:
avrdude: load data flash data from input file C:/Users/User/AppData/Local/Temp/arduino-create-agent680988764/Blink.hex:
avrdude: input file C:/Users/User/AppData/Local/Temp/arduino-create-agent680988764/Blink.hex contains 930 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.22s
avrdude: verifying ...
avrdude: 930 bytes of flash verified
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.

可見使用較低的 baud rate 傳送就能 sync 而上傳成功了.

沒有留言:

張貼留言