Programing ATmega4808 with avrdude

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I started a project with the Atmega328PB and subsequently found out that there was not enough memory so decided to use the Atmega4808.

 

So, I bought a few chips and made an experimental board with a minimum of external elements (as in the picture).

 

I'm using the Popolulo USB USB AVR v2 programmer and trying to connect it to the board via ISP or UART were got a strange signature:

 

c:\>avrdude -c stk500v2 -P COM5 -b 115200 -B 1 -p m4808 -F

avrdude: stk500v2_program_enable(): program enable instruction not defined for part "ATmega4808"
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x656570
avrdude: Expected signature for ATmega4808 is 1E 96 50

avrdude done.  Thank you.

 

So far, I told ISP can not be used for this purpose and follow the https://github.com/ElTangas/STK2... have programmed one Adruino nano 328bp and connect to my tiny 4808 board via UPDI pin and got the same result:

 

c:\1\>avrdude -v -c stk500 -P COM4 -b 57600 -p m4808 -F

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 "c:\1\avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega4808
         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 : STK500V2
         Description     : Atmel STK500
         Programmer Model: STK500
         Hardware Version: 0
         Firmware Version Master : 2.10
         Topcard         : Unknown
         Vtarget         : 5.5 V
         SCK period      : 0.5 us
         Varef           : 3.2 V
         Oscillator      : Off

avrdude: stk500v2_program_enable(): program enable instruction not defined for part "ATmega4808"
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x656570
avrdude: Expected signature for ATmega4808 is 1E 96 50

avrdude done.  Thank you.

 

Any input will be highly appreciated.

 

Thank you

 

Dave

Attachment(s): 

Last Edited: Fri. Nov 15, 2019 - 11:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

First welcome to AVRFreaks!

 

So from the above question, I take it you did not read the data sheet for the M4808, as on page 1 it says:

Which tells you it does not use ISP for programming, but rather UPDI, so you will need a programmer that supports UPDI to burn your flash.

One such programmer is the atmel ICE, there are others but are not as simple to use. 

There are lots of other differences between the new xtiny chips and and the older mega chips that you will need to learn as well, it is not a simple port.

Take it one step at a time, and you will get there.  Have you considered using another mega chip(atmega2560) with more flash?  Or perhaps writing more compact code to fit it into M328.

 

Jim

 

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Fri. Nov 15, 2019 - 02:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Jim,

 

Many thanks for your warm welcome and your quick feedback.

I saw what was written in the datasheet, but I interpreted it as saying that UPDI can be used in addition to standard methods such as ISP or UART.

I chose the m4808 because it has a ULP RTC built-in and doesn't need many external elements were planning to use ESP32 for a subsequent firmware change over Wi-Fi so need a way to do that w/o using a special programming tool. 

Anyway, I tried with STK2UPDI as described in  https://hackaday.io/project/134831-atmega4809-developing-board-project/log/144552-how-to-start-configurable-custom-logic-on-atmega4809 but got same signature which on top of that is floating - seems reading a dynamic data instead of chip signature.

 

I've been playing for a few days now and I'm fully blocked. Obviously there is some mistake in the protocol, but I have no attempt to do so (seems after over than 10 years as a manager, my developer experience is gone :)

 

Once again - many thanks to you!

 

Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

davidnik wrote:
... were planning to use ESP32 for a subsequent firmware change over Wi-Fi so need a way to do that w/o using a special programming tool.
fyi, Arduino Uno WiFi Rev 2 shows UPDI from the ESP32.

UNOWiFiREV2V4.0.sch

[page 1, A4]

via ARDUINO UNO WiFi REV2 (Documentation tab)

NINA-W13 series | u-blox

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

davidnik wrote:
So far, I told ISP can not be used for this purpose and follow the https://github.com/ElTangas/STK2... have programmed one Adruino nano 328bp and connect to my tiny 4808 board via UPDI pin and got the same result:

 

That's because that program is basically deprecated and not compatible with the mega AVR-0 series. I wrote a more up to date programmer that you can get here: https://github.com/ElTangas/jtag...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi El Tangas,

 

Many thanks for your replay.

I'm using Wemos CH340G -> A-Star 328PB with an external 8MHz oscillator (PD6) -> pin 27 (UPDI) on the simplest mega4808 board possible. I also added a 10uF capacitor to the RST-GND on 328PB board as suggested at https://github.com/SpenceKonde/m... - believe is adding a pull-up delay after powering up the device.

 

 

c:\1\>avrdude -Cavrdude.conf -v -v -c jtag2updi -P com7 -pm4808 -F

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 "avrdude.conf"

         Using Port                    : com7
         Using Programmer              : jtag2updi
avrdude: jtagmkII_open_pdi()
avrdude: jtagmkII_getsync(): Sending sign-on command: 0x86 (29 bytes msg)
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
avrdude: jtagmkII_getsync(): Using a 298-byte device descriptor
avrdude: jtagmkII_setparm()
avrdude: jtagmkII_setparm(): Sending set parameter command (parm 0x03, 1 bytes): 0x80 (1 bytes msg)
avrdude: jtagmkII_getsync(): Sending get sync command: 0x80 (1 bytes msg)
         AVR Part                      : ATmega4808
         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
avrdude: jtagmkII_getparm()
avrdude: jtagmkII_getparm(): Sending get parameter command (parm 0x01): 0x81 (3 bytes msg)
avrdude: jtagmkII_getparm()
avrdude: jtagmkII_getparm(): Sending get parameter command (parm 0x02): 0x81 (5 bytes msg)
         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
avrdude: jtagmkII_getparm()
avrdude: jtagmkII_getparm(): Sending get parameter command (parm 0x06): 0x81 (3 bytes msg)
         Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): trying to set baudrate to 115200
avrdude: jtagmkII_setparm()
avrdude: jtagmkII_setparm(): Sending set parameter command (parm 0x05, 1 bytes): 0x80 (1 bytes msg)
avrdude: jtagmkII_set_devdescr(): Sending set device descriptor command: avrdude: ser_recv(): programmer is not responding
avrdude: jtagmkII_recv(): Timeout receiving packet

avrdude: jtagmkII_set_devdescr(): timeout/error communicating with programmer (status -1)
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: jtagmkII_reset(): Sending reset command: avrdude: ser_recv(): programmer is not responding
avrdude: jtagmkII_recv(): Timeout receiving packet

avrdude: jtagmkII_reset(): timeout/error communicating with programmer (status -1)
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x656570
avrdude: Expected signature for ATmega4808 is 1E 96 50
avrdude: jtagmkII_close()
avrdude: jtagmkII_close(): Sending GO command: avrdude: ser_recv(): programmer is not responding
avrdude: jtagmkII_recv(): Timeout receiving packet

 

Then I thought my self I might have damaged the chip during soldering, so connected it to an original ATmega4809 Xplained Pro but ... all same.

 

Do you have an idea what could be wrong?

 

Thank you,

 

Dave

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi folks,

 

Many thanks for your support. Finally, I caught the problem:

 

   1. The board CPU frequency was #define F_CPU 16000000U where in my case is 8MHz

   2. It seems to work on 19200 baud rate only, at least in my case.

 

c:\1\>avrdude -v -v -c jtag2updi -P com7 -b19200 -pm4808

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 "C:\1\avrdude.conf"

         Using Port                    : com7
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 19200
avrdude: jtagmkII_open_pdi()
avrdude: jtagmkII_getsync(): Sending sign-on command: 0x86 (29 bytes msg)
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
avrdude: jtagmkII_getsync(): Using a 298-byte device descriptor
avrdude: jtagmkII_setparm()
avrdude: jtagmkII_setparm(): Sending set parameter command (parm 0x03, 1 bytes): 0x80 (1 bytes msg)
avrdude: jtagmkII_getsync(): Sending get sync command: 0x80 (1 bytes msg)
         AVR Part                      : ATmega4808
         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
avrdude: jtagmkII_getparm()
avrdude: jtagmkII_getparm(): Sending get parameter command (parm 0x01): 0x81 (3 bytes msg)
avrdude: jtagmkII_getparm()
avrdude: jtagmkII_getparm(): Sending get parameter command (parm 0x02): 0x81 (5 bytes msg)
         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
avrdude: jtagmkII_getparm()
avrdude: jtagmkII_getparm(): Sending get parameter command (parm 0x06): 0x81 (3 bytes msg)
         Vtarget         : 5.0 V

avrdude: jtagmkII_set_devdescr(): Sending set device descriptor command: 0x80 (1 bytes msg)
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: jtagmkII_reset(): Sending reset command: 0x80 (1 bytes msg)
avrdude: AVR device initialized and ready to accept instructions

Reading |                                                    | 0% 0.00savrdude: jtagmkII_read_byte(.., signature, 0x0, ...)
avrdude: jtagmkII_program_enable(): Sending enter progmode command: 0x80 (1 bytes msg)
avrdude: jtagmkII_program_enable(): Sending enter progmode command: 0x80 (1 bytes msg)
avrdude: jtagmkII_read_byte(): Sending read memory command: 0x82 (2 bytes msg)
avrdude: jtagmkII_read_byte(.., signature, 0x1, ...)
avrdude: jtagmkII_read_byte(): Sending read memory command: 0x82 (2 bytes msg)
Reading | #################                                  | 33% 0.40savrdude: jtagmkII_read_byte(.., signature, 0x2, ...)
avrdude: jtagmkII_read_byte(): Sending read memory command: 0x82 (2 bytes msg)
Reading | ################################################## | 100% 0.46s

avrdude: Device signature = 0x1e9650 (probably m4808)

avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)
avrdude: jtagmkII_program_disable(): Sending leave progmode command: 0x80 (1 bytes msg)
avrdude: jtagmkII_reset(): Sending reset command: 0x80 (1 bytes msg)
avrdude: jtagmkII_close()
avrdude: jtagmkII_close(): Sending GO command: 0x80 (1 bytes msg)
avrdude: jtagmkII_close(): Sending sign-off command: 0x80 (1 bytes msg)

avrdude done.  Thank you.

 

Once again - many thanks to all!

 

Cheers, 

 

Dave

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

davidnik wrote:
2. It seems to work on 19200 baud rate only, at least in my case.

 

Normally, jtag2updi defaults to 115200 baud, which is fine if the programmer MCU is running @ 16MHz, but too fast for a 8MHz device. In my tests, in general 8MHz programmers will work @ 57600 baud, but it's not totally unexpected that you need to go even lower.

 

edit: BTW, the 10uF cap is not really needed. I wrote that in the jtag2updi documentation due to a misunderstanding on my part on how avrdude uses the DTR line for different protocols. Unfortunately, SpenceKonde has propagated my mistake, I really need to correct that one of these days...

Last Edited: Sat. Nov 16, 2019 - 09:19 PM