SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By Demolishun
#122256
Okay, so I am playing around with the atmega8u2. I found out that the bootloader takes about half of the chip flash. So when I tried to load more code on it would not take unless it was less than 4K.

Then I had an epiphany. Is there a way to write the code such that both the bootloader and code share the same libraries on the chip? Then the new code would just reference the libs in the bootloader. Of course this limits the app code to using what was compiled in to the bootloader.

Has anyone thought about something like this? How would you tell the linker to not include libs that are in the boot space?
By stevech
#122288
There are bootloaders (serial port) that are just 512Bytes on AVRfreaks.net. Have you looked around on that website's projects uploads? And you can ask the AVR gurus in the forum there.

As to calling functions in the bootloader from the app - sure. But since they're independently compiled/linked, you need some scheme to enter the bootloader, such as a jump table at a specific offset in the bootloader.

But really, you could use a bootloader written in assembler to be small, rather than a bootloader written in C.
By Demolishun
#122580
I was thinking the serial port bootloaders would be smaller. The device I am using has USB built in and I am just using the AVRDude program with a serial programmer. Works well and I get full space of the chip.

I think the Arduino has the best of both worlds. A fully programmable chip that acts as a bootloader for the second chip. I think that combination is excellent.

Yeah, I think you would have to have an object file that assumes the libraries would appear at specific locations on the chip. Probably too tricky for the payoff. Also, having a USB bootloader that does not emulate a standard USB device might reduce the code quite a bit. I think the bootloader of usbpicprog is smaller as it just creates a simple USB device. Then uses software to talk to it.

Thanks,
Frank
By frank26080115
#123788
Demolishun wrote: Then I had an epiphany. Is there a way to write the code such that both the bootloader and code share the same libraries on the chip? Then the new code would just reference the libs in the bootloader. Of course this limits the app code to using what was compiled in to the bootloader.
Of course this is possible

you know how the ".text" section where all your code goes? if you give the attribute ".bootloader" to any function, then that function will be placed into the bootloader flash section instead.
By stevech
#123915
Demolishun wrote:I was thinking the serial port bootloaders would be smaller.
Smaller than 512 bytes?
Note too that some AVRs have a minimum bootstrap code area size of more than 512 bytes. Esp. the larger-Flash chips.