	Xvisor on Allwinner A10 board (or Sun4i) using SD Booting 

This section of readme explains how to build & run Xvisor on actual Allwinner
A10 boards (Hackberry or pcduino for example) using SD booting feature of
Sun4i SOC.

By default, Xvisor for Sun4i supports Realview-PB-A8 guest so we will show 
how to run Basic Firmware on Realview-PB-A8 guest. For more info refer,
<xvisor_source>/tests/arm32/realview-pb-a8/basic/README.

As first step of SD booting on Sun4i SOC, we need to re-partition and programme 
a SD card (> 4GB card) with Uboot. For detailed info on preparing SD card for 
booting refer: http://rhombus-tech.net/allwinner_a10/a10_mmc_boot

Once we have SD card prepared for SD booting, we add 2 images to the boot 
partition of SD card:
 1) U-Boot compatible Xvisor binary (uvmm.bin).
 2) Patched guest binary 
    (Patched Realview-pb-a8 Basic Firmware image, firmware.bin.patched)

Following are steps to create these images and then boot Xvisor on Allwinner
A10:

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

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

  [3. Configure Xvisor with Sun4i host default settings]
  # make ARCH=arm sun4i-defconfig 

  [4. Build Xvisor, this creates vmm.bin]
  # 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 for Realview-PB-A8 Guest, this creates firmware.bin.patched]
  # make -C tests/arm32/realview-pb-a8/basic
  
  [7. Unplug bootable SD card from the A10 board and plug it on your development machine]

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

  [9. Copy uvmm.bin to boot partition of SD card]
  # cp uvmm.bin <path_to_mounted_boot_partition_of_sd_card>

  [10. Copy firmware.bin.patched to boot partition of SD card]
  # cp build/tests/arm32/realview-pb-a8/basic/firmware.bin.patched <path_to_mounted_boot_partition_of_sd_card>/arm.bin

  (Note: If you want additional images like cmdlist, patched zImage, 
   rootfs.img etc. then you should copy these images to boot partition
   of SD card after above step.)
  (Note: For more info on images required for linux on Realview-PB-A8 guest 
   refer to <xvisor_source>/tests/arm32/realview-pb-a8/linux/README.)

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

  [12. Unplug SD card from your development machine and plug it back on A10 board]

  [13. Connect to serial port of A10 board using Putty or Minicom]

  [14. Power-up or Reset A10 board and press any key when U-Boot shows auto-boot count down]

  [15. Enable MMC interface from U-Boot command line]
  sun4i# mmc dev 0:0

  [16. Copy Xvisor from SD card to SDRAM]
  sun4i# fatload mmc 0 0x40200000 uvmm.bin

  [17. Copy Guest image from SD card to SDRAM]
  sun4i# fatload mmc 0 0x41000000 arm.bin

  (Note: If you want to load additional images like cmdlist, patched zImage, 
   rootfs.img, etc. from SD card then load these images at address 
   0x41000000 or higher using fatload command of U-Boot after above step.)
  (Note: The default DTS used by Xvisor for Sun4i has one pre-configured
   Realview-PB-A8 guest. The NOR flash of the guest is 16 MB in size and is 
   mapped to 0x41000000 host physical address. The guest boots from start of 
   NOR flash so we put Basic Firmware arm.bin at start of NOR flash and rest of
   the guest images like cmdlist, patched zImage, rootfs.img, etc. after it.)
  (Note: For e.g. if we want to load cmdlist, patched zImage and rootfs image
   into guest NOR flash then use:
   sun4i# fatload mmc 0 0x410FF000 cmdlist
   sun4i# fatload mmc 0 0x41100000 zImage
   sun4i# fatload mmc 0 0x41400000 rootfs.img )

  [18. Jump into Xvisor after disabling MMU, interrupts, etc]
  sun4i# bootm 0x40200000

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

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

  [21. 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# copy 0x70008000 0x40100000 0x4F8000
   basic# copy 0x70500000 0x40600000 0x600000
   basic# start_linux 0x70008000 0x70500000 0x600000 
   OR
   basic# autoexec)

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

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

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

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

