Go Down

Topic: ATmega328P programming extensions + bonus Null Core (Read 886 times) previous topic - next topic

Jiggy-Ninja

Oct 19, 2016, 04:29 pm Last Edit: Oct 19, 2016, 04:30 pm by Jiggy-Ninja
I've created a boards.txt and platform.txt file that exposes some more advanced options than the Arduino IDE normally uses for compiling and uploading a sketch. It contains three "boards", Standalone ATmega328P, Standalone ATmega328P (Custom Fuses), and Null Core.

The intended use for this is for people that might want to start taking off some of the training wheels when moving the processor off the development board, without having to start from scratch learning a different IDE.

Common Features
Common to all three "boards" are the following submenu options:

F_CPU
16 MHz: Standard Arduino clock frequency
8 MHz: calibrated internal oscillator frequency
4 MHz: Highest frequency allowed at minimu supply voltage (1.8V)
1 Mhz: Frequency of default clock setting for new chips (internal osclillator + CLKDIV8 fuse)
20 MHz: Fastest frequency of most AVRs.
128 kHz: low power internal oscillator
Watch crystal: 32.768 kHz-otimized low frequency oscillator

Memory to Flash, changes what is flashed when you hit Upload.
Sketch
Fuses
EEPROM
Lock Bits
Sketch + EEPROM

EEPROM, Fuses, and Lock Bits can be specified in the code at compile time using the macros in the avr/eeprom.h, avr/lock.h, and avr/fuse.h headers.

Also common are the following features:
  • No bootloader file, you must use an external programmer when flashing. Fortunately, an Arduino board can act as a programmer for the other chip.
  • Upload, by default, is set up to use Arduino as ISP. If there are other common programmers people use, I could add another submenu to accommodate.
  • Memory to Flash option is also used by the "Upload Using Programmer" command, so you can use anything you want to do the programming.


Standalone ATmega328P
A couple of the important fuse options, like Clock Source and Brownout Level are put in submenus. These fuses are written using the "Burn Bootloader" command, and the Fuses option is removed from Memory to Flash.

Also has a Package selection menu that lets you choose between the Standard 6 analog input variant and the 8analoginput variant used for SMD packages with A6 and A7 available.

Uses the official Arduino core.



Standalone ATmega328P (Custom Fuses)
Mostly the same as the normal Standalone board, except you can specify the Fuses in the code instead of the dropdown menu, and program them in the Memory to Flash option.

Null Core
Takes off all the training wheels, and gives you bare-bones nothing to start with. The Null Core is a totally blank canvas containing only the following two file:

Arduino.h
Code: [Select]
#ifndef Arduino_H
#define Arduino_H
#include <avr/io.h>

void setup(void);
void loop(void);

#endif

main.cpp
Code: [Select]
#include <Arduino.h>

int main()
{
setup();
   
for (;;) {
loop();
}
       
return 0;
}


Total freedom is yours. Because it's so simple, I put in an extra MCU submenu that will let you program other AVRs as well, like the ATtiny84 or ATmega1284P.

I have no idea how to make a file for the board manager to use. Maybe if someone shows me how to do that I'll put this up on Github or something.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

hansibull

How does one specify what to flash in the EEPROM? I've use avrdude to upload .eep files to the internal EEPROM before, but I didn't knew it was possible with Arduino IDE
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

Jiggy-Ninja

#2
Oct 19, 2016, 06:38 pm Last Edit: Oct 19, 2016, 06:38 pm by Jiggy-Ninja
How does one specify what to flash in the EEPROM? I've use avrdude to upload .eep files to the internal EEPROM before, but I didn't knew it was possible with Arduino IDE
How did you make the EEP files before? avr/eeprom.h header has an EEMEM attribute that lets you define variables in EEPROM memory (like PROGMEM works for flash). With the funcitons in that header, there's really no reason to ever use Arduino's EEPROM library.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

Go Up