Re: [AVaRICE-user] avr-gdb connects,but there is no prompt.

2021-06-26 Thread Joerg Wunsch
As Istvan Retaller wrote:

> > /usr/bin/avr-objcopy -j .text    \     -j .data
> > \     -O ihex testburst.out testburst.hex /usr/bin/avrdude -F -c jtag2isp
> > -P usb -B 10 -b 115200 -p t45 -e -U flash:w:testburst.hex -U
> lfuse:w:0x62:m -U hfuse:w:0x9f:m -U efuse:w:0xff:m avrdude:

Only as a side note: you can do all of this straight from the ELF
file, no need to objcopy into an Intel hex file.

As another side note, since you are already in debugWIRE mode: fuses
cannot be programmed at all in this mode. (Technically, debugWIRE is a
kind of ROM-based monitor program, so it can only access those
resources the CPU can reach. Fuses and lock bits don't belong to
that.)

In your case, the fuse "programming" just passes since they are not
changed at all.

> *I start avr-gdb in a new terminal**
> **The gdbinit content is_as follows:*
> /target remote localhost:4242//
> //break main//
> //continue/

Well, for a first test, you'd better leave out the gdbinit file.

> Pressing ^C I get a prompt and now gdb accepts commands.
> However I do not know how got to this point and what was done to get there.
> 
> 
> > Program received signal SIGINT, Interrupt. 0x0194 in __vector_3 ()
> > at testburst.c:122 122    } (gdb)

Your gdbinit doesn't only attach to AVaRICE, but sets a breakpoint on
main and tries proceeding there. As that breakpoint is never reached,
you have to manually stop it with ^C, and then it is presumably inside
the timer 1 compare A interrupt vector.

Something appears to not really match here: if main() really hasn't
ever been reached, how would interrupts become enabled so it could hit
an ISR? Maybe the actual flashing by AVRDUDE didn't work, so you are
debugging an entirely different firmware?

What you could try:

target remote :4242
display/i $pc

then repeatedly use the

si (step CPU instruction)

command, and watch the CPU instructions passing by, comparing them
with you disassemble file. Also, you could use the "disas" GDB
instruction, or "x" the hexdump the flash contents, and compare it to
what you think ought to be there.

-- 
cheers, Joerg   .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)


___
avarice-user mailing list
avarice-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avarice-user


[AVaRICE-user] avr-gdb connects,but there is no prompt.

2021-06-26 Thread Istvan Retaller
Hi all, here is a weird thing I cannot overcome: avr-gdb connects, but 
there is no prompt. Pressing ^C I get a prompt and now gdb accepts commands.
However I do not know how got to this point and what was done to get 
there.Here is what I do:


*steve@Apa:~/projects/avr/testburst$ make*

    /usr/bin/avr-gcc -D F_CPU=800 -I.  -ggdb -mmcu=attiny45 -Os 
-fpack-struct -fshort-enums -gdwarf-2 -std=gnu99 -funsigned-bitfields 
-funsigned-char -Wall -Wstrict-prototypes -Wa,-ahlms=testburst.lst -c 
testburst.c -o testburst.o
    /usr/bin/avr-gcc -D F_CPU=800 
-Wl,--no-undefined,-Map,testburst.out.map -mmcu=attiny45 -L  -lm  -o 
testburst.out testburst.o



*Flash program and enable debugwire:*

*steve@Apa:~/projects/avr/testburst$ make dwflash*

> /usr/bin/avr-objcopy -j .text    \     -j .data
> \     -O ihex testburst.out testburst.hex /usr/bin/avrdude -F -c jtag2isp
> -P usb -B 10 -b 115200 -p t45 -e -U flash:w:testburst.hex -U 
lfuse:w:0x62:m -U hfuse:w:0x9f:m -U efuse:w:0xff:m avrdude:

> jtagmkII_setparm(): bad response to set parameter command: RSP_FAILED
> avrdude: jtagmkII_getsync(): ISP activation failed, trying debugWire
> avrdude: Target prepared for ISP, signed off. avrdude: Now retrying
> without power-cycling the target.
>
> avrdude: AVR device initialized and ready to accept instructions
>
> Reading | ## | 100%
> 0.02s
>
> avrdude: Device signature = 0x1e9206 (probably t45) avrdude: erasing
> chip avrdude: reading input file "testburst.hex" avrdude: input file
> testburst.hex auto detected as Intel Hex avrdude: writing flash (482
> bytes):
>
> Writing | ## | 100%
> 0.30s
>
> avrdude: 482 bytes of flash written avrdude: verifying flash memory
> against testburst.hex: avrdude: load data flash data from input file
> testburst.hex: avrdude: input file testburst.hex auto detected as
> Intel Hex avrdude: input file testburst.hex contains 482 bytes
> avrdude: reading on-chip flash data:
>
> Reading | ## | 100%
> 0.31s
>
> avrdude: verifying ... avrdude: 482 bytes of flash verified avrdude:
> reading input file "0x62" avrdude: writing lfuse (1 bytes):
>
> Writing | ## | 100%
> 0.02s
>
> avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory
> against 0x62: avrdude: load data lfuse data from input file 0x62:
> avrdude: input file 0x62 contains 1 bytes avrdude: reading on-chip
> lfuse data:
>
> Reading | ## | 100%
> 0.01s
>
> avrdude: verifying ... avrdude: 1 bytes of lfuse verified avrdude:
> reading input file "0x9f" avrdude: writing hfuse (1 bytes):
>
> Writing | ## | 100%
> 0.02s
>
> avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory
> against 0x9f: avrdude: load data hfuse data from input file 0x9f:
> avrdude: input file 0x9f contains 1 bytes avrdude: reading on-chip
> hfuse data:
>
> Reading | ## | 100%
> 0.01s
>
> avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude:
> reading input file "0xff" avrdude: writing efuse (1 bytes):
>
> Writing | ## | 100%
> 0.02s
>
> avrdude: 1 bytes of efuse written avrdude: verifying efuse memory
> against 0xff: avrdude: load data efuse data from input file 0xff:
> avrdude: input file 0xff contains 1 bytes avrdude: reading on-chip
> efuse data:
>
> Reading | ## | 100%
> 0.01s
>
> avrdude: verifying ... avrdude: 1 bytes of efuse verified
>
> avrdude: safemode: Fuses OK (E:FF, H:9F, L:62)
>
> avrdude done.  Thank you.


*Trying debug*

*steve@Apa:~/projects/avr/testburst$ avarice -w -P attiny45 --jtag 
usb:24cf  --mkII :4242 &*



> AVaRICE version 2.14, Sep 17 2020 16:15:33
>
> JTAG config starting. Found a device: JTAGICEmkII Serial number:
> 00:b0:00:00:24:cf Reported debugWire device ID: 0x9206 Configured for
> device ID: 0x9206 attiny45 -- Matched with attiny45 JTAG config
> complete. Preparing the target device for On Chip Debugging. Waiting
> for connection on port 4242.





*I start avr-gdb in a new terminal**
**The gdbinit content is_as follows:*
/target remote localhost:4242//
//break main//
//continue/


*steve@Apa:~/projects/avr/testburst$ avr-gdb testburst.out -x gdbinit*

> GNU gdb (GDB) 10.1.90.20210103-git Copyright (C) 2021 Free Software
> Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
>  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-linux-gnu --target=avr".
> Type "show configuration" for configuration details. For bug reporting
> instructions,