Optiboot Bootloader on an Attiny841

Hi,

I made a custom Board using an Attiny841 without an external Oscillator!
When I try to burn the Optiboot Bootloader, which I downloaded from there:

GitHub - SpenceKonde/arduino-tiny-841: Arduino core for ATtny841, 828, 1634 and 441,

I get the following Error-Message:

avrdude: Expected signature for ATtiny841 is 1E 93 15
Double check chip, or use -F to override this check.

I tried to burn the Bootloader using an Arduino Nano and an Arduino UNO. Both running the ArduinoISP sketch.

Thank you in advance:)

You rang?

Enable verbose upload in preferences and post the output - we need to see what other signature it sees instead.

If it's 0x000000 then could you have attempted to do burn bootloaded with it set to use an external crystal? That will soft-brick it - connect a crystal, and then burn bootloader with it set to use internal oscillator, then remove crystal.

0x000000 can also indicate wiring problems, naturally. So check that (I often ohm out each pin of ISP header to each other pin, and to Vcc and gnd - set meter to beep on continuity, and drag over pins). Arduino as ISP is rather fickle - I recommend using a real ISP programmer; I use USPAsps.

When using Optiboot with the internal oscillator, be sure to read and understand the notes here regarding the internal oscillator and operating voltage. ATTinyCore/ATtiny_x41.md at OldMaster---DO-NOT-SUBMIT-PRs-here-Use-2.0.0-dev · SpenceKonde/ATTinyCore · GitHub I recommend using a crystal at all times when reliable serial functionality is required.

Hi, we are trying to use the Tiny841 for a new project. I have built a board with an 6-way ISP header and this works well using AVR Studio 6.2.

We have now wired up a FTDI chip with TX going to pin 11 and RX going to pin12, an dare trying to program the TIny841 with the TinyCore Arduino extension. Everythign is fine but avrdude hangs with no reply. DO we also have to wire in the DTR line from the FTDI chip?

DO we also have to wire in the DTR line from the FTDI chip?

Either that, or do a well-timed manual reset... Don't forget the cap.

I use them with the same autoreset circuit as the official uno/nano/pro-mini, with DTR and the cap. I suggest you do the same unless you like playing reflex games to reset the board in order to upload.

Also - be sure to read and understand this when using internal oscillator with a bootloader

At >4v, the speed of the internal oscillator on 828R, 1634R and 841 parts increases significantly - enough that serial (and hence the bootloader) does not work. It is recommended to run at 3.3v if using internal RC oscillator as a clock source - however, for these chips, a workaround is provided. This takes the form of a bootloader compiled assuming the chip is running a little fast, so that UART communication will work, and a matching board definition that tries to compensate by assuming the chip is running at 8.2mhz instead of 8. If you wish to handle tuning of the oscillator in your sketch (this means that serial won't work and timing will be off until you do something about it), you can use the 5v workaround as the bootloader but compile assuming 8mhz - select that option when you burn bootloader, but not when compiling and uploading. (New feature added in version 1.1.2)

OK, thanks for the replies. I have soldered in a 0.1uF cap from DTR to the Reset line. I can now see this line go low when Avrdude is running. I am runnign from 5V.

I do still have an issue where avrdude replies with an error and retries ten times before giving up. I have tried the * MHz internal (>4V) but still no luck. Thanks

C:\Program Files\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\Fergus Dixon\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.1.2/avrdude.conf -v -pattiny841 -carduino -PCOM2 -b57600 -D -Uflash:w:C:\tmp\arduino_build_539929/Blink.ino.hex:i

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

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

Using Port : COM2
Using Programmer : arduino
Overriding Baud Rate : 57600
Setting bit clk period : 5.0
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xee

Here is some more info. By the way should LTO be enabled or Disabled?

I reprogrammed the Tiny841 with AVRSTudio 6.2 with the Blink sketch on pin2 and it works well.

Global variables use 9 bytes (1%) of dynamic memory, leaving 503 bytes for local variables. Maximum is 512 bytes.
C:\Program Files\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\Fergus Dixon\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.1.2/avrdude.conf -v -pattiny841 -carduino -PCOM2 -b57600 -D -Uflash:w:C:\tmp\arduino_build_539929/Blink.ino.hex:i

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

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

Using Port : COM2
Using Programmer : arduino
Overriding Baud Rate : 57600
Setting bit clk period : 5.0
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20

avrdude done. Thank you.

An error occurred while uploading the sketch

Post your schematic, can't debug from that error (it is notoriously difficult to debug sync errors, because almost anything can cause them, and the errors look the same)

You realize that after uploading something via ISP, you need to reburn bootloader, right? ISP uploads will erase the bootloader (and the versions of the exported .hex files including the bootloader generated by the Arduino IDE don't work - see (sketchname)_bootloader.hex exports don't work for 841, 1634, and 167. · Issue #73 · SpenceKonde/ATTinyCore · GitHub )

I have soldered in a 0.1uF cap from DTR to the Reset line. I can now see this line go low when Avrdude is running.

It should briefly PULSE low at the start of Avrdude execution. I hope that's what you're seeing.

We should probably turn off the avrdude "retry" option; I've never seen a retry succeed, and when I looked into it more deeply, it seemed that the retry loop wasn't in a good place (didn't include the DTR pulse, for example, though you could argue that it shouldn't...

If you have AVRStudio running, you could load up the "ASCIITable" sketch and check whether serial communications seems to be happening at the correct rate (and is otherwise wired correctly/etc.) I just recently managed to set up an Arduino-programmable chip with RX and TX swapped from what they should have been :frowning:

I assumed the point of the retry was to make it easier if you wound up having to manually reset it?

Perhaps; but I haven't seen that work, either... I've seen it take 10 seconds per retry (all failing), and I've seen it blast through all 10 retries in a fraction of a second (not giving a chance for a manual reset.) It just doesn't work.

Thanks Dr Azzy. OK, the bootloader may be the problem. Can you point me in the right direction for this. I thought the Tiny841 didn't have a bootloader but used some Optiboot method. I will send the schematic shortly.

With the ASCIItable sketch, I received this error on compling:

C:\Program Files\Arduino\examples\04.Communication\ASCIITable\ASCIITable.ino: In function 'void setup()':

ASCIITable:25: error: no match for 'operator!' (operand type is 'HardwareSerial')

while (!Serial) {

^

C:\Program Files\Arduino\examples\04.Communication\ASCIITable\ASCIITable.ino:25:10: note: candidate is:

C:\Program Files\Arduino\examples\04.Communication\ASCIITable\ASCIITable.ino:25:10: note: operator!(bool)

C:\Program Files\Arduino\examples\04.Communication\ASCIITable\ASCIITable.ino:25:10: note: no known conversion for argument 1 from 'HardwareSerial' to 'bool'

exit status 1

I thought the Tiny841 didn't have a bootloader but used some Optiboot method

"Optiboot" is a bootloader...

while (!Serial) {

Oops. You can just remove that whole IF clause, it's only needed for the USB-based boards (leonardo, Micro, etc.)

Anything to upload code without using either ISP, HVSP, or parallel programming (the methids directly supported in hardware - nobody in hobby willingly uses anything other than ISP) involves a bootloader.

Optiboot is the same bootloader used on the uno - but for the 841 it has to use some extra tricks, namely virtualboot, since there's no BOOTRST fuse to run the bootloader on reset. It actually rewrites the vector table as it uploads a sketch (consequence is that the with bootloader hex exports don't work, and you can't use the WDT as an interrupt source - but you can use a bootloader on chips without hardware support for it)

OK, thanks for the info. The ASCIITable sketch now runs fine on the Tiny841 using the AVR ISP MkII

Here is the schematic

OK, so with the Tiny841 bootloader, where abouts does this live and how does it get programmed into the Tiny841. I found the Optiboot folder and I have reprogrammed the Arduino Uno Mega328 bootloaders before.

Thanks for the help so far.

OK, I did find some Optiboot bootloader files in this directory

C:\Users\My name\AppData\Local\Arduino15\packages\arduino-tiny-841\hardware\avr

Not sure which one to use. I tried this one: optiboot_attiny841at8.hex and the Arduino showed a few Hashes ### to show that it was programming the Tiny841 but still had some errors. The red light now blinks twice quickly then off for a second or so.

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Users\Fergus Dixon\AppData\Local\Arduino15\packages\arduino-tiny-841\hardware\avr\1.0.6/avrdude.conf"

Using Port : COM2
Using Programmer : arduino
Overriding Baud Rate : 57600
Setting bit clk period : 5.0
AVR Part : ATtiny841
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 12 32 0 yes 8192 16 512 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
Hardware Version: 3
Firmware Version: 6.2
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9315 (probably t841)
avrdude: reading input file "C:\tmp\arduino_build_628908/Blink.ino.hex"
avrdude: writing flash (920 bytes):

Writing | ################################################## | 100% 1.85s

avrdude: 920 bytes of flash written
avrdude: verifying flash memory against C:\tmp\arduino_build_628908/Blink.ino.hex:
avrdude: load data flash data from input file C:\tmp\arduino_build_628908/Blink.ino.hex:
avrdude: input file C:\tmp\arduino_build_628908/Blink.ino.hex contains 920 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.85s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0002
0xff != 0x3d
avrdude: verification error; content mismatch

avrdude done. Thank you.

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

I did find some Optiboot bootloader files in this directory
C:\Users\My name\AppData\Local\Arduino15\packages\arduino-tiny-841\hardware\avr

Which core are you using? Isn't the recommended core these days GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8? My install of that have a bunch of different tinys in "...packages/ATTinyCore/hardware/avr/1.1.2/bootloaders/optiboot" - there is no separate directory "arduino-tiny-841"...

That's an ancient version of the core from before I merged them. I dropped support for that as a separate core nearly a year ago. What could I have done to have prevented you from installing the obsolete core? It looks like you installed it via board manager, and the description of that core is "ATTENTION! ATtiny Modern has been merged with ATTinyCore. If you have ATtiny Modern installed please click the Remove button and install ATTinyCore."

You should use ATTinyCore, as westfw has said.

To install the bootloader, connect an ISP programmer to the ISP header, select the board and clock options you want from the tools menu (once a board in my core is selected, numerous additional submenus will become available), and do tools -> burn bootloader. Just like bootloading any other AVR

OK, thanks for the replies. I did have the ATTinyCore installed but I also had the TinyModern installed. I installed the TinyModern first since it was at the end in the Boards Manager then saw the message and installed ATTinyCore. I have removed the TinyModern now.

Anyway, now it works but the program still does not verify or run. Here is the error and log below:
avrdude: verification error, first mismatch at byte 0x0002
0xff != 0x32

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

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

Using Port : COM2
Using Programmer : arduino
Overriding Baud Rate : 57600
Setting bit clk period : 5.0
AVR Part : ATtiny841
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 12 32 0 yes 8192 16 512 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
Hardware Version: 3
Firmware Version: 6.2
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9315 (probably t841)
avrdude: reading input file "C:\tmp\arduino_build_430701/Blink.ino.hex"
avrdude: writing flash (878 bytes):

Writing | ################################################## | 100% 1.76s

avrdude: 878 bytes of flash written
avrdude: verifying flash memory against C:\tmp\arduino_build_430701/Blink.ino.hex:
avrdude: load data flash data from input file C:\tmp\arduino_build_430701/Blink.ino.hex:
avrdude: input file C:\tmp\arduino_build_430701/Blink.ino.hex contains 878 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.77s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0002
0xff != 0x32
avrdude: verification error; content mismatch

OK, Quick update this time. First thanks for all the help.

It is now WORKING 100%. I used the optiboot_attiny841at8_5v.hex bootloader file and the 8KHz (internal) >4V clock setting. By the way the 8MHz (internal) setting also works fine.

The problem with the FLash not verifying was caused by the SELFPRGEN fuse which was turned off by default. This prevents any bootloader from programming the flash.

With this turned on, the ASCIITable.hex file was flashed from the Arduino IDE and then the Blink sketch. I also changed the time period to 100ms to test it and it definitely fully works.

I did change the cap to 10uF but will change it back to 0.1uF and test it again.