2014년 11월 16일 일요일

Setting Karlinux for ARM Build Environment

Introduction


I want to be a excellent linux kernel developer, so I have a plan to make my own linux kernel, karlinux. To simplify the work, the target of karlinux is only ARMv7 multicore. (If I have a time, I will extend it to ARMv8 multicore.)
My karlinux will be excuted on QEMU. QEMU is an emulator for a specific hardware, such as versatile, etc. By using QEMU, I can test my bootloader, linux kernel, and framework.
Today, I will explain how to set up environment for karlinux. I will set QEMU and print "Hello! World!" in karlinux.

Step 1: Install QEMU from source


At first, necessary package should be installed
sudo apt-get install libpixman-1-dev libglib2.0 zlib1g-dev libsdl-console-dev libncurses5-dev

I prefer to use Linaro's release, so I downloaded source code from Linaro.
wget https://launchpad.net/qemu-linaro/trunk/2014.01/+download/qemu-linaro-1.7.0-2014.01.tar.gz

Unzip the tarball, and compile it.
tar xvf qemu-linaro-1.7.0-2014.01.tar.gz

Configure and build QEMU.
cd qemu-linaro-1.7.0-2014.01
mdkir build && cd build
sudo apt-get install flex bison
../configure --prefix=$PWD/../install --target-list=arm-softmmu --enable-debug

At this point, I got a problem of DTC. So, I downloaded DTC from its git, and manually installed. Download DTC

Extract the file and move it to qemu/dtc/, and compile dtc form source using make. For new DTC, restart configuring QEMU using previous command.
../configure --prefix=$PWD/../install --target-list=arm-softmmu --enable-debug

Install the generated QEMU binaries.
make install

For the last, add the path of qemu binaries to your environment variables.
vi /home/YOUR_ACCOUNT/.bashrc

export PATH=/home/YOUR_ACCOUNT/qemue-linao/qemu-linaro-1.7.0-2014.01/install/bin:$PATH

You may need to modify the path.

Step 2: Try ARM Linux prebuilt image on QEMU


Now, I will use QEMU to emulate Versatile Exporess, ARM's reference board for its Cortex-A processor.

First grab a system image for vexpress form Linaro's release site:
wget https://releases.linaro.org/images/12.02/oneiric/nano/vexpress-a9-nano.img.gz
gzip -d vexpress-a9-nano.img.gz

Note that -nano is one of Linaro's root filesystem. See here for details.

Since QEMU requires us to specify Linux kernel and init ramdisk in launching an emulated board, extract the two files from the downloaded image.
mkdir -p ~/tmp/boot/
sudo mount -o loop,offset=$((63*512)) vexpress-a9-nano.img ~/tmp/boot

Strip u-boot's header from uInitrd.
dd if=~/tmp/boot/uInitrd of=~/tmp/initrd skip=64 bs=1

At this point, I'm ready to the emulated vexpress.

Use the following commands to start the ARM Linux inside the QEMU emulator.
qemu-system-arm -kernel ~/tmp/boot/uImage -M vexpress-a9 -cpu cortex-a9 -smp 4 -serial stdio -m 1024 -initrd ~/tmp/initrd -append 'root=/dev/mmcblk0p2 rw mem=1024M raid=noautodetect console=ttyAMA0,38400n8 rootwait vmalloc=256MB devtmpfs.mount=0' -sd vexpress-a9-nano.img

By using the command, linux window is shown up.

For test QEMU, I used vexpress a9, but my real target is vexpress a15. From the next post, I will modify the command for vexpress a15.

Enjoy your QEMU.

 

댓글 없음:

댓글 쓰기