Add support of wic

WIC are supported only for disco and eval machine.
To enable it uncomment the preconized line on specific
machine.

Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
This commit is contained in:
Christophe Priouzeau 2019-10-09 11:29:30 +02:00
parent 614d4570f6
commit faff1bdb5d
8 changed files with 177 additions and 0 deletions

View File

@ -3,6 +3,8 @@ LICENSE = "MIT"
inherit core-image
IMAGE_FSTYPES_remove = "wic"
IMAGE_NAME_SUFFIX = ".${STM32MP_BOOTFS_LABEL}fs"
IMAGE_PARTITION_MOUNTPOINT = "${STM32MP_BOOTFS_MOUNTPOINT_IMAGE}"

View File

@ -3,6 +3,8 @@ LICENSE = "MIT"
inherit core-image
IMAGE_FSTYPES_remove = "wic"
IMAGE_NAME_SUFFIX = ".${STM32MP_USERFS_LABEL}"
IMAGE_PARTITION_MOUNTPOINT = "${STM32MP_USERFS_MOUNTPOINT_IMAGE}"

View File

@ -3,6 +3,8 @@ LICENSE = "MIT"
inherit core-image
IMAGE_FSTYPES_remove = "wic"
IMAGE_NAME_SUFFIX = ".${STM32MP_VENDORFS_LABEL}"
IMAGE_PARTITION_MOUNTPOINT = "${STM32MP_VENDORFS_MOUNTPOINT_IMAGE}"

View File

@ -0,0 +1,71 @@
# 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.
#
# This python script are copied/modified from rawcopy
# (https://github.com/openembedded/openembedded-core/blob/master/scripts/lib/wic/plugins/source/rawcopy.py)
#
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 GptCopyPlugin(SourcePlugin):
"""
Populate partition content from raw image file.
"""
name = 'gptcopy'
@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 '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
part.source_file = dst

View File

@ -0,0 +1,27 @@
# short-description: Create SD card image with a boot partition (1GB)
# long-description: Creates a partitioned SD card image (1GB)
#
# - ----- --------- -------------- -----------------------------------------------------
# | | TFA | u-boot | teeh | teed | teex | bootfs | vendorfs | rootfs | userfs |
# - ----- --------- -------------- -----------------------------------------------------
# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
# | | | | | | | | | | |
# 0 17kB 529kB 2.5MB 2.8MB 3MB 3.3MB 67.3MiB 83.3MB 851.3Mb 1024MB
#
# Warning: the first stage of boot (here fsbl1, fsbl2, ssbl) MUST be on GPT partition to be detected.
#
part fsbl1 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-dk2-trusted.stm32" --ondisk mmcblk --label fsbl1 --part-type 0x8301 --fixed-size 256K --align 17
part fsbl2 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-dk2-trusted.stm32" --ondisk mmcblk --label fsbl2 --part-type 0x8301 --fixed-size 256K
part ssbl --source gptcopy --sourceparams="file=u-boot-stm32mp157c-dk2-trusted.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 2048K
part teeh --source gptcopy --sourceparams="file=tee-header_v2-stm32mp157c-dk2-optee.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 256K
part teed --source gptcopy --sourceparams="file=tee-pageable_v2-stm32mp157c-dk2-optee.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 256K
part teex --source gptcopy --sourceparams="file=tee-pager_v2-stm32mp157c-dk2-optee.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 256K
part bootfs --source rawcopy --sourceparams="file=st-image-bootfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label bootfs --active --fixed-size 64M
part vendorfs --source rawcopy --sourceparams="file=st-image-vendorfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label vendorfs --active --fixed-size 16M
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --fixed-size 768M
part usrfs --source rawcopy --sourceparams="file=st-image-userfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label userfs --active --fixed-size 172M
bootloader --ptable gpt

View File

@ -0,0 +1,23 @@
# short-description: Create SD card image with a boot partition (1GB)
# long-description: Creates a partitioned SD card image (1GB)
#
# - ----- --------- -------------- ---------------------------------
# | | TFA | u-boot | bootfs | vendorfs | rootfs | userfs |
# - ----- --------- -------------- ---------------------------------
# ^ ^ ^ ^ ^ ^ ^ ^
# | | | | | | | |
# 0 17kB 529kB 4MB 66.5MB 82.5MB 850.5Mb 1024MB
#
# Warning: the first stage of boot (here fsbl1, fsbl2, ssbl) MUST be on GPT partition to be detected.
#
part fsbl1 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-dk2-trusted.stm32" --ondisk mmcblk --label fsbl1 --part-type 0x8301 --fixed-size 256K --align 17
part fsbl2 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-dk2-trusted.stm32" --ondisk mmcblk --label fsbl2 --part-type 0x8301 --fixed-size 256K
part ssbl --source gptcopy --sourceparams="file=u-boot-stm32mp157c-dk2-trusted.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 2048K
part bootfs --source rawcopy --sourceparams="file=st-image-bootfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label bootfs --active --fixed-size 64M
part vendorfs --source rawcopy --sourceparams="file=st-image-vendorfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label vendorfs --active --fixed-size 16M
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --fixed-size 768M
part usrfs --source rawcopy --sourceparams="file=st-image-userfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label userfs --active --fixed-size 173M
bootloader --ptable gpt

View File

@ -0,0 +1,27 @@
# short-description: Create SD card image with a boot partition (1GB)
# long-description: Creates a partitioned SD card image (1GB)
#
# - ----- --------- -------------- -----------------------------------------------------
# | | TFA | u-boot | teeh | teed | teex | bootfs | vendorfs | rootfs | userfs |
# - ----- --------- -------------- -----------------------------------------------------
# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
# | | | | | | | | | | |
# 0 17kB 529kB 2.5MB 2.8MB 3MB 3.3MB 67.3MiB 83.3MiB 852Mib 1024MiB
#
# Warning: the first stage of boot (here fsbl1, fsbl2, ssbl) MUST be on GPT partition to be detected.
#
part fsbl1 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-ev1-trusted.stm32" --ondisk mmcblk --label fsbl1 --part-type 0x8301 --fixed-size 256K --align 17
part fsbl2 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-ev1-trusted.stm32" --ondisk mmcblk --label fsbl2 --part-type 0x8301 --fixed-size 256K
part ssbl --source gptcopy --sourceparams="file=u-boot-stm32mp157c-ev1-trusted.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 2048K
part teeh --source gptcopy --sourceparams="file=tee-header_v2-stm32mp157c-ev1-optee.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 256K
part teed --source gptcopy --sourceparams="file=tee-pageable_v2-stm32mp157c-ev1-optee.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 256K
part teex --source gptcopy --sourceparams="file=tee-pager_v2-stm32mp157c-ev1-optee.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 256K
part bootfs --source rawcopy --sourceparams="file=st-image-bootfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label bootfs --active --fixed-size 64M
part vendorfs --source rawcopy --sourceparams="file=st-image-vendorfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label vendorfs --active --fixed-size 16M
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --fixed-size 768M
part usrfs --source rawcopy --sourceparams="file=st-image-userfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label userfs --active --fixed-size 172M
bootloader --ptable gpt

View File

@ -0,0 +1,23 @@
# short-description: Create SD card image with a boot partition (1GB)
# long-description: Creates a partitioned SD card image (1GB)
#
# - ----- --------- -------------- ---------------------------------
# | | TFA | u-boot | bootfs | vendorfs | rootfs | userfs |
# - ----- --------- -------------- ---------------------------------
# ^ ^ ^ ^ ^ ^ ^ ^
# | | | | | | | |
# 0 17kB 529kB 4MB 66.5MB 82.5MB 850.5Mb 1024MB
#
# Warning: the first stage of boot (here fsbl1, fsbl2, ssbl) MUST be on GPT partition to be detected.
#
part fsbl1 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-ev1-trusted.stm32" --ondisk mmcblk --label fsbl1 --part-type 0x8301 --fixed-size 256K --align 17
part fsbl2 --source gptcopy --sourceparams="file=tf-a-stm32mp157c-ev1-trusted.stm32" --ondisk mmcblk --label fsbl2 --part-type 0x8301 --fixed-size 256K
part ssbl --source gptcopy --sourceparams="file=u-boot-stm32mp157c-ev1-trusted.stm32" --ondisk mmcblk --label ssbl --part-type 0x8301 --fixed-size 2048K
part bootfs --source rawcopy --sourceparams="file=st-image-bootfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label bootfs --active --fixed-size 64M
part vendorfs --source rawcopy --sourceparams="file=st-image-vendorfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label vendorfs --active --fixed-size 16M
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --fixed-size 768M
part usrfs --source rawcopy --sourceparams="file=st-image-userfs-openstlinux-weston-stm32mp1.ext4" --ondisk mmcblk --fstype=ext4 --label userfs --active --fixed-size 173M
bootloader --ptable gpt