ATmega48/88 support

On the feature request list, I'd like to add support for the ATmega48 and 88. Someone on the forum suggested going through the code and adding the 48 to all the 168 ifdef's, and that worked for my little project. If you add the 48, may as well at the 88 for completeness.

I'm guessing it will be minimal effort to add support for the 48 and 88 at the same time you go through the code adding 328 support. :slight_smile:

-j

(As to why I used a 48? It's cheaper and big enough for the problem at hand, so I decided to save a buck or two.)

The mega48 doesn't support a separate bootloader area, does it?

I never figured out how the 88 got skipped, but it also never seemed enough cheaper than a 168 to complain about...

The mega48 doesn't support a separate bootloader area, does it?

Correct. I hadn't looked before, as I have an AVRISPmkII and never intended for my device to be bootloader enabled (it doesn't even have a serial port). The datasheet says "In ATmega48, there is no Read-While-Write support and no separate Boot Loader Section."

-j

I changed all the #ifdefs to check for the ATmega8 rather than the ATmega168, so I think the ATmega48/88 should just work. It will be in Arduino 0013.

thanks!

-j

a 48 bootloader is doable. I don't know how to do it in C, but in assembler you would

  1. write it at, say .org 0x700 (gives you 256 bytes to make a bootloader)
  2. make sure it does not write any pages at address 0x700 or above
  3. note the two bytes headed for address 0x00 when uploading. This is probably a rjmp to where the compiler wanted to start execution.
  4. make sure it overwrites the two bytes at 0x00 with FFC6 when doing a flash update. (relative jump from 0x00 to 0x700)
  5. store the 2 bytes from step three in the last address before the bootloader so you can find it again. use these bytes to figure out where to jump to when ready to start the application, or if it isnt a rjmp then maybe execute it and jmp 0x0002? (not perfect, but C will likely put the rjmp vectors there 99.9% of the time)

The 48s do get inexpensive :slight_smile: I don't see writing a bootloader for it, but just thinking out loud.