How to use it?
- Download or clone this repository with:
git clone https://github.com/msquirogac/avr-debugger-bootloader
- Customize the
platformio.inifile to match the programmer and board you have. For example, if you have an usbasp programmer and an Arduino Nano, then change it like this:
[env:loader]
upload_protocol = usbasp
board = nanoatmega328new
What you put into board will always depend on the hardware you have, or if you have a personalized one you can also use the generic definition. For example 328p16m means an atmega328p IC with a 16MHz clock. Besides that, you can and should also configure the fuses.
So if you have a bare atmega328p in a breadboard without external crystal then you use 328p8m and change the board_fuses.lfuse to 0xE2. What those magic numbers means?
Easy, just use a calculator like this one. Also remember to configure de baudrate, the default value is 115200, nonetheless low MHz crystals or the internal one aren't suitable for that baudrate, heceforth it should be lowered to 57600 at least.
- Connect your programmer to the board.
- Finally, compile and program the bootloader with:
pio run -t fuses && pio run -t program
Done!! Now your board has the avr-debugger bootloader installed and is able to use the Flash breakpoint mode. The major difference with the regular one comes when you use the avr-debugger library, which means that you don't need to revert to the regular one even if you don't need this library anymore.