Problems uploading to ATtiny84a over serial | ATTinyCore

I am trying to upload code to an attiny84a with a cheap FTDI serial adapter. I am using ATTinyCore with the attiny and trying to use it's support with optiboot.

This is how I first flashed the bootloader to the attiny84a through ISP. I connected my clone nano board (with the Arduino as ISP sketch flashed) to the ISP pins for the attiny, and sucessfully flashed the bootloader for it with these settings:


I then disconnected the nano board and hooked up the FTDI serial adapter as so: VCC - VCC, GND - GND, Tx - A2, Rx - A1, and DTR to a 0.1uF ceramic capacitor that connects to the RESET pin. On that RESET pin I also connected a 10K pullup to VCC and a shotky diode facing VCC. I then plugged in the serial adapter to my computer, opened up a new "bare minimum" sketch, pulled up the same settings as in the picture above, and hit "upload", and it gave me this error:

avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Family\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         Setting bit clk period        : 5.0
         AVR Part                      : ATtiny84
         Chip Erase delay              : 15000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         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     6     4    0 no        512    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      8192   64    128  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino

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

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

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00
         Hardware Version: 4745024
         Firmware Version: 0.59

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

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

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

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

I tried this many times with different variations and I still got error's like this. It's possible my serial adapter doesn't work as I have tried uploading code with it to other microcontrollers with no success, maybe there is something I could do to test it?
Here is a photo of my setup:

Thanks in advance.

Good news, after getting recommended to remove "Arduino as ISP" from the "programmer" option in the tools menu, i now just get this error:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930c (probably t84)
avrdude: reading input file "C:\Users\Family\AppData\Local\Temp\arduino\sketches\73BF67F54ADF95FBDDF1DCDCFC275CD5/ATtiny84_Blink_Test.ino.hex"
avrdude: writing flash (456 bytes):

Writing | ################################################## | 100% 0.39s

avrdude: 456 bytes of flash written
avrdude: verifying flash memory against C:\Users\Family\AppData\Local\Temp\arduino\sketches\73BF67F54ADF95FBDDF1DCDCFC275CD5/ATtiny84_Blink_Test.ino.hex:
avrdude: load data flash data from input file C:\Users\Family\AppData\Local\Temp\arduino\sketches\73BF67F54ADF95FBDDF1DCDCFC275CD5/ATtiny84_Blink_Test.ino.hex:
avrdude: input file C:\Users\Family\AppData\Local\Temp\arduino\sketches\73BF67F54ADF95FBDDF1DCDCFC275CD5/ATtiny84_Blink_Test.ino.hex contains 456 bytes
avrdude: reading on-chip flash data:

Reading | #####################################
avrdude: stk500_paged_load(): (a) protocol error, expect=0x10, resp=0x00
######avrdude: stk500_cmd(): programmer is out of sync
avr_read(): error reading address 0x0000
    read operation not supported for memory "flash"
avrdude: failed to read all of flash memory, rc=-2
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x00

avrdude done.  Thank you.

I'm afraid ATtinyX4 have no ńative serial. You can use softserial in the code but not in a bootloader.

So you need to use ISP to program your chip.

To my knowledge, using the optiboot bootloader allows me to upload to the chip through serial.

Do you see such option when choosing ATtinyX4 Optiboot?

I didn't realize their was an option. This is what I am using to assume i can upload to it from serial: https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x4.md#uart-serial-support

Compared to another ATtiny

The option Bootloader UART is missing for the X4 tiny. So no dice there, just ISP programming.

Well I wish I found this out a few days ago haha! Thank you very much. You have just saved me many more hours.

1 Like

Actually....

Optiboot works on the 84A. I've got one sitting in front of me blinking away at the moment.

The reason you don't see Bootloader UART on the 84A is that you don't have a choice of which to use. On the 841 you can choose between UART0 and UART1. On the 84A it's software on PA1 and PA2, period.

You may need to tune the internal oscillator to get it accurate enough for serial comms. At the moment I'm using an external 8MHz crystal and a couple of caps. Works a treat. I'm going to play around with OSCCAL and see how that goes.

Edit: I've gotten OSCCAL dialed in on one of my 84As in the sketch and have serial comms working. I'd have to adjust the value in the bootloader for that to work with the internal oscillator.

Optiboot has it's own "softwareSerial" for chips that don't have UARTs.

1 Like

Okay thank you. I was confused why the attiny84a wouldn't have software serial support after reading so much that it did. I will try to figure out how to calibrate the internal oscillator.

I haven't found anything, is this documented anywhere?

The fact that Optiboot is supported on the x4/x5 chips is right in the core docs.

The fact that the internal oscillator isn't terribly accurate (and is actually calibrated at 3V, not 5V) is documented in the x4A datasheet:

And as for Bootloader UART not showing up as an option, that would seem to just be common sense. When there's only one choice, it's not an option to set. You don't see it when you're using a 328P on an Uno or Nano, after all. But that doesn't mean that a bootloader doesn't work on a 328P.

1 Like

For MiniCore you got 3 choices,

bild

Regarding ATtinyCore, I'd say you get the choice here,

bild

Thank you and @westfw for sharing this, and my apologies to @big_rick for wrong info. :upside_down_face:

I switched the voltage on my serial adapter to 3.3v after looking at that chart, and was easily able to upload code to it! I guess the oscillator wasn't close enough in spec for 5V, but is for 3.3V?

If you look up a few replies, you see that the datasheet says that the internal oscillator is calibrated for 8HMz at 3V (and that its frequency is dependent on voltage and temperature). So it's likely a lot closer to that nominal 8MHz value at 3.3V than it is at 5V. The one I was tinkering with was running at about 8.3MHz at 5V.

Well thank you so much for the help. I am now looking at getting the ATtiny1606 and using it with megaTinyCore since it has hardware serial, and a more acurate internal oscillator.
EDIT: or maybe the ATtiny1616 as it isn't marked as "not recommended" for optiboot.

1 Like

If you're going to the ATtiny1616 or anything else in that series, look at UPDI programming. No bootloader required, and you can even program it with the same FTDI232 interface that you'll use for serial.

Check out the Yet another UPDI programmer Mk II topic for even more parts frugal solutions.

I have been reading the information about it for megaTinyCore, and seeing what i'll need to do and all of that.

It's pretty simple. You specify the programmer as serialupdi57k and upload to the same port you'll use for serial comms. The DTR pin determines whether it's programming (when it's high) or doing serial (when it's low). Here's what the FTDI+4053 version ends up looking like: