Openocd compilation for stm32mp157 on Ubuntu 20.04

1. Open console (Ubuntu ALT+CTRL+T)

2. Download specific openocd fork source code using following command

git clone -b stm32mp1 https://github.com/sysprogs/openocd.git

3. Type following commands

cd openocd
./bootstrap
./configure

For Ubuntu 20.04 needs to update 2 files

in file openocd/src/flash/mflash.c
modify in line 1162
from
memset(pSegIdDrvInfo->reserved7, 0x00, 190);
to
memset(pSegIdDrvInfo->reserved7, 0x00, 186);
In file openocd/src/helper/options.c
comment out lines
ifdef HAVE_SYS_SYSCTL_H
include
endif

After that, type in following commands

make
sudo make install

Copy stm32mp15x_dk2.cfg into /usr/local/share/openocd/scripts/target/stm32mp15x_dk2.cfg

sudo cp tcl/board/stm32mp15x_dk2.cfg /usr/local/share/openocd/scripts/target/stm32mp15x_dk2.cfg

Connect to target

sudo openocd -f target/stm32mp15x_dk2.cfg

Thanks to Rzepa for help in preparing this article

Lucjan Bryndza

Embedded software engineer