본문 바로가기
헝클어진 회로

STM32CubeIDE에서 원격지 GDB Server 연결

by 배굿맨 2022. 1. 2.

원격지에 CubePROG를 깔아놓코 chromeremote로 연결해서 bin 또는 elf 파일을 전송해서 보드에 파일을 다운로드했다. 그런데 디버깅을 할 일이 생겼다.

 

그래서 아래 화면을 보니 원격지에 GDB서버를 올려놓으면 되는 것처럼 나왔다.

그리고 구글링을 하다 보니 

https://www.st.com/resource/en/user_manual/um2576-stm32cubeide-stlink-gdb-server-stmicroelectronics.pdf

라는 문서를 찾게되었다.

 

내용은 아래와 같다.

 

Starting the GDB server

The GDB server can be started in a command window in the following way:

1. cd C:\ST\STM32CubeIDE_1.0.0.19w12patch\STM32CubeIDE\plugins\com.st.stm32cube.ide.mc u.externaltools.stlink-gdb-server.win32_1.0.0.201903011553\tools\bin\STLINK_gdbserver

2. Start the GDB server using –cp with the path to STM32_Programmer_CLI.exe

For instance: ST-LINK_gdbserver.exe -d -v -cp

"C:\ST\STM32CubeIDE_1.0.0.19w12patch\STM32CubeIDE\plugins\com.st.stm32cube.ide.m cu.externaltools.cubeprogrammer.win32_1.0.0.201903011553\tools\bin"

3. Then, the GDB server connects to the STM32 device using the ST-LINK JTAG and waits for commands from a GDB debug session.

 

결론은, pdf 파일을 꼭 열어서 읽어 본 후, 위에 정리한 명령들을 순차적으로 실행시키면 원격지에 연결된 보드에 bin 파일이 자동 다운로드 되고 디버깅할 수 있게 된다.

 

원격지 컴퓨터의 성느이 별로 안 좋아서 cubeIDE를 안 깔아 놓았다. 파일만 복사해서 실행시켜볼까? 하다가 그냥 전체 인스톨했다. (인스톨과정 설명 생략)

단 인스톨 중에 아래 화면이 보이면,

SEGGER J-Link drivers가 GDB Server관련 항목인것 같다. 꼭 깔자.

 

인스톨 한 후,  Starting the GDB server 항목을 원격 컴퓨터의 폴더명과 비교해 보고 따라해보자.

 

먼저

1. 현재 디렉토리 변경

cd  c:\STM32CubeIDE_1.8.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.100.202110141430\tools\bin\

 

2. 그리고 아래 명령어를 실행한다.

 

ST-LINK_gdbserver.exe -d -v -cp  c:\STM32CubeIDE_1.8.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.100.202110141430\tools\bin\

 

 

위 화면이 뜨면 다 된거다.

 

내 컴퓨터의 디버깅 컨피규레이션에서 아래와 같이 설정해둔다. 그리고 Debug를 실행한다.

위 화면이 뜨면, SWITCH를 눌러준다. 그럼 끝!

 

배치 파일을 만들어서 작업을 간략화 하자.

 

gdbserver.bat 파일을 생성한 후 아래 내용을 CCCV(Ctrl C Ctrl V)한 후 저장한다. 

-----------------------------

@echo off

:loop
call cmd /C "ST-LINK_gdbserver.exe -d -v -cp  c:\STM32CubeIDE_1.8.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.100.202110141430\tools\bin\ || echo "GDB server exited!!!"

echo.
pause
goto loop

-----------------------------

 

결론. 깔아 놓으니 오! 그냥 내컴에서 작업하면 원격지컴에서 보드로 데이타를 다운로드해준다. 좋네!