Monday 6 September 2021

openOCD Debug STM32

If working remotely, everything is terminal. No GUI like stm32cubeide to use for firmware debugging. I need to use openOCD now. I am using a stm32f407 discovery board for the following tests.

1. install openOCD
sudo apt-get install openocd
cd /usr/local/share 
sudo ln -s /usr/share/openocd .

2. install toolchain
sudo apt install gcc-arm-none-eabi

3. install stm32cubeMX
Generate a project with makefile.

4. go the project directory and make the project.

5. make a cfg file

cd /usr/local/share/openocd/scripts/board

boris@boris-T420:/usr/local/share/openocd/scripts/board$ sudo cp stm32f4discovery.cfg stm32f407discovery_boris.cfg

6. Terminal 1: launch openOCD to connect to the board

openocd -f /usr/local/share/openocd/scripts/board/stm32f407discovery_boris.cfg

You can see the following problem:


7. edit the cfg file


Now it works:


8. Terminal 2: start GDB

go to the project directory, go to build/

PATH/TO/PROJECT/build$ arm-none-eabi-gdb openocd_practice.elf



9. now in gdb teminal, start debuging:
ref:
https://www.youtube.com/watch?v=yDNbpXjWAuU&ab_channel=AimalKhan



ref:

https://www.youtube.com/watch?v=yDNbpXjWAuU&ab_channel=AimalKhan
https://www.youtube.com/watch?v=Df7gtGyQaxg&t=512s&ab_channel=EmbeddedTips
http://forum.chibios.org/viewtopic.php?t=3425
https://elinux.org/OpenOCD_Ubuntu_Package

No comments:

Post a Comment