These microcontrollers are already heavily supported by the IDE by default (well, almost all), but they are hidden behind names such as Arduino UNO, Arduino Duemilanove and Arduino NG. By default there's just a 16 MHz version of the Optiboot bootloader, and you'll have to do all the heavy lifting yourself if you want to do some changes. My idea was to compile a bunch of bootloaders and create a rather advanced boards.txt file where all the options can be selected. There will not be a separate copy of the core; the boards.txt will refer to the AVR core that's already included in the IDE.
It's going to be a simple and useful core if you want to experiment with different microcontrollers and clock frequencies with your Arduino UNO.
For me the hard part is to figure out a great name. I've already created MightyCore and MegaCore, so I want to stick with this style. I was thinking of names such as BasicCore or CommonCore, but these are just so lame! Can you help me find a suitable name?
If I recall correctly the bootloader (Optiboot in this case) "tricks" avrdude into believing an ATmega328 actually is an ATmega328p by "changing" the device signature. Is this correct? I was planning to make a "variant" option in the boards menu where one can select the ATmega328 or ATmega328p, but if the bootloader handles this there's no need to make an extra menu option
As I understand it, Optiboot reports the chip signature when avrdude requests it, but it does not read the signature value from the chip, it simply has the signature hard coded in Optiboot and uses that. So you should be able to make a custom Optiboot that outputs whatever signature you want (not that you would want it to report the actual signature for ATmega328, because that would complicate things more than help, but who knows). FlashyCore or MajeKore.
So you're thinking adding capability like was done for the 1284s to make it easy to manipulate the fuse settings?
I think that would be neat. Maybe Mighty328familyCore as that's the datasheet they are coming from? (well, the 328 family of data sheets, as there is a different sheet for the Automotive parts with extended temperature range (Atmega328P-15AZ & -15MZ)
It seems like the ATmega48 would be a hard nut to crack; It doesn't got a boot section like the rest of the family. I think the easiest would be to just skip the bootloader on this one and program it using an ISP instead
You could try VIRTUAL_BOOT_PARTITION option of Optiboot for Atmega48, but it could be tricky to get reliable entry point to flash write function.
I'm thinking about some kind of revolution: get rid of version number in 2 last bytes of flash (nobody uses this anyway) and put there jump to do_spm. It could be really constant for every chip, bootloader features and sizes. And it could save another 2 bytes of code
MiniCore is good idea. I thought also about HardCore as code writing to it's own flash is some kind of risky/advanced/hardcore thing
I'm thinking about some kind of revolution: get rid of version number in 2 last bytes of flash (nobody uses this anyway) and put there jump to do_spm. It could be really constant
No! Having a version number is really important! You're welcome to put the do_spm vector in FLASHEND-4
Just an idea, why not using classic stuff: mega, kilo, hecto, deca, mili, micro, nano, pico, femto.
Maybe the name of someone of the great: Ohm, Faraday, Tesla, Volta, Newton, Einstein, Feynman.
Anyway, is just in terms of aesthetics right?
ok, maybe you guys can help me out on this one. I was able to get my hands on an ATmega328 (non p) today. I compiled the bootloader (edited the makefile from 328p to 328) and burned the bootloader using a modified boards.txt file. The bootloader is burnt, and everything is fine, but when I try to upload a sketch, I get this error:
avrdude: Device signature = 0x1e950f
avrdude: Expected signature for ATmega328 is 1E 95 14
Double check chip, or use -F to override this check.
The bootloader pretends to be an ATmega328p, and AVRdude returns an error. Adding -F is a dirty workaround, so I want to avoid doing that if possible.
How can I get the bootloader to return the actual device signature? This problem will appear on the ATmega88/p and ATmega168p/pa as well.
hansibull:
ok, maybe you guys can help me out on this one. I was able to get my hands on an ATmega328 (non p) today. I compiled the bootloader (edited the makefile from 328p to 328) and burned the bootloader using a modified boards.txt file. The bootloader is burnt, and everything is fine, but when I try to upload a sketch, I get this error:
avrdude: Device signature = 0x1e950f
avrdude: Expected signature for ATmega328 is 1E 95 14
Double check chip, or use -F to override this check.
The bootloader pretends to be an ATmega328p, and AVRdude returns an error. Adding -F is a dirty workaround, so I want to avoid doing that if possible.
How can I get the bootloader to return the actual device signature? This problem will appear on the ATmega88/p and ATmega168p/pa as well. :(
modify the bootloader to actually read the signature. Right now it just returns the #defines for whatever part Optiboot was compiled for. Those SIGNATURE_0/1/2 come from the avrlibc includes.
else if(ch == STK_READ_SIGN) {
// READ SIGN - return what Avrdude wants to hear
verifySpace();
putch(SIGNATURE_0);
putch(SIGNATURE_1);
putch(SIGNATURE_2);
}
I saw a function somewhere in there to get sig bytes... I think it's just a matter of calling that instead of using the defines...
Of course! what registers holds the device signature? Every guide I've read refers to the io.h file
EDIT:
I found an old post from AVR freaks where mr. westfw (aka the father of optiboot(?)) posted an Arduino sketch where he used boot.h to read the signature bytes. When I try to implement his method (shown in the code below) I just get an error saying that SIGRD isn't defined. When I define it (like in the example sketch) I get the error message below:
else if(ch == STK_READ_SIGN) {
// READ SIGN - return what Avrdude wants to hear
verifySpace();
uint8_t tempval = boot_signature_byte_get(0); //variable to store device signature bytes
putch(tempval);//SIGNATURE_0);
tempval = boot_signature_byte_get(2);
putch(tempval);//SIGNATURE_1);
tempval = boot_signature_byte_get(4);
putch(tempval);//SIGNATURE_2);
}
$ make atmega328 AVR_FREQ=16000000L BAUD_RATE=115200 UART=0 LED=B5 LED_START_FLASHES=2
avr-gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Yeah, it's not compiling to under 510 bytes anymore (the last 2 are used for a version number). It looks like with the code to read the signature bytes, it's coming out to 518 bytes. Gotta lose 8 bytes somehow...
Couldn't you just use the same system of defining the chip in the makefile and then having the bootloader pass the signature associated with the chip it was compiled for? So there would be different bootloader files for ATmega328P and ATmega328? That shouldn't cause any increase in size.
Thanks! I'll be back with more info when the test microcontrollers have arrived and the core us up and running on Github. BTW the name I chose was MiniCore