avrdudes / avarice

AVaRICE is a program for interfacing the Atmel JTAG ICE to GDB to allow users to debug their embedded AVR target.
GNU General Public License v2.0
38 stars 12 forks source link

[bug #23] program fuse bits through avr-gdb, avarice and debugwire #23

Open avrs-admin opened 2 years ago

avrs-admin commented 2 years ago

seplog 2016-03-11 21:06:41.971000

Hey,

there exist a problem with avarice with the program loading within the avr-gdb. If there are fuse bits defined in the source code, then it is not possible to load the program with avr-gdb. Here is a short example code

#include <avr/io.h>

FUSES =
{
    .low = FUSE_CKSEL0 & FUSE_SUT1,
    .high = FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_EESAVE & FUSE_SPIEN,
    .extended = FUSE_BODLEVEL0 & FUSE_HWBE,
};

int __attribute__((OS_main)) main( void ) {
    while(1);
    return 0;
}

I compiled this with:

avr-gcc -mmcu=atmega32u2 -O0 -g -o firmware.elf main.c

For the ATmega32U2. Debugwire is enabled. For debugging I use a Atmel JTAGICE mkII. To use avarice with th ATmega32U2 I used this patch. I've started avarice with:

$ avarice -2 -P atmega32u2 -w -j usb -C :4242 -d

and avr-gdb:

$ avr-gdb firmware.elf 
GNU gdb (Gentoo 7.11 vanilla) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from firmware.elf...done.
(gdb) target remote :4242
Remote debugging using :4242
main () at main.c:11
11          while(1);
(gdb) load
Loading section .fuse, size 0x3 lma 0x820000
Load failed
(gdb) quit
A debugging session is active.

        Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y

The avarice log file is attached.

Greetings sep

This issue was migrated from https://sourceforge.net/p/avarice/bugs/23/

avrs-admin commented 2 years ago

jesultra 2016-03-25 18:46:02.318000

The DebugWire protocol does not support setting fuses, you will have to use ISP (or high-voltage programming) load such a program - at least initially.

Regards Jes

avrs-admin commented 2 years ago

joerg_wunsch 2016-03-25 19:20:33.874000

The DebugWire protocol does not support setting fuses

That's not the point. The point is that attempt to program fuses should be silently discarded, so GDB will proceed.