avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] [bug #39526] Why mega 2560 did not work as an ISP


From: Peter Saunderson
Subject: [avrdude-dev] [bug #39526] Why mega 2560 did not work as an ISP
Date: Fri, 19 Jul 2013 13:36:50 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0

URL:
  <http://savannah.nongnu.org/bugs/?39526>

                 Summary: Why mega 2560 did not work as an ISP
                 Project: AVR Downloader/UploaDEr
            Submitted by: peteasa
            Submitted on: Fri 19 Jul 2013 13:36:49 GMT
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Peter Saunderson
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I have tested out this fix for a number of weeks now and it is simple and
seems to work.  I started a chat discussion at
http://forum.arduino.cc/index.php?topic=174857.0 to get other peoples feedback
and share the fix so that others can try it out.

OBSERVATION:
         Using Port                    : /dev/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 9600
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

DISCUSSION:
The arduino code in avrdude adds a small bit to stk500 code.  The fix is in
arduino code and is sufficient to start the communications and then a small
fix to mega-isp  http://code.google.com/p/mega-isp/ enables full operation. 
The reason for the failure is that for example the mega2560 board resets when
USB serial is established. avrdude does not wait but attempts to start
communication whilst mega2560 is in reset so the communication is never
established.  With the bug fix avrdude allows mega2560 time reboot but still
because avrdude sends multiple start frames mega-isp tries to respond to all
the start messages and again once the communication is established mega-isp
now fails to send the correct responses to avrdude.  Best solution would be to
modify stk500 code and mega-isp with the proper (three way) handshake to
guarentee startup, however since stk500 obviously works the quick fix is to
delay the start of avrdude:
  /* Set DTR and RTS back to high */
  serial_set_dtr_rts(&pgm->fd, 1);

  /* Sleep to allow the Arduino board to reset */
  usleep(1000*1000);

  /*
   * drain any extraneous input
   */

The fix required in mega-isp is to discard all inbound messages and only
respond to one of the three signon attempts:

  uint8_t ch = getch();
  switch (ch) {
  case '0': // signon
    error = 0;
    if (getch() == CRC_EOP) {
      // empty the input stream
      while (0<Serial.available()) getch();
      Serial.print((char)STK_INSYNC);
      Serial.print((char)STK_OK);
    } else {
        error++;
        Serial.print((char)STK_NOSYNC);
    }
    break;

With these two fixes in place I have been able to use the mega2560 board
without any modifications as an in circuit programmer for ATmega644PA chip.

Patch files are attached
Command line used was
avrdude -b 9600 -c arduino -p m644p -t -vvvv -P /dev/ttyACM0





    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 19 Jul 2013 13:36:49 GMT  Name: arduino.c.patch  Size: 400B   By:
peteasa
patches that fix the communication issue
<http://savannah.nongnu.org/bugs/download.php?file_id=28614>
-------------------------------------------------------
Date: Fri 19 Jul 2013 13:36:49 GMT  Name: ArduinoISP.ino.patch  Size: 548B  
By: peteasa
patches that fix the communication issue
<http://savannah.nongnu.org/bugs/download.php?file_id=28615>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?39526>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]