FAQ emulation

From embeddedTS Manuals

If you want to emulate just the Debian environment you can do that quite easily using QEMU's userland emulation. On your Linux workstation you will need to install qemu-arm-static. If your workstation runs Debian you can find this as qemu-user-static. The qemu-arm-static application will emulate an ARM kernel.Refer to QEMU or your distribution's documentation for more details on setting this up. Once it is installed it will register with binfmt.

 $ cat /proc/sys/fs/binfmt_misc/qemu-arm
 enabled
 interpreter /usr/bin/qemu-arm-static
 flags: OC
 offset 0
 magic 7f454c4601010100000000000000000002002800
 mask ffffffffffffff00fffffffffffffffffeffffff

What this means is that anytime your system tries to run an ELF binary that is detected to be ARM it will use /usr/bin/qemu-arm-static. For example, lets say you want to use the TS-4800 Debian distribution. You can download the distribution here.

wget https://files.embeddedTS.com/ts-socket-macrocontrollers/ts-4800-linux/distributions/debian-squeeze-latest.tar.gz

# These next commands should all be run as root.
mkdir fs
cd fs
tar -xf ../debian-squeeze-latest.tar.gz
# Make sure this path matches the path used
# by the interpreter.  qemu-arm-static in my case must
# be in /usr/bin/qemu-arm-static or it will not call the interpreter correctly.
cp /usr/bin/qemu-arm-static ./usr/bin/
chroot .

This resulting shell will be in the TS-4800's debian environment, though keep in mind it will retain your hostname from the $PS1 variable. You can also mount the 4th partition of the SD card instead of extracting the root if you want to run your copy of the Debian FS instead of extracting this copy. You will still need to copy qemu-arm-static to the same path.

This will let you test ARM binaries, but this is not capable of emulating the hardware. If you need to test code that is talking to DIO, I2C, UARTs, SPI, etc then you will need to execute your code directly on the board. There are technical limitations such as emulating an FPGA in realtime, and legal restrictions such as emulating other companies intellectual property from various CPUs or other chips that make complete emulation impossible.