Skip to main content

Bootloader - Arduino

What is a bootloader, and what is bootloading?
The bootloader is the little program that runs when you turn the Arduino on, or press the reset button. Its main function is to wait for the Arduino software on your computer to send it a new program for the Arduino, which it then writes to the memory on the Arduino. This is important, because normally you need a special device to program the Arduino. The bootloader is what enables you to program the Arduino using just the USB cable.

When we refer to "bootloading" the Arduino, we are talking about using a special device (called an In-System Programmer or ISP) to replace the bootloader software.

Normally the default bootloader of arduino is Optiboot
Here I am showing that an alternative and some more advanced options in Arduino bootloader option called MiniCore

Why MiniCore?

An Arduino core for the ATmega328, ATmega168, ATmega88, ATmega48 and ATmega8, all running a custom version of Optiboot for increased functionality.

  • Bootloader option
  • BOD option
  • Link time optimization / LTO
  • Printf support
  • Pin macros
  • Programmers
  • Write to own flash

Bootloader option

MiniCore lets you select which serial port you want to use for uploading. UART0 is the default port for all targets, but ATmega328PB can also use UART1. If your application doesn't need or require a bootloader for uploading code you can also choose to disable this by selecting No bootloader. This frees 512 bytes of flash memory.

Note that you need to connect to a programmer and hit Burn bootloader if you want to change any of the Upload port settings.

BOD option

Brown out detection, or BOD for short lets the microcontroller sense the input voltage and shut down if the voltage goes below the brown out setting. To change the BOD settings you'll have to connect an ISP programmer and hit "Burn bootloader". Below is a table that shows the available BOD options:



ATmega328ATmega168ATmega88ATmega48ATmega8
4.3V4.3V4.3V4.3V4.0V
2.7V2.7V2.7V2.7V2.7V
1.8V1.8V1.8V1.8V-
DisabledDisabledDisabledDisabledDisabled
 BOD settings table

Printf support

Unlike the official Arduino cores, MiniCore has printf support out of the box. If you're not familiar with printf you should probably read this first. It's added to the Print class and will work with all libraries that inherit Print. Printf is a standard C function that lets you format text much easier than using Arduino's built-in print and println. Note that this implementation of printf will NOT print floats or doubles. This is a limitation of the avr-libc printf implementation on AVR microcontrollers, and nothing I can easily fix.

If you're using a serial port, simply use Serial.printf("Milliseconds since start: %ld\n", millis());. Other libraries that inherit the Print class (and thus supports printf) are the LiquidCrystal LCD library and the U8G2 graphical LCD library.

Pin macros

Note that you don't have to use the digital pin numbers to refer to the pins. You can also use some predefined macros that maps "Arduino pins" to the port and port number:
// Use PIN_PB5 macro to refer to pin PB5 (Arduino pin 13)
digitalWrite(PIN_PB5, HIGH);
// Results in the exact same compiled codedigitalWrite(13, HIGH);

Programmers

MiniCore does not add its own copies of all the standard programmers to the "Programmer" menu. Just select one of the stock programmers in the "Programmers" menu, and you're ready to "Burn Bootloader" or "Upload Using Programmer".

Select your microcontroller in the boards menu, then select the clock frequency. You'll have to hit "Burn bootloader" in order to set the correct fuses and upload the correct bootloader.

Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time critical operations an external oscillator is recommended.

Write to own flash

MiniCore implements majekw fork of Optiboot, which enables flash writing functionality within the running application. This means that content from e.g. a sensor can be stored in the flash memory directly, without the need of external memory. Flash memory is much faster than EEPROM, and can handle about 10 000 write cycles.

To enable this feature your original bootloader needs to be replaced by the new one. Simply hit "Burn Bootloader", and it's done!

Check out the Optiboot flasher example for more info about how this feature works, and how you can try it on your MiniCore compatible microcontroller.

ATMEGA* Memory & PWM Pins table


ATmega328ATmega168ATmega88ATmega48ATmega8
Flash32kB16kB8kB4kB8kB
RAM2kB1kB1kB512B1kB
EEPROM1kB512B512B256B512B
PWM pins6/9*6663

* ATmega328PB has 9 PWM pins

Supported clock frequencies

Freq.Oscillator typeComment
16 MHzExternal crystal/oscillator
Default clock on most AVR based Arduino boards and MiniCore
20 MHzExternal crystal/oscillator
18.4320 MHzExternal crystal/oscillatorGreat clock for UART communication with no error
14.7456 MHzExternal crystal/oscillatorGreat clock for UART communication with no error
12 MHzExternal crystal/oscillatorUseful when working with USB 1.1 (12 Mbit/s)
11.0592 MHzExternal crystal/oscillatorGreat clock for UART communication with no error
8 MHzExternal crystal/oscillatorCommon clock when working with 3.3V
7.3728 MHzExternal crystal/oscillatorGreat clock for UART communication with no error
4 MHzExternal crystal/oscillator
3.6864 MHzExternal crystal/oscillatorGreat clock for UART communication with no error
2 MHzExternal crystal/oscillator
1.8432 MHzExternal crystal/oscillatorGreat clock for UART communication with no error
1 MHzExternal crystal/oscillator
8 MHzInternal oscillator
Might cause UART upload issues. See comment above this table
4 MHzInternal oscillatorDerived from the 8 MHz internal oscillator
2 MHzInternal oscillatorDerived from the 8 MHz internal oscillator
1 MHzInternal oscillatorDerived from the 8 MHz internal oscillator

Boards Manager Installation

    • This installation method requires Arduino IDE version 1.6.4 or greater.
    • Open the Arduino IDE.
    • Open the File > Preferences menu item.
    • Enter the following URL in Additional Boards Manager URLs
    https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
    • Open the Tools > Board > Boards Manager... menu item.  
    • Wait for the platform indexes to finish downloading.
    • Scroll down until you see the MiniCore entry and click on it.

    • After installation is complete close the Boards Manager window.
    • Note: If you plan to use the *PB series, you need the latest version of the Arduino tool chain. This tool chain is available through IDE 1.8.6 or newer. Here's how you install/enable the tool chain:
    • Open the Tools > Board > Boards Manager... menu item.
    • Wait for the platform indexes to finish downloading.
    • The top is named Arduino AVR boards. Click on this item.
    • Make sure the latest version is installed and selected
    • Close the Boards Manager window.
    • Click Install. 

    Manual Installation

    • Click on the "Download ZIP" button in the upper right corner. Extract the ZIP file, and move the extracted folder to the location "~/Documents/Arduino/hardware". Create the "hardware" folder if it doesn't exist. Open Arduino IDE, and a new category in the boards menu called "MiniCore" will show up.

    Wiring 

    Comments

    Popular posts from this blog

    ATMEGA328P-TQFP32-PINOUT

    Here'a a pinout diagram I created for the ATMEGA328P TQFP32 . It is shared under CC-BY-SA license. You're free to modify it and share. Just give a backlink to my project website if possible (I have not posted the pinout diagram on my website yet. I'm also attaching a PDF,SVG version so that you can edit with any vector editing software. If you want me to create pinout diagrams for other boards, I'd be happy spend some free time on it. Let me know. Hope you'll find it useful :)  Github: https://github.com/Krishnawa/ATMEGA328P-TQFP32-PINOUT

    Arduino-Register Programming

    Simple LED Blink Program Here I'm explained my first register level coding, It is awesome and it's make me much more understand about how the microcontroller is working, I'm still learning, so here I'm sharing what I understood. Are you ready for this then let's go Arduino language Blink program This is simple Blink program without using any functions!. Take a look at the code the same code is converting to register level unsigned long counter = 0 ; // initializing  counter variable and set to 0 void setup ( ) {   pinMode ( LED_BUILTIN , OUTPUT ) ; // set 13th pin LED as output   Serial . begin ( 9600 ) ; // initializing Serial communications } void loop ( ) {   counter ++ ; //increment the counter   Serial . println ( counter ) ; // print the counter value on Serial monitor   if ( counter > 250 ) {     digitalWrite ( LED_BUILTIN , HIGH ) ; // if counter value greater than 250 then LED turn ON   }   if ( counter > 5