Pages: [1]   Go Down
Author Topic: Optiboot on Attiny84?  (Read 2566 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

Thanks
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 210
Posts: 13036
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
« Last Edit: June 07, 2012, 01:45:34 pm by Coding Badly » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6792
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
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.

Code:
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:
Code:
##############################################################
 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:
Code:
/* 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:
Code:

         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 smiley
« Last Edit: June 21, 2012, 10:08:33 am by martin_bg » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Coding Badly, I hope I grow to fully understand what you are saying one day  smiley-roll-blue

As for the:
• 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 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.

Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6792
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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 ?)

Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6792
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: