Sketch upload fails with raspberry pi [solved]

Started by cyrus007, July 04, 2014, 03:59:26 PM

cyrus007

Have been trying to upload the GarageMote & GarageMote_base sketches but have been unsuccessful so far. I am using raspbian build with gpio version of avrdude (v5.10) with the autoreset wrapper (from https://github.com/deanmao/avrdude-rpi ) and here is the result:
pi@raspberrypi ~/HEXs $ sudo avrdude-autoreset -p m328p -c gpio -P gpio -v -U flash:w:GarageMote_base.cpp.hex:i

avrdude-original: Version 5.10, compiled on Jun 18 2012 at 12:38:29
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2009 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : gpio
                  Using Programmer              : gpio
                  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     5     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 : GPIO
                  Description     : Use sysfs interface to bitbang GPIO lines

avrdude-original: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.12s

avrdude-original: Device signature = 0x1e950f
avrdude-original: safemode: lfuse reads as DE
avrdude-original: safemode: hfuse reads as DC
avrdude-original: safemode: efuse reads as 5
avrdude-original: NOTE: FLASH memory has been specified, an erase cycle will be performed
                  To disable this feature, specify the -D option.
avrdude-original: erasing chip
avrdude-original: reading input file "GarageMote_base.cpp.hex"
avrdude-original: writing flash (8440 bytes):

Writing | ################################################## | 100% 337.42s

avrdude-original: 8440 bytes of flash written
avrdude-original: verifying flash memory against GarageMote_base.cpp.hex:
avrdude-original: load data flash data from input file GarageMote_base.cpp.hex:
avrdude-original: input file GarageMote_base.cpp.hex contains 8440 bytes
avrdude-original: reading on-chip flash data:

Reading | ################################################## | 100% 334.73s

avrdude-original: verifying ...
avrdude-original: 8440 bytes of flash verified

avrdude-original: safemode: lfuse reads as DE
avrdude-original: safemode: hfuse reads as DC
avrdude-original: safemode: efuse reads as 5
avrdude-original: safemode: Fuses OK

avrdude-original done.  Thank you.

done with autoreset
pi@raspberrypi ~/HEXs $


Still after this, the moteino does not work, no LED indicator nor any output in serial link.

Note that I read somewhere that efuse = 0x05 is same as 0xFD  (www.engbedded.com/fusecalc)

What could be wrong ?

cyrus007

Needed to change the autoreset code a little bit to align with my pin assignment.

Was:
GPIO.setmode(GPIO.BOARD)

To:
GPIO.setmode(GPIO.BCM)
...
pin = 7


And with new pristine moteino ...here is the result.
pi@raspberrypi ~/HEXs $ sudo avrdude-autoreset -v -p m328p -c arduino -b 115200 -P /dev/ttyAMA0 -U flash:w:GarageMote.hex:i

avrdude-original: Version 5.10, compiled on Jun 18 2012 at 12:38:29
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2009 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 115200
done with autoreset
avrdude-original: stk500_getsync(): not in sync: resp=0x20
pi@raspberrypi ~/HEXs $

Still unsuccessful.

Felix

The only thing I can think of is a corrupt hex file. Once the bootloader is finished flashing, it should jump to the program section. If that is bad it can stall like you're reporting.

cyrus007

Thanks Felix. Finally solved it by using codebender.cc tool. It seems the various Arduino configurations on my Ubuntu64 and RPi are faulty.

Using gpio with SPI overwrites bootloader so I had to start from scratch. Downloaded the DualOptiboot hex file, burnt bootloader and then used codebender.cc to flash the chip. Work fine now.

Felix