aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2019-06-18 13:30:38 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-01-20 02:56:58 +0100
commit8fcd3677def5452cfae75d53303c910415fbb51e (patch)
treecc2280b25688746a0d26035d86e3db0e28a25a98
parent219d54332a09e8d8741c1e1982f5eae56099de85 (diff)
downloadkernel_replicant_linux-build-scripts.tar.gz
kernel_replicant_linux-build-scripts.tar.bz2
kernel_replicant_linux-build-scripts.zip
Add build, install and test scriptsbuild-scripts
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-xbuild.sh281
-rwxr-xr-xinstall.sh48
-rwxr-xr-xtests/charger.sh2
-rwxr-xr-xtests/touchkeys.sh5
4 files changed, 336 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 000000000000..a9b41207f3d5
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,281 @@
+#!/bin/bash
+# Copyright (C) 2019 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+set -e
+
+supported_devices=" \
+ i9300 \
+ i9305 \
+ n710x \
+"
+
+supported_os=" \
+ Android \
+ GNU/Linux \
+"
+
+supported_bootloaders="\
+ s-boot \
+ u-boot \
+"
+
+sentinel=""
+dtb=""
+cmdline=""
+
+print_supported()
+{
+ printf "<"
+ for elm in $@ ; do
+ printf "${elm}|"
+ done
+ printf "\b> "
+}
+
+# Example:
+# check_supported i9300 device ${supported_devices}
+check_supported()
+{
+ elm="$1"
+ type="$2"
+ shift 2
+
+ for supported in $@ ; do
+ if [ "${elm}" = "${supported}" ] ; then
+ return 0
+ fi
+ done
+
+ echo "Invalid ${type} '${elm}'. Usage:"
+ usage
+ exit 1
+}
+
+usage()
+{
+ printf "%s " "$0"
+ print_supported ${supported_devices}
+ print_supported ${supported_bootloaders}
+ print_supported ${supported_os}
+ printf "\b\n"
+
+ exit 1
+}
+
+add_secure_firmware_node()
+{
+ dtsi="arch/arm/boot/dts/exynos4412-midas.dtsi"
+ if ! grep "firmware@204f000" ${dtsi} 2>&1 > /dev/null ; then
+ # Add the node
+ cat ${dtsi} | \
+ awk 'BEGIN {chosen_found=0} \
+ { \
+ {print $0}
+ if ($0 == "\tchosen {") {chosen_found=1}; fi; \
+ if (chosen_found == 1 && $0 == "\t};") { \
+ chosen_found=0; \
+ print(""); \
+ print("\tfirmware@204f000 {"); \
+ print("\t\tcompatible = \"samsung,secure-firmware\";"); \
+ print("\t\treg = <0x0204F000 0x1000>;"); \
+ print("\t};"); \
+ }; fi; \
+ }' \
+ > ${dtsi}.1
+ mv -f ${dtsi}.1 ${dtsi}
+ fi
+}
+
+remove_secure_firmware_node()
+{
+ dtsi="arch/arm/boot/dts/exynos4412-midas.dtsi"
+ cat ${dtsi} | \
+ awk 'BEGIN {do_print=1} \
+ { \
+ if ($0 == "\tfirmware@204f000 {") {do_print=0}; fi; \
+ if (do_print == 1) {print $0} ; fi; \
+ if ($0 == "\t};") {do_print=1}; fi; \
+ }' \
+ > ${dtsi}.1
+ mv -f ${dtsi}.1 ${dtsi}
+}
+
+add_arm_decompressor_tlb_flush()
+{
+ head_s_file="arch/arm/boot/compressed/head.S"
+
+ if ! grep -A 1 -P '^\t\tmcrne\tp15, 0, r0, c8, c7, 0\t@ flush I,D TLBs$' \
+ arch/arm/boot/compressed/head.S | \
+ tail -n1 | \
+ grep -P '^\t\tmcr\tp15, 0, r0, c7, c5, 4\t@ ISB$' \
+ 2>&1 > /dev/null ; then
+ cat ${head_s_file} | \
+ awk 'BEGIN {armv7_mmu_cache_on_found=0;} \
+ { \
+ if ($0 == "__armv7_mmu_cache_on:") { \
+ armv7_mmu_cache_on_found=1; \
+ }; fi; \
+ if (armv7_mmu_cache_on_found == 1 && \
+ ($0 == "\t\tmcrne\tp15, 0, r3, c2, c0, 0\t@ load page table pointer")) { \
+ armv7_mmu_cache_on_found=0; \
+ print("\t\tmcrne\tp15, 0, r0, c8, c7, 0\t@ flush I,D TLBs"); \
+ print("\t\tmcr\tp15, 0, r0, c7, c5, 4\t@ ISB"); \
+ }; fi; \
+ {print $0} \
+ }' \
+ > ${head_s_file}.1
+ mv -f ${head_s_file}.1 ${head_s_file}
+fi
+}
+
+remove_arm_decompressor_tlb_flush()
+{
+ # I'm unlikely to make other changes to that file
+ git checkout -- arch/arm/boot/compressed/head.S
+}
+
+check_kconfig_empty_config()
+{
+ config="$1"
+
+ if [ "${config}" = "" ] ; then
+ echo "Exiting: empty kconfig configuration"
+ exit 1
+ fi
+}
+
+set_kconfig_value()
+{
+ config="$1"
+ check_kconfig_empty_config "${config}"
+
+ shift 1
+ value="$@"
+
+ sed "/^${config}=\"*\"/d" -i .config
+ echo "${config}=\"${value}\"" >> .config
+}
+
+set_kconfig_y()
+{
+ config="$1"
+
+ check_kconfig_empty_config "${config}"
+ sed "/^${config}=*/d" -i .config
+ echo "${config}=y" >> .config
+}
+
+unset_kconfig()
+{
+ config="$1"
+
+ check_kconfig_empty_config "${config}"
+ sed "/^${config}=*/d" -i .config
+ echo "# ${config} is not set" >> .config
+}
+
+jobs="-j$(grep processor /proc/cpuinfo | wc -l) -k"
+
+source arm_build.sh
+
+if [ $# -ne 3 ] ; then
+ usage
+fi
+
+device="$1"
+bootloader="$2"
+os="$3"
+
+check_supported "${device}" "device" ${supported_devices}
+check_supported "${bootloader}" "bootloader" ${supported_bootloaders}
+check_supported "${os}" "OS" ${supported_os}
+
+dtb="exynos4412-${device}.dtb"
+
+make replicant_defconfig
+
+if [ "${os}" = "Android" ] ; then
+ set_kconfig_y CONFIG_USB_FUNCTIONFS
+ cmdline="${cmdline} PARTLABEL=SYSTEM init=/init rootwait"
+ cmdline="${cmdline} androidboot.hardware=smdk4x12"
+ cmdline="${cmdline} androidboot.selinux=permissive enforcing=0"
+elif [ "${os}" = "GNU/Linux" ] ; then
+ unset_kconfig CONFIG_USB_FUNCTIONFS
+ cmdline="${cmdline} root=/dev/mmcblk0 rw"
+fi
+
+cmdline="${cmdline} buildvariant=eng device=${device} rootwait console=ttySAC2,115200 loglevel=8"
+cmdline="${cmdline} no_console_suspend"
+
+if [ "${bootloader}" = "s-boot" ] ; then
+ # boot.img cmdline is ignored and Android userspace needs access
+ # to the IMEI which is passed as boot arguments
+ unset_kconfig CONFIG_CMDLINE_FORCE
+ unset_kconfig CONFIG_CMDLINE_FROM_BOOTLOADER
+ set_kconfig_y CONFIG_CMDLINE_EXTEND
+ set_kconfig_value CONFIG_CMDLINE "${cmdline}"
+
+ # Workaround fatally flawed bootloader which has MMU on
+ add_arm_decompressor_tlb_flush
+ unset_kconfig CONFIG_STACKPROTECTOR_PER_TASK
+
+ # Make sure that samsung,secure-firmware is present
+ add_secure_firmware_node
+elif [ "${bootloader}" = "u-boot" ] ; then
+ # Make sure that the bootargs comes from the boot.img
+ unset_kconfig CONFIG_CMDLINE
+ unset_kconfig CONFIG_CMDLINE_FORCE
+ unset_kconfig CONFIG_CMDLINE_EXTEND
+ set_kconfig_y CONFIG_CMDLINE_FROM_BOOTLOADER
+
+ # Remove samsung,secure-firmware as we have no TrustZone OS
+ remove_secure_firmware_node
+
+ # Remove workaround for s-boot if present
+ remove_arm_decompressor_tlb_flush
+fi
+
+# Save the config
+yes '' | make oldconfig
+make savedefconfig
+cp -f defconfig arch/arm/configs/replicant_defconfig
+
+make ${jobs} \
+ zImage \
+ "${dtb}" \
+ ${sentinel}
+
+cat \
+ arch/arm/boot/zImage \
+ "arch/arm/boot/dts/${dtb}" \
+ > arch/arm/boot/zImage.dtb
+
+mkbootimg \
+ --base 0x10000000 \
+ --kernel arch/arm/boot/zImage.dtb \
+ --cmdline "${cmdline}" \
+ --output arch/arm/boot/boot.img \
+ ${sentinel}
+
+du -hs arch/arm/boot/boot.img
+unbootimg -i arch/arm/boot/boot.img
+
+if [ "${bootloader}" = "s-boot" ] ; then
+ echo "The kenrel is ready at arch/arm/boot/boot.img. You can install it with:"
+ echo "heimdall flash --BOOT arch/arm/boot/boot.img --RECOVERY arch/arm/boot/boot.img"
+else
+ echo OK
+fi
diff --git a/install.sh b/install.sh
new file mode 100755
index 000000000000..52fce33f7248
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+set -e
+
+flash_fastboot()
+{
+ fastboot flash BOOT arch/arm/boot/boot.img
+ sleep 1
+ fastboot flash RECOVERY arch/arm/boot/boot.img
+ sleep 1
+ fastboot reboot
+ echo "OK"
+}
+
+flash_heimdall()
+{
+ heimdall flash \
+ --BOOT arch/arm/boot/boot.img \
+ --RECOVERY arch/arm/boot/boot.img
+ echo "OK"
+}
+
+install_parabola_no_modules()
+{
+ host="$1"
+
+ rsync arch/arm/boot/zImage "${host}:/boot/vmlinuz-linux-custom"
+ rsync arch/arm/boot/dts/*.dtb "${host}:/boot/dtbs/linux-custom/"
+ rsync -a tests "${host}:"
+
+ ssh "${host}" "test -f /boot/initramfs-linux-custom.img || mkinitcpio -p linux-custom"
+}
+
+usage()
+{
+ echo "Usage: $0 <fastboot|heimdall>"
+ echo "Usage: $0 parabola <host>"
+ exit 1
+}
+
+if [ $# -eq 1 -a "$1" = "fastboot" ] ; then
+ flash_fastboot
+elif [ $# -eq 1 -a "$1" = "heimdall" ] ; then
+ flash_heimdall
+elif [ $# -eq 2 -a "$1" = "parabola" ] ; then
+ install_parabola_no_modules "$2"
+else
+ usage
+fi
diff --git a/tests/charger.sh b/tests/charger.sh
new file mode 100755
index 000000000000..8b9a04ea0dbc
--- /dev/null
+++ b/tests/charger.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+watch -n1 "cat /sys/class/power_supply/max77693-charger/uevent" > /dev/tty0
diff --git a/tests/touchkeys.sh b/tests/touchkeys.sh
new file mode 100755
index 000000000000..4586a8d9d352
--- /dev/null
+++ b/tests/touchkeys.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+cat /sys/class/leds/tm2-touchkey/max_brightness > \
+ /sys/class/leds/tm2-touchkey/brightness
+evtest /dev/input/event0