Merge pull request #232 from TobiasFaller/feature-kernel-modules

Added kernel module support
This commit is contained in:
John Davidson 2021-07-09 13:08:44 +03:00 committed by GitHub
commit 2fbf6f4e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 0 deletions

View File

@ -67,6 +67,13 @@ FIRMWARE_TYPE=bios
#
USE_PREDEFINED_KERNEL_CONFIG=false
# Build kernel modules and make them available in the overlayfs / rootfs in the
# /lib/modules directory. The modules can be loaded via 'insmod' to support
# additional periphery and software devices.
# Note however, that the essential drivers to load the overlayfs have to be
# included in the kernel as the overlayfs might not be loaded otherwise.
BUILD_KERNEL_MODULES=false
# Use predefined '.config' file when building Busybox. This overrides the
# config generation in 'xx_build_busybox.sh' and the build process uses the
# config file provided in this parameter. Place the configuration file here:

View File

@ -16,6 +16,7 @@ make mrproper -j $NUM_JOBS
# Read the 'USE_PREDEFINED_KERNEL_CONFIG' property from '.config'
USE_PREDEFINED_KERNEL_CONFIG=`read_property USE_PREDEFINED_KERNEL_CONFIG`
BUILD_KERNEL_MODULES=`read_property BUILD_KERNEL_MODULES`
if [ "$USE_PREDEFINED_KERNEL_CONFIG" = "true" -a ! -f $SRC_DIR/minimal_config/kernel.config ] ; then
echo "Config file '$SRC_DIR/minimal_config/kernel.config' does not exist."
@ -106,15 +107,28 @@ make \
CFLAGS="$CFLAGS" \
bzImage -j $NUM_JOBS
if [ "$BUILD_KERNEL_MODULES" = "true" ] ; then
echo "Building kernel modules."
make \
CFLAGS="$CFLAGS" \
modules -j $NUM_JOBS
fi
# Prepare the kernel install area.
echo "Removing old kernel artifacts. This may take a while."
rm -rf $KERNEL_INSTALLED
mkdir $KERNEL_INSTALLED
echo "Installing the kernel."
# Install the kernel file.
cp arch/x86/boot/bzImage \
$KERNEL_INSTALLED/kernel
if [ "$BUILD_KERNEL_MODULES" = "true" ] ; then
make INSTALL_MOD_PATH=$KERNEL_INSTALLED \
modules_install -j $NUM_JOBS
fi
# Install kernel headers which are used later when we build and configure the
# GNU C library (glibc).
echo "Generating kernel headers."

View File

@ -5,6 +5,8 @@ set -e
# Load common properties and functions in the current script.
. ./common.sh
BUILD_KERNEL_MODULES=`read_property BUILD_KERNEL_MODULES`
echo "*** GENERATE ROOTFS BEGIN ***"
echo "Preparing rootfs work area. This may take a while."
@ -69,6 +71,12 @@ if [ "$OVERLAY_LOCATION" = "rootfs" ] && \
$OVERLAY_ROOTFS/* $ROOTFS
cp -r --remove-destination \
$SRC_DIR/minimal_overlay/rootfs/* $ROOTFS
# Copy all modules to the sysroot folder.
if [ "$BUILD_KERNEL_MODULES" = "true" ] ; then
echo "Copying modules. This may take a while."
cp -r --remove-destination $KERNEL_INSTALLED/lib $ROOTFS
fi
fi
echo "The rootfs area has been generated."

View File

@ -21,6 +21,8 @@ OVERLAY_TYPE=`read_property OVERLAY_TYPE`
# Read the 'OVERLAY_LOCATION' property from '.config'
OVERLAY_LOCATION=`read_property OVERLAY_LOCATION`
BUILD_KERNEL_MODULES=`read_property BUILD_KERNEL_MODULES`
if [ "$OVERLAY_LOCATION" = "iso" ] && \
[ "$OVERLAY_TYPE" = "sparse" ] && \
[ -d $OVERLAY_ROOTFS ] && \
@ -64,6 +66,12 @@ if [ "$OVERLAY_LOCATION" = "iso" ] && \
cp -r $SRC_DIR/minimal_overlay/rootfs/* \
$ISOIMAGE_OVERLAY/sparse/rootfs
# Copy all modules to the sysroot folder.
if [ "$BUILD_KERNEL_MODULES" = "true" ] ; then
echo "Copying modules. This may take a while."
cp -r $KERNEL_INSTALLED/lib $ISOIMAGE_OVERLAY/sparse/rootfs
fi
# Unmount the sparse file and delete the temporary folder.
sync
$BUSYBOX umount $ISOIMAGE_OVERLAY/sparse
@ -92,6 +100,12 @@ elif [ "$OVERLAY_LOCATION" = "iso" ] && \
$ISOIMAGE_OVERLAY/minimal/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* \
$ISOIMAGE_OVERLAY/minimal/rootfs
# Copy all modules to the sysroot folder.
if [ "$BUILD_KERNEL_MODULES" = "true" ] ; then
echo "Copying modules. This may take a while."
cp -r $KERNEL_INSTALLED/lib $ISOIMAGE_OVERLAY/minimal/rootfs
fi
else
echo "The ISO image will have no overlay structure."
fi