#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
This page is dedicated to the installation and configuration of
the free-software on-chip debugger
<
>tool for various hardware architectures known as OpenOCD on Debian.
<
>
[[http://openocd.org/|OpenOCD]]
<
>
[[http://openocd.org/doc/pdf/openocd.pdf|OpenOCD User's Guide]]
<
>
----
<>
----
== What is OpenOCD ? ==
OpenOCD is a free-software tool mainly used for on-chip debugging, in-system
<
>programming and boundary-scan testing.
OpenOCD supports flashing and
<
>debugging a wide variety of platforms such as:
* ARMv5 through latest ARMv8
* MIPS
* AVR (incomplete)
* Andes
* RISC-V
The full list of supported CPU types can be accessed here: [[http://openocd.org/doc/html/CPU-Configuration.html|User's Guide ]].
<
>
The tool can be easily installed on x86_64,i386 and ARM hosts
<
> running Debian (as well as many other Unix-Like Operating Systems)
----
== Installation ==
=== Considerations ===
The OpenOCD tool can be found in Debian's repositories by default and installing
works as expected.
<
>
'''However''', (especially if you are running oldstable (Debian 9)), the packaged version
<
> might '''not''' coincide with the latest stable release of OpenOCD.
<
>Thus, depending on the latest changelog, you might be missing board configuration file additions, bug fixes, etc.
<
>
Installing via xpm, albeit lengthier, ensures an updated
<
> package version '''and''' automatic integration with Eclipse Plugins (Gnu-ARM-Eclipse).
=== Installing via the package manager ===
{{{sudo apt-get install openocd}}}
=== Installing via xpm (latest) ===
0.If applicable, remove previous installs of npm (local prefix) with:
{{{sudo rm -rf /usr/local/lib/nodejs}}}
<
>
{{{rm -rf ~/opt/npm}}}
<
>
{{{npm config delete prefix}}}
<
>
1.Install Node.js and npm with nvm
<
>
<
>
{{{curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash}}}
<
>
{{{bash}}}
<
>
{{{nvm install --lts node}}}
<
>
{{{nvm ls}}}
<
>
{{{nvm use node}}}
<
>
{{{node --version}}}
<
>
{{{nvm install-latest-npm}}}
<
>
{{{which npm}}}
<
>
<
>
2.Install xpm (openocd is provided as a dev-tool pack for xpm)
<
>
{{{npm install --global xpm@latest}}}
<
>
{{{which xpm}}}
<
>
{{{xpm --version}}}
<
>
<
>
3.Install openocd via xpm
<
>
{{{xpm install --global @xpack-dev-tools/openocd@latest}}}
<
>
<
>
If no errors are reported, OpenOCD should be installed
<
> at the following location (Substitute $user with your username <
>and $ver with your current version of the software):
<
> {{{/home/$user/opt/xPacks/@xpack-dev-tools/openocd/$ver/.content/bin/}}}
<
> <
>
Symlinking the executable to another location such as {{{/usr/bin}}} might be of interest: <
>
{{{ln -s /home/$user/opt/xPacks/@xpack-dev-tools/openocd/$ver/.content/bin/openocd /usr/bin/openocd}}}
----
== Configuration ==
The provided manual page for OpenOCD will guide you through most
<
> of its many switches and modes.
<
>Make sure to locate/create your board.cfg file which contains
<
>necessary hardware information, required for flashing/debugging.
<
>A sample shell script which flashes a firmware.hex to a STM32 development
<
>board with OpenOCD is provided below (edit your firmware.hex location and
<
>board.cfg file and you can confidently use this as a quick flash tool)
{{{
#!/bin/bash
echo "OPEN-OCD FOR STM32F4_Discovery_MP3 PROJECT BUILD !";
cd /home/worker/opt/xPacks/@xpack-dev-tools/openocd/0.10.0-13.1/.content/bin
sudo ./openocd -d-1 -f ../scripts/board/stm32f4discovery.cfg -c "init;targets;halt;flash write_image erase /home/worker/progs/stm32/STM32F4_Discovery_MP3/build/stm32f4_discovery_mp3.hex;shutdown"
}}}
## You can add other _helpful_ links here.
##== See also ==
----
## If this page belongs to an existing Category, add it below.
DebianSoftware | ProgrammingApplication