[Buildroot] [PATCH v1 3/9] board/intel/common: Add possibility for adding ACPI tables to the initrd

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Thu Aug 25 21:43:48 UTC 2016


Hello,

On Thu, 25 Aug 2016 17:04:41 +0300, Andy Shevchenko wrote:

>  in order to take advantage of these.
>  
> +BOARD_INTEL_ACPI_TABLES
> +	list of table names to built into the ``initrd``.

Please make this a Buildroot configuration option.

> +# Pick iASL.
> +# First try from buildroot and if not there then try from the host.
> +[ -x "$HOST_DIR/usr/bin/iasl" ] && iasl="$HOST_DIR/usr/bin/iasl" || iasl=$(which iasl)
> +
> +[ -x "$iasl" ] || {
> +	echo "You need to to have iASL compiler available. You can either enable"
> +	echo "BR2_PACKAGE_HOST_ACPICA or install it locally for your host."
> +	echo "Typically the package is called acpica-tools in major distros".
> +	exit 1
> +}
> +
> +# The name of the folder is the name of a board
> +board_name="${BOARD_DIR##*/}"
> +[ "$board_name" = "common" ] && {
> +	echo "Adding ACPI tables is always specific to a board!"
> +	echo "You are not supposed to use common as board here!"
> +	exit 1
> +}
> +
> +# Always prefix with the board name to avoid mistakes if the initrd is used
> +# with another board.
> +updated_initrd_name="${board_name}-acpi-rootfs.cpio"
> +updated_initrd="$BINARIES_DIR/$updated_initrd_name"
> +initrd="$(readlink -enq "$BINARIES_DIR/initrd")"
> +tmpamldir="$BINARIES_DIR/acpi-tables"
> +
> +# Make sure existing tables get cleared
> +rm -fr $tmpamldir
> +mkdir -p $tmpamldir/kernel/firmware/acpi
> +
> +for table in $ACPI_TABLES; do
> +	[ -f "$ACPI_DIR/$table" ] || continue
> +
> +	$iasl -p $tmpamldir/kernel/firmware/acpi/$table "$ACPI_DIR/$table" > /dev/null 2>&1
> +
> +	echo "ACPI: Compiled ASL from $(realpath --relative-to=$PWD $ACPI_DIR/$table)"
> +done
> +
> +# Exit if no tables were compiled
> +[ -n "$(find $tmpamldir -type f)" ] || {
> +	echo "ACPI: No tables were compiled"
> +	exit 0
> +}
> +
> +# Attach compiled tables to initrd
> +(
> +	cd $tmpamldir
> +	find kernel | cpio -H newc -o > $updated_initrd 2>/dev/null
> +	cat $initrd >> $updated_initrd
> +	ln -sf "$updated_initrd_name" "$BINARIES_DIR/initrd"
> +)
> +
> +echo "ACPI: Created initrd with updated ACPI tables in $(realpath --relative-to=$PWD $updated_initrd)"

And move all of this logic into Buildroot make code. I'm not sure yet
exactly where it fits. Maybe as an option of the host-acpica package ?
As an option in the "System configuration" menu ? Or, maybe better,
since those updated ACPI tables are consumed by the kernel, as a kernel
option ?

But clearly, something like that shouldn't be done in a post-image or
post-build script.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


More information about the buildroot mailing list