Table of contents
- Setup tftpd
- QEMU networking
- Verify all components of Virtual Development Platform
- What next ?
This was not trivial task to me. As usual
google is your friend and
First we will set tftp which we use to download modified kernel for U-Boot.
Second I will show how to setup bridged network for QEMU needs and finally we
will perform some basic test of our setup. Let’s go.
Make sure that
/srv/tftp is writable for your user. If directory doesn’t exist
create it and give needed privileges. If you want to change some server options
/etc/inetd.conf. Copy or link our kernel to tftp server
Verify if everything works correctly:
1 2 3 4
Check if kernel file is in current directory. If yes than you tftp server is configured correctly, if not then google or ask me a question in comments section. Note: For Ubuntu follow instructions from here.
Update: For Ubuntu users please read this section
I mixed this BKM and few other resources that I found in the net. Setting up network depend a lot on your configuration. I will briefly describe my situation. It is quite possible that this won’t fit yours.
eth0 with ip
10.0.2.15. What I want to do is create another interface
br0 that will connect
tap0. To do this I need few things:
brctlis provided in Debian by
- check if TUN module was installed
you should get
m, if it is
- create tun device
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/etc/qemu-ifupscript to bring up your network:
1 2 3 4 5 6 7 8
Give executable permissions for this file:
Restart networking services locally:
This should prepare you environment for tftp booting in qemu.
I had experienced few problems with my Ubuntu 12.04.
First thing was defect that cause looping u-boot during emulation in qemu-system-arm. I checked latest qemu and version delivered in distro repository but qemu wasn’t issue. I tried debug problem with gdb and qemu
-s -Sswitches and find out that u-boot crashes at
serial_init. I tried to google this issue but found only one comment about this on Balau blog:
Problem is at least 2-years old and still occurs. Unfortunately Grant’s tricks didn’t help. I move to toolchain built by my own and problem was fixed. So the moral of the story is: DO NOT USE TOOLCHAIN PROVIDED BY UBUNTU at least in 12.04.
For anyone trying to reproduce this, at least on a recent Ubuntu host, you may need to pass “-cpu all” or “-cpu cortex-a8″ to qemu. The libgcc that gets linked to u-boot appears to be compiled with thumb2 instructions which are not implemented in the Versatile cpu. I don’t get any u-boot console output without this flag, and using gdb I can see that the cpu takes an exception during
__udivsi3()called from serial_init().
Second thing also involve a lot of debugging time and when I found workaround it was accidentally. I saw that using procedure correct for Debian on Ubuntu I was unable to obtain any packet inside U-Boot. Network traffic analysis show that U-Boot correctly send DHCP discovery and server reply with DHCP offer, but bootloader behaves like no packet was received. Static configuration also didn’t work. Finally I get to information how to capture traffic from inside of emulated setup (parameter
-net dump,file=/path/to/file.pcapdo the thing). Surprisingly for some reason adding dump param fix problem and U-Boot received DHCP Offer and ACK. I will try to narrow down this problem for further reading please take a look qemu and u-boot mailing list thread.
Verify all components of Virtual Development Platform
Run your qemu with network using U-Boot image as a kernel.
NOTE: We want to use u-boot file instead of u-boot.bin. First is ELF binary
image and second is raw binary. Raw binary image can be used with
parameter for qemu. If you try to give raw binary as a kernel parameter it will result with error:
NOTE 2: We have to specify
versatilepb machine. If we forget it we will get
Right now we have u-boot booted. Let’s set ip addresses to boot uImage from our
tftp server. For verification needs we don’t want to
image, so we disable this through environment variable.
1 2 3 4 5
Set addresses according to your configuration. For some reason I was unable to
dhcp feature. It assign me address that exist in the network.
We can take a close look on out downloaded image with
iminfo should looks like that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
So, that what we want to see. Pretty new kernel
3.9.0-rc8 compiled as ARM
image. We can try to boot it but we will end with kernel panic because lack of
NOTE 3: If you want to see anything after booting this image with
have to pass to kernel additional boot argument with serial device that should
be used as a console. Before
You should get something similar to below log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
This is expected result.
What next ?
We happily built basic virtual development, what we need right now is some initial filesystem.