jdolinay / avr_debug

Source level debugger for Arduino - GDB stub for Atmega328 microcontroller used in Arduino Uno.
GNU Lesser General Public License v3.0
139 stars 33 forks source link

Flash mode debugging does not work with optiboot.hex bootloader. #51

Open markjl140 opened 1 year ago

markjl140 commented 1 year ago

On an atmega328 the optiboot.hex bootloader in avr_debug/bootloader/optiboot/Debug writes 44 as the version number in 7ffe, 7fff but avr8-stub checks for and requires >= 8 in 7fff when AVR8_BREAKPOINT_MODE == 2. The debugging in this mode works correctly with an optiboot bootloader >= 8 major version.

jdolinay commented 1 year ago

Hi, the bootloader in avr_debug/bootloader/optiboot/Debug can be used only in AVR8_BREAKPOINT_MODE=0. It is a modified version of optiboot 4.4 that's why the version 44.

Before optiboot version 8.0 it was not possible to write to flash memory (needed for flash breakpoints), so I created this custom version of optiboot with functions for writing to flash. Now with optiboot version 8+ there is native support for writing to flash, but I kept the modified bootloader as another option (it provides some extra functions).

So there are currently 2 options for flash breakpoints:

Please see the doc/avr_debug.pdf, page 62 (How to enable breakpoints in flash memory) for more info on this.