summaryrefslogtreecommitdiffstats
path: root/meta-phosphor
diff options
context:
space:
mode:
authorAlexander Filippov <a.filippov@yadro.com>2018-07-17 16:41:37 +0300
committerJoel Stanley <joel@jms.id.au>2018-07-25 11:02:54 +0930
commit3dcf6f9c47ab70b73c55da788b297772263b7fab (patch)
tree51ff2ff9a6efaf41a40dd5e9103b7e7fc7421225 /meta-phosphor
parent1c054b8e6ab4f4aff37d0d69141856f251a7e1cd (diff)
downloadtalos-openbmc-3dcf6f9c47ab70b73c55da788b297772263b7fab.tar.gz
talos-openbmc-3dcf6f9c47ab70b73c55da788b297772263b7fab.zip
Check size of the firmware image parts
Prevent building unbootable firmware images. Resolves: openbmc/openbmc#3314 Tested: I checked builds for `palmetto` and `romulus`. To reproduce the problem I appended a big file to initramfs by modify `meta-phosphor/common/recipes-phosphor/initfs/obmc-phosphor-initfs.bb`. The building process failed with message about too large initramfs image. Change-Id: I0176e9c47a9cb26ce8ba588794e681b6426d567d Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
Diffstat (limited to 'meta-phosphor')
-rw-r--r--meta-phosphor/classes/image_types_phosphor.bbclass56
1 files changed, 43 insertions, 13 deletions
diff --git a/meta-phosphor/classes/image_types_phosphor.bbclass b/meta-phosphor/classes/image_types_phosphor.bbclass
index 19422fc05..243739010 100644
--- a/meta-phosphor/classes/image_types_phosphor.bbclass
+++ b/meta-phosphor/classes/image_types_phosphor.bbclass
@@ -183,24 +183,54 @@ do_make_ubi[depends] += " \
mtd-utils-native:do_populate_sysroot \
"
-do_generate_static() {
+do_mk_static_nor_image() {
# Assemble the flash image
mk_nor_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd ${FLASH_SIZE}
- dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
- if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
- of=${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd
+}
+
+python do_generate_static() {
+ import subprocess
+
+ bb.build.exec_func("do_mk_static_nor_image", d)
+
+ nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True),
+ '%s.static.mtd' % d.getVar('IMAGE_NAME', True))
- dd bs=1k conv=notrunc seek=${FLASH_KERNEL_OFFSET} \
- if=${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} \
- of=${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd
+ def _append_image(imgpath, start_kb, finish_kb):
+ imgsize = os.path.getsize(imgpath)
+ if imgsize > (finish_kb - start_kb) * 1024:
+ bb.fatal("Image '%s' is too large!" % imgpath)
- dd bs=1k conv=notrunc seek=${FLASH_ROFS_OFFSET} \
- if=${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMAGE_BASETYPE} \
- of=${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd
+ subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc',
+ 'seek=%d' % start_kb,
+ 'if=%s' % imgpath,
+ 'of=%s' % nor_image])
+
+ _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
+ 'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
+ int(d.getVar('FLASH_UBOOT_OFFSET', True)),
+ int(d.getVar('FLASH_KERNEL_OFFSET', True)))
+
+ _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
+ d.getVar('FLASH_KERNEL_IMAGE', True)),
+ int(d.getVar('FLASH_KERNEL_OFFSET', True)),
+ int(d.getVar('FLASH_ROFS_OFFSET', True)))
+
+ _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True),
+ '%s.%s' % (
+ d.getVar('IMAGE_LINK_NAME', True),
+ d.getVar('IMAGE_BASETYPE', True))),
+ int(d.getVar('FLASH_ROFS_OFFSET', True)),
+ int(d.getVar('FLASH_RWFS_OFFSET', True)))
+
+ _append_image('rwfs.%s' % d.getVar('OVERLAY_BASETYPE', True),
+ int(d.getVar('FLASH_RWFS_OFFSET', True)),
+ int(d.getVar('FLASH_SIZE', True)))
+
+ bb.build.exec_func("do_mk_static_symlinks", d)
+}
- dd bs=1k conv=notrunc seek=${FLASH_RWFS_OFFSET} \
- if=rwfs.${OVERLAY_BASETYPE} \
- of=${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd
+do_mk_static_symlinks() {
# File needed for generating non-standard legacy links below
cp rwfs.${OVERLAY_BASETYPE} ${IMGDEPLOYDIR}/rwfs.${OVERLAY_BASETYPE}
OpenPOWER on IntegriCloud