Skip to content

Instantly share code, notes, and snippets.

@tnishinaga
Last active December 28, 2017 19:09
Show Gist options
  • Save tnishinaga/5eff718512801ea689fe023650fa232a to your computer and use it in GitHub Desktop.
Save tnishinaga/5eff718512801ea689fe023650fa232a to your computer and use it in GitHub Desktop.
#!/bin/sh -x
# setup cross toolchain
wget http://releases.linaro.org/archive/15.02/components/toolchain/binaries/aarch64-linux-gnu/gcc-linaro-4.9-2015.02-3-x86_64_aarch64-linux-gnu.tar.xz
wget http://releases.linaro.org/archive/15.02/components/toolchain/binaries/arm-linux-gnueabihf/gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf.tar.xz
mkdir arm-tc arm64-tc
tar --strip-components=1 -C ${PWD}/arm-tc -xf gcc-linaro-4.9-*-x86_64_aarch64-linux-gnu.tar.xz
tar --strip-components=1 -C ${PWD}/arm64-tc -xf gcc-linaro-4.9-*-x86_64_arm-linux-gnueabihf.tar.xz
export PATH="${PWD}/arm-tc/bin:${PWD}/arm64-tc/bin:$PATH"
# get source code
UEFI_TOOLS_GIT_URL=https://git.linaro.org/uefi/uefi-tools.git
UEFI_TOOLS_GIT_BRANCH=master
EDK2_GIT_URL=https://github.com/96boards-hikey/edk2.git
EDK2_GIT_VERSION="origin/hikey-aosp"
ATF_GIT_URL=https://github.com/96boards-hikey/arm-trusted-firmware.git
ATF_GIT_VERSION="origin/hikey"
OPEN_PLATFORM_PKG_GIT_URL=https://github.com/96boards-hikey/OpenPlatformPkg.git
OPEN_PLATFORM_PKG_GIT_BRANCH=hikey-aosp
OPTEE_OS_GIT_URL=https://github.com/OP-TEE/optee_os.git
OPTEE_GIT_VERSION=master
export AARCH64_TOOLCHAIN=GCC49
git clone https://github.com/96boards-hikey/l-loader.git
git clone -b $UEFI_TOOLS_GIT_BRANCH $UEFI_TOOLS_GIT_URL uefi-tools
git clone $EDK2_GIT_URL edk2
cd edk2
git checkout -b stable-baseline $EDK2_GIT_VERSION
cd ..
git clone -b $OPEN_PLATFORM_PKG_GIT_BRANCH $OPEN_PLATFORM_PKG_GIT_URL OpenPlatformPkg
cd edk2
rm -rf OpenPlatformPkg
ln -s ../OpenPlatformPkg
cd ..
git clone $ATF_GIT_URL arm-trusted-firmware
cd arm-trusted-firmware
git checkout -b stable-baseline $ATF_GIT_VERSION
cd ..
git clone $OPTEE_OS_GIT_URL optee_os
cd optee_os
git checkout -b stable-baseline $OPTEE_GIT_VERSION
cd ..
#build uefi
export EDK2_DIR=${PWD}/edk2
export ATF_DIR=${PWD}/arm-trusted-firmware
export OPTEE_OS_DIR=${PWD}/optee_os
export UEFI_TOOLS_DIR=${PWD}/uefi-tools
cd ${EDK2_DIR}
bash -x ${UEFI_TOOLS_DIR}/uefi-build.sh -T GCC49 -b RELEASE -a ${ATF_DIR} -s ${OPTEE_OS_DIR} hikey
# To use UART0 instead of UART3 as the console, uncomment the appropriate line(s) in
# ${UEFI_TOOLS_DIR}/platforms.config before running the command above.
cd ../l-loader
ln -s ${EDK2_DIR}/Build/HiKey/RELEASE_GCC49/FV/bl1.bin
ln -s ${EDK2_DIR}/Build/HiKey/RELEASE_GCC49/FV/fip.bin
make # requires sudo for creating the partition tables
mkdir ~/hikey_uefi_files
cp fip.bin ptable-* l-loader.bin ~/hikey_uefi_files
cd
tar Jcvf hikey_uefi_files.tar.xz hikey_uefi_files/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment