“Xen on Hikey960”的版本间的差异
free6d1823(讨论 | 贡献) |
free6d1823(讨论 | 贡献) |
||
第146行: | 第146行: | ||
make defconfig | make defconfig | ||
make -j8 | make -j8 | ||
− | cp xen.efi ../../ | + | cp xen.efi ../../ ##xen.efi is a symbolic link |
+ | cp xen ../../ | ||
+ | |||
4. Extract the wl18xx-fw-4.bin so your WiFi will work | 4. Extract the wl18xx-fw-4.bin so your WiFi will work |
2019年11月14日 (四) 15:23的版本
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.a) 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"
It will download these files:
config hisi-sec_uce_boot.img l-loader.bin recovery.bin fip.bin hisi-sec_usb_xloader.img MD5SUMS.txt sec_ptable.img hikey_idt hisi-sec_xloader.img prm_ptable.img
==>>check this http://www.smartfire.cn/thread-707-1-1.html 2019/11/12
(1.b) build from source:
- fetch repositories:
#git clone https://github.com/ARM-software/arm-trusted-firmware -b integration git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5 git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4 git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2 git clone https://github.com/96boards-hikey/atf-fastboot
- Create the symbol link to OpenPlatformPkg in edk2.
$cd ${BUILD_PATH}/edk2 $ln -sf ../OpenPlatformPkg
- prepare AARCH64 toolchain
- build (debug mode)
export LOADER_DIR=${BUILD_PATH}/l-loader cd ${LOADER_DIR} # Build UEFI & ARM Trust Firmware ## bash ./l-loader.sh hikey960
l-loader.sh not found, modify build_uefi.sh
##OPTEE=1 #no OPTEE AARCH64_GCC=LINARO_GCC_7_4 "LINARO_GCC_7_4") ## line#45 AARCH64_GCC_7_4=/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin/ PATH=${AARCH64_GCC_7_4}:${PATH} && export PATH
GenFvInternalLib.c:24:23: fatal error: uuid/uuid.h: 沒有此一檔案或目錄
(1) vi vi ./edk2/BaseTools/Source/C/GenFv/GenFvInternalLib.c #include <linux/uuid.h> //uuid/uuid.h (2) sudo ln -sf /lib/x86_64-linux-gnu/libuuid.so.1 /lib/libuuid.so
Output imagres including partition table are generated in l-loader directory.
recovery.bin = bl1.bin + BL33_AP_UEFI.fd (by gen_loader_hikey960.py) l-loader.bin = bl2.bin fip.bin
(2)flash recovery files
(2.1)prepare config and files (if build from source)
vi config # The content of config file ./hisi-sec_usb_xloader.img 0x00020000 ./hisi-sec_uce_boot.img 0x6A908000 ./recovery.bin 0x1AC00000
Used files:
#recovery mode: hike_idt from 1.a download config can be copied from 1.a download hisi-sec_usb_xloader.img from 1.a download hisi-sec_uce_boot.img from 1.a download recovery.bin from 1.b #fastboot mode prm_ptable.img from 1.a download hisi-sec_xloader.img from 1.a download l-loader.bin from 1.b fip.bin from 1.b
(2.2) change board to recovery mode
steps:
1. board power off, USB->UART convertor connect to host PC (/dev/ttyUSB0) 2. board in recovery mode: jumper: on-on-off 3. plug type-C in OTG. 4. board power on. In host PC, you will see /dev/ttyUSB1 node. 只有在recover mode才會有USB 變COM. 5. cd ./uefi 6. sudo ./hikey_idt -c config -p /dev/ttyUSB1
(3) change board to fastboot mode
燒完直接進入fastoot mode, 不用改jumper
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 (not used)
download uefi boot
boot-0.0+AUTOINC+<some number>hikey960-<some number>.uefi.img
find these:
boot-0.0+AUTOINC+06e4def583-fb1158a365-r0-hikey-20191111073000-224.uefi.img
rpb-console-image-hikey-20191111073000-224.rootfs.img.gz
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 ../../ ##xen.efi is a symbolic link cp xen ../../
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.下載 rootfs
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. Building GRUB
Pre-requirement:
sudo apt-get install autoconf automake libtool autopoint
6.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 ../
6.2 create grub.config
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 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/lib/grub/arm64-efi \ ##correct: change lib64 to lib --output=grubaa64.efi \ --format=arm64-efi \ --prefix="/boot/grub" \ $GRUB_MODULES
6.4 create new boot.img
sudo mount boot-0.0+AUTOINC+<some number>hikey960-<some number>.uefi.img loop -o loop cp grubaa64.efi loop/EFI/BOOT sudo umount loop
- the new grubbaa64.efi will be installed in (hd3,gpt7)/efi/boot/grubaa64.efi
7 create file system 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 - ) cd .. ##change dir to build/ sudo umount loop img2simg rootfs.img rootfs.sparse.img 4096
Note: need install img2simg
sudo apt install android-tools-fsutils
8. Flash boot.img and system.img
sudo fastboot flash boot boot-0.0+AUTOINC+06e4def583-fb1158a365-r0-hikey-20191111073000-224.uefi.img sudo fastboot flash system rootfs.sparse.img
connect UART-USB as /dev/ttyUSB0
connect USB type-C
board switch to fastbootmode (Jumper :on-off-on)
Power on the board, it will enter fastboot mode (Shows "Press ESCAPE for boot options .Android Fastboot mode - version 0.7.") Press anykey will enter grub.