I have had only minimal success thus far debugging with arm-elf-insight and OpenOCD.
I was able to debug in ram using sw-breakpoints and my elf file.
I could download to the target and hit my breakpoint in main() but as soon as I start the vTaskStartScheduler() at the end of main(), I never hit another breakpoint.
This is my environment:
Board: Olimex LPC2148, BSL is grounded.
Software: FreeRTOS ported to lpc2148 plus test code
JTAG Interface: Olimex Wiggler, LPT1 is using EPP, not ECP.
OpenOCD: Using parallel port and lpc2148_pp.cfg (below, in the code section)
Compiler Toolchain: GNUARM 4.1.1
arm-elf-insight: 6.5.0.20060626-cvs, with the “monitor arm7_9 sw_bkpts enable”
please make sure you’re using the latest version of OpenOCD. You can get precompiled binaries from www.yagarto.de.
Regarding your individual problems:
You have to use the “arm7_9 force_hw_bkpts enable” command. You can use it on the telnet command interface, put it in a .gdbinit file, or you can issue it via Insight, but you have to prepend it with “monitor” if it’s not used via telnet.
Insight isn’t meant to use .bin files, these lack all the debug information. The .bin files are only necessary when using the OpenOCD to write to the target, either to RAM (load_binary command) or flash (flash write command). For Insight, use the ELF output file.
I suppose lpc2148_freertos.elf was built to be run from flash. That’s why Insight/GDB tried to write to address 0x0, which (of course) failed, as there’s only flash at that address.
If you want to debug code running in flash, you have to manually write the target flash. This can be done either from a telnet session, or from within Insight/GDB (For Insight/GDB use the ‘monitor’ keyword):
flash probe 0
flash erase 0 0
flash write 0 /path/to/binary 0x0
After that, don’t use the “Download” command. Use a “monitor soft_reset_halt” to initialize the ARM core, and continue execution from there, or reset the target, and attach later. It is not possible to debug a LPC2000 uC “out of reset”, as the content read protection (CRP) prevents that (even if CRP is not enabled).
You could work around this problem by placing a loop that does many iterations at the beginning of your main() for example. Flash the target, reset it, and attach the debugger. The OpenOCD should have caught your target before it was able to complete the loop. You can then manually advance the loop counter so that the loop is quit.
Mifi’s versions are the most official binary releases available, so that’s fine.
Keep in mind that you can only have two breakpoints when debugging code in flash. This is a limitation of the ARM debug system. If you want to single-step your code, delete or disable your breakpoints, and enable them again before you’re ready to 'c’ontinue.
I tried what you suggested and I still have issues.
I followed these steps:
Start openocd
Open insight
Load lpc2148_freertos.elf (built for debugging in flash with a beginning loop)
Connect insight to target
Downloaded lpc2148_freertos.bin to the target (using your method)
Reset the target
Clicked “run” icon
Output from the insight console:
(gdb) monitor flash probe 0
flash 'lpc2000' found at 0x00000000
(gdb) monitor flash erase 0 0 26
erased sectors 0 through 26 on flash bank 0 in 0s 531250us
(gdb) monitor flash write 0
F:\EclipseWorkspace\FreeRTOS_LPC2148\lpc2148_freertos.bin 0x0
wrote file F:\EclipseWorkspace\FreeRTOS_LPC2148\lpc2148_freertos.bin to flash bank 0 at offset 0x00000000 in 2s 250000us
wrote file F:\EclipseWorkspace\FreeRTOS_LPC2148\lpc2148_freertos.bin to flash bank 0 at offset 0x00000000 in 2s 250000us
(gdb) monitor arm7_9 force_hw_bkpts enable
force hardware breakpoints enabled
(gdb) monitor soft_reset_halt
requesting target halt and executing a soft reset
(gdb)
Output from the insight debugger window:
Screen is blank (where the source code should be)
On the bottom text bar there is "Program stopped at 0x7fffd2c0.
The only icon that is active now is the “stop” icon.
When I click it, it takes a few seconds for insight to respond and I get a warning pop-up that says: “Program received signal SIGINT, Interrupt”
Is there something I have to do in my code to “enable” debugging?
Are there some IO settings I need?
Does the chip need a certain config in the pin connect block?
Does the PLL need to be disabled?
I think I am very close to having this working… any more hints would be very helpful and much appreciated.
I am old fashioned (and old) and think that the first ting to do is to debug the HelloWorld.bin/elf program or the simple Blinky using the telnet interface. Without using any long scripts but writing the command in the telnet window, reading the result, checking the debug output in the openocd window, before entering the next command.
YES This is slow, silly and oldfashioned (copy/paste from a text editor into the command window is allowed) but will teach us some good things:
does the basic communication work
we will learn the openocd commands, and understand the error messages
is the setup OK
is it a problem writing to flash or is my code buggy
can we halt/resume/reset, display memeory etc. directly before asking insight/gdb to do it for us
Programming Power is knowing more than your tools !!!