Commit e4a2a821 authored by Angus Ainslie's avatar Angus Ainslie
Browse files

Merge branch 'mainline-atf-bump' into 'mainline-atf'

Mainline atf bump

See merge request Librem5/u-boot-builder!11
parents 2857ae27 7fdde69c
......@@ -15,12 +15,13 @@ UBOOT_BRANCH=2017.11+fslc
COPY_UBOOT=copy_uboot
pureos_board=imx6
make_clean=1
MKIMAGE_REPO=""
CWD=$(pwd)
usage() {
echo "Usage : $1 "
echo " -h Display this help message."
echo " -b [imx6|imx8|ec-som|devkit-recovery|devkit] select the board type."
echo " -b [imx6|imx8|ec-som|devkit-recovery|devkit|librem5|librem5-recovery] select the board type."
echo " -c don't make clean."
}
......@@ -38,6 +39,7 @@ function checkout_uboot()
cd "u-boot-${board}"
git pull
git checkout "${branch}"
cd ..
}
......@@ -48,11 +50,23 @@ function build_uboot()
local cc=$3
local config=$4
cd "u-boot-${board}"
if [ "${make_clean}" -eq 1 ]; then
make distclean
fi
if [ -z "${MKIMAGE_REPO}" ]; then
cd ..
build_atf "u-boot-${board}"
get_ddr_firmware "u-boot-${board}"
cd "u-boot-${board}"
fi
make ARCH="${arch}" CROSS_COMPILE="${cc}" "${config}"
make ARCH="${arch}" CROSS_COMPILE="${cc}"
if [ -z "${MKIMAGE_REPO}" ]; then
make ARCH="${arch}" CROSS_COMPILE="${cc}" flash.bin
make ARCH="${arch}" CROSS_COMPILE="${cc}" u-boot.imx
fi
cd ..
}
......@@ -74,7 +88,73 @@ function build_cortex_m4()
}
function build_atf()
{
DEST=$1
CWD=$(pwd)
ATF_DIR=$(echo "${ATF_REPO}" | awk -F '/' '{ print $NF }')
if [ ! -e "${ATF_DIR}" ]; then
git clone "${ATF_REPO}"
fi
cd "${ATF_DIR}"
git checkout "${ATF_BRANCH}"
make PLAT="${ATF_PLAT}" CROSS_COMPILE="${CROSS_COMPILER}" bl31
cd "${CWD}"
cp "${ATF_DIR}/build/imx8mq/release/bl31.bin" "${DEST}"
}
function get_ddr_firmware()
{
DEST=$1
if [ -z "${DEST}" ]; then
DEST="imx-mkimage/iMX8M/"
fi
if [ -n "${DDR_FILE}" ]; then
mkdir -p "firmware-${pureos_board}"
tar -C "firmware-${pureos_board}" -xf "${DDR_FILE}"
if [ -n "${DEST}" ]; then
cp firmware-"${pureos_board}"/imx-mkimage/iMX8M/*.bin "${DEST}"
fi
fi
if [ -n "${DDR_URL}" ]; then
DDR_BIN="$(basename "${DDR_URL}")"
DDR_DIR="$(basename "${DDR_URL}" .bin )"
if [ ! -e "${DDR_BIN}" ]; then
wget "${DDR_URL}"
chmod +x "${DDR_BIN}"
"./${DDR_BIN}" --auto-accept
fi
cp "${DDR_DIR}"/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem.bin "${DEST}"
cp "${DDR_DIR}"/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem.bin "${DEST}"
cp "${DDR_DIR}"/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem.bin "${DEST}"
cp "${DDR_DIR}"/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem.bin "${DEST}"
cp "${DDR_DIR}"/firmware/hdmi/cadence/signed_hdmi_imx8m.bin "${DEST}"
cp "${DDR_DIR}"/firmware/hdmi/cadence/signed_dp_imx8m.bin "${DEST}"
fi
}
function copy_uboot()
{
local board=$1
local out=$2
local uboot="u-boot-${board}.imx"
mkdir -p "${out}"
cp u-boot.imx "${out}/${uboot}"
}
function copy_uboot_mkimage()
{
local board=$1
local out=$2
......@@ -105,7 +185,7 @@ function generate_full_boot_image()
# Image size is 1055 KiB: m4.bin(31KiB) + flash.bin(1024KiB)
dd if=/dev/zero of="${img}" bs=1024 count=1055
dd if="${out}/m4.bin" conv=notrunc of="${img}" bs=1024
dd if="${CWD}/imx-mkimage/${UBOOT_BIN}" conv=notrunc of="${img}" bs=1024 seek=31
dd if="${out}/u-boot-${board}.imx" conv=notrunc of="${img}" bs=1024 seek=31
}
function combine_uboot_bins()
......@@ -119,76 +199,25 @@ function combine_uboot_bins()
cd "${CWD}"
if [ ! -z "${ATF_REPO}" ]; then
ATF_DIR=$(echo "${ATF_REPO}" | awk -F '/' '{ print $NF }')
if [ ! -e "${ATF_DIR}" ]; then
git clone "${ATF_REPO}"
fi
cd "${ATF_DIR}"
git checkout "${ATF_BRANCH}"
set +e
case "${pureos_board}" in
ec-som|devkit*)
if [ -e "${CWD}/files/imx-atf-disable-lpddr4-init.patch" ]; then
patch -N -p1 < "${CWD}/files/imx-atf-disable-lpddr4-init.patch"
fi
;;
esac
set -e
make PLAT="${ATF_PLAT}" CROSS_COMPILE="${CROSS_COMPILER}" bl31
fi
cd "${CWD}"
if [ ! -z "${DDR_URL}" ]; then
DDR_BIN=$(echo "${DDR_URL}" | awk -F '/' '{ print $NF }')
if [ ! -e "${DDR_BIN}" ]; then
wget "${DDR_URL}"
chmod +x "${DDR_BIN}"
"./${DDR_BIN}" --auto-accept
fi
fi
if [ ! -z "${DDR_FILE}" ]; then
mkdir -p "firmware-${pureos_board}"
tar -C "firmware-${pureos_board}" -xf "${DDR_FILE}"
fi
cd "${CWD}"
get_ddr_firmware
if [ "${MKIMAGE_REPO}" != "" ]; then
MKIMAGE_DIR=$(echo "${MKIMAGE_REPO}" | awk -F '/' '{ print $NF }')
if [ -n "${MKIMAGE_REPO}" ]; then
MKIMAGE_DIR="$(basename "${MKIMAGE_REPO}" .git)"
if [ ! -e "${MKIMAGE_DIR}" ]; then
git clone "${MKIMAGE_REPO}" -b "${MKIMAGE_BRANCH}"
fi
#Copy the following binaries to imx-mkimage/iMX8M folder:
# Copy the following binaries to imx-mkimage/iMX8M folder:
cp "u-boot-${pureos_board}/u-boot-nodtb.bin" imx-mkimage/iMX8M/
cp "u-boot-${pureos_board}/u-boot.bin" imx-mkimage/iMX8M/
cp "u-boot-${pureos_board}/spl/u-boot-spl.bin" imx-mkimage/iMX8M/
cp "u-boot-${pureos_board}/arch/arm/dts/${UBOOT_DTB}" imx-mkimage/iMX8M/fsl-imx8mq-evk.dtb
# Copy the following firmwares to imx-mkimage/iMX8 folder :
if [ ! -z "${DDR_URL}" ]; then
cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem.bin imx-mkimage/iMX8M/
cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem.bin imx-mkimage/iMX8M/
cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem.bin imx-mkimage/iMX8M/
cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem.bin imx-mkimage/iMX8M/
cp firmware-imx-7.2/firmware/hdmi/cadence/signed_hdmi_imx8m.bin imx-mkimage/iMX8M/
else
cp firmware-"${pureos_board}"/imx-mkimage/iMX8M/*.bin "imx-mkimage/iMX8M/"
fi
cp "u-boot-${pureos_board}/arch/arm/dts/${UBOOT_DTB}" imx-mkimage/iMX8M/
# This overwrites the default with the version we have built
if [ ! -z "${ATF_DIR}" ]; then
cp "${ATF_DIR}/build/imx8mq/release/bl31.bin" imx-mkimage/iMX8M/
build_atf imx-mkimage/iMX8M/
fi
#Before generating the flash.bin, transfer the mkimage generated by U-Boot to iMX8M folder:
# Before generating the flash.bin, transfer the mkimage generated by U-Boot to iMX8M folder:
cp "u-boot-${pureos_board}/tools/mkimage" imx-mkimage/iMX8M/
mv imx-mkimage/iMX8M/mkimage imx-mkimage/iMX8M/mkimage_uboot
......@@ -196,7 +225,7 @@ function combine_uboot_bins()
git pull
#Or for using HDMI:
make SOC=iMX8M flash_hdmi_spl_uboot
make dtbs="${UBOOT_DTB}" SOC=iMX8M flash_hdmi_spl_uboot
fi
cd "${CWD}"
......@@ -248,7 +277,7 @@ case ${pureos_board} in
UBOOT_BIN=iMX8M/flash.bin
UBOOT_DTB=fsl-imx8mq-evk.dtb
ARCH=arm
COPY_UBOOT=copy_uboot
COPY_UBOOT=copy_uboot_mkimage
;;
ec-som)
ATF_REPO=https://source.codeaurora.org/external/imx/imx-atf
......@@ -264,28 +293,40 @@ case ${pureos_board} in
UBOOT_BIN=iMX8M/flash.bin
UBOOT_DTB=emcraft-imx8m-som.dtb
ARCH=arm
COPY_UBOOT=copy_uboot_mkimage
;;
librem5*)
ATF_REPO=https://source.puri.sm/Librem5/trusted-firmware-a
ATF_BRANCH=librem5
ATF_PLAT=imx8mq
DDR_URL=https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-7.9.bin
UBOOT_REPO=https://source.puri.sm/Librem5/uboot-imx.git
HW_DEFCONFIG=librem5_defconfig
CROSS_COMPILER=aarch64-linux-gnu-
UBOOT_BRANCH=busfreq
UBOOT_BIN=iMX8M/flash.bin
UBOOT_DTB=librem5.dtb
ARCH=arm
COPY_UBOOT=copy_uboot
;;
devkit*)
ATF_REPO=https://source.puri.sm/Librem5/trusted-firmware-a
ATF_BRANCH=librem5
ATF_PLAT=imx8mq
DDR_FILE=files/imx-mkimage-emcraft.tar.gz
MKIMAGE_REPO=https://source.codeaurora.org/external/imx/imx-mkimage
MKIMAGE_BRANCH=imx_4.9.51_imx8m_ga
DDR_URL=https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-7.9.bin
UBOOT_REPO=https://source.puri.sm/Librem5/uboot-imx.git
case ${pureos_board} in
devkit)
HW_DEFCONFIG=librem5_devkit_defconfig
;;
devkit-recovery)
HW_DEFCONFIG=librem5_devkit_base_defconfig
HW_DEFCONFIG=librem5_devkit_defconfig
;;
esac
CROSS_COMPILER=aarch64-linux-gnu-
UBOOT_BRANCH=devkit-wip
UBOOT_BRANCH=busfreq
UBOOT_BIN=iMX8M/flash.bin
UBOOT_DTB=librem5-evk.dtb
UBOOT_DTB=librem5-devkit.dtb
ARCH=arm
COPY_UBOOT=copy_uboot
;;
......@@ -302,14 +343,16 @@ build_uboot "${pureos_board}" "${ARCH}" "${CROSS_COMPILER}" "${HW_DEFCONFIG}" "$
cd "${CWD}"
case ${pureos_board} in
devkit-recovery)
combine_uboot_bins "${pureos_board}"
cd imx-mkimage
devkit-recovery|librem5-recovery)
cd "u-boot-${pureos_board}"
;;
devkit|librem5)
build_cortex_m4 "${UBOOT_OUTPUT}"
cd "u-boot-${pureos_board}"
;;
imx8|ec-som|devkit)
imx8|ec-som)
build_cortex_m4 "${UBOOT_OUTPUT}"
combine_uboot_bins "${pureos_board}"
generate_full_boot_image "${pureos_board}"
cd imx-mkimage
;;
*)
......@@ -319,6 +362,18 @@ esac
"${COPY_UBOOT}" "${pureos_board}" "${UBOOT_OUTPUT}" "${UBOOT_BIN}"
cd "${CWD}"
case ${pureos_board} in
devkit|librem5|imx8|ec-som)
generate_full_boot_image "${pureos_board}"
;;
*)
;;
esac
cd "u-boot-${pureos_board}"
echo "${UBOOT_REPO}" > "${UBOOT_OUTPUT}/u-boot-${pureos_board}-git.txt"
git log --format=format:%H -1 >> "${UBOOT_OUTPUT}/u-boot-${pureos_board}-git.txt"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment