Running GDB testsuite with OpenOCD GDB stub


Download and setup bare-metal gcc:

export PATH=/home/omair/work/tools/gcc-linaro-5.4.1-2017.05-x86_64_aarch64-elf/bin:$PATH

STEP 1: Checkout sources, configure and build OpenOCD

git clone --depth 1 git:// openocd-src
cd openocd-src/
make -j8

STEP 2: Checkout sources, configure and build GDB

git clone --depth 1 git://

For arm-none-eabi:

mkdir gdb-build/arm-none-eabi
cd gdb-build/arm-none-eabi
../../binutils-gdb/configure --target=arm-none-eabi --with-expat --disable-nls --disable-sim --disable-install-libbfd
make -j8 all-gdb

For aarch64-none-elf:

mkdir gdb-build/aarch64-none-elf
cd gdb-build/aarch64-none-elf
../../binutils-gdb/configure --target=aarch64-none-elf --with-expat --disable-nls --disable-sim --disable-install-libbfd
make -j8 all-gdb

STEP 3: Checkout sources, configure and build NewLib

git clone --depth 1 git://

For arm-none-eabi:

mkdir -p build/aarch64-elf
../../newlib-cygwin/configure --target=aarch64-elf --prefix=$(pwd)/../../install

For aarch64-none-elf:

mkdir -p build/aarch64-elf
../../newlib-cygwin/configure --target=aarch64-elf --prefix=$(pwd)/../../install
make -j8
make install

STEP 4: BASH Script to fake GDB Connection

Create a file and write following lines in it.

sleep 5
echo "Listening on :3333"

Make it executable:

chmod +x

Your gdb board file specifies this script as gdb stub executable. This will fake a connection to gdb stub while we ll actually connection to openocd spawned above.

STEP 5: Download OpenOCD board configuration files and start openOCD

In case your board files are not already available in OpenOCD board files or you want to make some changes to the available board files. Create a folder in your working directory and copy your OpenOCD board configuration files in that folder.

Custom OpenOCD Board Configurations:

Spawn OpenOCD with Beagle Bone Black via FlysWatter2 JTAG:

cd openocd-src
./src/openocd -s tcl/ -f interface/ftdi/flyswatter2.cfg -f board/ti_beaglebone_black.cfg -c init -c "reset init"

Spawn OpenOCD with Leemaker Hikey Board via BusBlaster v4 JTAG:

cd openocd-src
./src/openocd -s tcl/ -f interface/ftdi/dp_busblaster.cfg -f board/lemaker_hikey.cfg

STEP 6: Setup GDB Testsuite and Start Testing

mkdir -p gdb_board_files/boards
cd gdb_board_files
touch site.exp
cd boards

Copy board files for Hikey Board and Beagle Bone Black to this directory

export DEJAGNU=$(pwd)/gdb_board_files/site.exp

GDB Board files

Run GDB Testsuite on Hikey Board with following command:

make check RUNTESTFLAGS="--target_board=openocd-hikey"

Run GDB Testsuite on Beagle Bone Black with following command:

make check RUNTESTFLAGS="--target_board=openocd-bbb"