|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +set -eu |
| 4 | + |
| 5 | +# patches in this repo/branch were submitted upstream here: |
| 6 | +# https://lore.kernel.org/u-boot/[email protected]/ |
| 7 | +GIT_REPO="https://github.com/b49020/u-boot" |
| 8 | +GIT_BRANCH="qcom-mainline" |
| 9 | +CONFIG="qcom_defconfig" |
| 10 | +U_BOOT_DEVICE_TREE="qcom/qrb2210-rb1" |
| 11 | +ABOOT_BASE_ADDRESS="0x80000000" |
| 12 | +ABOOT_PAGE_SIZE="4096" |
| 13 | +ABOOT_OUTPUT="rb1-boot.img" |
| 14 | + |
| 15 | +log_i() { |
| 16 | + echo "I: $*" >&2 |
| 17 | +} |
| 18 | + |
| 19 | +fatal() { |
| 20 | + echo "F: $*" >&2 |
| 21 | + exit 1 |
| 22 | +} |
| 23 | + |
| 24 | +# needed to clone repository |
| 25 | +packages="git" |
| 26 | +# will pull gcc-aarch64-linux-gnu; should pull a native compiler on arm64 and |
| 27 | +# a cross-compiler on other architectures |
| 28 | +packages="${packages} crossbuild-essential-arm64" |
| 29 | +# u-boot build-dependencies |
| 30 | +packages="${packages} make bison flex bc libssl-dev gnutls-dev xxd" |
| 31 | +# for nproc |
| 32 | +packages="${packages} coreutils" |
| 33 | +# needed to pack resulting u-boot binary into an Android boot image |
| 34 | +packages="${packages} gzip mkbootimg" |
| 35 | + |
| 36 | +log_i "Checking build-dependencies ($packages)" |
| 37 | +missing="" |
| 38 | +for pkg in ${packages}; do |
| 39 | + # check if package with this name is installed |
| 40 | + if dpkg -l "${pkg}" 2>&1 | grep -q "^ii ${pkg}"; then |
| 41 | + continue |
| 42 | + fi |
| 43 | + # otherwise, check if it's a virtual package and if some package providing |
| 44 | + # it is installed |
| 45 | + providers="$(apt-cache showpkg "${pkg}" | |
| 46 | + sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' | |
| 47 | + sort -u)" |
| 48 | + provider_found="no" |
| 49 | + for provider in ${providers}; do |
| 50 | + if dpkg -l "${provider}" 2>&1 | grep -q "^ii ${provider}"; then |
| 51 | + provider_found="yes" |
| 52 | + break |
| 53 | + fi |
| 54 | + done |
| 55 | + if [ "${provider_found}" = yes ]; then |
| 56 | + continue |
| 57 | + fi |
| 58 | + missing="${missing} ${pkg}" |
| 59 | +done |
| 60 | +if [ -n "${missing}" ]; then |
| 61 | + fatal "Missing build-dependencies: ${missing}" |
| 62 | +fi |
| 63 | + |
| 64 | +log_i "Cloning U-Boot (${GIT_REPO}:${GIT_BRANCH})" |
| 65 | +git clone --depth=1 --branch "${GIT_BRANCH}" "${GIT_REPO}" u-boot |
| 66 | + |
| 67 | +cd u-boot |
| 68 | + |
| 69 | +log_i "Configuring U-Boot (${CONFIG})" |
| 70 | +make "${CONFIG}" |
| 71 | + |
| 72 | +log_i "Building U-Boot (with device tree ${U_BOOT_DEVICE_TREE})" |
| 73 | +make -j`nproc` \ |
| 74 | + CROSS_COMPILE=aarch64-linux-gnu- DEVICE_TREE="${U_BOOT_DEVICE_TREE}" |
| 75 | + |
| 76 | +log_i "Creating Android boot image (${ABOOT_OUTPUT})" |
| 77 | +gzip u-boot-nodtb.bin |
| 78 | +cat u-boot-nodtb.bin.gz \ |
| 79 | + "dts/upstream/src/arm64/${U_BOOT_DEVICE_TREE}.dtb" \ |
| 80 | + >u-boot-nodtb.bin.gz-dtb |
| 81 | +mkbootimg --base "${ABOOT_BASE_ADDRESS}" \ |
| 82 | + --pagesize "${ABOOT_PAGE_SIZE}" \ |
| 83 | + --kernel u-boot-nodtb.bin.gz-dtb \ |
| 84 | + --cmdline "root=/dev/notreal" \ |
| 85 | + --ramdisk u-boot.bin \ |
| 86 | + --output "${ABOOT_OUTPUT}" |
| 87 | + |
0 commit comments