If you want to own a Development Board without spending any money, you can create a virtual development board by yourself.
A Virtual Development Board is a board simulated by QEMU. It is actually a virtual machine.
Contents
[Hide]
1. debugging mode
1.1 QEMU
1.1.1 download QEMU
1.1.2 install QEMU
1.2 bootloader
1.2.1 prepare a cross-compilation tool
1.2.2 download U-Boot
1.2.3 cross-compile U-Boot
1.2.4 debug U-Boot
1.3 Linux Kernel
1.3.1 download the Linux Kernel
1.3.2 cross-compile Linux Kernel
1.3.3 load Linux Kernel
1.3.3.1 download and install the TFTP Server
1.3.3.2 prepare qemu-ifup and qemu-ifdown
1.3.3.3 tftpboot uImage
1.3.4 run Linux Kernel
1.3.4.1 prepare ROOTFS
1.3.4.2 prepare NFS
1.3.4.3 run uImage
1.4 Device Drivers
1.4.1 Add a device to QEMU
1.4.2 Device Driver
1.5 GUI
2 Run Mode
2.1 QEMU
2.1.1Support FLASH on QEMU
2.2 U-Boot
2.2.1burn U-Boot into flash
3 References
4 External links
Debugging mode
QEMU
Download QEMU
We usually have two ways to obtain the source code:
Zip package, get the latest release version qemu-0.13.0.tar.gz from the qemu download page. Decompress the file:
$ Tar zxvf qemu-0.13.0.tar.gz
Use git tool to capture source code:
$ Git clone git: // git.qemu.org/qemu.git
Install QEMU
Now we can go to the QEMU source code directory and run the following command to install the qemu arm simulation part to the '/opt/qemu/' directory on the local machine.
$./Configure -- prefix =/opt/qemu -- target-list = arm-softmmu, arm-linux-user -- enable-debug $ make-s $ make install-s
Add "PATH =/opt/qemu/bin: $ PATH" to the file '/etc/profile'. Then run the following command to directly run the QEMU command on the console.
$./Etc/profile
We can download arm-test-0.2.tar.gz from the qemu download page, which is the testing kernel of ARM Linux 2.6 and the initrd disk image (thanks to Paul Brook ).
$ Tar zxvf arm-test-0.2.tar.gz $ cd arm-test $ qemu-system-arm-kernel zImage. integrator-initrd arm_root.img-nographic-append "console = ttyAMA0"
Command to start an ARM Virtual Machine with command lines, type "CTRL-a x" to exit. Now, the installation is complete.
Bootloader
Prepare a cross-compilation tool
Open the Sourcery G ++ Lite Edition for ARM page and click "GNU/Linux> Packages> Recommended Packages> IA32 GNU/Linux Installer ". After the download, install it in the '/opt' directory:
$ Chmod + x arm-VERSION-arm-none-linux-gnueabi.bin $./arm-VERSION-arm-none-linux-gnueabi.bin
After the installation is complete, you can find the required cross-edit tool in the '/opt/CodeSourcery/Sourcery_G ++ _ Lite/bin' directory. You can write a "hello world" test program to test them:
$ Sudo mkdir-p/usr/gnemul $ sudo ln-sf/opt/CodeSourcery/Sourcery_G ++ _ Lite/arm-none-linux-gnueabi/libc/usr/gnemul/qemu -arm $ arm-none-linux-gnueabi-gcc-o hello. c $ qemu-arm hello
If we can see that there is "hello world" or other characters that you want to output appear on the screen, the cross compilation tool is ready.
Download U-Boot
Release: u-boot-latest.tar.bz2
Current Source program:
$ Git clone git: // git.denx.de/u-boot.git
Cross-compile U-Boot
Go to the root directory of U-Boot and execute:
$ Make ARCH = arm CROSS_COMPILE = arm-none-linux-gnueabi-versatilepb_config $ make ARCH = arm CROSS_COMPILE = arm-none-linux-gnueabi--s
The files 'u-boot' and 'u-boot. bin' are generated in the directory '.
You can also get the tool "mkimage" in the 'tool' Directory, which will be used when compiling the Linux kernel uImage.
$ Sudo ln-sf 'pwd'/tools/mkimage/usr/local/bin/mkimage
Now we can start U-Boot in the console:
$ Qemu-system-arm-M versatilepb-nographic-kernel u-boot
After the startup is successful, the command prompt "VersatilePB #" is displayed. Now you can enter U-Boot commands such as "printenv. Enter the key combination "CTRL-a x" to exit.
Debug U-Boot
Add the-s and-S options when calling QEMU.
-S-gdb tcp: 1234 written
-S: Stop the CPU at startup (type 'C' to start execution)
$ Qemu-system-arm-M versatilepb-nographic-kernel u-boot-s-S
When debugging U-Boot, load the file 'u-boot' to gdb (remember not 'u-boot. bin '), 'U-boot' is an ELF file that contains all the symbols used for debugging, unlike 'u-boot. bin' removes the debugging information file after running the "stripe" command. Open another console window to execute the ARM cross debugging tool and load the file 'u-boot ':
$ Arm-none-linux-gnueabi-gdb u-boot (gdb) target remote: 1234 (gdb) B do_printenv Breakpoint 1 at 0x10080f4: file __nvedit.c, line 147. (gdb) c Continuing.
In the QEMU Console window, the following information is displayed:
U-Boot 2010.06 (Aug 31 2010-16:23:16) DRAM: 0 Bytes Flash: 64 MiB *** Warning-bad CRC, using default environment In: serial Out: serial Err: serial Net: SMC91111-0 VersatilePB #
Enter the U-Boot command "printenv" after the "VersatilePB #" prompt, and its execution will be interrupted by gdb:
VersatilePB # printenv
In the gdb Console window, the following information is displayed:
Breakpoint 1, do_printenv (cost TP = 0x1015520, flag = 0, argc = 1, argv = 0xfddee4) at 1__nvedit.c: 147 147 if (argc = 1) {(gdb)
From here on, we can use the normal gdb debugging command for debugging. Good!
Linux Kernel
Download Linux Kernel
Download the latest stable kernel: linux-2.6.36.2.tar.bz2 from the Linux kernel homepage.
Use git to capture the source code:
$ Git clone git: // git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Cross-compile Linux Kernel
$ Make ARCH = arm CROSS_COMPILE = arm-none-linux-gnueabi-versatile_defconfig-s $ make ARCH = arm CROSS_COMPILE = arm-none-linux-gnueabi-uImage-s
After compilation, the 'uimage' file is generated in the 'arch/arm/boot' directory '.
Load Linux Kernel
Download and install the TFTP Server
Download opentftpmtv1.63.tar.gz from the master page of Open TFTP server and install it:
$ Tar zxvf opentftpmtV1.63.tar.gz $ mv opentftp // opt/$ cd/opt/opentftp/
Modify the configuration file 'opentftpd. ini to specify the working directory of the tftpserver, that is, the directory that provides the tftp service externally. For example, we add the word "/opt/versatilepb/firmware" to the configuration file 'opentftpd. under the [HOME] entry of ini, and then link the compiled Linux kernel uImage to this directory:
$ Ln-sf PATH_TO_LINUX_KERNEL/arch/arm/boot/uImage/opt/versatilepb/firmware/
Run the following command to start tftpserver:
$ Mkdir-p/opt/versatilepb/firmware $ sudo rc. opentftp start
"Server opentftpd started" indicates that tftpserver has been started.
We can add the following two lines of text to the file '/etc/rc. d/rc. local' so that the tftpserver can be automatically started at startup:
$/Opt/opentftp/rc. opentftp start $/opt/opentftp/rc. opentftp status
Prepare qemu-ifup and qemu-ifdown
Using the TAP network interface is the standard way for QEMU to access the real network.
If the device '/dev/net/tun' does not exist, run the following command to create it:
$ Sudo mkdir-p/dev/net $ sudo mknod/dev/net/tun c 10 $200 $ sudo/sbin/modprobe tun
You can also add the above command to the file '/etc/rc. d/rc. local' so that the device is automatically created every time it is started.
Refer to QEMU/Networking to make two files: 'qemu-ifup' and 'qemu-ifup'. But you do not need to comment out the line related to openvpn:
$ Sudo cp qemu-ifup qemu-ifdown/etc/$ sudo chmod + x qemu-ifup $ sudo chmod + x qemu-ifdown
Tftpboot uImage
Assume that the IP address of the Virtual Development Board is 192.168.1.123, And the IP address of the PC host (tftpserver) is 192.168.1.234.
$ Sudo qemu-system-arm-M versatilepb-nographic-net nic-net tap, ifname = tap0-kernel $ PATH_TO_YOUR_U-BOOT/u-boot U-Boot 2010.09 (Dec 15 2010-18:16:35) DRAM: 0 Bytes # Unknown FLASH on Bank 1-Size = 0x00000000 = 0 MB Flash: 0 Bytes *** Warning-bad CRC, using default environment In: serial Out: serial Err: serial Net: SMC91111-0 VersatilePB # sete ipaddr 192.168.1.123 VersatilePB # sete serverip 192.168.1.234 VersatilePB # sete bootfile uImage VersatilePB # parameter weight: PHY auto-Snapshot timed out weight: MAC 52: 54: 00: 12: 34: 56 Using SMC91111-0 device TFTP from server 192.168.1.234; our IP address is 192.168.1.123 Filename 'uimage '. load address: 0x7fc0 Loading: T #################################### T ### ######################################## ########################### done Bytes transferred = 1556392 (17bfa8 hex) versatilePB # iminfo # Checking Image at %7fc0... legacy image found Image Name: Linux-2.6.36.2 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 1556328 Bytes = 1.5 MiB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum... OK VersatilePB #
? In normal user mode, how does one execute qemu-system-arm with a tap network?
Run Linux Kernel
Prepare ROOTFS
Prepare NFS
Run uImage
Device Driver
Add a device to QEMU
Device Driver
GUI
Run Mode
QEMU
Support FLASH on QEMU
Now, the emulation of Intel flashes is present in Qemu (in hw/pflash_cfi01.c) and this emulation is already used in some emulated ARM platforms, but not the Versatile PB platform that we use for our object (this platform is nice because it has Ethernet, serial ports, LCD, etc .). so, we must add flash emulation to the Versatile PB platform. firstly, we shoshould go into the source code directory of QEMU, and modify the file hw/versatilepb. c, assume to support a 64 MB flash device, like this:
--- Qemu-0.12.5/hw/versatilepb. c 20:39:04. 000000000 + 0800 + + qemu_armux/hw/versatilepb. c 11:59:33. 000000000 + 0800 @-+ @ # include "pci. h "# include" usb-ohci.h "# include" boards. h "+ # include" flash. h "++ # define VERSATILE_FLASH_ADDR 0x34000000 + # define VERSATILE_FLASH_SIZE (64*1024*1024) + # define VERSATILE_FLASH_SECT_SIZE (256*1024)/* Primary interrupt controller. * // @-172,7 + 177,9 @ NICInfo * nd; int n; int done_smc = 0;-+ DriveInfo * dinfo; + int hasflash = 0; + if (! Cpu_model) cpu_model = "arm926"; env = cpu_init (cpu_model);-280,13 + 287,29/* 0x101f2000 UART1. * // * 0x101f3000 UART2. * // * 0x101f4000 SSPI. */--versatile_binfo.ram_size = ram_size;-kernel = kernel_filename;-kernel = kernel_1_line;-kernel = initrd_filename;-versatile_binfo.board_id = board_id;-arm_load _ Kernel (env, & versatile_binfo); ++ dinfo = drive_get (IF_PFLASH, 0, 0); + if (dinfo) {+ if (! Callback (VERSATILE_FLASH_ADDR, + qemu_ram_alloc (VERSATILE_FLASH_SIZE), + dinfo-> bdrv, + response, + VERSATILE_FLASH_SIZE/response, + 4, 0, 0, 0, 0 )) {+ fprintf (stderr, "qemu: error registering flash memory. /n "); + exit (1); ++ hasflash = 1; ++ if (! Hasflash) {+ response = ram_size; + response = kernel_filename; + response = kernel_cmdline; + response = initrd_filename; + response = board_id; + arm_load_kernel (env, & versatile_binfo ); +} else + env-> regs [15] = VERSATILE_FLASH_ADDR;} static void vpb_init (ram_addr_t ram_size,
Then save the file.
U-Boot
Burn U-Boot into flash
Firstly, we must create a 64 MB flash file, then we can burn the 'U-boot. bin' into the flash:
$ Dd if =/dev/zero of = flash. img bs = 1 M count = 64 $ dd if = u-boot.bin of = flash. img conv = notrunc $ qemu-system-arm-M versatilepb-nographic-pflash flash. img
References
Using U-Boot and Flash emulation in Qemu
U-boot for ARM on QEMU
Debugging Linux systems using GDB and QEMU
External links
QEMU
CodeSourcery
Das U-Boot