summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta-agl-bsp/classes')
-rw-r--r--meta-agl-bsp/classes/image-vm.bbclass181
-rw-r--r--meta-agl-bsp/classes/image.bbclass624
-rw-r--r--meta-agl-bsp/classes/sdcard_image-rpi.bbclass184
-rw-r--r--meta-agl-bsp/classes/sdcard_image-socfpga.bbclass181
4 files changed, 181 insertions, 989 deletions
diff --git a/meta-agl-bsp/classes/image-vm.bbclass b/meta-agl-bsp/classes/image-vm.bbclass
deleted file mode 100644
index ec8f0cb8f..000000000
--- a/meta-agl-bsp/classes/image-vm.bbclass
+++ /dev/null
@@ -1,181 +0,0 @@
-# image-vm.bbclass
-# (loosly based off image-live.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.)
-#
-# Create an image which can be placed directly onto a harddisk using dd and then
-# booted.
-#
-# This uses syslinux. extlinux would have been nice but required the ext2/3
-# partition to be mounted. grub requires to run itself as part of the install
-# process.
-#
-# The end result is a 512 boot sector populated with an MBR and partition table
-# followed by an msdos fat16 partition containing syslinux and a linux kernel
-# completed by the ext2/3 rootfs.
-#
-# We have to push the msdos parition table size > 16MB so fat 16 is used as parted
-# won't touch fat12 partitions.
-
-inherit live-vm-common
-
-do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \
- virtual/kernel:do_deploy \
- syslinux:do_populate_sysroot \
- syslinux-native:do_populate_sysroot \
- parted-native:do_populate_sysroot \
- mtools-native:do_populate_sysroot \
- ${PN}:do_image_${VM_ROOTFS_TYPE} \
- "
-
-IMAGE_TYPEDEP_vmdk = "${VM_ROOTFS_TYPE}"
-IMAGE_TYPEDEP_vmdk.xz = "${VM_ROOTFS_TYPE}"
-IMAGE_TYPEDEP_vdi = "${VM_ROOTFS_TYPE}"
-IMAGE_TYPEDEP_qcow2 = "${VM_ROOTFS_TYPE}"
-IMAGE_TYPEDEP_hdddirect = "${VM_ROOTFS_TYPE}"
-IMAGE_TYPES_MASKED += "vmdk vmdk.xz vdi qcow2 hdddirect"
-
-VM_ROOTFS_TYPE ?= "ext4"
-ROOTFS ?= "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${VM_ROOTFS_TYPE}"
-
-# Used by bootloader
-LABELS_VM ?= "boot"
-ROOT_VM ?= "root=/dev/sda2"
-# Using an initramfs is optional. Enable it by setting INITRD_IMAGE_VM.
-INITRD_IMAGE_VM ?= ""
-INITRD_VM ?= "${@'${IMGDEPLOYDIR}/${INITRD_IMAGE_VM}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE_VM}' else ''}"
-do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${INITRD_IMAGE_VM}' else ''}"
-
-BOOTDD_VOLUME_ID ?= "boot"
-BOOTDD_EXTRA_SPACE ?= "16384"
-
-DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
-DISK_SIGNATURE[vardepsexclude] = "DISK_SIGNATURE_GENERATED"
-
-build_boot_dd() {
- HDDDIR="${S}/hdd/boot"
- HDDIMG="${S}/hdd.image"
- IMAGE=${IMGDEPLOYDIR}/${IMAGE_NAME}.hdddirect
-
- populate_kernel $HDDDIR
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_hddimg_populate $HDDDIR
- fi
- if [ "${EFI}" = "1" ]; then
- efi_hddimg_populate $HDDDIR
- fi
-
- BLOCKS=`du -bks $HDDDIR | cut -f 1`
- BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}`
-
- # Remove it since mkdosfs would fail when it exists
- rm -f $HDDIMG
- mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS
- mcopy -i $HDDIMG -s $HDDDIR/* ::/
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_hdddirect_install $HDDIMG
- fi
- chmod 644 $HDDIMG
-
- ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1`
- TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS`
- END1=`expr $BLOCKS \* 1024`
- END2=`expr $END1 + 512`
- END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1`
-
- echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3
- rm -rf $IMAGE
- dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1
-
- parted $IMAGE mklabel msdos
- parted $IMAGE mkpart primary fat16 0 ${END1}B
- parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B
- parted $IMAGE set 1 boot on
-
- parted $IMAGE print
-
- awk "BEGIN { printf \"$(echo ${DISK_SIGNATURE} | sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/')\" }" | \
- dd of=$IMAGE bs=1 seek=440 conv=notrunc
-
- OFFSET=`expr $END2 / 512`
- if [ "${PCBIOS}" = "1" ]; then
- dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc
- fi
-
- dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512
- dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512
-
- cd ${IMGDEPLOYDIR}
-
- ln -sf ${IMAGE_NAME}.hdddirect ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.hdddirect
-}
-
-python do_bootdirectdisk() {
- validate_disk_signature(d)
- set_live_vm_vars(d, 'VM')
- if d.getVar("PCBIOS") == "1":
- bb.build.exec_func('build_syslinux_cfg', d)
- if d.getVar("EFI") == "1":
- bb.build.exec_func('build_efi_cfg', d)
- bb.build.exec_func('build_boot_dd', d)
-}
-
-def generate_disk_signature():
- import uuid
-
- signature = str(uuid.uuid4())[:8]
-
- if signature != '00000000':
- return signature
- else:
- return 'ffffffff'
-
-def validate_disk_signature(d):
- import re
-
- disk_signature = d.getVar("DISK_SIGNATURE")
-
- if not re.match(r'^[0-9a-fA-F]{8}$', disk_signature):
- bb.fatal("DISK_SIGNATURE '%s' must be an 8 digit hex string" % disk_signature)
-
-DISK_SIGNATURE_GENERATED := "${@generate_disk_signature()}"
-
-run_qemu_img (){
- type="$1"
- qemu-img convert -O $type ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.hdddirect ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type
-
- ln -sf ${IMAGE_NAME}.$type ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type
-}
-create_vmdk_image () {
- run_qemu_img vmdk
-}
-
-create_vmdkxz_image () {
- run_qemu_img vmdk
- xz -f ${XZ_COMPRESSION_LEVEL} ${XZ_THREADS} --check=${XZ_INTEGRITY_CHECK} ${IMGDEPLOYDIR}/${IMAGE_NAME}.vmdk
- ln -sf ${IMAGE_NAME}.vmdk.xz ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.vmdk.xz
- rm -f ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.vmdk
-}
-
-create_vdi_image () {
- run_qemu_img vdi
-}
-
-create_qcow2_image () {
- run_qemu_img qcow2
-}
-
-python do_vmimg() {
- if bb.utils.contains('IMAGE_FSTYPES', 'vmdk.xz', True, False, d):
- bb.build.exec_func('create_vmdkxz_image', d)
- if bb.utils.contains('IMAGE_FSTYPES', 'vmdk', True, False, d):
- bb.build.exec_func('create_vmdk_image', d)
- if 'vdi' in d.getVar('IMAGE_FSTYPES', True):
- bb.build.exec_func('create_vdi_image', d)
- if 'qcow2' in d.getVar('IMAGE_FSTYPES', True):
- bb.build.exec_func('create_qcow2_image', d)
-}
-
-addtask bootdirectdisk before do_vmimg
-addtask vmimg after do_bootdirectdisk before do_image_complete
-do_vmimg[depends] += "qemu-native:do_populate_sysroot"
diff --git a/meta-agl-bsp/classes/image.bbclass b/meta-agl-bsp/classes/image.bbclass
deleted file mode 100644
index ccaffce60..000000000
--- a/meta-agl-bsp/classes/image.bbclass
+++ /dev/null
@@ -1,624 +0,0 @@
-inherit rootfs_${IMAGE_PKGTYPE}
-
-# Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
-# in the non-Linux SDK_OS case, such as mingw32
-SDKEXTCLASS ?= "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
-inherit ${SDKEXTCLASS}
-
-TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
-TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
-POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_sysroot_relativelinks; "
-
-LICENSE = "MIT"
-PACKAGES = ""
-DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
-RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL}"
-RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}"
-
-INHIBIT_DEFAULT_DEPS = "1"
-
-TESTIMAGECLASS = "${@base_conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
-inherit ${TESTIMAGECLASS}
-
-# IMAGE_FEATURES may contain any available package group
-IMAGE_FEATURES ?= ""
-IMAGE_FEATURES[type] = "list"
-IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs empty-root-password allow-empty-password post-install-logging"
-
-# Generate companion debugfs?
-IMAGE_GEN_DEBUGFS ?= "0"
-
-# rootfs bootstrap install
-ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"
-
-# These packages will be removed from a read-only rootfs after all other
-# packages have been installed
-ROOTFS_RO_UNNEEDED = "update-rc.d base-passwd shadow ${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}"
-
-# packages to install from features
-FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
-FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}"
-FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
-FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}"
-
-# Define some very basic feature package groups
-FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}"
-SPLASH ?= "psplash"
-FEATURE_PACKAGES_splash = "${SPLASH}"
-
-IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}'
-
-def check_image_features(d):
- valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems') or "").split()
- valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys()
- for var in d:
- if var.startswith("PACKAGE_GROUP_"):
- bb.warn("PACKAGE_GROUP is deprecated, please use FEATURE_PACKAGES instead")
- valid_features.append(var[14:])
- elif var.startswith("FEATURE_PACKAGES_"):
- valid_features.append(var[17:])
- valid_features.sort()
-
- features = set(oe.data.typed_value('IMAGE_FEATURES', d))
- for feature in features:
- if feature not in valid_features:
- if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d):
- raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES (added via EXTRA_IMAGE_FEATURES) is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
- else:
- raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
-
-IMAGE_INSTALL ?= ""
-IMAGE_INSTALL[type] = "list"
-export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}"
-PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}"
-
-IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete"
-
-# Images are generally built explicitly, do not need to be part of world.
-EXCLUDE_FROM_WORLD = "1"
-
-USE_DEVFS ?= "1"
-USE_DEPMOD ?= "1"
-
-PID = "${@os.getpid()}"
-
-PACKAGE_ARCH = "${MACHINE_ARCH}"
-
-LDCONFIGDEPEND ?= "ldconfig-native:do_populate_sysroot"
-LDCONFIGDEPEND_libc-uclibc = ""
-LDCONFIGDEPEND_libc-musl = ""
-
-# This is needed to have depmod data in PKGDATA_DIR,
-# but if you're building small initramfs image
-# e.g. to include it in your kernel, you probably
-# don't want this dependency, which is causing dependency loop
-KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata"
-
-do_rootfs[depends] += " \
- makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \
- virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \
- ${KERNELDEPMODDEPEND} \
-"
-do_rootfs[recrdeptask] += "do_packagedata"
-
-def rootfs_command_variables(d):
- return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','ROOTFS_POSTUNINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND',
- 'IMAGE_PREPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS','RPM_POSTPROCESS_COMMANDS','DEB_PREPROCESS_COMMANDS','DEB_POSTPROCESS_COMMANDS']
-
-python () {
- variables = rootfs_command_variables(d) + sdk_command_variables(d)
- for var in variables:
- if d.getVar(var, False):
- d.setVarFlag(var, 'func', '1')
-}
-
-def rootfs_variables(d):
- from oe.rootfs import variable_depends
- variables = ['IMAGE_DEVICE_TABLE','IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE','IMAGE_ROOTFS_EXTRA_SPACE',
- 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS',
- 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS',
- 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS',
- 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY']
- variables.extend(rootfs_command_variables(d))
- variables.extend(variable_depends(d))
- return " ".join(variables)
-
-do_rootfs[vardeps] += "${@rootfs_variables(d)}"
-
-do_build[depends] += "virtual/kernel:do_deploy"
-
-def build_live(d):
- if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg
- d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d))
- d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d))
- if d.getVar('NOISO') == "0" or d.getVar('NOHDD') == "0":
- return "image-live"
- return ""
- return "image-live"
-
-IMAGE_TYPE_live = "${@build_live(d)}"
-inherit ${IMAGE_TYPE_live}
-
-IMAGE_TYPE_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vmdk.xz", "vdi", "qcow2", "hdddirect"], "image-vm", "", d)}'
-
-inherit ${IMAGE_TYPE_vm}
-
-IMAGE_TYPE_container = '${@bb.utils.contains("IMAGE_FSTYPES", "container", "image-container", "", d)}'
-inherit ${IMAGE_TYPE_container}
-
-def build_uboot(d):
- if 'u-boot' in (d.getVar('IMAGE_FSTYPES') or ''):
- return "image_types_uboot"
- else:
- return ""
-
-IMAGE_TYPE_uboot = "${@build_uboot(d)}"
-inherit ${IMAGE_TYPE_uboot}
-
-IMAGE_TYPE_wic = "image_types_wic"
-inherit ${IMAGE_TYPE_wic}
-
-python () {
- def extraimage_getdepends(task):
- deps = ""
- for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
- deps += " %s:%s" % (dep, task)
- return deps
-
- d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_lic'))
- d.appendVarFlag('do_image_complete', 'depends', extraimage_getdepends('do_populate_sysroot'))
-
- deps = " " + imagetypes_getdepends(d)
- d.appendVarFlag('do_rootfs', 'depends', deps)
-
- #process IMAGE_FEATURES, we must do this before runtime_mapping_rename
- #Check for replaces image features
- features = set(oe.data.typed_value('IMAGE_FEATURES', d))
- remain_features = features.copy()
- for feature in features:
- replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature) or "").split())
- remain_features -= replaces
-
- #Check for conflict image features
- for feature in remain_features:
- conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature) or "").split())
- temp = conflicts & remain_features
- if temp:
- bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN'), feature, ' '.join(list(temp))))
-
- d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features))))
-
- check_image_features(d)
- initramfs_image = d.getVar('INITRAMFS_IMAGE') or ""
- if initramfs_image != "":
- d.appendVarFlag('do_build', 'depends', " %s:do_bundle_initramfs" % d.getVar('PN'))
- d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_image_complete" % initramfs_image)
-}
-
-IMAGE_CLASSES += "image_types"
-inherit ${IMAGE_CLASSES}
-
-IMAGE_POSTPROCESS_COMMAND ?= ""
-
-# some default locales
-IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
-
-LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS').split()))}"
-
-# Prefer image, but use the fallback files for lookups if the image ones
-# aren't yet available.
-PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
-
-inherit rootfs-postcommands
-
-PACKAGE_EXCLUDE ??= ""
-PACKAGE_EXCLUDE[type] = "list"
-
-fakeroot python do_rootfs () {
- from oe.rootfs import create_rootfs
- from oe.manifest import create_manifest
- import logging
-
- logger = d.getVar('BB_TASK_LOGGER', False)
- if logger:
- logcatcher = bb.utils.LogCatcher()
- logger.addHandler(logcatcher)
- else:
- logcatcher = None
-
- # NOTE: if you add, remove or significantly refactor the stages of this
- # process then you should recalculate the weightings here. This is quite
- # easy to do - just change the MultiStageProgressReporter line temporarily
- # to pass debug=True as the last parameter and you'll get a printout of
- # the weightings as well as a map to the lines where next_stage() was
- # called. Of course this isn't critical, but it helps to keep the progress
- # reporting accurate.
- stage_weights = [1, 203, 354, 186, 65, 4228, 1, 353, 49, 330, 382, 23, 1]
- progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
- progress_reporter.next_stage()
-
- # Handle package exclusions
- excl_pkgs = d.getVar("PACKAGE_EXCLUDE").split()
- inst_pkgs = d.getVar("PACKAGE_INSTALL").split()
- inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY").split()
-
- d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
- d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
-
- for pkg in excl_pkgs:
- if pkg in inst_pkgs:
- bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs))
- inst_pkgs.remove(pkg)
-
- if pkg in inst_attempt_pkgs:
- bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL_ATTEMPTONLY (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs))
- inst_attempt_pkgs.remove(pkg)
-
- d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
- d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
-
- # Ensure we handle package name remapping
- # We have to delay the runtime_mapping_rename until just before rootfs runs
- # otherwise, the multilib renaming could step in and squash any fixups that
- # may have occurred.
- pn = d.getVar('PN')
- runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
- runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
- runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
-
- # Generate the initial manifest
- create_manifest(d)
-
- progress_reporter.next_stage()
-
- # generate rootfs
- create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher)
-
- progress_reporter.finish()
-}
-do_rootfs[dirs] = "${TOPDIR}"
-do_rootfs[cleandirs] += "${S} ${IMGDEPLOYDIR}"
-do_rootfs[umask] = "022"
-addtask rootfs before do_build after do_prepare_recipe_sysroot
-
-fakeroot python do_image () {
- from oe.utils import execute_pre_post_process
-
- pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND")
-
- execute_pre_post_process(d, pre_process_cmds)
-}
-do_image[dirs] = "${TOPDIR}"
-do_image[umask] = "022"
-addtask do_image after do_rootfs before do_build
-
-fakeroot python do_image_complete () {
- from oe.utils import execute_pre_post_process
-
- post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND")
-
- execute_pre_post_process(d, post_process_cmds)
-}
-do_image_complete[dirs] = "${TOPDIR}"
-do_image_complete[umask] = "022"
-SSTATETASKS += "do_image_complete"
-SSTATE_SKIP_CREATION_task-image-complete = '1'
-do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}"
-do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
-do_image_complete[stamp-extra-info] = "${MACHINE}"
-addtask do_image_complete after do_image before do_build
-
-# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
-#
-# IMAGE_QA_COMMANDS += " \
-# image_check_everything_ok \
-# "
-# This task runs all functions in IMAGE_QA_COMMANDS after the image
-# construction has completed in order to validate the resulting image.
-fakeroot python do_image_qa () {
- from oe.utils import ImageQAFailed
-
- qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
- qamsg = ""
-
- for cmd in qa_cmds:
- try:
- bb.build.exec_func(cmd, d)
- except oe.utils.ImageQAFailed as e:
- qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
- except bb.build.FuncFailed as e:
- qamsg = qamsg + '\tImage QA function %s failed' % e.name
- if e.logfile:
- qamsg = qamsg + ' (log file is located at %s)' % e.logfile
- qamsg = qamsg + '\n'
-
- if qamsg:
- imgname = d.getVar('IMAGE_NAME')
- bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
-}
-addtask do_image_qa after do_image_complete before do_build
-
-def setup_debugfs_variables(d):
- d.appendVar('IMAGE_ROOTFS', '-dbg')
- d.appendVar('IMAGE_LINK_NAME', '-dbg')
- d.appendVar('IMAGE_NAME','-dbg')
- d.setVar('IMAGE_BUILDING_DEBUGFS', 'true')
- debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS')
- if debugfs_image_fstypes:
- d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes)
-
-python setup_debugfs () {
- setup_debugfs_variables(d)
-}
-
-python () {
- vardeps = set()
- # We allow CONVERSIONTYPES to have duplicates. That avoids breaking
- # derived distros when OE-core or some other layer independently adds
- # the same type. There is still only one command for each type, but
- # presumably the commands will do the same when the type is the same,
- # even when added in different places.
- #
- # Without de-duplication, gen_conversion_cmds() below
- # would create the same compression command multiple times.
- ctypes = set(d.getVar('CONVERSIONTYPES').split())
- old_overrides = d.getVar('OVERRIDES', False)
-
- def _image_base_type(type):
- basetype = type
- for ctype in ctypes:
- if type.endswith("." + ctype):
- basetype = type[:-len("." + ctype)]
- break
-
- if basetype != type:
- # New base type itself might be generated by a conversion command.
- basetype = _image_base_type(basetype)
-
- return basetype
-
- basetypes = {}
- alltypes = d.getVar('IMAGE_FSTYPES').split()
- typedeps = {}
-
- if d.getVar('IMAGE_GEN_DEBUGFS') == "1":
- debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split()
- for t in debugfs_fstypes:
- alltypes.append("debugfs_" + t)
-
- def _add_type(t):
- baset = _image_base_type(t)
- input_t = t
- if baset not in basetypes:
- basetypes[baset]= []
- if t not in basetypes[baset]:
- basetypes[baset].append(t)
- debug = ""
- if t.startswith("debugfs_"):
- t = t[8:]
- debug = "debugfs_"
- deps = (d.getVar('IMAGE_TYPEDEP_' + t) or "").split()
- vardeps.add('IMAGE_TYPEDEP_' + t)
- if baset not in typedeps:
- typedeps[baset] = set()
- deps = [debug + dep for dep in deps]
- for dep in deps:
- if dep not in alltypes:
- alltypes.append(dep)
- _add_type(dep)
- basedep = _image_base_type(dep)
- typedeps[baset].add(basedep)
-
- if baset != input_t:
- _add_type(baset)
-
- for t in alltypes[:]:
- _add_type(t)
-
- d.appendVarFlag('do_image', 'vardeps', ' '.join(vardeps))
-
- maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split()
- maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")]
-
- for t in basetypes:
- vardeps = set()
- cmds = []
- subimages = []
- realt = t
-
- if t in maskedtypes:
- continue
-
- localdata = bb.data.createCopy(d)
- debug = ""
- if t.startswith("debugfs_"):
- setup_debugfs_variables(localdata)
- debug = "setup_debugfs "
- realt = t[8:]
- localdata.setVar('OVERRIDES', '%s:%s' % (realt, old_overrides))
- localdata.setVar('type', realt)
- # Delete DATETIME so we don't expand any references to it now
- # This means the task's hash can be stable rather than having hardcoded
- # date/time values. It will get expanded at execution time.
- # Similarly TMPDIR since otherwise we see QA stamp comparision problems
- localdata.delVar('DATETIME')
- localdata.delVar('TMPDIR')
-
- image_cmd = localdata.getVar("IMAGE_CMD")
- vardeps.add('IMAGE_CMD_' + realt)
- if image_cmd:
- cmds.append("\t" + image_cmd)
- else:
- bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t)
- cmds.append(localdata.expand("\tcd ${IMGDEPLOYDIR}"))
-
- # Since a copy of IMAGE_CMD_xxx will be inlined within do_image_xxx,
- # prevent a redundant copy of IMAGE_CMD_xxx being emitted as a function.
- d.delVarFlag('IMAGE_CMD_' + realt, 'func')
-
- rm_tmp_images = set()
- def gen_conversion_cmds(bt):
- for ctype in sorted(ctypes):
- if bt.endswith("." + ctype):
- type = bt[0:-len(ctype) - 1]
- if type.startswith("debugfs_"):
- type = type[8:]
- # Create input image first.
- gen_conversion_cmds(type)
- localdata.setVar('type', type)
- cmd = "\t" + (localdata.getVar("CONVERSION_CMD_" + ctype) or localdata.getVar("COMPRESS_CMD_" + ctype))
- if cmd not in cmds:
- cmds.append(cmd)
- vardeps.add('CONVERSION_CMD_' + ctype)
- vardeps.add('COMPRESS_CMD_' + ctype)
- subimage = type + "." + ctype
- if subimage not in subimages:
- subimages.append(subimage)
- if type not in alltypes:
- rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
-
- for bt in basetypes[t]:
- gen_conversion_cmds(bt)
-
- localdata.setVar('type', realt)
- if t not in alltypes:
- rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
- else:
- subimages.append(realt)
-
- # Clean up after applying all conversion commands. Some of them might
- # use the same input, therefore we cannot delete sooner without applying
- # some complex dependency analysis.
- for image in sorted(rm_tmp_images):
- cmds.append("\trm " + image)
-
- after = 'do_image'
- for dep in typedeps[t]:
- after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_")
-
- t = t.replace("-", "_").replace(".", "_")
-
- d.setVar('do_image_%s' % t, '\n'.join(cmds))
- d.setVarFlag('do_image_%s' % t, 'func', '1')
- d.setVarFlag('do_image_%s' % t, 'fakeroot', '1')
- d.setVarFlag('do_image_%s' % t, 'prefuncs', debug + 'set_image_size')
- d.setVarFlag('do_image_%s' % t, 'postfuncs', 'create_symlinks')
- d.setVarFlag('do_image_%s' % t, 'subimages', ' '.join(subimages))
- d.appendVarFlag('do_image_%s' % t, 'vardeps', ' '.join(vardeps))
- d.appendVarFlag('do_image_%s' % t, 'vardepsexclude', 'DATETIME')
-
- bb.debug(2, "Adding type %s before %s, after %s" % (t, 'do_image_complete', after))
- bb.build.addtask('do_image_%s' % t, 'do_image_complete', after, d)
-}
-
-#
-# Compute the rootfs size
-#
-def get_rootfs_size(d):
- import subprocess
-
- rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT'))
- overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR'))
- rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE'))
- rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE'))
- rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE')
- image_fstypes = d.getVar('IMAGE_FSTYPES') or ''
- initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or ''
- initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE')
-
- output = subprocess.check_output(['du', '-ks',
- d.getVar('IMAGE_ROOTFS')])
- size_kb = int(output.split()[0])
- base_size = size_kb * overhead_factor
- base_size = max(base_size, rootfs_req_size) + rootfs_extra_space
-
- if base_size != int(base_size):
- base_size = int(base_size + 1)
- else:
- base_size = int(base_size)
-
- base_size += rootfs_alignment - 1
- base_size -= base_size % rootfs_alignment
-
- # Do not check image size of the debugfs image. This is not supposed
- # to be deployed, etc. so it doesn't make sense to limit the size
- # of the debug.
- if (d.getVar('IMAGE_BUILDING_DEBUGFS') or "") == "true":
- return base_size
-
- # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
- if rootfs_maxsize:
- rootfs_maxsize_int = int(rootfs_maxsize)
- if base_size > rootfs_maxsize_int:
- bb.fatal("The rootfs size %d(K) overrides IMAGE_ROOTFS_MAXSIZE: %d(K)" % \
- (base_size, rootfs_maxsize_int))
-
- # Check the initramfs size against INITRAMFS_MAXSIZE (if set)
- if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize:
- initramfs_maxsize_int = int(initramfs_maxsize)
- if base_size > initramfs_maxsize_int:
- bb.error("The initramfs size %d(K) overrides INITRAMFS_MAXSIZE: %d(K)" % \
- (base_size, initramfs_maxsize_int))
- bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should")
- bb.fatal("be less than 1/2 of ram size, or you may fail to boot it.\n")
- return base_size
-
-python set_image_size () {
- rootfs_size = get_rootfs_size(d)
- d.setVar('ROOTFS_SIZE', str(rootfs_size))
- d.setVarFlag('ROOTFS_SIZE', 'export', '1')
-}
-
-#
-# Create symlinks to the newly created image
-#
-python create_symlinks() {
-
- deploy_dir = d.getVar('IMGDEPLOYDIR')
- img_name = d.getVar('IMAGE_NAME')
- link_name = d.getVar('IMAGE_LINK_NAME')
- manifest_name = d.getVar('IMAGE_MANIFEST')
- taskname = d.getVar("BB_CURRENTTASK")
- subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split()
- imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix') or d.expand("${IMAGE_NAME_SUFFIX}.")
-
- if not link_name:
- return
- for type in subimages:
- dst = os.path.join(deploy_dir, link_name + "." + type)
- src = img_name + imgsuffix + type
- if os.path.exists(os.path.join(deploy_dir, src)):
- bb.note("Creating symlink: %s -> %s" % (dst, src))
- if os.path.islink(dst):
- os.remove(dst)
- os.symlink(src, dst)
- else:
- bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src))
-}
-
-MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
-MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
-MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
-
-do_fetch[noexec] = "1"
-do_unpack[noexec] = "1"
-do_patch[noexec] = "1"
-do_configure[noexec] = "1"
-do_compile[noexec] = "1"
-do_install[noexec] = "1"
-deltask do_populate_sysroot
-do_package[noexec] = "1"
-deltask do_package_qa
-do_packagedata[noexec] = "1"
-do_package_write_ipk[noexec] = "1"
-do_package_write_deb[noexec] = "1"
-do_package_write_rpm[noexec] = "1"
-
-# Allow the kernel to be repacked with the initramfs and boot image file as a single file
-do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs"
-do_bundle_initramfs[nostamp] = "1"
-do_bundle_initramfs[noexec] = "1"
-do_bundle_initramfs () {
- :
-}
-addtask bundle_initramfs after do_image_complete
diff --git a/meta-agl-bsp/classes/sdcard_image-rpi.bbclass b/meta-agl-bsp/classes/sdcard_image-rpi.bbclass
deleted file mode 100644
index c22a6f880..000000000
--- a/meta-agl-bsp/classes/sdcard_image-rpi.bbclass
+++ /dev/null
@@ -1,184 +0,0 @@
-inherit image_types
-inherit linux-raspberrypi-base
-
-#
-# Create an image that can by written onto a SD card using dd.
-#
-# The disk layout used is:
-#
-# 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved for other data
-# IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - bootloader and kernel
-# BOOT_SPACE -> SDIMG_SIZE - rootfs
-#
-
-# Default Free space = 1.3x
-# Use IMAGE_OVERHEAD_FACTOR to add more space
-# <--------->
-# 4MiB 40MiB SDIMG_ROOTFS
-# <-----------------------> <----------> <---------------------->
-# ------------------------ ------------ ------------------------
-# | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | ROOTFS_SIZE |
-# ------------------------ ------------ ------------------------
-# ^ ^ ^ ^
-# | | | |
-# 0 4MiB 4MiB + 40MiB 4MiB + 40Mib + SDIMG_ROOTFS
-
-# This image depends on the rootfs image
-IMAGE_TYPEDEP_rpi-sdimg = "${SDIMG_ROOTFS_TYPE}"
-
-# Set kernel and boot loader
-IMAGE_BOOTLOADER ?= "bcm2835-bootfiles"
-
-# Set initramfs extension
-KERNEL_INITRAMFS ?= ""
-
-# Kernel image name
-SDIMG_KERNELIMAGE_raspberrypi ?= "kernel.img"
-SDIMG_KERNELIMAGE_raspberrypi2 ?= "kernel7.img"
-SDIMG_KERNELIMAGE_raspberrypi3-64 ?= "kernel8.img"
-
-# Boot partition volume id
-BOOTDD_VOLUME_ID ?= "${MACHINE}"
-
-# Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT)
-BOOT_SPACE ?= "40960"
-
-# Set alignment to 4MB [in KiB]
-IMAGE_ROOTFS_ALIGNMENT = "4096"
-
-# Use an uncompressed ext3 by default as rootfs
-SDIMG_ROOTFS_TYPE ?= "ext3"
-SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.${SDIMG_ROOTFS_TYPE}"
-
-IMAGE_DEPENDS_rpi-sdimg = " \
- parted-native \
- mtools-native \
- dosfstools-native \
- virtual/kernel:do_deploy \
- ${IMAGE_BOOTLOADER} \
- ${@bb.utils.contains('KERNEL_IMAGETYPE', 'uImage', 'u-boot', '',d)} \
- "
-
-# SD card image name
-SDIMG = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.rpi-sdimg"
-
-# Compression method to apply to SDIMG after it has been created. Supported
-# compression formats are "gzip", "bzip2" or "xz". The original .rpi-sdimg file
-# is kept and a new compressed file is created if one of these compression
-# formats is chosen. If SDIMG_COMPRESSION is set to any other value it is
-# silently ignored.
-#SDIMG_COMPRESSION ?= ""
-
-# Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS.
-FATPAYLOAD ?= ""
-
-IMAGE_CMD_rpi-sdimg () {
-
- # Align partitions
- BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
- BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
- SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE)
-
- echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $ROOTFS_SIZE KiB"
-
- # Check if we are building with device tree support
- DTS="${@get_dts(d)}"
-
- # Initialize sdcard image file
- dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE}
-
- # Create partition table
- parted -s ${SDIMG} mklabel msdos
- # Create boot partition and mark it as bootable
- parted -s ${SDIMG} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT})
- parted -s ${SDIMG} set 1 boot on
- # Create rootfs partition to the end of disk
- parted -s ${SDIMG} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s
- parted ${SDIMG} print
-
- # Create a vfat image with boot files
- BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
- rm -f ${WORKDIR}/boot.img
- mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
- mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/
- if test -n "${DTS}"; then
- # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' (4.1.x) or by '.dtbo' (4.4.9+) string and will be put in a dedicated folder
- DT_OVERLAYS="${@split_overlays(d, 0)}"
- DT_ROOT="${@split_overlays(d, 1)}"
-
- # Copy board device trees to root folder
- for DTB in ${DT_ROOT}; do
- DTB_BASE_NAME=`basename ${DTB} .dtb`
-
- mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb
- done
-
- # Copy device tree overlays to dedicated folder
- mmd -i ${WORKDIR}/boot.img overlays
- for DTB in ${DT_OVERLAYS}; do
- DTB_EXT=${DTB##*.}
- DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
-
- mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.${DTB_EXT} ::overlays/${DTB_BASE_NAME}.${DTB_EXT}
- done
- fi
- case "${KERNEL_IMAGETYPE}" in
- "uImage")
- mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_KERNELIMAGE}
- mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::uImage
- mcopy -o -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::boot.scr
- ;;
- *)
- mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${SDIMG_KERNELIMAGE}
- ;;
- esac
-
- if [ -n ${FATPAYLOAD} ] ; then
- echo "Copying payload into VFAT"
- for entry in ${FATPAYLOAD} ; do
- # add the || true to stop aborting on vfat issues like not supporting .~lock files
- mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true
- done
- fi
-
- # Add stamp file
- echo "${IMAGE_NAME}" > ${WORKDIR}/image-version-info
- mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}/image-version-info ::
-
- # Burn Partitions
- dd if=${WORKDIR}/boot.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
- # If SDIMG_ROOTFS_TYPE is a .xz file use xzcat
- if echo "${SDIMG_ROOTFS_TYPE}" | egrep -q "*\.xz"
- then
- xzcat ${SDIMG_ROOTFS} | dd of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
- else
- dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
- fi
-
- # Optionally apply compression
- case "${SDIMG_COMPRESSION}" in
- "gzip")
- gzip -k9 "${SDIMG}"
- ;;
- "bzip2")
- bzip2 -k9 "${SDIMG}"
- ;;
- "xz")
- xz -k "${SDIMG}"
- ;;
- esac
-}
-
-ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; "
-
-rpi_generate_sysctl_config() {
- # systemd sysctl config
- test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \
- echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf
-
- # sysv sysctl config
- IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf"
- test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \
- sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF}
- echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF}
-}
diff --git a/meta-agl-bsp/classes/sdcard_image-socfpga.bbclass b/meta-agl-bsp/classes/sdcard_image-socfpga.bbclass
new file mode 100644
index 000000000..e1f7b1846
--- /dev/null
+++ b/meta-agl-bsp/classes/sdcard_image-socfpga.bbclass
@@ -0,0 +1,181 @@
+inherit image_types
+
+# Create an sdcard image suitable for the atlas board
+# This is copied from the raspberrypi and freescale sdcard classes
+
+# Disk layout
+# 0 -> 8*1024 - reserverd
+# 8*1024 -> 32*1024 -
+# 32*1024 -> 1024*1024 -
+# 1024*1024 -> BOOT_SPACE - bootloader and kernel in Part 3
+# BOOT_SPACE*1024 -> FAT_SPACE
+
+
+
+# This image depends on the rootfs image
+IMAGE_TYPEDEP_socfpga-sdimg = "${SDIMG_ROOTFS_TYPE}"
+
+# Boot partition volume id
+BOOTDD_VOLUME_ID ?= "${MACHINE}"
+
+# Boot partition size [in KiB] -> size 2M for A10
+BOOT_SPACE ?= "2048"
+
+# Fat partition size
+FAT_SPACE ?= "102400"
+
+# uBoot ENV offset
+SDIMG_UBOOT_ENV_OFFSET ?= "512"
+ENV_BASE_NAME ??= "${UBOOT_CONFIG}"
+
+# Boot partition begin at sector 1024
+# This is required as for c5/a5 mainline uboot hard codes the location
+# of the uboot image in the sdcard to 0xa00 sector
+IMAGE_ROOTFS_ALIGNMENT = "1024"
+
+# ROOTFS_SIZE_MOD ?= "524288"
+ROOTFS_SIZE_MOD ?= "16384"
+
+# Use an uncompressed ext3 by default as rootfs
+SDIMG_ROOTFS_TYPE = "ext3"
+SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.${SDIMG_ROOTFS_TYPE}"
+
+
+do_image_socfpga-sdimg[depends] += " \
+ parted-native:do_populate_sysroot \
+ mtools-native:do_populate_sysroot \
+ dosfstools-native:do_populate_sysroot \
+ virtual/kernel:do_deploy \
+ virtual/bootloader:do_deploy \
+ "
+
+rootfs[depends] += "virtual/kernel:do_deploy"
+
+# SD card image name
+SDIMG = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.socfpga-sdimg"
+
+IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}"
+
+# After uboot v2016.05 the boot partition number was changed from 3 to 1 so as a
+# result we need 2 different functions for creating the boot partitions just to
+# change the partition creation order
+
+SOCFPGA_SDIMG_PARTITION_COMMAND ?= "generate_sdcard_partitions"
+
+generate_sdcard_partitions () {
+
+ # Create partition table
+ parted -s ${SDIMG} mklabel msdos
+ # P1: Fat partition
+ parted -s ${SDIMG} unit KiB mkpart primary fat32 $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ ${FAT_SPACE_ALIGNED})
+ # set fat partition as bootable for distroboot
+ parted -s ${SDIMG} set 1 boot on
+ # P2: Linux FS partition
+ parted -s ${SDIMG} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ ${FAT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ ${FAT_SPACE_ALIGNED} \+ ${ROOTFS_SIZE_ALIGNED})
+ # P3: A2 partition for bootloader
+ parted -s ${SDIMG} unit KiB mkpart primary ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT})
+
+ # set part 3 to type a2 for spl / uboot image
+ # 446 to partition table, 16 bytes per entry, 4 byte offset to partition type
+ echo -ne "\xa2" | dd of=${SDIMG} bs=1 count=1 seek=$(expr 446 + 16 + 16 + 4) conv=notrunc && sync && sync
+
+ # Create a vfat image with boot files
+ FAT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
+ rm -f ${WORKDIR}/fat.img
+ mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/fat.img $FAT_BLOCKS
+
+}
+
+IMAGE_CMD_socfpga-sdimg () {
+
+ # Align partitions
+ BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
+ BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
+ FAT_SPACE_ALIGNED=$(expr ${FAT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
+ FAT_SPACE_ALIGNED=$(expr ${FAT_SPACE_ALIGNED} - ${FAT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
+
+ ROOTFS_SIZE_ALIGNED=$(expr ${ROOTFS_SIZE} \+ ${ROOTFS_SIZE_MOD})
+ ROOTFS_SIZE_ALIGNED=$(expr ${ROOTFS_SIZE_ALIGNED} \- ${ROOTFS_SIZE_ALIGNED} \% ${ROOTFS_SIZE_MOD})
+
+ SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + ${FAT_SPACE_ALIGNED} + ${ROOTFS_SIZE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT})
+
+ # Initialize sdcard image file
+ dd if=/dev/zero of=${SDIMG} bs=1 count=0 seek=$(expr 1024 \* ${SDIMG_SIZE}) && sync && sync
+
+ # Create partition table
+ ${SOCFPGA_SDIMG_PARTITION_COMMAND}
+
+ # Copy kernel image
+ mcopy -i ${WORKDIR}/fat.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
+
+ # Copy boot scripts
+ if [ -e "${DEPLOY_DIR_IMAGE}/${MACHINE}.scr" ]
+ then
+ mcopy -i ${WORKDIR}/fat.img -s ${DEPLOY_DIR_IMAGE}/${MACHINE}.scr ::/u-boot.scr
+ fi
+
+ # Copy device tree file
+ if test -n "${KERNEL_DEVICETREE}"; then
+ for DTS_FILE in ${KERNEL_DEVICETREE}; do
+ DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
+ if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then
+ kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
+ kernel_bin_for_dtb="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`"
+ if [ $kernel_bin = $kernel_bin_for_dtb ]; then
+ mcopy -i ${WORKDIR}/fat.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb
+ fi
+ fi
+ done
+ fi
+
+ # copy extlinux stuff
+ if [ "${UBOOT_EXTLINUX}" = "1" ]
+ then
+ if [ -e "${DEPLOY_DIR_IMAGE}/extlinux.conf" ]
+ then
+ rm -Rf ${WORKDIR}/extlinux
+ mkdir ${WORKDIR}/extlinux
+ cp ${DEPLOY_DIR_IMAGE}/extlinux.conf ${WORKDIR}/extlinux/
+ mcopy -i ${WORKDIR}/fat.img -s ${WORKDIR}/extlinux ::/
+ fi
+
+ fi
+
+ # copy any files listed as extra files
+ if test -n "${SOCFPGA_SDIMG_EXTRA_FILES}"; then
+ for EXTRA_FILE in ${SOCFPGA_SDIMG_EXTRA_FILES}; do
+ if [ -e "${DEPLOY_DIR_IMAGE}/${EXTRA_FILE}" ]; then
+ mcopy -i ${WORKDIR}/fat.img -s ${DEPLOY_DIR_IMAGE}/${EXTRA_FILE} ::/${EXTRA_FILE}
+ fi
+ done
+ fi
+
+ # Add stamp file
+ echo "${IMAGE_NAME}-${IMAGEDATESTAMP}" > ${WORKDIR}/image-version-info
+ mcopy -i ${WORKDIR}/fat.img -v ${WORKDIR}//image-version-info ::
+
+ # Burn Partitions
+ dd if=${WORKDIR}/fat.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+ # If SDIMG_ROOTFS_TYPE is a .xz file use xzcat
+ if echo "${SDIMG_ROOTFS_TYPE}" | egrep -q "*\.xz"
+ then
+ xzcat ${SDIMG_ROOTFS} | dd of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + 1024 \* ${FAT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+ else
+ dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + 1024 \* ${FAT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+ fi
+
+ if [ -e "${DEPLOY_DIR_IMAGE}/${SPL_BINARY}-${UBOOT_CONFIG}" ]
+ then
+ dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY}-${UBOOT_CONFIG} of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+ elif [ -e "${DEPLOY_DIR_IMAGE}/${SPL_BINARY}" ]
+ then
+ dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+ else
+ bbfatal "${SPL_BINARY} does not exist."
+ fi
+
+ if [ -e "${DEPLOY_DIR_IMAGE}/u-boot-env-${ENV_BASE_NAME}.bin" ]; then
+ dd if=${DEPLOY_DIR_IMAGE}/u-boot-env-${ENV_BASE_NAME}.bin of=${SDIMG} conv=notrunc bs=1 seek=${SDIMG_UBOOT_ENV_OFFSET} && sync && sync
+ fi
+
+}