diff --git a/.gitignore b/.gitignore index e86bc51e47dce3dbc9b3342b62dfa5291c693ed3..12bf15eb986cb2942f9ade6918d77caf5cbae31f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /vagrant /tools/wa_venv /tools/wa_user_directory/dependencies +src/buildroot diff --git a/LisaShell.txt b/LisaShell.txt index 1eb9fa538d374914699f7bbaa64021ef8a6a5feb..7f231f952edc65ef9db7ad33f3cf971624d3a083 100644 --- a/LisaShell.txt +++ b/LisaShell.txt @@ -10,6 +10,7 @@ For a longer description type "lisa- help" lisa-help - Print this help, or command specific helps lisa-version - Dump info on the LISA in use +lisa-buildroot-create-rootfs - Create a buildroot based rootfs to be used as userland for testing .:: Maintenance commands ------------------------ diff --git a/src/shell/buildroot_config b/src/shell/buildroot_config new file mode 100644 index 0000000000000000000000000000000000000000..d32156fac4402a0f463f7aed4d8ca4c72f41a04e --- /dev/null +++ b/src/shell/buildroot_config @@ -0,0 +1,23 @@ +BR2_arm=y +BR2_cortex_a53=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_KERNEL_HEADERS_4_9=y +BR2_TARGET_GENERIC_ROOT_PASSWD="root" +BR2_PACKAGE_LINUX_FIRMWARE=y +BR2_PACKAGE_LINUX_FIRMWARE_TI_WL18XX=y +BR2_PACKAGE_OPENSSH=y +BR2_PACKAGE_WPA_SUPPLICANT=y +BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y +BR2_PACKAGE_WPA_SUPPLICANT_WIFI_DISPLAY=y +BR2_PACKAGE_WPA_SUPPLICANT_MESH_NETWORKING=y +BR2_PACKAGE_WPA_SUPPLICANT_AUTOSCAN=y +BR2_PACKAGE_WPA_SUPPLICANT_EAP=y +BR2_PACKAGE_WPA_SUPPLICANT_HOTSPOT=y +BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG=y +BR2_PACKAGE_WPA_SUPPLICANT_WPS=y +BR2_PACKAGE_WPA_SUPPLICANT_CLI=y +BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y +BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y +BR2_TARGET_ROOTFS_CPIO=y +BR2_TARGET_ROOTFS_CPIO_XZ=y +# BR2_TARGET_ROOTFS_TAR is not set diff --git a/src/shell/lisa_buildroot_create_rootfs b/src/shell/lisa_buildroot_create_rootfs new file mode 100755 index 0000000000000000000000000000000000000000..2e4e58e2455493a3b452ceebfaf690a803751bb3 --- /dev/null +++ b/src/shell/lisa_buildroot_create_rootfs @@ -0,0 +1,118 @@ +#! /bin/bash +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2018, ARM Limited and contributors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set -eu + +BUILDROOT_URI=git://git.busybox.net/buildroot +BUILDROOT_VERSION=2018.08 +BUILDROOT_DIR=$LISA_HOME/src/buildroot +BUILDROOT_CONFIG=$(dirname "$0")/buildroot_config + +function print_usage { + echo "Usage: $0 [options]" + echo " options:" + echo " -p: purge buildroot to force a fresh build" + echo " -h: print this help message" +} + +while getopts "hp" opt +do + case $opt in + h) + print_usage + exit 0 + ;; + p) + rm -rf "$BUILDROOT_DIR" + exit 0 + ;; + *) + print_usage + exit -1 + ;; + esac +done + +# Execute function @$1 once +function do_once { + FILE="$BUILDROOT_DIR/.lisa_$1" + if [ ! -e "$FILE" ]; then + "$1" + touch "$FILE" + fi +} + +function br_clone { + git clone $BUILDROOT_URI "$BUILDROOT_DIR" +} + +function br_checkout_version { + pushd "$BUILDROOT_DIR" >/dev/null + git checkout -b $BUILDROOT_VERSION $BUILDROOT_VERSION + popd >/dev/null +} + +function br_pre_patch { + pushd "$BUILDROOT_DIR" >/dev/null + + # Apply 'before build' changes here + + # Automount debugfs + echo "debugfs /sys/kernel/debug debugfs defaults 0 0" >> "$BUILDROOT_DIR/package/skeleton-init-sysv/skeleton/etc/fstab" + + popd >/dev/null +} + +function br_post_patch { + pushd "$BUILDROOT_DIR" >/dev/null + + # Apply 'post build' changes here + + # Generate ssh-keys so that they persist across multiple runs + ssh-keygen -A -f "$BUILDROOT_DIR/output/target/" + # Enable root login on sshd + sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' "$BUILDROOT_DIR/output/target/etc/ssh/sshd_config" + # run udhcpc by default at startup + echo "null::once:/sbin/udhcpc # PATCHED BY LISA" >> "$BUILDROOT_DIR/output/target/etc/inittab" + + popd >/dev/null + + # Rebuild to apply the changes + make -C "$BUILDROOT_DIR" +} + +function br_apply_config { + cp "$BUILDROOT_CONFIG" "$BUILDROOT_DIR/.config" + make -C "$BUILDROOT_DIR" olddefconfig +} + + +do_once br_clone + +do_once br_checkout_version + +do_once br_pre_patch + +do_once br_apply_config + +make -C "$BUILDROOT_DIR" + +do_once br_post_patch + +echo "---===::: RootFS Created :::===---" +echo "Path: $BUILDROOT_DIR/output/images/rootfs.cpio.xz" diff --git a/src/shell/lisa_buildroot_update_kernel_config b/src/shell/lisa_buildroot_update_kernel_config new file mode 100755 index 0000000000000000000000000000000000000000..145a7d31683c617563c2da89902c3d32f39d9a00 --- /dev/null +++ b/src/shell/lisa_buildroot_update_kernel_config @@ -0,0 +1,65 @@ +#! /bin/bash +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2018, ARM Limited and contributors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set -e + +BUILDROOT_DIR=$LISA_HOME/src/buildroot + +ROOTFS="$1" +KERNEL_DIR="$2" +KERNEL_CONFIG="$2/.config" + +function print_usage { + echo "Usage: $0 " + echo " options:" + echo " -h: print this help message" +} + +while getopts "hp" opt +do + case $opt in + h) + print_usage + exit 0 + ;; + *) + print_usage + exit -1 + ;; + esac +done + +if [[ -z "$1" || -z "$2" ]]; then + echo "ERROR: missing argument" + echo "" + print_usage + exit -1 +fi + +# Automatically detect the arm arch we are building for +ARCH="`grep -owE "(arm|arm64)" $KERNEL_CONFIG`" +if [ -z "$ARCH" ]; then + echo "ERROR: unknown arch, arm and arm64 are assumed" + exit -1 +fi + +set -u + +# Update kernel .config to use the provided rootfs as builtin initramfs +sed -i "s#[.]*CONFIG_INITRAMFS_SOURCE.*#CONFIG_INITRAMFS_SOURCE=\"$ROOTFS\"#" "$KERNEL_CONFIG" +make -C "$KERNEL_DIR" ARCH=$ARCH olddefconfig diff --git a/src/shell/lisa_shell b/src/shell/lisa_shell index 72594f7b97051895d82acd8af2a397ac2cad1821..115cc6e509731c6eed2b5f8fd56dfbae2717ff71 100755 --- a/src/shell/lisa_shell +++ b/src/shell/lisa_shell @@ -527,6 +527,18 @@ $WLTEST_HOME/test_series "$@" deactivate } +################################################################################ +# LISA Shell buildroot rootfs generation functions +################################################################################ + +function lisa-buildroot-create-rootfs { + "$LISA_HOME/src/shell/lisa_buildroot_create_rootfs" "$@" +} + +function lisa-buildroot-update-kernel-config { + "$LISA_HOME/src/shell/lisa_buildroot_update_kernel_config" "$@" +} + ################################################################################ # LISA Shell MAIN ################################################################################