Ray Of Hope

VirtualDroid: Initial step port type 1 hypervisor

Selected and got my ODroid u2 board – quad core with 1 GB of RAM with UART to USB converter for debugging and a HDMI cable for connecting it to monitor.

As mentioned in my previous post, I was looking for opttion i.e whether to go for type 1 hypervisor or type 2. So after some R&D I decided to go for type 1 hypervisor and selected open-source xVisor as my hypervisor to post.

So currently involved in to get my xvisor compiling and to port it to oDroid board. Run Realview-PB-a8 guest and linux guest OS over it. Then ultimately will try to run Android Guest OS overt Realview-PB-a8 guest.

Here are some of the steps that I found useful while compiling xvisor on my fedor 17 32 bit host OS. (Most of these steps are mentioned in xvisor source, but I have added some extra comments and link related to problems that I faced and how I resolved them.)

1) install toolchain from kernel.org : https://www.kernel.org/pub/tools/crosstool/files/bin/i686/4.6.3/ (i686-gcc-4.6.3-nolibc_arm-unknown-linux-gnueabi.tar.gz)
2) export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/anshul/.local/bin:/home/anshul/bin:/home/anshul/kernel_org_arm_toolchain/gcc-4.6.3-nolibc/arm-unknown-linux-gnueabi/bin (Not the order of compilation toolchain should be last in the path. Also make sure host also has its own native gcc installed)
3) export CROSS_COMPILE=arm-unknown-linux-gnueabi-
4) download kernel 3.7.4 from kernel.org (with other kernel versions patching was failing .)
5) download busybox 1.21.0 http://www.busybox.net/downloads/
4) install curses library “yum install ncurses-devel ncurses”

[1. Set cross toolchain prefix (can be different)]
# export CROSS_COMPILE=arm-none-linux-gnueabi-
[2. GoTo Xvisor source directory]
# cd <xvisor_source_directory>
[3. Configure Xvisor with ODroid-X host default settings]
# make ARCH=arm exynos4412-odroidx-defconfig or you can do make menuconfig. I selected “target architecture as arm”, “target processor as Cortex A9” and “target board as Exynos4” for my odroid u2 board carry Exynos4 processor.
[4. Build Xvisor]
# make
[5. Build Basic Firmware]
# make -C tests/arm32/realview-pb-a8/basic
[6. Copy defconfig to Linux build directory]
# cp tests/arm32/realview-pb-a8/linux/linux-<linux_version>_realview_pba8_defconfig <linux_build_directory>/.config
[7. GoTo Linux source directory]
# cd <linux_source_directory>
[8. Configure Linux in build directory]
# make O=<linux_build_directory> ARCH=arm oldconfig
[9. Build Linux in build directory]
# make O=<linux_build_directory> ARCH=arm zImage (for me O was not working so I used 0=<linux build directory> ARCh=arm zImage)
[10. Patch Linux kernel to replace sensitive non-priviledged instructions]
# <xvisor_source_directory>/arch/arm/cpu/arm32/elf2cpatch.py -f <linux_build_directory>/vmlinux | <xvisor_source_directory>/build/tools/cpatch/cpatch32 <linux_build_directory>/vmlinux 0
[11. Build Linux in build directory to reflect changes in kernel image]
# make O=<linux_build_directory> ARCH=arm zImage
[12. Patch Linux compressed kernel to replace sensitive non-priviledged instructions]
# <xvisor_source_directory>/arch/arm/cpu/arm32/elf2cpatch.py -f <linux_build_directory>/arch/arm/boot/compressed/vmlinux | <xvisor_source_directory>/build/tools/cpatch/cpatch32 <linux_build_directory>/arch/arm/boot/compressed/vmlinux 0
[13. Create final compressed kernel image]
# $(CROSS_COMPILE)objcopy -O binary <linux_build_directory>/arch/arm/boot/compressed/vmlinux <linux_build_directory>/arch/arm/boot/zImage
[14. Create BusyBox RAMDISK to be used as RootFS for Linux kernel]
(Note: For subsequent steps, we will assume that your RAMDISK is located at <busybox_rootfs_directory>/rootfs.img)
(Note: Please refer tests/arm32/common/busybox/README for creating rootfs.img using BusyBox)
[15. GoTo XVisor build directory]
# cd <xvisor_source_directory>/build
[16. Make U-Boot compatible uImage, for use with bootm command. install uboot-tools for mkimage. yum -y install uboot-tools]
# mkimage -A arm -O linux -T kernel -C none -a 0x40010000 -e 0x40010000 -n “Xvisor” -d vmm.bin uImage
[17. Unplug bootable SD card from the ODroid-X and plug it into your development machine]
[18. Mount the VFAT partition of the SD card on your development machine]
# sudo mount /dev/mmcblk0p2 /media/usb
[19. Copy uImage (and other components) to the mounted partition of the SD card]
# cp uImage /media/usb
# cp <linux_build_directory>/arch/arm/boot/zImage /media/usb
# cp tests/arm32/realview-pb-a8/linux/cmdlist /media/usb
# cp tests/arm32/realview-pb-a8/basic/firmware.bin.patched /media/usb
# cp <busybox_rootfs_directory>/rootfs.img /media/usb
[20. Unmount the partiton from your development machine]
# sudo umount /media/usb
[21. Connect a usb cable to the serial port of the ODroid-X and start your favorite terminal emulator]
[22. Power-up or Reset the ODroid-X and press any key to interrupt normal boot on U-Boot]
[23. Copy Xvisor from SD card to SDRAM]
ODROIDX# fatload mmc 0:2 0x50000000 uImage
ODROIDX# fatload mmc 0:2 0x41000000 firmware.bin.patched
ODROIDX# fatload mmc 0:2 0x410FF000 cmdlist
ODROIDX# fatload mmc 0:2 0x41100000 zImage
ODROIDX# fatload mmc 0:2 0x41600000 rootfs.img
[24. Jump into Xvisor after disabling MMU, interrupts, etc]
ODROIDX# bootm start 0x50000000
ODROIDX# loados
ODROIDX# bootm go 0x50000000
[25. Kick Guest0 for starting Basic Firmware]
XVisor# guest kick guest0
[26. Bind to virtual UART]
XVisor# vserial bind guest0/uart0
[27. Start Linux]
[guest0/uart0] basic# autoexec
[28. Enter character seqence ‘ESCAPE+x+q” return to Xvisor prompt]
[guest0/uart0] basic#

———————For step 14, need to follow following steps.———————–
[1. Build environment for busybox]
kernel_org toolchain can’t be used for busybox as it doesn’t contain libc. So compilation of busybox gives error of missing header files.
For compiling busybox, use Sourcery toolchain or any other that contains libc.
1) For busybox, export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/anshul/.local/bin:/home/anshul/bin:/home/anshul/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin
export CROSS_COMPILE=arm-none-linux-gnueabi-

[2. GoTo Xvisor source directory]
# cd <xvisor_source_directory>
[3. Copy defconfig to Busybox source directory]
# cp tests/arm32/busybox/busybox-<busybox_version>_defconfig <busybox_source_directory>/.config
[4. GoTo Busybox source directory]
# cd <busybox_source_directory>
[5. Configure Busybox source]
# make oldconfig
[6. Build Busybox RootFS]
# make install
[7. Change ownership of installed RootFS]
# sudo chown -R root:root ./_install
[8. Create RootFS image. Install fakeroot to perform this step. yum -y install fakeroot. Also download genext2 from filesystem and install from source.http://sourceforge.net/projects/genext2fs/?source=dlp]
# fakeroot /bin/bash -c “genext2fs -b 5120 -N 1024 -D <xvisor_source_directory>/tests/arm32/common/busybox/busybox_dev.txt -d ./_install <busybox_rootfs_directory>/rootfs.img”

(Note: <busybox_rootfs_directory>/rootfs.img is our final RAMDISK)
(Note: replace all <> brackets based on your workspace)
(Note: you are free to the change ordering of above steps based on your workspace)


Anshul Makkar




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.