Problems debugging with ARM-USB-OCD (solved)

Hello. I am a student and my experience with microcontrollers has been using pre-configured windows computers, running IAR and working with the HC12 (under the watchful and helpful eye of the lab supervisor).

Well, I have moved on to working with the Olimex SAM7-P256 development board outside of university, taking the open source route using Eclipse and OpenOCD. It has been quite a learning experience getting everything set up, and not having my trusty lab supervisor to quiz at every wrong turn :slight_smile:

I have found James Lynch’s document very helpful, and I am successfully running code on my board. My question relates to debugging. I am reading from revision C (it is the latest I could find).

I am a little stuck when it comes to debugging. I attempt to follow the instructions on page 129, but when I get to page 131 I run into a problem when entering ‘commands’. In his description he shows Eclipse as having two text boxes for entering ‘Initialise’ and ‘Run’ commands, but my version (3.2.0) only has one window for ‘Commands’.

Also, (this will show me to be the extreme novice I am), he discusses using the main.out file. My projects are usually built on top of demonstration projects, or other examples that I can modify. Some of my projects aren’t generating a main.out (which I can see is instructed in the makefile), but they are generating a .elf file…am I correct in assuming I can use this file instead?

Also, in his images he has left the GDB command file section blank, but in mine I have ‘.gdbinit’ as default. Removing it doesn’t seem to do anything, but I’d like to know if it’s better to remove it or keep it.

Finally, when I attempt to debug (leaving the ‘Commands’ section I mentioned before blank), and enter those commands from James Lynch’s document into the console, I get this:

(gdb) target remote localhost:3333
localhost:3333: Connection refused.

and any other commands I attempt to enter say something along the lines of “monitor” command not supported by this target (which I can assume is because I never successfully set a target with that first line).

As you can tell, I am very green, but I am learning a lot and loving it…I just wish I could get this debugger working. Any advice would be much appreciated.

One last thing, I downloaded the IAR embedded workbench kick start, but I can’t find a way to tell IAR to use my ARM-USB-OCD. From trawling the internet, it looks as though it is unsupported at the moment. Does anyone have any information to the contrary?

Thanks in advance for any help.

Well, I figured it out for myself a couple of weeks ago (been away for christmas), fairly simple stuff I guess.

The reason my debugger could never find a connection to the localhost port was because openocd was running a shutdown command at the end of its normal run, so I removed the shutdown line from the end of the script.ocd file.

edit: oh and I am running openocd from the command line because it loops endlessly in eclipse if the shutdown line is removed :frowning:

As for the commands, it doesn’t seem to matter that there isn’t two windows for init and run, I just copied them into the single command window and they work fine. I left the GDB command file blank, and I changed the reference to the main.out file to the .elf file…it hasn’t had any errors and I am successfully debugging (stepping into, over etc.), but I still am unclear about the differences between the .out and .elf files. They seem to work fine with the debugger though :stuck_out_tongue:

edit: actually it is a bit temperamental about the commands, sometimes I just have to leave it blank and type them in myself

Hope this info is helpful to any extreme novices like myself who get caught on this little stumbling block (seems so simple now that I have sorted it heh)

StrugglingMike:
edit: oh and I am running openocd from the command line because it loops endlessly in eclipse if the shutdown line is removed :frowning:

That's what it should do, so what's the problem? You can run more than 1 "process" via Eclipse without any problems.

4/3!!

Thanks for your reply. When I say it loops endlessly, I mean it runs the instructions in script.ocd over and over again, which restarts and copies the program into flash over and over.

Since then I have come upon a more elegant solution, I added another instance of openocd to the eclipse external tools, which points to another working directory containing a stripped down script.ocd, containing only the two following commands

wait_halt			# halt the processor and wait
armv4_5 core_state arm	# select the core state

I am not sure if I even need those, but since then, I can run that instance of openocd in eclipse without any trouble.

Also, I upgraded the compiler I was using from 4.0.2 to 4.4.2, and when using the arm-elf-gdb that came with the new version, I can use the commands copied into the interface in eclipse consistently and without errors. This workstation was set up for me so I hadn’t thought to upgrade the compiler but I am glad I did. In the commands I omit the line containing the symbol-file command though because I can’t get it to point to the file properly, but it doesn’t seem to cause any trouble…

Unless it is the cause of some issues I get occasionally with the debugger locking in the BOARD_RemapRam routine in board_lowlevel.c, or sitting in the default spurious interrupt handler, but after a reset it halts at main and I can get down to business.

It has been a learning experience but very rewarding, and I am not so afraid of the whole thing anymore :slight_smile: