OK3568 4.19.206 Buildroot Debugging with GDB and GDB Server

Document classification: □ Top secret □ Secret □ Internal information ■ Open

Revision History

Date

Version

Revision History

15/09/2023

V1.0

Initial Version

Debugging with GDB and GDB Server

GDB Path in Ubuntu Virtual Machine:

forlinx@ubuntu:~/ok3568/OK3568-linux-source/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin$

Set Up Environment Variables:

(Modify the path according to your actual environment)

After configuring the environment variables, you can directly invoke the cross-compilation toolchain from the command line.

export 	PATH=$PATH:/home/forlinx/ok3568/OK3568-linux-source/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin

1. Set the board IP and port number;

Image

2. Set the IP address of the virtual machine to ensure that the development board IP can be pinged.

Use the network cable to connect the development board and the computer, and set the development board, the computer and the virtual machine in the same network segment;

3. Compile the application in the development environment;

aarch64-linux-gnu-gcc -g gpiotest.c -o gpiotest

4. Copy to the development board;

Image

Copy the gpiotest executable file to the development board and execute the following command:

gdbserver 172.16.0.169:2345 gpiotest

Where 172.16.0.169 is the IP address of the board and the port number is 2345.

5. Debug.

Change to the gpiotest executable directory:

Execute the following command:

arch64-linux-gnu-gdb ./gpiotest
target remote 172.16.0.169:2345

At this point, you can debug according to your needs. Here are some common commands.

(1) l (list): List): List all source code

(2) b (breakpoint): Set a breakpoint

(3) c (continue): Continue execution until the next breakpoint

(4) s: Single step execution

(5) n: Single step execution, but step will enter the function, but next will not

(6) p a: Print the value of the variable a

(7) Q: Exit. Enter this command to exit gdbserver on the development board.

Image