Need optiboot mega8 8mhz HEX and LST

hi,

ive been browsing this site for a long time and learned a lot but until now havent actually needed help. ive inherited a large quantity of mega8 dip and want to get optiboot installed but cant find an 8mhz hex file. i have arduino and avr assembler running but due to linited resources on my netbook cant compile the needed hex and lst files. a 16mhz version was posted here: http://arduino.cc/forum/index.php?topic=52873 but the 8mhz one is wrong offset and dont work. can anyone assist?

-j

I am piggy backing here as I also need the same resources

Duane B

The last post in that thread you posted a link to is an 8MHz version.

EDIT: Oh right, i see what you mean about the offset. What Baud rate would you like? I will compile it for you.

Edit (again): As it is quick to do, here are two common Baud rates: 57600B

:101E000011248FE594E09EBF8DBF84B714BE81FF7F
:101E1000D5D085E08EBD82E08BB988E18AB986E8AD
:101E200080BD80E189B98EE0B5D0BD9A96E028E109
:101E30003EEF40E23DBD2CBD88B7846088BF08B648
:101E400002FEFDCF88B3842788BBA895915091F7F7
:101E5000CC24DD244424439435E0632E21E1522E2A
:101E600093E0792E90D0813461F48DD0082F96D0F4
:101E7000023811F0013811F484E001C083E07FD012
:101E80007BC0823411F484E103C0853419F485E009
:101E90008DD072C0853541F476D0A82E74D0B82E7E
:101EA000AA0CBB1C650167C0863521F484E07ED096
:101EB00080E0E5CF843609F039C065D064D0082FC2
:101EC00062D020E0C21628E1D20618F4F60177BEEF
:101ED000E895C0E0D1E057D089930C17E1F7F0E026
:101EE000CF16F8E1DF0618F0F60177BEE89556D078
:101EF00007B600FCFDCFC601A0E0B1E08C901196C2
:101F00009C9011971296FC01040147BEE89511249C
:101F10000296F1E0A034BF0789F7F60167BEE895A5
:101F200007B600FCFDCF57BEE89526C08437B1F454
:101F30002AD029D0E82E27D031D0F601FE2C8F01EF
:101F40000F5F1F4F84911BD0FA94F801C1F70894DA
:101F5000C11CD11CEA94CE0CD11C0EC0853739F4BB
:101F60001DD08EE10CD083E90AD087E088CF81357F
:101F700011F488E00FD012D080E101D073CF5D9BC7
:101F8000FECF8CB908955F9BFECF5C9901C0A895E8
:101F90008CB1089598E191BD81BD0895F4DF803240
:101FA00019F088E0F7DFFFCF84E1E9CF1F93182F06
:101FB000EADF1150E9F7F2DF1F91089580E0EADFD0
:061FC000EE27FF27099443
:021FFE000404D9
:0400000300001E00DB
:00000001FF

115200B:

:101E000011248FE594E09EBF8DBF84B714BE81FF7F
:101E1000D5D085E08EBD82E08BB988E18AB986E8AD
:101E200080BD88E089B98EE0B5D0BD9A96E028E102
:101E30003EEF40E23DBD2CBD88B7846088BF08B648
:101E400002FEFDCF88B3842788BBA895915091F7F7
:101E5000CC24DD244424439435E0632E21E1522E2A
:101E600093E0792E90D0813461F48DD0082F96D0F4
:101E7000023811F0013811F484E001C083E07FD012
:101E80007BC0823411F484E103C0853419F485E009
:101E90008DD072C0853541F476D0A82E74D0B82E7E
:101EA000AA0CBB1C650167C0863521F484E07ED096
:101EB00080E0E5CF843609F039C065D064D0082FC2
:101EC00062D020E0C21628E1D20618F4F60177BEEF
:101ED000E895C0E0D1E057D089930C17E1F7F0E026
:101EE000CF16F8E1DF0618F0F60177BEE89556D078
:101EF00007B600FCFDCFC601A0E0B1E08C901196C2
:101F00009C9011971296FC01040147BEE89511249C
:101F10000296F1E0A034BF0789F7F60167BEE895A5
:101F200007B600FCFDCF57BEE89526C08437B1F454
:101F30002AD029D0E82E27D031D0F601FE2C8F01EF
:101F40000F5F1F4F84911BD0FA94F801C1F70894DA
:101F5000C11CD11CEA94CE0CD11C0EC0853739F4BB
:101F60001DD08EE10CD083E90AD087E088CF81357F
:101F700011F488E00FD012D080E101D073CF5D9BC7
:101F8000FECF8CB908955F9BFECF5C9901C0A895E8
:101F90008CB1089598E191BD81BD0895F4DF803240
:101FA00019F088E0F7DFFFCF84E1E9CF1F93182F06
:101FB000EADF1150E9F7F2DF1F91089580E0EADFD0
:061FC000EE27FF27099443
:021FFE000404D9
:0400000300001E00DB
:00000001FF

I haven't posted the lst files as they are not necessary. If you want them I can post them. Note that this my own modified version of optiboot, but it works the same - there were just some improvements in efficiency.

thank you tom. that is exactly what i need. 115.2kb is great because its fastest for a pc. i will try this out right away.

btw if you can find the .a or .lst file it would be a great help because i can then change baud and some other things w/o the hassle of recompile. thanks again for that hex file.

Here you go. The makefile generates a .lst file as well.

optiboot_atmega8_8.lst (21.7 KB)

i got the 57.6k version running like a charm so problem solved. thank you very much. it has saved me a lot of time and hassle. the 115.2k dont work but maybe expected what with divisor and cable issues. thanks again and for anyone who might want to save a few minutes heres the board.txt entries i used:

opti8a.name=Optiboot8a mega8 8mhz 115k
opti8a.upload.protocol=stk500
opti8a.upload.maximum_size=7680
opti8a.upload.speed=115200
opti8a.bootloader.low_fuses=0xbf
opti8a.bootloader.high_fuses=0xdc
opti8a.bootloader.path=optiboot
opti8a.bootloader.file=optiboot_mega8.hex
opti8a.bootloader.unlock_bits=0x3F
opti8a.bootloader.lock_bits=0x0F
opti8a.build.mcu=atmega8
opti8a.build.f_cpu=8000000L
opti8a.build.core=arduino

##############################################################

opti8b.name=Optiboot8b mega8 8mhz 57.6k
opti8b.upload.protocol=stk500
opti8b.upload.maximum_size=7680
opti8b.upload.speed=57600
opti8b.bootloader.low_fuses=0xbf
opti8b.bootloader.high_fuses=0xdc
opti8b.bootloader.path=optiboot
opti8b.bootloader.file=optiboot_mega8.hex
opti8b.bootloader.unlock_bits=0x3F
opti8b.bootloader.lock_bits=0x0F
opti8b.build.mcu=atmega8
opti8b.build.f_cpu=8000000L
opti8b.build.core=arduino

##############################################################

ps i often wonder if simply changing the xtl from 8mhz to 16mhz would allow operation at the higher baud rate. there are probably other timing issues so who knows. just postulating.

[quote author=Tom Carpenter link=topic=127354.msg957978#msg957978 date=1350322850] Here you go. The makefile generates a .lst file as well. [/quote]

great! icing on the cake. some rainy day ill convert to asm and play with minor changes. ive been testing the hex you gave me and its working fine with my many test pde files. hopefully some day when i get more up to speed ill be able to help people the way guys like you, westfw, and the rest do. thanks again.

Wow, fast response. I will have to book mark this and come back when I have a bit more time.

Thanks

Duane B

john1993: i got the 57.6k version running like a charm so problem solved. thank you very much. it has saved me a lot of time and hassle. the 115.2k dont work but maybe expected what with divisor and cable issues

Yeah, at 8MHz, 115200 is really pushing it (I think there is about a 6% error). Normally I use 115200 for 16MHz, and 57600 for 8MHz.

i have arduino and avr assembler running but due to linited resources on my netbook cant compile the needed hex and lst files.

I don’t understand this part. Recent optiboot sources are set up to compile using the same tools and same environment as Arduino itself. Just connect to the source directory and use the “omake” batch script.

Screen Shot 2012-10-15 at 5.06.58 PM.jpg

thats what i thought too but the only tutorial i saw referred to something called "mercurial" or something and im literally on the edge of overflow on my ssd so made no attempt to download. some of these modern tools are horrifically bloated so my main toolset is atmel assembler and an older arduino shell. im not fully up to speed on raw winavr procedures. im using an older version (arduino 0022 in a folder named 0arduino-0018) and newer ones dont fit. with raw winavr i get bogged down with missing files and directories which is not a problem with assembler and current arduino shell which are working ok for me right now. i hestate to change anything because it all falls down when i do.

there is (probably older) version of optiboot.c and makefile in "f:\0arduino-0018\hardware\arduino\bootloaders". clicking on makeall or makefile causes xp to ask for a program. any suggestions how to fix?

Here is my optiboot folder. I have made a batch file which redirects calls to the missing files to the correct folder so windows can find them.

optiboot.zip (131 KB)

this is great. i unzipped into the optiboot folder then clicked on the tiny84 batch which created elf/hex/lst. i cant believe how easy that was. nothing like this worked before. thanks again.

now to do this for mega8 8mhz i add a modified mega8 entry in makefile and create another batch file? i know how to do that. is there anything else needed?

Yeah, sorry that version of the folder is from my laptop, I created the mega8 batch file on my desktop. Either you can make your own, or i can upload the one I made this evening. If you make your own you will have to modify the makefile to add an 8MHz entry.

yes, i did that and it worked. the hex needs testing but i have a good feeling that will work too. thanks for showing me the way. i got a fish AND was taught the black art of fishing. :slight_smile:

mega8x: TARGET = atmega8
mega8x: MCU_TARGET = atmega8
mega8x: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=57600'
mega8x: AVR_FREQ = 8000000L 
mega8x: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
mega8x: $(PROGRAM)_mega8x.hex
mega8x: $(PROGRAM)_mega8x.lst

btw last night i was able to convert your lst fiie to assembly source and got it to work at 115200kb. by hacking the code to use rc instead of crystal and adding osccal/eeprom routines was able to fine tune the rate for that baud. its dead on now (±1%) and will even work with chips that have factory rc that is way off. this was not possible using c language and a crystal so there are definite advantages to assembler over the more popular tools.

i now have what has to be the lowest cost option for mega arduino. thanks again.

Just FYI, a crystal is accurate to within <0.1%. It is possible that you didn’t set the fuse settings correct for an 8MHz crystal.

with strong hardware background i can say even cheapo ebay crystals are much more accurate than that. few ppm. and ckopt or cksel settings while having some effect on startup and power have very little ability to "pull" a quartz crystal. i was using the arduino recommended settings btw. so more likely the uart divisor which is problematic at 8mhz or cable capacitance was the problem. if the 6% figure you mentioned is correct that in itself will kill it. generally even at low baud 4% is considered the limit. anyway the current method which ive used with many avr designs is cheaper and more correct baud than that crystal.

john1993:
with strong hardware background i can say even cheapo ebay crystals are much more accurate than that. few ppm.

Yeah sorry that was a typo, I meant to say <0.01%, but even that is on the high side - generally 20ppm is a standard figure.

It is possible that the RC is working better at 115200 baud as it’s frequency is calibrated in such a way that the % error is reduced.

Interestingly if the U2X bit is a 0, the error is +8.5%, but it it is set to a 1, that gets reduced to -3.5%. Optiboot uses the U2X bit, so the error in baud rate should be ‘acceptable’ (not great - in comparison 57600B results in a 2.1% error)

by hacking the code to use rc instead of crystal and adding osccal/eeprom routines was able to fine tune the rate for that baud.

Publish your code, please? Did it fit in 12 bytes, or did you have to get rid of some other stuff, or did you go to a 1k bootloader? Too bad the cpu can't switch clock sources from program control; a bootloader that is self-tuning to a bitrate during upload, but runs off the (exact) crystal freq when running the app, would be an interesting development...

i will upload the source file when i get home. as mentioned its based on the lst file i got here and only required half dozen or so extra instructions (jump to end, rd ee, poke osccal, then back). the magic ee value is written as part of the bootload install process. i only need to tap the keyboard a few times at 9600 to aquire a rather accurate number.

btw it is possible to free a few dozen bytes by optimizing in assembler but that was not necessary here. i did have to do some hacking to get my attiny bootloaders down to less than 256 bytes though.

3.5% is right on the edge but does sound better than 6% so the failure might have been cable distortion or something else. ill look into that in more detail with a scope when i get a chance. i try not to let school/dayjob interfere with hobby but dont always succeed. :)

ps whats REALLY too bad is adruino dudes didnt pick a better frequency standard from the start like 7.3728 or 14.7456 since the whole scheme is so rs232 centric. i guess italians like round numbers. lol!