Here are some patches to GDB to allow the existing gdb ARM emulator to run uClinux targets. It can run both little-endian and big-endian code, as well as apcs-32/26 code and Thumb. I have tested little/big endian kernels but haven't played with thumb at this point.
The patch is heavily based on an ARM7100 patch that Ben Williamson
Fernando José Cardozo de Sá has been kind enough to send in his Win32
native port of the ARMulator. All the files needed are in the
Win32 directory. The Win32 binaries work just like
the unix versions, check the section below on Running the precompiled
binaries.
Fixed the 'ls'/'ps' problem with big-endian targets by stealing a small bit
of the patch provided by Daniel Versick's (http://mac.os.nctu.edu.tw/distfiles/4530.patch). More of this patch may be required I just haven't
had time to digest it all.
Wow an update :-) Needed to implement the IPR (Interrupt Pending Register)
in order to work with a bug fix pending for the 2.4.x kernel.
Here's a patch to fix problems compiling
the armulator on newer systems (invalid lvalue error).
Here are some files you can use to put together uClinux running in the
GDB/ARMulator.
The ARMulator expects the romfs to be in a file called "boot.rom". You
must use the matching kernel/romfs combo's.
And likewise for 2.4, just change the names.
Checkout the example-session.txt file
to see what it looks like.
If you are using an older uClinux distro, just apply the patch and see
how you go. Anything more recent than the patches mention will include the
GDB/ARMulator target by default with the patches included.
You can get the source from:
Build as for any other target, the images above were built with uC-libc.
When building from source, create a file in the top directory called
".gdbinit" that contains:
If you want to see how much of a hack this really is, the main files to
look at are:
These still include the old 7100 code commented out and the Atmel emulation
that is truly hacked in on top. You can add more memory and change the
size of the rom in armmem.c. You can fix most bugs in the emulation in
armio.c.
Patrick Doyle for the time.h patch to fixcompiling on RedHat 7.2/7.3
Copyright (C) 2002,2005 News
What you get
linux.2.4.x.gz
romfs.2.4.x.gz
linux.2.4.x-xip.gz
romfs.2.4.x-xip.gz
Building the Debugger/Emulator
bunzip2 < gdb-5.0.tar.bz2 | tar xvf -
gunzip < gdb-5.0-uclinux-armulator-20060104.patch.gz | patch -p0
cd gdb-5.0
./configure --target=arm-elf
make
su root -c "make install"
Running the precompiled binaries
gunzip romfs.2.0.x
gunzip linux.2.0.x
ln -s romfs.2.0.x boot.rom
arm-elf-gdb linux-2.0.x
...
gdb> target sim
...
gdb> load
...
gdb> run
Using the Debugger
Just type ^C to drop into gdb. There are no symbols in the binaries
provided above, but if you build your own your will have full source
debugging of the kernel (and apps if you load their symbols appropriately).
You can step and continue just like a normal debugger.
Building from Source
http://www.uclinux.org/pub/uClinux/dist/
Be sure to check for any patches above that are required for the version
you download. You can get the tools from:
http://www.uclinux.org/pub/uClinux/arm-elf-tools/
target sim
load
to save some typing ;-) Then link the romfs.img to boot.rom with:
ln -s images/romfs.img boot.rom
and run
arm-elf-gdb linux-2.X.X/linux
to have full source debug of the kernel and friends.
Messing with the Emulator
gdb-5.0/sim/arm/armmem.c
gdb-5.0/sim/arm/armio.c
Thanks to
Fernando José Cardozo de Sá for his Native 32 port (and binaries).
Daniel Versick's big-endian patches for uaccess (taken from http://mac.os.nctu.edu.tw/distfiles/4530.patch).
David McCullough <davidm@snapgear.com>