summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Smirnov <evgenii.smirnov@here.com>2019-10-23 13:42:41 +0200
committerEugene Smirnov <evgenii.smirnov@here.com>2020-06-30 10:48:21 +0200
commitdf3d58ab8e6d54f5ae945869efbf4d2cbfdb9612 (patch)
treeb06c57dc088e49e357a656bac723c238859f30ae
parent45294e576cc0a9b48f80b7a2a90b070cdfc96292 (diff)
downloadmeta-updater-df3d58ab8e6d54f5ae945869efbf4d2cbfdb9612.tar.gz
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 <evgenii.smirnov@here.com>
-rw-r--r--scripts/lib/wic/canned-wks/ls1043ardb-ota.wks14
-rw-r--r--scripts/lib/wic/plugins/source/rawcopy2.py93
2 files changed, 107 insertions, 0 deletions
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 @@
1# short-description: Create SD card OTA image for NXP LS1043ARDB
2# long-description:
3# Create an OTA-enabled image that can be written onto a SD card using dd
4# for use with NXP LS1043ARDB SoC.
5# For data layout see Layerscape SDK User Guide, Chapter 4.2, tables 14 and 16.
6#
7part BL2 --source rawcopy2 --sourceparams="file=atf/bl2_sd.pbl" --ondisk mmcblk --no-table --align 4
8part BL3 --source rawcopy2 --sourceparams="file=atf/fip_uboot.bin" --ondisk mmcblk --no-table --align 1024
9part fman-ucode --source rawcopy2 --sourceparams="file=fsl_fman_ucode_ls1043_r1.1_108_4_9.bin" --ondisk mmcblk --no-table --align 9216
10part qe-ucode --source rawcopy2 --sourceparams="file=boot/fsl_qe_ucode_1021_10_A.bin" --ondisk mmcblk --no-table --align 9472
11part uboot-scr --source bootimg-partition --ondisk mmcblk --fstype=msdos --fixed-size=100M --align 65540
12part / --source otaimage --ondisk mmcblk --fstype=ext4 --label root --align 167940
13
14bootloader --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 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License version 2 as
6# published by the Free Software Foundation.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along
14# with this program; if not, write to the Free Software Foundation, Inc.,
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16#
17
18import logging
19import os
20
21from wic import WicError
22from wic.pluginbase import SourcePlugin
23from wic.misc import exec_cmd, get_bitbake_var
24from wic.filemap import sparse_copy
25
26logger = logging.getLogger('wic')
27
28class RawCopy2Plugin(SourcePlugin):
29 """
30 Populate partition content from raw image file.
31 """
32
33 name = 'rawcopy2'
34
35 @staticmethod
36 def do_image_label(fstype, dst, label):
37 if fstype.startswith('ext'):
38 cmd = 'tune2fs -L %s %s' % (label, dst)
39 elif fstype in ('msdos', 'vfat'):
40 cmd = 'dosfslabel %s %s' % (dst, label)
41 elif fstype == 'btrfs':
42 cmd = 'btrfs filesystem label %s %s' % (dst, label)
43 elif fstype == 'swap':
44 cmd = 'mkswap -L %s %s' % (label, dst)
45 elif fstype == 'squashfs':
46 raise WicError("It's not possible to update a squashfs "
47 "filesystem label '%s'" % (label))
48 else:
49 raise WicError("Cannot update filesystem label: "
50 "Unknown fstype: '%s'" % (fstype))
51
52 exec_cmd(cmd)
53
54 @classmethod
55 def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
56 oe_builddir, bootimg_dir, kernel_dir,
57 rootfs_dir, native_sysroot):
58 """
59 Called to do the actual content population for a partition i.e. it
60 'prepares' the partition to be incorporated into the image.
61 """
62 if not kernel_dir:
63 kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
64 if not kernel_dir:
65 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
66
67 logger.debug('Kernel dir: %s', kernel_dir)
68
69 if 'file' not in source_params:
70 raise WicError("No file specified")
71
72 src = os.path.join(kernel_dir, source_params['file'])
73 dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno))
74 if not os.path.exists(os.path.dirname(dst)):
75 os.makedirs(os.path.dirname(dst))
76
77 if 'skip' in source_params:
78 sparse_copy(src, dst, skip=int(source_params['skip']))
79 else:
80 sparse_copy(src, dst)
81
82 # get the size in the right units for kickstart (kB)
83 du_cmd = "du -Lbks %s" % dst
84 out = exec_cmd(du_cmd)
85 filesize = int(out.split()[0])
86
87 if filesize > part.size:
88 part.size = filesize
89
90 if part.label:
91 RawCopy2Plugin.do_image_label(part.fstype, dst, part.label)
92
93 part.source_file = dst