From df3d58ab8e6d54f5ae945869efbf4d2cbfdb9612 Mon Sep 17 00:00:00 2001 From: Eugene Smirnov Date: Wed, 23 Oct 2019 13:42:41 +0200 Subject: Support wic file creation for LS1043ARBD board Current rawcopy function doesn't support files that are located in subdirectories of DEPLOYDIR. Add a new rawcopy2 function to handle that. Shouldn't be necessary once upstream patch is available: https://git.yoctoproject.org/cgit.cgi/poky/commit/scripts/lib/wic/plugins/source/rawcopy.py?h=zeus&id=6fb5afb65de3a2f94d705e93ebdbc1f46299e885 Signed-off-by: Eugene Smirnov --- scripts/lib/wic/canned-wks/ls1043ardb-ota.wks | 14 ++++ scripts/lib/wic/plugins/source/rawcopy2.py | 93 +++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 scripts/lib/wic/canned-wks/ls1043ardb-ota.wks create mode 100644 scripts/lib/wic/plugins/source/rawcopy2.py (limited to 'scripts/lib/wic') diff --git a/scripts/lib/wic/canned-wks/ls1043ardb-ota.wks b/scripts/lib/wic/canned-wks/ls1043ardb-ota.wks new file mode 100644 index 0000000..aed6870 --- /dev/null +++ b/scripts/lib/wic/canned-wks/ls1043ardb-ota.wks @@ -0,0 +1,14 @@ +# short-description: Create SD card OTA image for NXP LS1043ARDB +# long-description: +# Create an OTA-enabled image that can be written onto a SD card using dd +# for use with NXP LS1043ARDB SoC. +# For data layout see Layerscape SDK User Guide, Chapter 4.2, tables 14 and 16. +# +part BL2 --source rawcopy2 --sourceparams="file=atf/bl2_sd.pbl" --ondisk mmcblk --no-table --align 4 +part BL3 --source rawcopy2 --sourceparams="file=atf/fip_uboot.bin" --ondisk mmcblk --no-table --align 1024 +part fman-ucode --source rawcopy2 --sourceparams="file=fsl_fman_ucode_ls1043_r1.1_108_4_9.bin" --ondisk mmcblk --no-table --align 9216 +part qe-ucode --source rawcopy2 --sourceparams="file=boot/fsl_qe_ucode_1021_10_A.bin" --ondisk mmcblk --no-table --align 9472 +part uboot-scr --source bootimg-partition --ondisk mmcblk --fstype=msdos --fixed-size=100M --align 65540 +part / --source otaimage --ondisk mmcblk --fstype=ext4 --label root --align 167940 + +bootloader --ptable msdos diff --git a/scripts/lib/wic/plugins/source/rawcopy2.py b/scripts/lib/wic/plugins/source/rawcopy2.py new file mode 100644 index 0000000..e2166d6 --- /dev/null +++ b/scripts/lib/wic/plugins/source/rawcopy2.py @@ -0,0 +1,93 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +import logging +import os + +from wic import WicError +from wic.pluginbase import SourcePlugin +from wic.misc import exec_cmd, get_bitbake_var +from wic.filemap import sparse_copy + +logger = logging.getLogger('wic') + +class RawCopy2Plugin(SourcePlugin): + """ + Populate partition content from raw image file. + """ + + name = 'rawcopy2' + + @staticmethod + def do_image_label(fstype, dst, label): + if fstype.startswith('ext'): + cmd = 'tune2fs -L %s %s' % (label, dst) + elif fstype in ('msdos', 'vfat'): + cmd = 'dosfslabel %s %s' % (dst, label) + elif fstype == 'btrfs': + cmd = 'btrfs filesystem label %s %s' % (dst, label) + elif fstype == 'swap': + cmd = 'mkswap -L %s %s' % (label, dst) + elif fstype == 'squashfs': + raise WicError("It's not possible to update a squashfs " + "filesystem label '%s'" % (label)) + else: + raise WicError("Cannot update filesystem label: " + "Unknown fstype: '%s'" % (fstype)) + + exec_cmd(cmd) + + @classmethod + def do_prepare_partition(cls, part, source_params, cr, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): + """ + Called to do the actual content population for a partition i.e. it + 'prepares' the partition to be incorporated into the image. + """ + if not kernel_dir: + kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not kernel_dir: + raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") + + logger.debug('Kernel dir: %s', kernel_dir) + + if 'file' not in source_params: + raise WicError("No file specified") + + src = os.path.join(kernel_dir, source_params['file']) + dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno)) + if not os.path.exists(os.path.dirname(dst)): + os.makedirs(os.path.dirname(dst)) + + if 'skip' in source_params: + sparse_copy(src, dst, skip=int(source_params['skip'])) + else: + sparse_copy(src, dst) + + # get the size in the right units for kickstart (kB) + du_cmd = "du -Lbks %s" % dst + out = exec_cmd(du_cmd) + filesize = int(out.split()[0]) + + if filesize > part.size: + part.size = filesize + + if part.label: + RawCopy2Plugin.do_image_label(part.fstype, dst, part.label) + + part.source_file = dst -- cgit v1.2.3-54-g00ecf