Go Down

Topic: Using Arduino as ISP to burn Blink to atmega328pu chip - Help! (Read 566 times) previous topic - next topic

maglobal

Do you have any inisghts into the error message?

the selected serial port
 does not exist or your board is not connected


The Gammon instructions are well documented and were successful up to burning the bootloader.....but still not resolving the issue.....I cannot upload Blink using Arduino as ISP.

larryd

Read these:
https://www.gammon.com.au/forum/?id=11643   

https://www.gammon.com.au/forum/?id=11633   

What is written on the breadboard controller chip?




Did you upload the ISP sketch to the original Arduino board?
Did you then load the blink sketch in the IDE editor?
Then did you select the proper target for the breadboard controller?
Then did you use the upload using the Arduino ISP programmer?

No technical PMs.
The last thing you did is where you should start looking.

kprims

Quote
Do you have any inisghts into the error message?
kprims@mint ~ $ /home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/bin/avrdude -C/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b19200 -Uflash:w:/tmp/arduino_build_671156/Blink1.ino.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 "/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf"
         User configuration file is "/home/kprims/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         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

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 4238814
         Firmware Version: 20649456.0
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

***********Notice the -carduino in the avrdude command.

Now I change it to -cstk500v1.

kprims@mint ~ $ /home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/bin/avrdude -C/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -Uflash:w:/tmp/arduino_build_671156/Blink1.ino.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 "/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf"
         User configuration file is "/home/kprims/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         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.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as FD
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/tmp/arduino_build_671156/Blink1.ino.hex"
avrdude: writing flash (1080 bytes):

Writing | ################################################## | 100% 1.26s

avrdude: 1080 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_671156/Blink1.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_671156/Blink1.ino.hex:
avrdude: input file /tmp/arduino_build_671156/Blink1.ino.hex contains 1080 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.70s

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

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.

Try changing your command in a terminal something like this. -cstk500v1
Code: [Select]
/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/bin/avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

This is just the first command to set your fuse, but it should give you some different information.

I don't know why your commands are selecting -carduino, because when I burn bootloader or upload using "sketch/Upload Using Programmer" I always get -cstk500v1.

If I select just the upload button, then I get -carduino.

Running:
Linux Mint 18.3
Arduino IDE1.8.5
Boards 1.6.207



maglobal

OK....to maintain sanity...I read and am following the below instruction set. I was able to proceed according to script all the way to the point of loading the ASCII sketch.
´Mr. Gammon's discussion here:
https://www.gammon.com.au/breadboard   ´
Below are the results of the Board Detector and Board Programming (selected U)  sketches as well as the error I get when trying to upload the ASCII sketch.

Board matches the picture...using the Sparkfun FTDI cable.

I am left with what seems to be a basic issue with avrdude....I can´t come up with a lead on how to decipher or trace this error.

Would appreciate the śilver bullet´ or some ´bread crumbs´ to follow.

Thanks for your support!

kprims

Gammon was using the 8MHz Lilypad without a crystal. Are you using the crystal (16MHz) plus the 22pf capacitors?

maglobal

Hi...

Yes I am using the crytal plus the 2 22pf capacitors. I tried the lilypad as well but was unsure of what other settings to use for the Programmer.

Itś hard to tell what is going on during compilation...I had ledś set up on the heartbeat, error and processor action pins previously. Not sure they have much value actually...the error messages are the key.

I am looking into your previous observation....that is interesting...I believe I ran it using the sketch/Upload command but I am going to go back and double check....I am trying to focus on the error messages so your response was well received!


I don't know why your commands are selecting -carduino, because when I burn bootloader or upload using "sketch/Upload Using Programmer" I always get -cstk500v1.

Should I revert to the lIlypad? Also...any insights in the FTDI errors?

Thank you!

maglobal

ok  this is a follow up to my previous....I re-created the Blink upload....

uploaded ArduinoISP on the UNO R3....successful.

Changed Programmer to Arduino as ISP and uploaded the Blink sketch.  The results are below....same issue...does not recognize serial port in the end.

I did note the -carduino was selected again from the conf.......just as in the previous. As the error message references

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

Can it be concluded that it is expecting the skt500 programmer? That would be cool to think there is a clue coming from the error message!

I will try to change it as you recommended before and see what results I get....

Note...I also tried this using FTDI cable per the Gammon site....not successful either...

Arduino IDE 1.8.6

RPI3  Linux 9 Jessie


MartynC


Budvar10

...
I don't know why your commands are selecting -carduino, because when I burn bootloader or upload using "sketch/Upload Using Programmer" I always get -cstk500v1
...
The only difference is that the avrdude -cArduino produces the reset pulse on DTR and RTS at the beginning for starting the bootloader. The stk500v1 is without the reset. In case of Arduino as ISP, we do not want the reset pulse because it will reset the programmer (the reset of target is provided by Arduino ISP sketch). So, the stk500v1 should be used, or to strongly tie the reset pin on Arduino as ISP to high level (strong pull-up - e.g. big capacitor between RESET and GND) for passing over the reset pulse if -cArduino switch is used.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

maglobal

Progress - following Kprims and Budvar10 - using command line to try to upload.

Here is the command and results I get.....everything seems to be falling into place....but I am not familar enough with avrdude commandline options....you can see my command falls apart at the end...not sure how to separate the last w:0xFF:m from the write Blink directory....tried :w, :m, 

Looking for tutorial for avrdude...but would appreciate a boost or hint! ...Thanks

maglobal@clifton:~ $ avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/bin/avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m:/tmp/arduino_build_477991/Blink.ino.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 "/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/maglobal/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         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.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as FD
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDE"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDE:
avrdude: load data hfuse data from input file 0xDE:
avrdude: input file 0xDE contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF:m:/tmp/arduino_build_477991/Blink.ino.hex"
avrdude: can't open input file 0xFF:m:/tmp/arduino_build_477991/Blink.ino.hex: No such file or directory
avrdude: read from file '0xFF:m:/tmp/arduino_build_477991/Blink.ino.hex' failed

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.


kprims

Try this. Just for the command line. I am assuming you are using Arduino as ISP.

Code: [Select]
avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/bin/avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m -Uflash:w:/tmp/arduino_build_477991/Blink.ino.hex:i

At this point you should be able to use the Arduino IDE and just select Arduino as ISP and the correct Port then select burn bootloader. You should get a successful burn. Then without changing anything and using the Blink sketch , Select/ Sketch/Upload using Programmer should load the Blink Sketch and also wipe out the bootloader which would need to be burned again if you want to use the FTDI cable.

Budvar10

...not sure how to separate the last w:0xFF:m from the write Blink directory....tried :w, :m,  
Hex file has to be passed as separate parameter:
Code: [Select]
-Uflash:w:/tmp/arduino_build_477991/Blink.ino.hex:i

See the averdude UG: -U memtype :op :filename [:format ]
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

maglobal

OK....some success...I think!

1. SUCCESS uploaded ArduinoISP sketch unto UNO via ttyACM0 and Arduino IDE ArduinoISP programmer. straight forward.
2. FAIL using the Arduino IDE...set Programmer to Arduino as ISP. Uploaded Blink from Sketch/Upload using Programmer. No success...looking at error...programmer set to .carduino (I have a 10Kohm resisitor on the reset pin 1).

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

3. SUCCESS got the location of the /tmp/blink.ino.hex file and uploaded uploaded Blink to the target chip via the commandline.

maglobal@clifton:~ $ avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/bin/avrdude -C/opt/arduino_1_8/arduino-nightly/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m -Uflash:w:/tmp/arduino_build_477991/Blink.ino.hex:i


Removed all wires from target bb and UNO...connected battery pak....BLINK runs.


4. Next I will try to bypass the UNO altogether and upload Blink via commandline using FTDI Basic board from Sparkfun and if not successful will try the usb/FTDI cable.

5. Next I will try to upload another sketch. Using both the UNO method and the FTDI method.

6. Working with avrdude at the command line has been a great learning approach....that said...I am not confident that I am on the right path...don´t understand why I can´t use the Arduino IDE and the UNO as the Arduino as ISP and the ttyACM0 serial port to burn the sketch.

7. can I add the stk500v1 Programmer to the pull down options...(hmmm...just thought of that...will have to pursue).

Kprims - I don´t understand your directions...I had previously burned the target chip with the UNO bootloader via the Gammon sketch. Once I ran the commandliine...I followed this and the Arduino IDE seemed disconnected as detailed above - would you mind clairfying this for me? My head may be twisted !


  At this point you should be able to use the Arduino IDE and just select Arduino as ISP and the correct Port then select burn bootloader. You should get a successful burn. Then without changing anything and using the Blink sketch , Select/ Sketch/Upload using Programmer should load the Blink Sketch and also wipe out the bootloader which would need to be burned again if you want to use the FTDI cable.

Budvar - thank you for the avrdude bread crumbs and code! working at the commandline level is a great...if not a bit painful...way to learn!


More crumbs welcome!



hansibull

Now that you're up and running you should definitely check out MiniCore. It gives you more options (if you want them) than the default UNO or NANO option, like if you want to use the internal 8 MHz oscillator instead if the external 16 MHz one you're hassling with right now, or if you want to ditch the bootloader completely in order to be able to use the entire flash memory for your application.

Oh, and if you're into Ebay you can pin compatible variants like the ATmega8 for ridiculously little money (also supported by MiniCore). These are great if your application don't need 32kB flash or 2kB RAM ;)
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

kprims

Quote
2. FAIL using the Arduino IDE...set Programmer to Arduino as ISP. Uploaded Blink from Sketch/Upload using Programmer. No success...looking at error...programmer set to .carduino (I have a 10Kohm resisitor on the reset pin 1).

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14
I wonder if someone else will just try this.

Grab the blink sketch and set programmer to Arduino as ISP. Uno  plugged in and correct Port selected. Sketch/Upload Using Programmer. Then check the command and see if it is using -carduino or -cstk500v1.

Mine is using -cstk500v1 on IDE1.8.5.
Downloaded Linux 64 bit IDE1.8.6 Hourly 2018/07/11 05:25  and now I get -carduino and the 10uF Cap works.

Quote
Kprims - I don´t understand your directions...I had previously burned the target chip with the UNO bootloader via the Gammon sketch. Once I ran the commandliine...I followed this and the Arduino IDE seemed disconnected as detailed above - would you mind clairfying this for me? My head may be twisted !


 " At this point you should be able to use the Arduino IDE and just select Arduino as ISP and the correct Port then select burn bootloader. You should get a successful burn. Then without changing anything and using the Blink sketch , Select/ Sketch/Upload using Programmer should load the Blink Sketch and also wipe out the bootloader which would need to be burned again if you want to use the FTDI cable."
I forgot, that you are getting *-arduino* on your command when you do Sketch/Upload using Programmer. You might want to try a 10uF capacitor between Reset and Gnd on the Uno used as Arduino as ISP. I can confirm the capacitor works when I use the command line and -carduino with the capacitor with the stripe towards GND just like @Budvar10 said.







Go Up