Arduino Forum

Using Arduino => Avrdude, stk500, Bootloader issues => Topic started by: samyoue on Feb 23, 2019, 07:07 pm

Title: issue uploading to breadboard ATMEGA4809 via uno
Post by: samyoue on Feb 23, 2019, 07:07 pm
Hi,

I'm trying to build my first arduino from components on a breadboard (First time building arduino on a breadboard, figured I'd start easy by using a 4809 ::) ).
I have the ATMEGA4809 chip on my breadboard via a tqfp adapter and attached all necessary basic elements such as 16mhz clock and capacitors, power etc.

I have an uno R3 board hooked up via mosi/miso/sclk/d10 to mosi/miso/sclk/reset and uploaded the ISP sketch to the uno.

I've downloaded the 'megaAVR boards' into the board manager and have selected the arduino uno wifi as my board with the 'Registers emulation:' option set to 'None (ATMEGA4809)'

I have my uno connected via usb and 4809 breadboard connected via dupont wires as mentioned above

I have selected 'arduino as ISP' in 'Programmer:' option

However when I click burn bootloader it comes up with:
Code: [Select]
Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "Arduino Uno WiFi Rev2, None (ATMEGA4809)"

Please select a programmer from Tools->Programmer menu

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


before I downloaded the 'megaAVR boards' I was getting 'invalid device signature' error (ie. further than I am now that I have the correct board definition...  :smiley-eek: )

any help greatly appreciated

Sam

EDIT:
Ive tried a few times using 'arduino Uno' as my board (ie. that of the ISP not the target) and I've got error device signature invalid 0xFFFFFF, but also have got the following:
Code: [Select]
Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14/bin/avrdude -CC:\Users\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -PCOM8 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

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\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf"

         Using Port                    : COM8
         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
         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

Error while burning bootloader.
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x00007f
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
and also received device signatures of ff0000, 0000ff as well, not sure if its relevant or not...
Title: Re: issue burning bootloader to breadboard ATMEGA4809 via uno
Post by: Juraj on Feb 23, 2019, 07:53 pm
you are funny. 4809 doesn't use ISP for programming and doesn't use a bootloader.
it uses UPDI.
Title: Re: issue burning bootloader to breadboard ATMEGA4809 via uno
Post by: westfw on Feb 23, 2019, 10:11 pm
4809 COULD use a bootloader, but the Uno WiFi 2 Arduino board that has a 4809 doesn't use one (it has an on-board programmer instead), and thus Arduino doesn't have one.

It's on the Optiboot "issues" list, but ... it's complicated.  One of the major changes in the 4809 chip is the way the bootloader works :-(
Title: Re: issue burning bootloader to breadboard ATMEGA4809 via uno
Post by: samyoue on Feb 25, 2019, 12:25 am
OK didn't realise that (like I said, first voyage into this...). That explains my problems thank you.

After some research, I believe I can use my Uno to program my 4809 by using this (https://github.com/ElTangas/jtag2updi).

Am I correct in assuming that if I use this method I can upload a sketch to the 4809 through the Uno using "atmel jtagice3 (jtag mode)" in the programmer option of Arduino IDE?

(WARNING: SUPER N00B QUESTION!) if there is no bootloader on the 4809, would the sketch auto run on powerup?

Thanks again guys

Sam
Title: Re: issue burning bootloader to breadboard ATMEGA4809 via uno
Post by: westfw on Feb 25, 2019, 02:15 am
Quote
if there is no bootloader on the 4809, would the sketch auto run on powerup?
Yes.  On the UW2, the programmer chip will have very complete control over the chip, and won't hold up execution unless it's getting explicit "program" or "debug" instructions on the USB port.
On a bare 4809 (well, in both cases, actually), the sketch is the only thing on the chip, and it will start after reset.

Title: Re: issue burning bootloader to breadboard ATMEGA4809 via uno
Post by: samyoue on Feb 26, 2019, 01:51 pm
Thats great thank you, can anyone confirm/correct this for me please?
After some research, I believe I can use my Uno to program my 4809 by using this (https://github.com/ElTangas/jtag2updi).

Am I correct in assuming that if I use this method I can upload a sketch to the 4809 through the Uno using "atmel jtagice3 (jtag mode)" in the programmer option of Arduino IDE?
Thanks again everyone

Sam
Title: Re: issue uploading sketch to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 03, 2019, 01:53 am
OK so I tried it out and experimented and googled and I'm completely at a loss now...
I followed this tutorial
https://github.com/ElTangas/jtag2updi (https://github.com/ElTangas/jtag2updi)
and couldn't get much joy.
Followed this tutorial afterwards:
https://hackaday.io/project/134831-atmega4809-developing-board-project/log/156750-how-to-setup-arduino-ide-full-support-including-binary-upload-for-my-board (https://hackaday.io/project/134831-atmega4809-developing-board-project/log/156750-how-to-setup-arduino-ide-full-support-including-binary-upload-for-my-board)
and managed to finally upload a sketch to my 4809 (via my uno with firmware from 1st tutorial)
if I click upload sketch or upload via programmer (with "onboard atmel..." selected as the programmer) then I get successful uploads to my 4809 according to avrdude
Code: [Select]
Sketch uses 1406 bytes (2%) of program storage space. Maximum is 49152 bytes.
Global variables use 28 bytes (0%) of dynamic memory, leaving 6116 bytes for local variables. Maximum is 6144 bytes.
C:\Users\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14/bin/avrdude -CC:\Users\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf -v -patmega4809 -cjtag2updi -Pcom8 -Uflash:w:C:\Users\CeX\AppData\Local\Temp\arduino_build_617903/BlinkWithoutDelay.ino.hex:i -Ufuses:w:C:\Users\CeX\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.6.25/fuses/fuses_4809.bin:r

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\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf"

         Using Port                    : com8
         Using Programmer              : jtag2updi
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
Serial number:                   00:00:00:00:00:00
Device ID:                       JTAGICE mkII
         AVR Part                      : ATmega4809
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
           fuses          0     0     0    0 no          9    0      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
           usersig        0     0     0    0 no         64   64      0     0     0 0x00 0x00
           flash          0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGMKII_PDI
         Description     : JTAGv2 to UPDI bridge
         M_MCU hardware version: 1
         M_MCU firmware version: 6.00
         S_MCU hardware version: 1
         S_MCU firmware version: 6.00
         Serial number:          00:00:00:00:00:00
         Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: NOTE: Programmer supports page erase for Xmega devices.
         Each page will be erased before programming it, but no chip erase is performed.
         To disable page erases, specify the -D option; for a chip-erase, use the -e option.
avrdude: reading input file "C:\Users\CeX\AppData\Local\Temp\arduino_build_617903/BlinkWithoutDelay.ino.hex"
avrdude: writing flash (1406 bytes):

Writing | ################################################## | 100% 0.42s

avrdude: 1406 bytes of flash written
avrdude: verifying flash memory against C:\Users\CeX\AppData\Local\Temp\arduino_build_617903/BlinkWithoutDelay.ino.hex:
avrdude: load data flash data from input file C:\Users\CeX\AppData\Local\Temp\arduino_build_617903/BlinkWithoutDelay.ino.hex:
avrdude: input file C:\Users\CeX\AppData\Local\Temp\arduino_build_617903/BlinkWithoutDelay.ino.hex contains 1406 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.27s

avrdude: verifying ...
avrdude: 1406 bytes of flash verified
avrdude: reading input file "C:\Users\CeX\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.6.25/fuses/fuses_4809.bin"
avrdude: writing fuses (9 bytes):

Writing | ################################################## | 100% 0.07s

avrdude: 9 bytes of fuses written
avrdude: verifying fuses memory against C:\Users\CeX\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.6.25/fuses/fuses_4809.bin:
avrdude: load data fuses data from input file C:\Users\CeX\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.6.25/fuses/fuses_4809.bin:
avrdude: input file C:\Users\CeX\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.6.25/fuses/fuses_4809.bin contains 9 bytes
avrdude: reading on-chip fuses data:

Reading | ################################################## | 100% 0.05s

avrdude: verifying ...
avrdude: 9 bytes of fuses verified

avrdude done.  Thank you.

and due to this line:
Code: [Select]
avrdude: Device signature = 0x1e9651 (probably m4809)
 it is definitely uploading to the 4809 and not the uno...

yet no blinky blinky :(
Title: Re: issue burning bootloader to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 03, 2019, 01:59 am
I've checked the LED connections etc (if i take the dupont lead connected to the portD0 pin on the 4809 and touch it to the 5v rail, the LED lights up)
I've also tried manual upload of this hex file, https://github.com/szczys/had_AVRtut_2 (https://github.com/szczys/had_AVRtut_2) which is referenced to by this tutorial: https://hackaday.com/2010/10/25/avr-programming-02-the-hardware/ (https://hackaday.com/2010/10/25/avr-programming-02-the-hardware/) by using avrdude directly and I get the same 'result'
Code: [Select]
C:\Users\CeX\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino14\bin> .\avrdude -c jtag2updi -P com8
 -p m4809 -U flash:w:main.hex

avrdude.exe: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude.exe: Device signature = 0x1e9651 (probably m4809)
avrdude.exe: NOTE: Programmer supports page erase for Xmega devices.
             Each page will be erased before programming it, but no chip erase is performed.
             To disable page erases, specify the -D option; for a chip-erase, use the -e option.
avrdude.exe: reading input file "main.hex"
avrdude.exe: input file main.hex auto detected as Intel Hex
avrdude.exe: writing flash (258 bytes):

Writing | ################################################## | 100% 0.37s

avrdude.exe: 258 bytes of flash written
avrdude.exe: verifying flash memory against main.hex:
avrdude.exe: load data flash data from input file main.hex:
avrdude.exe: input file main.hex auto detected as Intel Hex
avrdude.exe: input file main.hex contains 258 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 0.29s

avrdude.exe: verifying ...
avrdude.exe: 258 bytes of flash verified

avrdude.exe done.  Thank you.

 with again no LED activity on the 4809.

Its almost like the 4809 is accepting uploads but not actually executing the program...

Note when using arduino IDE, I also tried changing ledPin to 0 and also 1 to see if it was a pin issue but again nothing.

If I hold the reset button on the 4809 board while uploading the upload fails (which is correct)

I've tried resetting my 4809 afterwards which has no effect

please help me, any pointers/ideas/solutions welcomed

Thanks

Sam

(had to split into 2 posts as exceeded the post length limit)
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: westfw on Mar 03, 2019, 07:17 am
What (chip) pin is your LED connected to, and what (arduino board) pin is your sketch manipulating?
Chances are that they don't match.
Are you using the Uno-WiFi2 board type, or have you made your own board?

Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 04, 2019, 02:01 pm
In the sketch I've tried builtin, 0 and 1, on the chip I've tried port D pin 0 and port D pin 1, Port C pin 0, Port B pin 0 and port A pin 0 on all the sketch variations...

I've built it on a breadboard using a tqfp breadboard adapter

Sam
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: pert on Mar 04, 2019, 02:43 pm
LED_BUILTIN is PD6 on the ATmega4809.
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 04, 2019, 05:35 pm
OK I'll try it again on builtin and pd6 tonight

Ahhh I've just found the pinout spreadsheet for the 4809 on here, that explains it - I mistakenly thought it would follow the same pattern as the normal uno pinouts Re ports and Arduino pins...

Thank you all!

Sam
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 04, 2019, 09:45 pm
Just to confirm, finally all working! Thank you!

now onto the rest of the project!

Sam
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: pert on Mar 05, 2019, 12:41 am
Way cool! It's a wonderful feeling to see that LED start blinking.
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: A_neves on Mar 14, 2019, 01:27 pm
@samyoue,

I am trying to program my atmega 4809 with arduino uno using ELTangas software (https://github.com/ElTangas/jtag2updi).
But I can not program the atmega4809. I am getting
Code: [Select]
avrdude.exe : jtagmkII_getsync(): sign-on command: status -1

Could you tell me how do you get this working?

Thank you!
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 14, 2019, 01:52 pm
erm I'll try lol


Don't forget to check "C:\Users\*WINUSER*\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.6.25\variants\uno2018\pins_arduino.h" to see the pin mappings (not sure what path it would be on a Mac)

thats all I can remember, hopefully this will get you up and running.

If you get errors uploading try disconnecting usb and reconnecting...

Sam
Title: Re: issue uploading to breadboard ATMEGA4809 via uno
Post by: samyoue on Mar 15, 2019, 12:25 am
Also worth noting that if you are using TQFP - DIP adapter the top left pins go like this
DIP - CHIP
1 - 43
2 - 44
3 - 45
4 - 46
5 - 47
6 - 48
7 - 1
8 - 2
...
23 - 17
24 - 18

and then the right side of the adapter goes (from bottom right to top right) 19-42


Sam