Bootloader has been installed...now what ?

Hi folks,

I have built a PCB (see picture) that fits on a UNO to allow me to install a bootloader on a ATMega328/ATMega328P. It works fine ! It is based on this setup:

Q1: First question: when I "push" the bootloader to an ATMega328, in order to test it, I normally place it into another UNO, and upload the basic "Blink" sketch ... I noticed that in order to be successful, when I install the bootloader, the UNO board has to be selected.

Does that mean that there is more than one bootloader version ? My intention by installing a bootloader, is to be able to upload an Arduino sketch into a 328, and use it on a custom PCB.

Q2: If there are many flavors of the bootloader, and if I had selected the UNO, does that mean that in order to be able to upload a sketch in that newly bootloaded chip, I will have to make Arduino believe that it is actually a UNO ?

Q3: if I use the wiring like in the post mentioned above, and upload a sketch as a UNO, will I need to install a crystal on my circuit ? Can I use the internal oscillator ? do I need to set some config/fuse ?

Thanks,

problem uploading the picture …

The image:-
150217972aca326fb28cd3af44f2fcd90467d40c.jpg

for whatever reason, it took me a couple of times to be able to reply and add the image...It was part of the original post, but the picture didn't make it !

When you upload the bootloader to an Atmega 328 it makes the 328 appear to the IDE as an Uno hence when you want to upload code to the new chip you need to tell the IDE that you are using an Uno even if the 328 is in a breadboard or a custom PCB. (I am assuming you are planning to run the 328 at 16MHz).

...R

jasmino:
Does that mean that there is more than one bootloader version ?

Yes, there are multiple bootloaders included with the Arduino IDE and also 3rd party bootloaders available. Some of the Arduino boards do use the same bootloader, for example, the Arduino Nano/ATmega328 and Arduino Pro or Pro Mini/ATmega328 (5V, 16 MHz) use the same bootloader, atmega/ATmegaBOOT_168_atmega328.hex.

jasmino:
Q2: If there are many flavors of the bootloader, and if I had selected the UNO, does that mean that in order to be able to upload a sketch in that newly bootloaded chip, I will have to make Arduino believe that it is actually a UNO ?

When you do Tools > Burn Bootloader. Two things happen, the fuses on the microcontroller are set and the bootloader is uploaded to the microcontroller. The fuses configure things like the the clock source(e.g. external crystal or internal oscillator) and how large a boot section the bootloader requires

The way that the IDE knows which settings to use is by reading the boards.txt entry for the current selection in the Tools > Board menu. You should open up the Arduino AVR Boards boards.txt file in a text editor and check it out. It's located at {Arduino IDE installation folder}/hardware/arduino/avr/boards.txt or Arduino15/packages/arduino/hardware/avr/{current Arduino AVR Boards version}/boards.txt. You can locate your Arduino15 folder by checking File > Preferences > More preferences can be edited directly in the file.

In order to upload a sketch, the IDE needs to know the clock speed(determined by the fuse setting and the crystal frequency), the baud rate of the bootloader, which microcontroller model, and how much program space is available. As long as the settings match your board any boards.txt could be used, regardless of what was selected when you burned the bootloader. For example, you could burn bootloader with Arduino Nano/ATmega328 selected and upload with Arduino Pro or Pro Mini/ATmega328 (5V, 16 MHz) and it won't matter because they have the same settings but if you burn bootloader with Arduino/Genuino Uno selected those other boards won't work because the upload.speed values are different. Also the upload.maximum_size values are different because the Uno bootloader is smaller which would cause the IDE to think a 31kB sketch was too large when there is actually 31.5kB of space available on a board with the smaller bootloader the Uno uses.

jasmino:
Q3: if I use the wiring like in the post mentioned above, and upload a sketch as a UNO, will I need to install a crystal on my circuit ? Can I use the internal oscillator ? do I need to set some config/fuse ?

That's correct. The fuses need to be set differently and the build.f_cpu value needs to be set to the correct value. If you want all this done for you check out GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB. It's simple to install and has options for any ATmega328/ATmega328P configuration you could want and uses the Optiboot bootloader similar to the Uno.

to Pert :

WOW !

That's the kind of answer that everyone expect: informative, precise and interesting !

Thanks. Working on it tonight !