Archive for June, 2009

MACH_TYPE

June 28, 2009

I’ve had this happen a couple of times now when testing kernels. When the kernel is starting you get an error like “Error: unrecognized/unsupported machine ID (r1 = 0×0000034e)”. The reason you get an error is because the bootloader is supposed to pass the MACH_TYPE to the kernel, and if it doesn’t match what the kernel was compiled with then the kernel won’t start. This time I knew what was going on, but I didn’t remember where the ID was defined. So I did a few fgreps for 34e, with no luck. This is because MACH_TYPE is defined in decimal not hex. Once you figure out to look in include/asm-arm/mach-types.h everything makes sense.

u-boot & gdb

June 19, 2009

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.