summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2021-02-05 19:51:37 -0600
committerAlex Elder <elder@linaro.org>2021-02-05 19:51:37 -0600
commit1f7194dd02382c5091e98c953ac55a0df03e7976 (patch)
treef0e1da8beea6579b07c2fe8a7b25692fb0fd0ed1
Initial commit of SDX55 build toolsHEADmaster
-rwxr-xr-xbuild-sdx55.sh249
-rw-r--r--initrd-temp.cpio.gzbin0 -> 5557883 bytes
-rw-r--r--mtp-sdx55-mtp.cfg8
-rw-r--r--sdx55-root-image.tar.xzbin0 -> 18578592 bytes
4 files changed, 257 insertions, 0 deletions
diff --git a/build-sdx55.sh b/build-sdx55.sh
new file mode 100755
index 0000000..6a26d48
--- /dev/null
+++ b/build-sdx55.sh
@@ -0,0 +1,249 @@
+#!/bin/bash
+
+# Remote system on which "cdba" and/or "fastboot" are run
+REMOTE=qc.lab
+# User name on ${REMOTE}
+REMOTE_USER=elder
+# Path on remote host in which to place image files, etc.
+REMOTE_PATH=/local/mnt/workspace/${REMOTE_USER}/sdx55
+# Target host name (used by "cdba" on the remote host)
+REMOTE_TARGET=sdx55-mtp-1
+
+# Path to kernel source tree on build machine
+BUILD_ROOT=~/git/linux/integration-sdx55
+
+# Target board type and max max-leb-cnt value for mkfs.ubifs
+BOARD=mtp-sdx55-mtp # XXX Can this be just sdx55-mtp?
+# Board fastboot device serial number
+BOARD_FBID=6842abd7 # Available in /etc/cdba
+
+# BOARD=telit-fn980
+# BOARD_FBID=???? # Available in /etc/cdba
+#
+# Maximum logical erase block count for mkfs.ubifs (board-specific)
+BOARD_ERASE=1188
+# BOARD_ERASE=528
+
+# UBI image file name for root file system
+UBI_IMAGE=${BOARD}-ubi.img
+
+# It would be nice to keep the commit id in the kernel release, but
+# it's hard to prune previous kernel modules and we're adding kernel
+# modules to /lib/modules every time. Setting this means we just
+# keep reusing /lib/modules/5.11/ in the target image.
+RELEASE=5.11
+
+# Where on the build machine to place output files
+BUILD_OUT=${BUILD_ROOT}-out
+
+# Where on the build machine to place image files
+IMAGE_OUT=${BUILD_ROOT}-image
+
+# Boot image file name
+BOOT_IMAGE=${BOARD}-boot.img
+# Initial ramdisk file used in the boot image
+RAMDISK=initrd-temp.cpio.gz
+# Command line used in the boot image
+CMDLINE='ubi.mtd=24 root=ubi0:system rootfstype=ubifs rootwait rw earlycon=qcom_geni,0xa90000 console=ttyMSM0,115200n8 ignore_loglevel pd_ignore_unused clk_ignore_unused earlycon'
+# Some versions of "mkbootimg" don't like hexadecimal
+BASE=2147483648 # 0x80000000
+
+#################
+
+PROGNAME=$(basename $0)
+JFLAG=$(grep ^processor /proc/cpuinfo | wc -l)
+
+function report() {
+ echo ======== "$@" ========
+}
+
+function usage() {
+ [ $# -gt 0 ] && echo ${PROGNAME}: $@ >&2
+
+ echo Usage: ${PROGNAME} OPTION [OPTION...] >&2
+ echo >&2
+ echo Valid options are: >&2
+ echo " config - configure the kernel" >&2
+ echo " kernel - build the kernel" >&2
+ echo " modules - build kernel modules" >&2
+ echo " dtbs - build device tree blobs" >&2
+ echo " root - build root image to install" >&2
+ echo " boot - build boot image" >&2
+ echo " copy - copy images to ${REMOTE}" >&2
+ echo " clean - clean up generated files" >&2
+ echo >&2
+
+ exit 1
+}
+
+function parseargs() {
+ [ $# -eq 0 ] && usage "at least one argument is required"
+
+ unset BUILD_CONFIG BUILD_MODULES BUILD_KERNEL BUILD_DTBS
+ unset BUILD_ROOT BUILD_BOOT CLEANUP
+ for i in "$@"; do
+ case $i in
+ config) BUILD_CONFIG=1
+ ;;
+ kernel) BUILD_KERNEL=1
+ ;;
+ modules) BUILD_MODULES=1
+ ;;
+ dtbs) BUILD_DTBS=1
+ ;;
+ root) BUILD_ROOT=1
+ ;;
+ boot) BUILD_BOOT=1
+ ;;
+ copy) BUILD_COPY=1
+ ;;
+ clean) CLEANUP=1
+ ;;
+ *) usage "unrecognized argument '$1'" ;;
+ esac
+ done
+}
+
+function build() {
+ make -j ${JFLAG} O=${BUILD_OUT} \
+ ARCH=arm \
+ CROSS_COMPILE=arm-linux-gnueabihf- \
+ KERNELRELEASE=${RELEASE} \
+ "$@"
+}
+
+function build_config() {
+ report Configuring
+ build qcom_defconfig
+}
+
+function build_kernel() {
+ [ ! -f ${BUILD_OUT}/.config ] &&
+ usage "must configure kernel before building kernel"
+
+ report Building kernel
+ build zImage
+}
+
+function build_modules() {
+ [ ! -f ${BUILD_OUT}/.config ] &&
+ usage "must configure kernel before building modules"
+
+ report Building modules
+ build modules
+}
+
+function build_dtbs() {
+ [ ! -f ${BUILD_OUT}/.config ] &&
+ usage "must configure kernel before building dtbs"
+
+ report Building device tree blobs
+ build dtbs
+}
+
+function build_root() {
+ [ ! -f ${BUILD_OUT}/arch/arm/boot/zImage ] &&
+ usage "must build kernel before building image"
+ [ ! -f ${BUILD_OUT}/arch/arm/boot/dts/qcom-sdx55-mtp.dtb ] &&
+ usage "must build dtbs before building image"
+ [ -d ${BUILD_OUT}/lib/modules/${RELEASE} ] &&
+ usage "must build modules before building image"
+
+ # Clean up any existing output files first
+ rm -f ${UBI_IMAGE} ${UBI_IMAGE}.gz
+
+ report Building root file system image
+ # Remove old file system contents and repopulate it
+ rm -rf ${IMAGE_OUT}
+ mkdir -p ${IMAGE_OUT}
+ tar -C ${IMAGE_OUT} -xJf - < sdx55-root-image.tar.xz
+
+ # Now install the most recently built modules
+ build INSTALL_MOD_PATH=${IMAGE_OUT} INSTALL_MOD_STRIP=1 \
+ modules_install
+
+ # XXX These image files should be created in ${IMAGE_OUT}
+ report Building UBI image
+ mkfs.ubifs -q -r ${IMAGE_OUT} \
+ -m 4096 -e 253952 -c ${BOARD_ERASE} \
+ -o ubifs.img
+ ubinize -o ${UBI_IMAGE} -m 4096 -p 256KiB -s 4096 ${BOARD}.cfg
+ gzip --rsyncable ${UBI_IMAGE}
+}
+
+function build_boot() {
+ [ ! -f ${BUILD_OUT}/arch/arm/boot/zImage ] &&
+ usage "must build kernel before building boot"
+ [ ! -f ${BUILD_OUT}/arch/arm/boot/dts/qcom-sdx55-mtp.dtb ] &&
+ usage "must build dtbs before building boot"
+
+ # Clean up any existing output files first
+ rm -f ${BUILD_OUT}/${BOOT_IMAGE} ${BUILD_OUT}/${BOOT_IMAGE}.gz
+
+ report Building boot image:
+ report " board: ${BOARD}"
+ report " options: \"${CMDLINE}\""
+ report " ramdisk: ${RAMDISK}"
+ cat ${BUILD_OUT}/arch/arm/boot/zImage \
+ ${BUILD_OUT}/arch/arm/boot/dts/qcom-sdx55-mtp.dtb \
+ > ${BUILD_OUT}/Image-huracan.gz+dtb
+ mkbootimg \
+ --kernel ${BUILD_OUT}/Image-huracan.gz+dtb \
+ --cmdline "${CMDLINE}" \
+ --ramdisk ${RAMDISK} \
+ --base "${BASE}" \
+ --pagesize 4096 \
+ --board ${BOARD} \
+ --output ${BUILD_OUT}/${BOOT_IMAGE}
+ gzip --rsyncable ${BUILD_OUT}/${BOOT_IMAGE}
+}
+
+function copy_out() {
+ [ ! -f ${UBI_IMAGE}.gz ] &&
+ usage "must build root image before copying"
+ [ ! -f ${BUILD_OUT}/${BOOT_IMAGE}.gz ] &&
+ usage "must build boot image before copying"
+
+ report Copying root file system image to ${REMOTE}
+ rsync -avz ${BUILD_OUT}/${BOOT_IMAGE}.gz \
+ "${REMOTE_USER}@${REMOTE}:${REMOTE_PATH}"
+ ssh ${REMOTE_USER}@${REMOTE} gunzip -f ${REMOTE_PATH}/${BOOT_IMAGE}.gz
+
+ report Copying boot image to ${REMOTE}
+ rsync -avz ${UBI_IMAGE}.gz \
+ "${REMOTE_USER}@${REMOTE}:${REMOTE_PATH}"
+ ssh ${REMOTE_USER}@${REMOTE} gunzip -f ${REMOTE_PATH}/${UBI_IMAGE}.gz
+
+ echo Run on ${REMOTE}:
+ echo " cd ${REMOTE_PATH}"
+ echo " fastboot -s ${BOARD_FBID} flash system ${UBI_IMAGE}"
+ echo " cdba -b ${REMOTE_TARGET} -h localhost ${BOOT_IMAGE}"
+}
+
+function cleanup() {
+ report Cleaning up
+ rm -rf ${IMAGE_OUT} ${BUILD_OUT}
+ # XXX These get created in the build directory
+ rm -f ubifs.img ${UBI_IMAGE} ${UBI_IMAGE}.gz
+}
+
+########
+
+cd ${BUILD_ROOT}
+
+parseargs "$@"
+
+echo ==== Starting at $(date) ====
+
+[ "${BUILD_CONFIG}" ] && build_config
+[ "${BUILD_KERNEL}" ] && build_kernel
+[ "${BUILD_MODULES}" ] && build_modules
+[ "${BUILD_DTBS}" ] && build_dtbs
+[ "${BUILD_ROOT}" ] && build_root
+[ "${BUILD_BOOT}" ] && build_boot
+[ "${BUILD_COPY}" ] && copy_out
+[ "${CLEANUP}" ] && cleanup
+
+echo ==== Done at $(date) ====
+
+exit 0
diff --git a/initrd-temp.cpio.gz b/initrd-temp.cpio.gz
new file mode 100644
index 0000000..ed279e0
--- /dev/null
+++ b/initrd-temp.cpio.gz
Binary files differ
diff --git a/mtp-sdx55-mtp.cfg b/mtp-sdx55-mtp.cfg
new file mode 100644
index 0000000..44ee721
--- /dev/null
+++ b/mtp-sdx55-mtp.cfg
@@ -0,0 +1,8 @@
+[ubifs]
+mode=ubi
+image=ubifs.img
+vol_id=28
+vol_size=100MiB
+vol_type=dynamic
+vol_name=system
+vol_flags=autoresize
diff --git a/sdx55-root-image.tar.xz b/sdx55-root-image.tar.xz
new file mode 100644
index 0000000..168d40a
--- /dev/null
+++ b/sdx55-root-image.tar.xz
Binary files differ