您的位置:首页 > 产品设计 > 产品经理

Using QEMU for Embedded Systems Development, Part 3

2013-03-19 21:09 204 查看
In embedded systems, especially in mobile devices, ARM processor-based devices are leading the market. For ARM, U-Boot is the best choice for a bootloader. The good thing about it is that we can use it for different architectures like PPC, MIPS, x86, etc.
So let’s get started.

Download and compile U-Boot

U-Boot is released under a GPL licence. Download it from
this FTP server, which has every version of U-Boot available. For this article, I got version 1.2.0 (
u-boot-1.2.0.tar.bz2
). Extract the downloaded tar ball and enter the source code directory:

To begin, we must configure U-Boot for a particular board. We will use the same ARM Versatile Platform Baseboard (
versatilepb
) we used in the

previous article, so let’s run:

After configuration is done, compile the source code:

Find the size of the compiled U-Boot binary file (around 72 KB in my experience) with
ls -lh u-boot*
— we will use it later in this article. I assume that you have set up QEMU, networking and the ARM tool chain, as explained in previous articles in this series (1,

2,
3). If not, then I suggest you read the last three articles.

Boot U-Boot in QEMU

Now we can boot the U-Boot binary in QEMU, which is simple. Instead of specifying the Linux kernel as the file to boot in QEMU, use the U-Boot binary:

Run some commands in U-Boot, to check if it is working:




Figure 1: U-Boot

The next step is to boot a small program from U-Boot. In the
previous article, we wrote a small bare-metal program — so let us use that.

We will create a flash binary image that includes
u-boot.bin
and the bare-metal program in it. The test program from the last article will be used here again with some modification. As the
u-boot.bin
size is around 72 KB, we will move our sample program upward in memory. In the linker script, change the starting address of the program:

Compile the test program as shown below:

Now, our test program’s binary file and the
u-boot.bin
must be packed in a single file. Let’s use the
mkimage
tool for this; locate it in the U-Boot source-code directory.

Our sample binary file is ready. Let’s combine it with
u-boot.bin
to create the final flash image file:

Calculate the starting address of the test program in the
flash.bin
file:

Boot the flash image in QEMU:

Now verify the image address in U-Boot:

The image is present at the address
0x21C68
. Boot it by executing the
bootm
command:

That’s all folks!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: