Xen on Hikey960
Reference: https://wiki.xenproject.org/wiki/HiKey960
1. Building UEFI
export BUILD_PATH=~/build cd ${BUILD_PATH}
download tools-images-hikey960
git clone https://github.com/96boards-hikey/tools-images-hikey960 cd tools-images-hikey960
see README-flash-uefi.md to install ser2net first.
參考 recovery-flash-uefi-prebuilt.sh 分成三步驟
(1) download prebuild from
https://snapshots.linaro.org/reference-platform/components/uefi-staging/${VERSION}/hikey960/${RELEASE}/
BASE_URL=https://snapshots.linaro.org/reference-platform/components/uefi-staging
VERSION=latest
PRODUCT=hikey960
RELEASE=release
DEVICE=/dev/ttyUSB1
UEFI_URL=${BASE_URL}/${VERSION}/${PRODUCT}/${RELEASE}/
mkdir -p ./uefi cd uefi wget -A bin,config,efi,hikey_idt,img,txt -m -nd -np "$UEFI_URL"
(2) change board to recovery mode (沒成功)
download hikey_idt hisi-sec_usb_xloader.img, hisi-sec_uce_boot.img, hisi-sec_fastboot.img
sudo ./hikey_idt -c config -p ${DEVICE}
(3) change board to fastboot mode
sudo fastboot flash ptable prm_ptable.img sudo fastboot flash xloader hisi-sec_xloader.img (無法寫入) sudo fastboot flash fastboot l-loader.bin sudo fastboot flash fip fip.bin
Switch to normal mode, power on
xxx2. Download boot and system image
boot - The FAT32 64MB partition containing GRUB (or xen.efi if desired)
system - The rootfs (Ext4) containing the OS and /boot directory for GRUB to search.
try this:(NO HIKEY960)
https://snapshots.linaro.org/reference-platform/embedded/morty/hikey/latest/rpb/
download rootfs from
rpb-console-image-hikey960-<some number>.rootfs.img.gz
download uefi boot
boot-0.0+AUTOINC+<some number>hikey960-<some number>.uefi.img
2. Building Linux
export TOOLS=/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin export PATH=$PATH:$TOOLS git clone https://github.com/96boards-hikey/linux.git cd linux git checkout origin/hikey960-upstream-rebase export CROSS_COMPILE=aarch64-linux-gnu- export ARCH=arm64 make defconfig
check .config, CONFIG_XEN_DOM0=y CONFIG_XEN=y
make -j8 cp -f arch/$ARCH/boot/Image ../Image cp -f arch/$ARCH/boot/dts/hisilicon/hi3660-hikey960.dtb ../Image.dtb
3. Building Xen
git clone git://xenbits.xen.org/xen.git cd xen/xen
export CROSS_COMPILE=aarch64-linux-gnu- export ARCH=arm64 export XEN_TARGET_ARCH=arm64 make defconfig make -j8 cp xen.efi ../../
4. Extract the wl18xx-fw-4.bin so your WiFi will work
git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git cd linux-firmware cp ti-connectivity/wl18xx-fw-4.bin ../
5. Building GRUB
Pre-requirement:
sudo apt-get install autoconf automake libtool autopoint
5.1 Make
git clone https://git.savannah.gnu.org/git/grub.git cd grub ./bootstrap => autoconf->autogen.sh=>configure export CROSS_COMPILE=aarch64-linux-gnu- export ARCH=arm64 ./configure --prefix=/usr --target=aarch64-linux-gnu --with-platform=efi ## --target=target-type the type of system for which any compiler tools in the package produce code ## --host=host-type the type of system on which the package runs.包grub image 的機器. X86 ## --prefix ## --with-platform make mkdir ../grub-install make DESTDIR=`pwd`/../grub-install install cd ../
5.3 create grubaa64.efi
export GRUB_MODULES="boot chain configfile echo efinet eval ext2 fat font gettext gfxterm gzio help linux loadenv lsefi normal part_gpt part_msdos read regexp search search_fs_file search_fs_uuid search_label terminal terminfo test tftp time xen_boot" grub-install/usr/bin/grub-mkimage --config grub.config \ --dtb Image.dtb \ --directory=`pwd`/grub-install/usr/lib64/grub/arm64-efi \ --output=grubaa64.efi \ --format=arm64-efi \ --prefix="/boot/grub" \ $GRUB_MODULES
6. rootfs
6.1 下載
check https://releases.linaro.org/debian/images/developer-arm64/latest/
wget https://releases.linaro.org/debian/images/developer-arm64/latest/linaro-stretch-developer- 20170720-71.tar.gz sudo tar -xzf linaro-stretch-developer-20180416-89.tar.gz sudo mv binary rootfs sudo cp Image rootfs/boot sudo cp Image.dtb rootfs/boot sudo cp xen.efi rootfs/boot sudo mkdir -p rootfs/lib/firmware/ti-connectivity sudo cp wl18xx-fw-4.bin rootfs/lib/firmware/ti-connectivity
6.2 包grub.config in rootfs/boot
copied from rootfs/usr/share/96boards-tools/grub/grub.configfile
search.fs_label rootfs root set prefix=($root)/boot/grub configfile $prefix/grub.cfg
6.3 create image
mkdir loop dd if=/dev/zero of=rootfs.img bs=1M count=2096 mkfs.ext4 -F -L rootfs rootfs.img #kernel use the label rootfs to mount the rootfs as / sudo mount -o loop rootfs.img loop cd rootfs sudo tar -cf - * | (cd ../loop;sudo tar -xf - ) sudo umount loop img2simg rootfs.img rootfs.sparse.img 4096
7. Update boot.img
8. Flash boot.img and system.img