Checkout OpenOCD sources:
Clone git repository. This will create a folder called openocd-src:
git clone --depth 1 git://git.code.sf.net/p/openocd/code openocd-src
Install dependency packages for OpenOCD build:
sudo apt build-dep openocd
If you see an error like:
E: You must put some 'source' URIs in your sources.list
Then add src-deb repositories to /etc/apt/sources.list
sudo apt update sudo apt build-dep openocd
Build OpenOCD from source:
cd openocd-src/ CFLAGS='-O0 -ggdb3' ./bootstrap ./configure $CFLAGS --enable-cmsis-dap --enable-ftdi make -j4