Optiboot on Attiny84?

I am aware luminet has it, but am more interested in first hand experience. If anyone has done it, may you please share experience and things to watch out for before I dip myself into this :slight_smile:

Thanks

I am interested too, bought some more ATMega8's today because I am familiar with them, but would be nice to have a 'sometimes' cheaper option.

Duane B

I don't think you can put ANY Arduino bootloader on an ATtiny because it has no asynchronous serial port. You use an ISP device to write programs into the ATtiny. The "Burn Bootloader" process only sets the fuses to prepare the ATtiny for running the ATtiny core.

Thanks John,
but that is not entirely correct. The Optiboot supports software serial and the makefile has a build option for the attiny84 based Luminet.

My question was not if it is possible (because it is possible and it is done), but rather for practical guidance advices before I jump into it.

Some things...

• Search the forum. A few folks have promised a general purpose ATtiny bootloader and have written snippets about the experience.

• It's my understanding that one of the biggest obstacles is the RESET interrupt vector. I believe ATmega processors help manage it and ATtiny processors do not.

• ATtiny processors do not have a mechanism for protecting the bootloader. If an application is "too big" there is the possibility of overwriting the bootloader.

• I suspect the Atmel folks intended ATtiny bootloaders to be included with the application so that code (like Serial) could be shared (and other reasons).

• I suggest starting with a specific application. I believe that's one of the reasons Luminet was a success.

optiboot has "some" support for tiny chips without a separate bootloader space, and with bit-banged serial. I don't know whether it works any more; I'm not sure it ever did...

Here is my 'progress' or at least steps I undertook so far:

I modified the optiboot makefile to change the AVR_FREQ to 8Mhz, as I will be runnint the Attiny on its internal oscillator:

luminet: TARGET = luminet
luminet: MCU_TARGET = attiny84
luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
luminet: AVR_FREQ = 8000000L
luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
luminet: $(PROGRAM)_luminet.hex
luminet: $(PROGRAM)_luminet.lst

I burned the OptiBoot bootloader and am able to see the led on PA7 blink three times as expected.

avrdude -c usbtiny -p attiny84 -e -u -U lock:w:0x3f:m -U efuse:w:0xFE:m -U hfuse:w:0xDF:m -U lfuse:w:0x62:m
avrdude  -c usbtiny -p attiny84 -U flash:w:optiboot_luminet.hex

I modified my boards.txt to add a new section as follows:

##############################################################
 attiny84.name=ATtiny84 Optiboot
 attiny84.upload.protocol=stk500   //tried 'arduino' as well
 attiny84.upload.maximum_size=7424
 attiny84.upload.speed=9600
  attiny84.build.mcu=attiny84
 attiny84.build.f_cpu=8000000L
 attiny84.build.core=tiny

I hooked up the FTDI cable, TX and RX as follows:

 /* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */

.. and yes, I tried swapping the lines just in case.

I hooked up a 0.1uF ceramic capacitor in series with the RtS line on the FTDI

I try to upload a sketch, but get:

         Using Port                    : COM20
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 9600
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv:
avrdude: stk500_getsync(): not in sync: resp=0x00

avrdude done.  Thank you.

Comments are welcome :slight_smile:

Thanks Coding Badly, I hope I grow to fully understand what you are saying one day :roll_eyes:

As for the:

I think the Optiboot has a build flag for that, called VIRTUAL_BOOT_PARTITION, the bootloader itself can ensure that it won't get self-erased.

The last time I compiled a luminet optiboot ("stock"), it was rather larger than 512 bytes:

avr-size optiboot_luminet.hex
   text    data     bss     dec     hex filename
      0     610       0     610     262 optiboot_luminet.hex

So you'd probably need to change the addresses in this line:luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
Since the tiny84 doesn't have a "real" boot partition, I THINK you can change it to any required value, rather than the fixed sizes (512, 1k, 2k, 4k) that the ATmega cpus require (and it looks like 1d00 is already 8k-768, so that should be OK, but .version looks wrong (should be 1ffe ?)

Here is a good article on Attiny85 bootloader, it talks about the issues Coding Badly mentioned and the solutions to them:

http://embedded-creations.com/projects/attiny85-usb-bootloader-overview/avr-jtag-programmer/

Unfortunately, it requires a modified avrdude to work, whilst I wanted something more available to the general public

Most of those issues seem to be because of his desire to use USB. A serial bootloader like optiboot is a lot simpler; for instance, optiboot doesn't use any interrupts at all...

please consider http://arduino.cc/forum/index.php/topic,85238.0.html
thank to http://harizanov.com/2012/06/two-way-serial-communication-between-raspberry-pi-and-a-tinysensor/

and republish it

pescadito:
please consider http://arduino.cc/forum/index.php/topic,85238.0.html
thank to http://harizanov.com/2012/06/two-way-serial-communication-between-raspberry-pi-and-a-tinysensor/

and republish it

Thanks pescadito, but this is my blog site. I got stuck on the bootloader and am asking for help here

please, sorry me (i trying to colaborate).
thanks