Skip to content
Sandro Benigno edited this page Jul 8, 2024 · 6 revisions

To program the board for the first time by adding a bootloader, there is an ICSP (In Circuit Serial Programming) port available.
This can be done by softwares like AVRDUDE or Microchip Studio through a hardware like USBASP or AVRISP.

This port also exposes some useful pins:

  • MOSI is the digital pin ~D11 (wich is PWM capable).
  • MISO is the digital pin D12.
  • SCK is the digital pin D13.

ICSP programming port.

We need to write a bootloader and set the fuses the first time.

Note: We recently switched from the Uno's bootloader to the one used on the "Arduino Pro or Pro Mini."
That's why the high fuse is set to 0xDA instead of 0xDE.
Thanks to Steve Daniels from Toronto Metropolitan University for diving into it and identifying this need.

The command line below is an example with a usbasp programmer on avrdude:

avrdude -c usbasp -p m328p -P usb -B 4 -e -U flash:w:"wrboot.hex":a -U lfuse:w:0xFF:m -U hfuse:w:0xDA:m -U efuse:w:0xFD:m

A new chip is usually factory-set to use an internal clock of 1 MHz.
The "-B 4" option is for first time writing to a new Atmega 328p chip.
In this way, the clock is divided by 4 so that programmer can communicate with the chip.
Setting the fuse bits in the command line above will configure, among other things, the external clock, using the board's 16MHz resonator.

Clone this wiki locally