	Xvisor on ODroid-X using SD Booting

This section of the readme explains how to build & run Xvisor on an actual
ODroid-X development board, using the SD card for booting.

By default, Xvisor for Exynos4 supports Realview-PB-A8 guests, so we will
show how to run Basic Firmware (and/or Linux) on Realview-PB-A8 guest.

For booting from SD card we first need to install the first and second
level bootloader as well as u-boot to the SD card. For more info, refer
http://com.odroid.com/sigong/blog/blog_list.php?bid=130

We need to add 2 images in boot partition of SD card that is shipped with
ODroid-X:
 1) U-Boot compatible Xvisor binary (uvmm.bin).
 2) Disk image containing guest binaries (disk.img).

Following steps to create these images and then boot Xvisor on ODroid-X:

  [1. Build environment]
  # CROSS_COMPILE=arm-linux-gnueabi-

  [2. GoTo Xvisor source directory]
  # cd <xvisor_source_directory>

  [3. Configure Xvisor with ODroid-X host default settings]
  # make ARCH=arm generic-v7-defconfig

  [4. Build Xvisor]
  # make

  [5. Make U-Boot compatible uvmm.bin, for use with bootm command]
  # mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n "Xvisor" -d build/vmm.bin build/uvmm.bin
 
  [6. Build Basic Firmware]
  # make -C tests/arm32/realview-pb-a8/basic

  [7. Create disk image for Xvisor]
  # mkdir -p ./build/disk/images/arm32/realview-pb-a8
  # ./build/tools/dtc/dtc -I dts -O dtb -o ./build/disk/images/arm32/realview-pb-a8.dtb ./tests/arm32/realview-pb-a8/realview-pb-a8.dts
  # cp -f ./build/tests/arm32/realview-pb-a8/basic/firmware.bin.patched ./build/disk/images/arm32/realview-pb-a8/firmware.bin
  # cp -f ./tests/arm32/realview-pb-a8/basic/nor_flash.list ./build/disk/images/arm32/realview-pb-a8/nor_flash.list
  # genext2fs -B 1024 -b 16384 -d ./build/disk ./build/disk.img
  OR
  # mkdir -p ./build/disk/images/arm32/realview-pb-a8
  # ./build/tools/dtc/dtc -I dts -O dtb -o ./build/disk/images/arm32/realview-pb-a8.dtb ./tests/arm32/realview-pb-a8/realview-pb-a8.dts
  # cp -f ./build/tests/arm32/realview-pb-a8/basic/firmware.bin.patched ./build/disk/images/arm32/realview-pb-a8/firmware.bin
  # cp -f ./tests/arm32/realview-pb-a8/linux/nor_flash.list ./build/disk/images/arm32/realview-pb-a8/nor_flash.list
  # cp -f ./tests/arm32/realview-pb-a8/linux/cmdlist ./build/disk/images/arm32/realview-pb-a8/cmdlist
  # cp -f <linux_build_directory>/arch/arm/boot/Image ./build/disk/images/arm32/realview-pb-a8/Image
  # cp -f <busybox_rootfs_directory>/rootfs.img ./build/disk/images/arm32/rootfs.img
  # genext2fs -B 1024 -b 16384 -d ./build/disk ./build/disk.img

  (Note: For creating <linux_build_directory>/arch/arm/boot/Image refer
   <xvisor_source_directory>/tests/arm32/realview-pb-a8/linux/README)
  (Note: For creating <busybox_rootfs_directory>/rootfs.img refer
   <xvisor_source_directory>/tests/arm32/common/busybox/README)

  [8. Make U-boot compatible initrd for use with bootm command]
  # mkimage -A arm -O linux -T ramdisk -a 0x41000000 -n "Xvisor ramdisk" -d build/disk.img build/udisk.img
 
  [9. Unplug SD card from ODroid-X and plug it on your development machine]

  [10. Mount boot partition (or partition 0) of SD card on your development machine]

  [11. Copy uvmm.bin, DTB, and disk.img to boot partition of SD card]
  # cp -f build/uvmm.bin <path_to_mounted_boot_partition_of_sd_card>
  # cp -f build/arch/arm/board/generic/dts/exynos4/odroidx/one_guest_pb-a8.dtb <path_to_mounted_boot_partition_of_sd_card>
  # cp -f build/udisk.img <path_to_mounted_boot_partition_of_sd_card>

  [12. Unmount boot partition (or partition 0) of SD card from your development machine]

  [13. Unplug SD card from your development machine and plug it back on ODroid-X]

  [14. Connect to serial port of ODroid-X using Putty or Minicom]

  [15. Power-up or Reset ODroid-X and press any key when U-Boot shows auto-boot count down]

  [16. Enabled MMC interface from U-Boot command line interface]
  ODROIDX# mmc dev 0:2

  [17. Copy Xvisor from SD card to SDRAM]
  ODROIDX# fatload mmc 0:2 0x40200000 uvmm.bin

  [18. Copy the Xvisor DTB from SD card to SDRAM]
  ODROIDX# fatload mmc 0 0x40800000 one_guest_pb-a8.dtb

  [19. Copy disk image from SD card to SDRAM]
  ODROIDX# fatload mmc 0:2 0x42000000 udisk.img

  [20. Jump into Xvisor after disabling MMU, interrupts, etc]
  ODROIDX# bootm 0x40200000 0x42000000 0x40800000

  [21. Kick Guest0 for starting Basic Firmware]
  XVisor# guest kick guest0

  [22. Bind to virtual UART]
  XVisor# vserial bind guest0/uart0

  [23. Say 'hi' to Basic Firmware]
  [guest0/uart0] basic# hi

  (Note: If you had linux images loaded in guest NOR flash then
   instead of above step you can start booting linux,
   basic# autoexec)

  [24. Say 'hello' to Basic Firmware]
  [guest0/uart0] basic# hello

  [25. Check various commands of Basic Firmware]
  [guest0/uart0] basic# help

  [26. Enter character seqence 'ESCAPE+x+q" return to Xvisor prompt]
  [guest0/uart0] basic# 

  (Note: replace all <> brackets based on your workspace)

