Hi,
( I wanted to make a tutorial, for quite some time, on how to debug a AVR firmware on Windows. At least how I do it for my hobbyist projects. )
Assuming that you have a workable avr embedded free pascal cross compiler, you'll need ( at the time of writing ) Lazarus trunk and to download also:
After installing MS7, open Lazarus->Options, select from the left options tree the Debugger->Debugger backend, add a new configuration and select "GNU remote debugger (gdbserver)" for debugger type and put the avr-gdb-8.3 full path ( press the ... button to open the Choose debugger executable ).
Lazarus and MS7's backend agent ( atbackend.exe ) simulator setup :
- Uncheck the Debugger_Remote_DownloadExe.
- In Debugger_Remote_Port put the same port number that you'll use in the MS7's backend agent /avr8-gdb-ports parameter ( see below ).
i.e. 2345
- Drop down the EventProperties and
- in AfterConnect ( press the ... button to open the editor ) add the following :
monitor tool simulator
monitor device [avr device] ( i.e. monitor device atmega328p )
load
break pascalmain
monitor reset
delete breakpoint 1
- in AfterInit you'll need the full path of your project elf file with forward slash dir separator:
i.e. file "G:/Programming/dimitris/Projects/uIP_FP/apps/hello-world/bin/avr-embedded/Debug/hello_world.elf"
- Select ieRunCloseOnStop for InitExec_Mode.
- In InitExec_RemoteTarget put the full path of the MS7's backend agent ( atbackend.exe ) with the parameter /avr8-gdb-ports matching the Debugger_Remote_Port.
i.e. "C:\Program Files (x86)\Atmel\Studio\7.0\atbackend\atbackend.exe" /avr8-gdb-ports=2345
Make sure that the Debugger_Remote_Port also have the same port number.
- Drop down the InternalExceptionBreakPoints
- uncheck the ieRaiseBreakPoint
- uncheck the ieRunErrorBreakPoint.
- Select gdsbMain for InternalStartBreak.
- In RemoteTimeout put something like ~30 - 50.
You'll end up with something like in LazarusATBackend_Simulator image.
Lazarus and MS7's backend agent ( atbackend.exe ) and physical mcu's / boards setup :
- In Debugger_Remote_Port put the same port number that you'll use in the MS7's backend agent /avr8-gdb-ports parameter ( see below ).
i.e. 2345
- Drop down the EventProperties and
- in AfterConnect ( press the ... button to open the editor ) add the following :
monitor tool [avr debugger] [serial] (if needed) ( i.e. for MPLAB SNAP, monitor snap BURXXXXXX )
monitor device [avr device] [debug interface] ( i.e. monitor device atmega328p debugwire)
- Select ieRunCloseOnStop for InitExec_Mode.
- In InitExec_RemoteTarget put the full path of the MS7's backend agent ( atbackend.exe ) with the parameter /avr8-gdb-ports matching the Debugger_Remote_Port.
i.e. "C:\Program Files (x86)\Atmel\Studio\7.0\atbackend\atbackend.exe" /avr8-gdb-ports=2345
Make sure that the Debugger_Remote_Port also have the same port number.
- Drop down the InternalExceptionBreakPoints
- uncheck the ieRaiseBreakPoint
- uncheck the ieRunErrorBreakPoint.
- Select gdsbMain for InternalStartBreak.
- In RemoteTimeout put something like ~30 - 50.
You'll end up with something like in LazarusATBackend_Physical image. ( in the image I'm using a custom mEDBG debugger )
Also, for AVR debugging is better to use dwarf 3 and not dwarf 2. But either is working fine, at least for me .
Happy debugging !
PS: You can see a screenshot ( LazarusAVRDebugSession image ) from an actual Lazarus debugging session using MS7's backend agent ( atbackend.exe ).
regards,