Closed wenhuizhang closed 7 years ago
Won't work with 'gdb' you need to use 'avr-gdb' -- As the message This GDB was configured as "x86_64-linux-gnu" suggest, it won't grock AVR.
Got it, thanks for your insights and suggestions , I will give it a try and let you know how it goes
Hi, thanks so much , @buserror , I tried to connect it to avr-gdb, still got some issues, any suggestions?
// test: led.c
#ifndef F_CPU
#define F_CPU 16000000UL // or whatever may be your frequency
#endif
#include <avr/io.h>
#include <util/delay.h> // for _delay_ms()
int main(void)
{
DDRC = 0x01; // initialize port C
while(1)
{
// LED on
PORTC = 0b00000001; // PC0 = High = Vcc
_delay_ms(500); // wait 500 milliseconds
//LED off
PORTC = 0b00000000; // PC0 = Low = 0v
_delay_ms(500); // wait 500 milliseconds
}
}
avr-gcc -g -Os -mmcu=atmega2560 -c led.c
avr-gcc -g -mmcu=atmega2560 -o led.elf led.o
client-130-203-90-97:simavr WenhuiZhang$ sudo ./run_avr -m atmega2560 -f 9600 -g /Users/WenhuiZhang/Downloads/Arduino_Project/env_test/led.hex
Loaded 1 section of ihex
Load HEX flash 00000000, 306
avr_gdb_init listening on port 1234
gdb_network_handler connection opened
(gdb) bt
#0 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
(gdb) down
Bottom (innermost) frame selected; you cannot go down.
(gdb) down
Bottom (innermost) frame selected; you cannot go down.
(gdb) up
Initial frame selected; you cannot go up.
(gdb) up
Initial frame selected; you cannot go up.
(gdb) frame
#0 0x00000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
Cannot access memory at address 0x802201
(gdb) fram e
No symbol table is loaded. Use the "file" command.
(gdb) frame
#0 0x00000000 in ?? ()
(gdb) backtrace
#0 0x00000000 in ?? ()
Whats your problem there? you tell it to stop with -g, so it doesn't run and wait at the reset vector at 0x0... and there is no stack frame anyway, so 'down' 'up' and 'backtrace' won't do a thing...
try 'cont' then hit control-c... but then again there's only main is being called, and likely without a return address either, so you won't be able to see a stack there...
Got it, yet the thing is that, it seems like there is no func table in .hex, they are in .elf, and some func are not searchable.
That's not really a simavr bug either ;-)
Hi, I tried remote debug, yet not sure how it works, any idea on which command I should I use please?