Thursday, August 24, 2017

Linux ARM on QEMU

Many times we want to develop a generic device driver for ARM processor, but we want first to test it on an emulator.  In this case, the emulator we're gonna use is ARM.

Here's the content of my script to build Linux for generic ARM (Versatile/PB (ARM926EJ-S). According to https://www.kernel.org/doc/Documentation/arm/Booting, Typically the physical RAM does not start at address zero. LOADADDR specifies the address where the kernel image will be located by U-Boot and is stored in the U-Boot header by the mkimage utility. Typically the load address (for placement in memory) is also the start address (for execution). Note that the uImage file is typically just the (self-extracting, compressed) zImage file with the U-Boot wrapper.

ARCH=arm

core=$(nproc)
make ARCH=$ARCH versatile_defcocnfig
make -j${core} ARCH=$ARCH CROSS_COMPILE=arm-linux-gnueabihf- uImage LOADADDR=0x80008000


There is a much easier way: using Yocto.

The following steps would be everything needed to run Linux arm on Qemu:


1.  git clone git://git.yoctoproject.org/poky

2.  cd poky

3.  git checkout -b pyro origin/pyro

4.  Edit ./build/conf/local.conf and add:

    INHERIT += "rm_work"

    Uncomment (and comment out the x32 one):
     MACHINE ?= "qemuarm"

    exit from editor

5.  From shell, type:
 
    . ./oe-init-build-env

    bitbake core-image-sato

or, if we want to build everything:

  bitbake world 

6.  Once a particular image (in this case is qemuarm) has been built, we can
    test it with command:

        runqemu qemuarm


The target files are located in ${yocto_dir}/build.  In my case it is in ${HOME}/poky.  For example, in my case:

./qemuarm-poky-linux-gnueabi/linux-yocto/4.10.17+gitAUTOINC+e92bd55409_3926e38630-r0/deploy-linux-yocto/zImage


No comments:

Post a Comment