解决Arduino Uno: AVRDude STK500_Recv():程序员无响应

背景

用arduino uno板子在做BLDC电机调试时,不小心电流过大,把主芯片atmel328给烧了,网上购买了新的芯片换上,下载过程中一直报错:avrdude: stk500_recv(): programmer is not responding。

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         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=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x2f
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x2f

avrdude done.  Thank you.

Problem uploading to board.  See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.

原因分析

avrdude是一款下载/上传/烧录AVR单片机ROM、EEPROM的工具软件,采用ISP(in-system progrmming)方式。类似于STM32系列的烧录软件STM32Programmer,烧录过程中需要用到reset复位。

ArduinoIDE在编译完成后,会自动调用avrdude来下载程序,首先需要通过串口连接arduino硬件并读取硬件信息,然后读取编译好的.hex文件,接着写入.hex文件,最后校验写入数据。具体过程如下:

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         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: 3
         Firmware Version: 5.0
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\49196\AppData\Local\Temp\arduino_build_959754/Blink.ino.hex"
avrdude: writing flash (1198 bytes):

Writing | ################################################## | 100% 0.23s

avrdude: 1198 bytes of flash written
avrdude: verifying flash memory against C:\Users\49196\AppData\Local\Temp\arduino_build_959754/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\49196\AppData\Local\Temp\arduino_build_959754/Blink.ino.hex:
avrdude: input file C:\Users\49196\AppData\Local\Temp\arduino_build_959754/Blink.ino.hex contains 1198 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.15s

avrdude: verifying ...
avrdude: 1198 bytes of flash verified

avrdude done.  Thank you.

报错报错:avrdude: stk500_recv(): programmer is not responding。说明avrdude通过串口连接arduino板子时出了问题。最常见的问题是数字脚0/1(也就是RX、TX)上面插了东西,串口被其它外设占用了,直接拔掉就可以了。具体可以参考arduino报错:

但是尝试过了没有解决问题。于是尝试了以下几种方法,记录如下:

  1. 我手头有两款arduino uno板子,分别交互MCU,发现交换了后可以正常烧录,说明不是MCU芯片的问题,内部的BootLoader应该是没有问题的。排查ch340串口芯片
  2. 交互两个arduino uno板子上的串口芯片ch340,问题一样,好的板子仍然是好的,坏的板子依然报错,说明ch340芯片是好的。问题出在电路板上,最可能是串口芯片ch340的外围电路问题,导致无法通信。
  3. 用单独的CH340USB转串口板连接arduino uno的Rx、TX,注意:还需要连接reset复位引脚,在下载过程中需要对MCU进行复位,把原理arduino uno的串口CH340芯片更换到usb转串口板上,连线测试可以正常烧录,确定是ch340外围电路问题。


4. 两块arduino uno板子对比测试:
– 上电测试ch340外围引脚电压,所有电压都相同
– ch340晶振:频率都是12MHz,幅度4V,都正常
– 测试外围电阻值都正确,测试外围电容无短路。

5. 最后剩下两种可能:

  • ch340外围电容损坏(没有可靠设备测试),更换所有电容再次测试,问题依然存在
  • arduino uno的PCB板子出现问题:单独测试所有连接正常
  • 目前能想到的方法都测试过了,问题依然存在。已经超出我的目前认知水平,以后认知提升了,有了新的想法再次测试。

    经验总结

    1. MCU(包括STM32、atmel、c51等)下载、烧录的方式有三种:专用的烧录口(STM32的SWD、atmel的ICSP)、串口烧录
    2. 使用ArduinoIDE+串口下载时,MCU内部需要先下载好BootLoader
    3. MCU下载烧录过程中需要RESET引脚对MCU进行复位操作
    物联沃分享整理
    物联沃-IOTWORD物联网 » 解决Arduino Uno: AVRDude STK500_Recv():程序员无响应

    发表评论