From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6652197203295076352 X-Received: by 2002:a19:5519:: with SMTP id n25mr3904lfe.1.1549295701951; Mon, 04 Feb 2019 07:55:01 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:8ec8:: with SMTP id e8-v6ls2141778ljl.5.gmail; Mon, 04 Feb 2019 07:55:01 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia202jGrkq0fSWeLiObt6PHpn15nCwv4MAI2rwc6JQWUEJgDuS7XL4DE67TxzdbV7qP9JXb X-Received: by 2002:a2e:7803:: with SMTP id t3-v6mr1880ljc.11.1549295700826; Mon, 04 Feb 2019 07:55:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549295700; cv=none; d=google.com; s=arc-20160816; b=El4Bl0cZg4bmBEQbwaa2Q9ORz3MYmRsqU1GWu3kMg2NcAVPDlz0oYqf4HX+SasIglL XjaYRP9Av9fPfz3mGj340eKL9BZUcUKhZ1pMaGyzzS3X3EYNiCwQEQkDKsMhXjE8oQ0e lGpFWHK3DC4j3x6IJGf+pqhoJZSxQoBpw+DAIaoH69IU/5YS7f2I2/AaimUMGUosYZVl P+Vx9HKHKBmh+kDQH4sqh9xXvDGOwIqkXfOT6c9FHzdJKy+EZ9dDX66qYAsQ06F/bGC0 2qE61JsSqvNl+ZxpM1gfFrOIOC7XBvcmU8FFGaiRcOSQxCX6+MIXrLXPZCVRhW2TQ8In 5/hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=s1fuxvYlqp6BeSJxwm+8RRcWb9Z8/QMZgmdPsYzrjNs=; b=H0Ftn5anp9HO9Oe0+yCtHGYvGZ0wRaxqVbttHsFAKQOS50xga4uS9CiKdHfnMVJd/Y JEXG8KpfjD3PgF6m3QhE5aQhCSlYIWx8wiqmWbLyMDxry9TTC2Im7RP4EOZeQuMxj3Cp HFgBKn2chRU/H/oyt0CgsgcgmDaOcafJzi9bqqPIsdUqacl8QGUG0FzIIAWB8zAqO5kU 1jk+iob+iSrLxJSMUX8YyCk9Pyq1RzYW+Bc4mNTNEw0SPV6Rt0GXz078exA97cRd+xN5 S0VTm7ASCxxT0dm1TZ/bRl9AMwQCoQ9RnjbvuD3CTpAM2BQK32t+wIXvFixgMxig8ow6 Attw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id w10si790180lfc.5.2019.02.04.07.55.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 07:55:00 -0800 (PST) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id x14Fsxj2007432 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Feb 2019 16:54:59 +0100 Received: from ring.ppmd.siemens.net (linux-ses-ext02.ppmd.siemens.net [139.25.69.181]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id x14FswrU024792; Mon, 4 Feb 2019 16:54:58 +0100 From: claudius.heine.ext@siemens.com To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH v3 3/5] meta/classes: added ubi-img class Date: Mon, 4 Feb 2019 16:54:52 +0100 Message-Id: <20190204155454.27465-4-claudius.heine.ext@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204155454.27465-1-claudius.heine.ext@siemens.com> References: <20190204155454.27465-1-claudius.heine.ext@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: 5bs0ZV4evclJ From: Claudius Heine This class implements a new image type for UBI formatted nand flashes. It allows custom ubinize configuration file templates to be placed into the SRC_URI of the image recipe and has mechanims to replace variables within those. It does this by using `envsubst` from the gettext project. The interface for custom template variables is implemented via the `UBINIZE_CFG_TMPL_VARS` bitbake variable. The value of this variable is an array of template variable names. Each template variable name corresponds to a flag of the `UBINIZE_CFG_TMPL_VARS` variable, with which the value can be set. Signed-off-by: Claudius Heine --- doc/user_manual.md | 2 ++ meta/classes/ubi-img.bbclass | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 meta/classes/ubi-img.bbclass diff --git a/doc/user_manual.md b/doc/user_manual.md index c9924ad..c9e18e0 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -350,6 +350,7 @@ Isar can generate various images types for specific machine. The type of the ima - `ext4` - Raw ext4 filesystem image (default option for `qemuarm` machine). - `rpi-sdimg` - A complete, partitioned Raspberry Pi SD card image (default option for the `rpi` machine). - `wic-img` - A full disk image with user-specified partitions created and populated using the wic tool. + - `ubi-img` - A image for use on mtd nand partitions employing UBI --- @@ -477,6 +478,7 @@ Isar contains additional image type classes that can be used as reference: - `rpi-sdimg` - `targz-img` - `ubifs-img` + - `ubi-img` - `wic-img` --- diff --git a/meta/classes/ubi-img.bbclass b/meta/classes/ubi-img.bbclass new file mode 100644 index 0000000..367c48a --- /dev/null +++ b/meta/classes/ubi-img.bbclass @@ -0,0 +1,52 @@ +# This software is a part of ISAR. +# Copyright (C) Siemens AG, 2019 +# +# SPDX-License-Identifier: MIT + +python() { + if not d.getVar("UBINIZE_ARGS"): + bb.fatal("UBINIZE_ARGS must be set") +} + +UBINIZE_CFG ??= "ubinize.cfg" + +inherit image + +UBI_IMAGE_FILE ?= "${IMAGE_FULLNAME}.ubi.img" + +IMAGER_INSTALL += "mtd-utils" + +PP = "/home/builder/${PN}" +PP_DEPLOY = "${PP}/deploy" +PP_ROOTFS = "${PP}/rootfs" +PP_WORK = "${PP}/work" + +BUILDROOT = "${BUILDCHROOT_DIR}${PP}" +BUILDROOT_DEPLOY = "${BUILDCHROOT_DIR}${PP_DEPLOY}" +BUILDROOT_ROOTFS = "${BUILDCHROOT_DIR}${PP_ROOTFS}" +BUILDROOT_WORK = "${BUILDCHROOT_DIR}${PP_WORK}" + +do_ubi_image[stamp-extra-info] = "${DISTRO}-${MACHINE}" + +# Generate ubi filesystem image +do_ubi_image() { + if [ ! -e "${WORKDIR}/${UBINIZE_CFG}" ]; then + die "UBINIZE_CFG does not contain ubinize config file." + fi + + rm -f ${DEPLOY_DIR_IMAGE}/${UBI_IMAGE_FILE} + + buildchroot_do_mounts + + sudo flock ${MOUNT_LOCKFILE} -c ' \ + mkdir -p ${BUILDROOT_DEPLOY} ${BUILDROOT_ROOTFS} ${BUILDROOT_WORK} + mount --bind ${DEPLOY_DIR_IMAGE} ${BUILDROOT_DEPLOY} + mount --bind ${IMAGE_ROOTFS} ${BUILDROOT_ROOTFS} + mount --bind ${WORKDIR} ${BUILDROOT_WORK} + ' + + # Create ubi image using buildchroot tools + sudo chroot ${BUILDCHROOT_DIR} /usr/sbin/ubinize ${UBINIZE_ARGS} \ + -o "${PP_DEPLOY}/${UBI_IMAGE_FILE}" "${PP_WORK}/${UBINIZE_CFG}" +} +addtask ubi_image before do_build after do_copy_boot_files do_install_imager_deps do_unpack do_transform_template -- 2.20.1