1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

Fix openocd makefile target by using TARGET_MCU_FAMILY (#13410)

* Fix openocd makefile target by using TARGET_MCU_FAMILY

The condition before this commit in mk/openocd.mk

ifeq ($(TARGET_MCU),STM32F4)
OPENOCD_CFG := target/stm32f4x.cfg

else ifeq ($(TARGET_MCU),STM32F7)
OPENOCD_CFG := target/stm32f7x.cfg
else
endif

ifneq ($(OPENOCD_CFG),)
OPENOCD_COMMAND = $(OPENOCD) -f $(OPENOCD_IF) -f $(OPENOCD_CFG)
endif

resulted in a not defined OPENOCD_COMMAND, because TARGET_MCU does not
contain the MCU family such as STM32F4, but e.g. STM32F411xE.

Thus executing e.g (note: CONFIG=BLACKPILL411 is a custom config I created for the Blackpill Board)

$ make DEBUG=GDB CONFIG=BLACKPILL411 openocd-gdb
make: *** No rule to make target 'openocd-gdb'.  Stop.

whereas after the patch:
$ make DEBUG=GDB CONFIG=BLACKPILL411 openocd-gdb

...
...
Linking STM32F411_BLACKPILL411
Memory region         Used Size  Region Size  %age Used
           FLASH:        7680 B        16 KB     46.88%
    FLASH_CONFIG:          0 GB        16 KB      0.00%
          FLASH1:      329297 B       480 KB     67.00%
   SYSTEM_MEMORY:          0 GB        29 KB      0.00%
             RAM:       62612 B       128 KB     47.77%
       MEMORY_B1:          0 GB         0 GB
   text	   data	    bss	    dec	    hex	filename
 331757	   5220	  56980	 393957	  602e5	./obj/main/betaflight_STM32F411_BLACKPILL411.elf
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg & ./tools/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb ./obj/main/betaflight_STM32F411_BLACKPILL411.elf -ex "target remote localhost:3333" -ex "load"
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
...
...
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08009014 msp: 0x2001fff0
Start address 0x08009014, load size 336977
Transfer rate: 37 KB/sec, 11232 bytes/write.
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x08021a1c in scheduler () at ./src/main/scheduler/scheduler.c:695
695	                    task->taskAgePeriods = (cmpTimeUs(currentTimeUs, task->lastExecutedAtUs) / task->attribute->desiredPeriodUs);
(gdb) quit

works as expected.

In addition add also G4 and H7 TARGET_MCU_FAMILY support. When installing openocd the config files for G4 and H7, should
be provided in directory: /usr/share/openocd/scripts/target

$ grep -r TARGET_MCU_FAMILY | awk '/ STM32/{print $3}' | sort | uniq && find /usr/share/openocd/scripts/target -type f | grep "stm32f4x.cfg\|stm32f7x.cfg\|stm32g4x.cfg\|stm32h7x.cfg"

STM32F4
STM32F7
STM32G4
STM32H7

/usr/share/openocd/scripts/target/stm32g4x.cfg
/usr/share/openocd/scripts/target/stm32h7x.cfg
/usr/share/openocd/scripts/target/stm32f4x.cfg
/usr/share/openocd/scripts/target/stm32f7x.cfg

* Remove useless else
This commit is contained in:
Thomas Stibor 2024-03-08 11:14:26 +01:00 committed by GitHub
parent 6d98dbb742
commit 94be8f0673
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,12 +1,17 @@
OPENOCD ?= openocd OPENOCD ?= openocd
OPENOCD_IF ?= interface/stlink-v2.cfg OPENOCD_IF ?= interface/stlink-v2.cfg
ifeq ($(TARGET_MCU),STM32F4) ifeq ($(TARGET_MCU_FAMILY),STM32F4)
OPENOCD_CFG := target/stm32f4x.cfg OPENOCD_CFG := target/stm32f4x.cfg
else ifeq ($(TARGET_MCU),STM32F7) else ifeq ($(TARGET_MCU_FAMILY),STM32G4)
OPENOCD_CFG := target/stm32g4x.cfg
else ifeq ($(TARGET_MCU_FAMILY),STM32F7)
OPENOCD_CFG := target/stm32f7x.cfg OPENOCD_CFG := target/stm32f7x.cfg
else
else ifeq ($(TARGET_MCU_FAMILY),STM32H7)
OPENOCD_CFG := target/stm32h7x.cfg
endif endif
ifneq ($(OPENOCD_CFG),) ifneq ($(OPENOCD_CFG),)