u-boot & gdb

By openhardware

U-boot is a full featured bootloader that is often used to load Linux on non-x86 platforms. Recently I’ve been messing with u-boot some. I’ll go through how to quickly get started with u-boot and a simple gdb + JTAG setup. I’m using the signalyzer JTAG with openocd software. First grab a copy of u-boot. Either a released version from ftp or if you want the latest git testing version do “git clone git://git.denx.de/u-boot-testing.git”. Now building u-boot is really very easy all you have to do is choose a config by doing “make xxx_config”  to look at the different configs look at include/configs/. So for example “make imx27lite_config”. Now just run make specifying the cross compiler “make CROSS_COMPILE=compiler_prefix”. This creates two output files u-boot and u-boot.bin. u-boot is the the elf file that we will want to use with gdb. First we need gdbinit file, the following works fine:

# SETUP GDB :
#
# Common gdb setup for ARM CPUs
set complaints 1
set output-radix 10
set input-radix 10
set prompt (arm-gdb)
set endian little
dir .

# CONNECT TO TARGET :
target remote 127.0.0.1:3333

#  LOAD IMAGE :
#

# Load the program executable called "u-boot"
load u-boot

# Load the symbols for the program.
symbol-file u-boot

# RUN TO MAIN :
#
# Set a breakpoint at _start.
b _start

Now openocd needs to already be running to allow the gdb connection, then running a command like “arm-unknown-linux-gnu-gdb –command=gdbinit” will start gdb. The gdb prefix should be the same as the compiler prefix. Now there should be a command prompt like (arm-gdb) before we can start stepping through u-boot we need to issue 1 continue just using the letter “c” works for this. Now we can start stepping through u-boot using the step or “s” command. You’ll notice that u-boot begins in start.S. If you look back at the source code you’ll notice that there is a start.S for each CPU architecture. Now we can go to town stepping and adding break points.

Leave a Reply