Firmware/STM32

Cube IDE 에 OpenOCD 연결. / stm32 blue pill

또난 2023. 3. 19. 14:49

Cube IDE에서 st-link로 실시간 디버깅시 ST MCU가 아니라고 하면서 정지됨.

정품 MCU 사용하면 되지만 시중(중국)에서 stm32f103 정품 부착된 제품 구하기가 쉽지 않음.

st-link로 연결하는것은 불가능한것 같고, 시중에 OpenOCD로는 가능할것으로 보여 확인해봄.

 

저렴한 DAP LINK라는 디버거로 시도.

연결하면 COM포트, HID USB 입력 장치가 추가됨.

openOCD 프로그램 다운..

 

https://gnutoolchains.com/arm-eabi/openocd/

 

Download OpenOCD for Windows

Download pre-built OpenOCD for Windows OpenOCD is an open-source tool that allows debugging various ARM devices with GDB using a wide variety of JTAG programmers. You can download the pre-built OpenOCD for windows from this page: Each build above includes

gnutoolchains.com

openocd-20230202.7z
7.04MB

 

bin 폴더에서 터미널로 openOCD 연결..먼저 port 3333 연결한 후  Cube IDE에서 디버깅 가능.

>>   .\openocd.exe -f interface\cmsis-dap.cfg -f target\stm32f1x.cfg

 

Open On-Chip Debugger 0.12.0 (2023-02-02) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : [stm32f1x.cpu] Cortex-M3 r2p1 processor detected
Info : [stm32f1x.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections

 

펌웨어 버전이 1.0이고 나머지 정상적으로 연결됨.

 

cube IDE에 GDB 하드웨어 디버깅 부분에 새로 추가.

 

 

디버깅 탭에 GDB 명령 추가.

${gnu_tools_for_stm32_compiler_path}\arm-none-eabi-gdb

 

저장 후  디버깅하면 잘 실행됨... Live Expressions 은 지원 안하는 것 같음.

 

디버깅 시작하면 하기와 같이 메시지 출력.

Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x000fa410
Info : flash size = 64 KiB
undefined debug reason 8 - target needs reset
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000420 msp: 0x20005000
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000420 msp: 0x20005000

 

 

터미널 열어서 연결하기 불편하면 외부 명령을 통해 터미널 실행.

 

블루필로 연결할 필요 없음..

-c "adapter driver cmsis-dap" -f board\stm32f103c8_blue_pill.cfg

 

stm32f103 이면.

-f interface\cmsis-dap.cfg -f target\stm32f1x.cfg

 

Cube  IDE 의 plugin 의 내장 OpenOCD를 사용하려면 하기처럼 설정

(Cube IDE 내장 OpenOCD는 기본 usb로 연결 되는 것 같음.)

설치된 CubeIDE 플러그인 폴더 지정후

가지고 있는게 CMSIS-DAP FW Version 1.0 이라 hid로 설정 필요함.

다른 상위 2.0버전이면 usb_bulk 로 설정.

-c "adapter driver cmsis-dap" -c "cmsis_dap_backend hid" -f target\stm32f1x.cfg

 

openocd.pdf
0.88MB

 

디버깅 하기전에 먼저 실행하고 디버깅 하면 됨.

이후 콘솔창에 계속 연결이 유지되기때문에 다시 실행할 필요 없음.