[meta-intel] [PATCH 1/6] rmc: Add Runtime Machine Configuration (RMC) project

Saul Wold saul.wold at intel.com
Tue Jul 12 16:04:26 PDT 2016


On Tue, 2016-07-12 at 10:59 -0700, Jianxun Zhang wrote:
> RMC recipes fetch RMC project and build it more than once in
> build time:
> 
> RMC tool is built for host architecture (native). The tool for
> host is used to generate RMC database in build time.
> 
> RMC tool is also built for target architecture, so that scripts
> in user space can call RMC tool on a running target. Developers
> can also boot a target and run rmc tool to obtain fingerprint
> for a new board type.
> 
> RMC libraries are compiled for both of UEFI context and user
> space. They are always linked in RMC tool and can be linked
> into an EFI bootloader. The recipes don't install libraries
> for target's user space until we have a new client needs it.
> 
> The rmc-native.bbclass provides functions to generate rmc database
> file for other software components to reuse.
> 
> Signed-off-by: Jianxun Zhang <jianxun.zhang at linux.intel.com>
> ---
>  classes/rmc-native.bbclass           | 92
> ++++++++++++++++++++++++++++++++++++
>  common/recipes-bsp/rmc/rmc-native.bb |  7 +++
>  common/recipes-bsp/rmc/rmc.bb        | 21 ++++++++
>  common/recipes-bsp/rmc/rmc.inc       | 22 +++++++++
>  4 files changed, 142 insertions(+)
>  create mode 100644 classes/rmc-native.bbclass
>  create mode 100644 common/recipes-bsp/rmc/rmc-native.bb
>  create mode 100644 common/recipes-bsp/rmc/rmc.bb
>  create mode 100644 common/recipes-bsp/rmc/rmc.inc
> 
> diff --git a/classes/rmc-native.bbclass b/classes/rmc-native.bbclass
> new file mode 100644
> index 0000000..2591b6c
> --- /dev/null
> +++ b/classes/rmc-native.bbclass
> @@ -0,0 +1,92 @@
> +# RMC native bbclass
> +# provide functions to generate RMC database file on build host
> (native)
> +
> +DEPENDS += "rmc-native"
> +
> +# rmc_generate_db()
> +# $1: a list of directories. Each directory holds directories for a
> group of
> +# boards.
> +# $2: path_name of rmc generates database file and records
> +#
> +# WARNING: content of directory of database file will be removed.
> +#
> +# Each board directory shall contain a fingerprint file (*.fp) at
> least, with
> +# optional file blob(s) associated to the type of board. If a board
> directory
> +# has no file blob, no record is created for that board.
> +#
> +# An example of two directories each of which contains two boards
> for RMC:
> +# (All file and directory names are for illustration purpose.)
> +#
> +# dir_1/
> +#     board_1/
> +#         board_1_fingerprint.fp
> +#         file_1.blob
> +#     board_2/
> +#         board_2.fp
> +# dir_2/
> +#     board_3/
> +#         b3.fp
> +#         file_1.blob
> +#         file_2.conf
> +#     board_4/
> +#         board_foo.fp
> +#         mylib.config
> +#
> +# To generate a RMC database "rmc.db" with data of all (actually 3)
> of boards in
> +# a directory "deploy_dir":
> +#
> +# rmc_generate_db "dir_1 dir_2" "deploy_dir/rmc.db"
> +#
> +# The board_2 will be skipped. No record or any data for it is
> packed in
> +# generated database because it only contains a fingerprint file.
> +#
> +
> +rmc_generate_db () {
> +	RMC_BOARD_DIRS=$1
> +
> +	if [ "$#" -ne 2 ]; then
> +		echo "rmc_generate_db(): Wrong number of arguments:
> $#"
> +		return 1
> +	fi
> +
> +	RMC_DB_DIR=$(dirname "$2")
> +	RMC_RECORDS=""
> +
> +	rm -rf ${RMC_DB_DIR}
> +	mkdir -p ${RMC_DB_DIR}
> +
> +	# generate rmc database
> +	for topdir in ${RMC_BOARD_DIRS}; do
> +		# For all board dirs in a topdir:
> +		CUR_BOARD_DIRS=$(find ${topdir}/* -type d)
> +		for board_dir in ${CUR_BOARD_DIRS}; do
> +			# FIXME: we shall fail when having more than
> one .fp file
> +			CUR_FINGERPRINT=$(find ${board_dir}/ -name
> "*.fp")
> +
> +			# disallow a board directory without any
> fingerprint file in it.
> +			if [ -z "${CUR_FINGERPRINT}" ]; then
> +				echo "Cannot find RMC fingerprint
> file in ${board_dir}"
> +				return 1
> +			fi
> +
> +			CUR_FILES=$(find ${board_dir}/ -type f |grep
> -v '\.fp$' || true)
> +
> +			# allow a directory only with fingerprint
> file. Developer may
> +			# check in fingerprint for future use.
> +			if [ -z "${CUR_FILES}" ]; then
> +				continue
> +			fi
> +
> +			CUR_TAG=$(echo "${board_dir}"|sed  's/\//-
> /g')
> +			CUR_RECORD=${RMC_DB_DIR}/rmc${CUR_TAG}.rec
> +
> +			rmc -R -f ${CUR_FINGERPRINT} -b ${CUR_FILES}
> -o ${CUR_RECORD}
> +
> +			RMC_RECORDS="${RMC_RECORDS} ${CUR_RECORD}"
> +		done
> +	done
> +
> +	if [ ! -z "${RMC_RECORDS}" ]; then
> +		rmc -D ${RMC_RECORDS} -o "$2"
> +	fi
> +}
> diff --git a/common/recipes-bsp/rmc/rmc-native.bb b/common/recipes-
> bsp/rmc/rmc-native.bb
> new file mode 100644
> index 0000000..ae95f06
> --- /dev/null
> +++ b/common/recipes-bsp/rmc/rmc-native.bb
> @@ -0,0 +1,7 @@
> +require rmc.inc
> +
> +inherit native
> +
> +do_install() {
> +	install -m 0755 ${S}/src/rmc ${bindir}
> +}

Why did you split this out into -native and non-native?

You can use BBCLASSEXTEND = "native"  and then for the do_install() use
do_install_class-native().


> diff --git a/common/recipes-bsp/rmc/rmc.bb b/common/recipes-
> bsp/rmc/rmc.bb
> new file mode 100644
> index 0000000..1cac285
> --- /dev/null
> +++ b/common/recipes-bsp/rmc/rmc.bb
> @@ -0,0 +1,21 @@
> +require rmc.inc
> +
> +DEPENDS = "gnu-efi"
> +
> +# from gnu-efi, we should align arch-mapping with it.
> +def rmc_efi_arch(d):
> +    import re
> +    arch = d.getVar("TARGET_ARCH", True)
> +    if re.match("i[3456789]86", arch):
> +        return "ia32"
> +    return arch
> +
> +do_compile () {
> +	oe_runmake
> +	oe_runmake RMC_EFI_HEADER_PREFIX=${STAGING_INCDIR}/efi
> RMC_EFI_ARCH="${@rmc_efi_arch(d)}" -f Makefile.efi
> +}
> +
> +do_install () {
> +	oe_runmake RMC_EFI_ARCH="${@rmc_efi_arch(d)}"
> RMC_INSTALL_PREFIX=${D}/usr install
> +	oe_runmake RMC_EFI_ARCH="${@rmc_efi_arch(d)}"
> RMC_INSTALL_PREFIX=${D}/usr -f Makefile.efi install
> +}

You might want to explain briefly about the 2 makefiles.


> diff --git a/common/recipes-bsp/rmc/rmc.inc b/common/recipes-
> bsp/rmc/rmc.inc
> new file mode 100644
> index 0000000..c046e2e
> --- /dev/null
> +++ b/common/recipes-bsp/rmc/rmc.inc
> @@ -0,0 +1,22 @@
> +SUMMARY = "RMC (Runtime Machine Configuration)"
> +
> +DESCRIPTION = "Recipes of RMC feature integrates RMC project into
> build. RMC \
> +project itself provides an executable RMC tool to be called in build
> and run- \
> +time, as well as RMC libraries to be linked into RMC bootloader and
> the tool. \
> +Other two main parts of the feature are RMC installer and RMC
> bootloader. \
> +RMC recipes are responsible to build and deploy all of these RMC
> bits in an \
> +image. Another important task for recipes is to generate RMC
> database file, \
> +which is also deployed into image, based on all inputs (fingerprint,
> config \
> +files, board-specific file blobs) of all board types added by
> developer in \
> +RMC. More information can be obtained in README files in RMC
> project. \
> +"
> +
> +LICENSE = "MIT"
> +
> +LIC_FILES_CHKSUM =
> "file://COPYING;md5=bcdd376d27b26bde6afadd67aa3c8b07"
> +
> +SRC_URI = "git://git@git.yoctoproject.org/rmc;protocol=ssh"

The protocol=ssh should go away, since we have the rmc repo available
now.

Sau!
> +
> +SRCREV = "f10c018fbaa19072c7281726e1457c73a409e1d1"
> +
> +S = "${WORKDIR}/git"
> -- 
> 2.7.4
> 


More information about the meta-intel mailing list