You should see something like the image below. Then in the command line, navigate to C:\GDB_OpenOCD_init and run CodeSourcery GDB. To test the init script, start OpenOCD as normal. Alternatively, name the file gdbinit without a period and then rename it from the command line: Note that in Windows Explorer you can't give a file a name that begins with a period. The init script should halt the target, but just in case # Reset the target and call its init script
Copy the code below into the file:Įcho Executing GDB with. Create a new folder on your C:\ drive called GDB_OpenOCD_init, and create a new text file in that folder. You can use the script below to have GDB automatically connect to OpenOCD and run reset init on the target. GDB looks for it in the current working directory.
Instead of typing commands yourself every time you start GDB, you can create a script to always start GDB with the same series of commands. This changes the current directory only for GDB, not for Linux when you exit GDB, you will be back in the directory where you started. You can use the Linux command cd to change the current working directory in GDB. You can see a list of common OpenOCD commands here. Type monitor, then the command, then enter. You can send commands to OpenOCD through GDB just like you can through a telnet connection. If you don't run monitor reset init, you will encounter errors like this: You need to do this while GDB is connected to the OpenOCD, or you won't be able to halt or reset the target. Use the monitor command to tell GDB to send the command to OpenOCD, like this:
Don't actually type the characters (gdb).)īefore doing anything else, run reset init on the target. (In this guide if you see (gdb) at the beginning of a command, that means enter that line into the GDB command prompt. In GDB, connect to OpenOCD by typing target remote localhost:3333. OpenOCD listens for GDB connections on port 3333. To connect to OpenOCD, start GDB as above: Run OpenOCD as normal, as described in Running OpenOCD on Windows. You can also run GDB directly from "Run" in the Start menu.Įither way you should look like the image below, with a prompt reading (gdb) in place of the normal > command prompt.
If you're unsure how to open the Windows command console, see Running OpenOCD on Windows. In the windows command console, type arm-none-eabi-gdb and press Enter. It also adds this path to your system PATH variable so you can run arm-none-eabi-gdb and other tools from any directory. The installer installs the CodeSourcery toolchain, by default to C:\Program Files\CodeSourcery\Sourcery G++ Lite (or C:\Program Files (x86)\CodeSourcery\Sourcery G++ Lite on 64-bit Windows).
This guide will assume that you choose the default option on each page. You should see a loading bar followed by an installer GUI. Direct link to the Windows installer is here.ĭownload and run the installer. Installing the CodeSourcery ARM ToolchainĬodeSourcery provides development tools for use with embedded devices, including a GCC cross-compiler and a GDB build for ARM targets. One such GDB build is provided with the CodeSourcery ARM toolchain.
You will need to download or compile a version of GDB that supports embedded devices. OpenOCD's configure script already includes the -g flag.
The -g flag tells the gcc compiler to build with GDB support. If you have installed OpenOCD according to the guides on the Compiling OpenOCD page, your version of OpenOCD already supports GDB. The configure script provided with OpenOCD 0.5.0 already compiles OpenOCD to support the GDB debugger. 2 Installing the CodeSourcery ARM Toolchain.