arm-none- eabi-gdb가 없을 때 해결방법 참고 사이트
암 툴체인 다운로드
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
툴체인 설치후 실행이 되지 않을 경우에는 vim에 경로를 추가해준다.
$ vim ~/.bashrc
만약 툴체인이 설치된 곳이 /usr/share//bin 경로라고 가정하면 .bashrc에 아래와 같이 PATH를 추가해주어야 한다.
PATH=$PATH:/usr/share//bin
경로를 추가한 이후에는 터미널에서 bash를 다시 실행해준다.
GDB 실행시 아래와 같이 에러가 발생하면, 라이브러리를 설치해서 해결할 수 있다.
$ arm-none-eabi-gdb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
$ sudo apt-get install libncurses5
...
$ arm-none-eabi-gdb
GNU gdb (GNU Tools for STM32 11.3.rel1.20230912-1600) 12.1.90.20220802-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) exit
1. JlinkGDBServer 사용법
- JLinkGDBServer 실행한다.
$ JLinkGDBServer -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device STM32F405RG
SEGGER J-Link GDB Server V7.86d Command Line Version
JLinkARM.dll V7.86d (DLL compiled Mar 15 2023 13:56:20)
Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device STM32F405RG
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 50000
SWO raw output listening port: 50001
Terminal I/O port: 50002
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: STM32F405RG
Target device parameters: none
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.20
Feature(s): GDB, RDI, FlashBP, FlashDL, JFlash
Checking target voltage...
Target voltage: 3.26 V
Listening on TCP/IP port 50000
Connecting to target...
Halting core...
Connected to target
Waiting for GDB connection...
- GDB 서버를 통해 localhost에 Listening 포트를 50000으로 열어 놓았다.
swift@swift-HP-Pavilion-dv6-Notebook-PC:~$ netstat -tulpn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:55878 0.0.0.0:* LISTEN 4713/code
tcp 0 0 127.0.0.1:19080 0.0.0.0:* LISTEN 9912/JLinkGDBServer
tcp 0 0 0.0.0.0:19021 0.0.0.0:* LISTEN 9912/JLinkGDBServer
tcp 0 0 0.0.0.0:50000 0.0.0.0:* LISTEN 9912/JLinkGDBServer
tcp 0 0 0.0.0.0:50001 0.0.0.0:* LISTEN 9912/JLinkGDBServer
tcp 0 0 0.0.0.0:50002 0.0.0.0:* LISTEN 9912/JLinkGDBServer
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:19030 0.0.0.0:* LISTEN 9912/JLinkGDBServer
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp6 0 0 :::50000 :::* LISTEN 9912/JLinkGDBServer
tcp6 0 0 ::1:631 :::* LISTEN -
udp 0 0 0.0.0.0:47723 0.0.0.0:* -
udp 0 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 0.0.0.0:631 0.0.0.0:* -
udp 0 0 224.0.0.251:5353 0.0.0.0:* 5078/chrome --type=
udp 0 0 224.0.0.251:5353 0.0.0.0:* 5033/chrome
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp6 0 0 :::47266 :::* -
udp6 0 0 :::5353 :::* -
- 새로운 터미널 창을 열어서 arm-none-eabi-gdb로 접속한다.
$ arm-none-eabi-gdb nuttx/nuttx.hex
GNU gdb (Arm GNU Toolchain 12.2.MPACBTI-Rel1 (Build arm-12-mpacbti.34)) 13.1.90.20230307-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.linaro.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from nuttx/nuttx.hex...
(No debugging symbols found in nuttx/nuttx.hex)
(gdb)
- Target에 remote로 접근한다.
(gdb) target remote localhost:50000
Remote debugging using localhost:50000
0x080073ce in ?? ()
- 정상적으로 서버에 접속되면 GDBServer에서 Target에 연결된 레지스터 상태를 확인할 수 있다.
Waiting for GDB connection...Connected to 127.0.0.1
GDB client (conn. 11) requested target.xml from GDB Server
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0xF80B0020
Read register 'r2' (4 bytes) from hardware: 0xA4420020
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x780B0020
Read register 'r5' (4 bytes) from hardware: 0x280C0020
Read register 'r6' (4 bytes) from hardware: 0x2C0C0020
Read register 'r7' (4 bytes) from hardware: 0x700B0020
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0x802A0020
Read register 'lr' (4 bytes) from hardware: 0x6F240008
Read register 'pc' (4 bytes) from hardware: 0xCE730008
Read register 'xpsr' (4 bytes) from hardware: 0x00000041
Read 4 bytes @ address 0x080073CE (Data = 0xB5384770)
Read 2 bytes @ address 0x080073CE (Data = 0x4770)
Arm 툴체인은 더 이상 업데이트가 되지 않아 지원이 되지 않는 것으로 보인다. 하지만 STM32CubeIDE에서 제공하는 플러그인에에는 다양한 툴체인과 디버그 도구들이 모여져 있다. VSCODE에서도 이 플러그인에 있는 도구들을 링크하여 사용할 수 있다.
해당 툴체인의 경로는 설치한 STM32CubeIDE의 아래 경로를 참고하면 된다.
arm-none-eabi 툴체인 -> st/stm32cubeide_1.14.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin
J-link GDB 툴체인 ->
st/stm32cubeide_1.14.0/plugins/cohttp://m.st.stm32cube.ide.mcu.externaltools.jlink.linux64_2.2.100.202310121458/tools/bin
VSCODE나 STM32CubeIDE나 동일한 방법으로 빌드 및 컴파일 및 디버깅이 가능하다.
'엔지니어링 > 임베디드' 카테고리의 다른 글
ROS2 humble 학습하기 (0) | 2025.01.12 |
---|---|
Ubuntu 22.04에 ROS2 humble 설치하기 (0) | 2025.01.12 |
[ STM32 ] STM32F4보드에 NuttxOS 설치하기 (0) | 2023.05.07 |
NuttX OS 알아보기 (0) | 2023.03.16 |
Docker로 Ubuntu 18.04 + ROS melodic 개발환경 구축 (0) | 2022.01.08 |
댓글