-
Notifications
You must be signed in to change notification settings - Fork 29
6. Examples
- In case you don't have installed "arm-none-eabi-gdb", download it. It is included in the "gcc-arm-none-eabi" package from ARM Developer.
- Linux users may need to download the pre-compiled version instead of using "apt-get install arm-none-eabi" to get the ARM GDB.
sudo apt-get install openocd
sudo brew install openocd
In certain situations where using a package manager or self-compiling OpenOCD is impractical, several community members provide regularly updated binary builds on their websites.
-
Liviu Ionescu maintains multi-platform binaries, including Windows 32/64-bit, Intel GNU/Linux 32/64-bit, Arm GNU/Linux 32/64-bit, and Intel macOS 64-bit as part of The xPack OpenOCD project.
-
The official GitHub mirror automatically generates Windows binary archives for releases and all master commits.
OpenOCD
- Execute OpenOCD by calling your configuration file for your microcontroller.
You can create your own configuration file or download the provided ones in the main repository.
Example:
sudo openocd -f saml21.cfg
The flag "-f" loads a specific file from your system. The example assumes you have the file "saml21.cfg" in the same folder you're executing OpenOCD from.
Note: In Windows, there is no "sudo" command. Execute the Command Prompt as an administrator.
If your microcontroller is well-connected, you should see something like this:
At this point, everything is well connected to OpenOCD, and you have a running GDB server on your machine at port 3333.
Now we need to connect to the GDB server using the client previously installed with the ARM GCC toolchain.
To invoke it, simply type:
arm-none-eabi-gdb
Once GDB is running, we need to connect to OpenOCD with one of the following commands:
- When the debugged program exits or you detach from it, GDB disconnects from the target.
target remote localhost:3333
- When the debugged program exits or you detach from it, GDB remains connected to the target.
target extended-remote localhost:3333
Choose one of the above options.
Now you're connected to the OpenOCD GDB server.
Once connected, you're able to debug and flash your microcontroller.
To flash, use the following commands:
- monitor reset halt
- set mem inaccessible-by-default off
- load yourBinary.elf
- q
A single command to initialize GDB:
arm-none-eabi-gdb -ex 'target extended-remote localhost:3333'
A single command to flash with GDB:
arm-none-eabi-gdb yourBinary.elf -ex 'target extended-remote localhost:3333' -ex 'load' -ex 'q'
Thank you for reading our Wiki!