blob: 1edf3a3be668b8cd0b2766a105a05d43f6e5a663 [file] [log] [blame]
Brad Bishop97cce002017-07-22 14:49:25 -04001# Base image class extension, inlined into every image.
2
Saqib Khan41723472017-09-22 10:21:30 -05003inherit image_version
Brad Bishop97cce002017-07-22 14:49:25 -04004
Brad Bishop19fc4f82017-08-04 23:38:54 -04005# Phosphor image types
6#
Brad Bishop3aa1ef62017-08-04 23:48:12 -04007# Phosphor OpenBMC supports a fixed partition mtd layout,
8# A dynamic mtd with ubi layout, and a tar file for use with
9# The reference BMC software update implementation.
Brad Bishop19fc4f82017-08-04 23:38:54 -040010
11# Image composition
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012FLASH_KERNEL_IMAGE ?= "fitImage-${INITRAMFS_IMAGE}-${MACHINE}-${MACHINE}"
Brad Bishop8623bbe2018-03-09 00:04:00 -050013FLASH_KERNEL_IMAGE_df-obmc-ubi-fs ?= "fitImage-${MACHINE}.bin"
14
Brad Bishop19fc4f82017-08-04 23:38:54 -040015IMAGE_BASETYPE ?= "squashfs-xz"
16OVERLAY_BASETYPE ?= "jffs2"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040017FLASH_UBI_BASETYPE ?= "${IMAGE_BASETYPE}"
18FLASH_UBI_OVERLAY_BASETYPE ?= "ubifs"
Brad Bishop19fc4f82017-08-04 23:38:54 -040019
Brad Bishop02ee6ae2018-03-30 08:43:23 -040020IMAGE_TYPES += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar"
Brad Bishop19fc4f82017-08-04 23:38:54 -040021
22IMAGE_TYPEDEP_mtd-static = "${IMAGE_BASETYPE}"
23IMAGE_TYPEDEP_mtd-static-tar = "${IMAGE_BASETYPE}"
24IMAGE_TYPEDEP_mtd-static-alltar = "mtd-static"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040025IMAGE_TYPEDEP_mtd-ubi = "${FLASH_UBI_BASETYPE}"
26IMAGE_TYPEDEP_mtd-ubi-tar = "${FLASH_UBI_BASETYPE}"
Brad Bishop02ee6ae2018-03-30 08:43:23 -040027IMAGE_TYPES_MASKED += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar"
Brad Bishop19fc4f82017-08-04 23:38:54 -040028
Brad Bishop3aa1ef62017-08-04 23:48:12 -040029# Flash characteristics in KB unless otherwise noted
Brad Bishop19fc4f82017-08-04 23:38:54 -040030FLASH_SIZE ?= "32768"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040031FLASH_PEB_SIZE ?= "64"
32# Flash page and overhead sizes in bytes
33FLASH_PAGE_SIZE ?= "1"
34FLASH_NOR_UBI_OVERHEAD ?= "64"
Brad Bishop19fc4f82017-08-04 23:38:54 -040035
36# Fixed partition offsets
37FLASH_UBOOT_OFFSET ?= "0"
38FLASH_KERNEL_OFFSET ?= "512"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040039FLASH_UBI_OFFSET ?= "${FLASH_KERNEL_OFFSET}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040040FLASH_ROFS_OFFSET ?= "4864"
41FLASH_RWFS_OFFSET ?= "28672"
42
Brad Bishop3aa1ef62017-08-04 23:48:12 -040043# UBI volume sizes in KB unless otherwise noted.
Adriana Kobylakb70005d2018-02-14 16:35:30 -060044FLASH_UBI_RWFS_SIZE ?= "6144"
45FLASH_UBI_RWFS_TXT_SIZE ?= "6MiB"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040046
Eddie Jamesb2b7ff62018-02-09 11:59:18 -060047SIGNING_KEY ?= "${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv"
48INSECURE_KEY = "${@'${SIGNING_KEY}' == '${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv'}"
49SIGNING_KEY_DEPENDS = "${@oe.utils.conditional('INSECURE_KEY', 'True', 'phosphor-insecure-signing-key-native:do_populate_sysroot', '', d)}"
50
Brad Bishop3e37d382018-03-31 12:17:28 -040051UBOOT_SUFFIX ?= "bin"
52
Brad Bishop3aa1ef62017-08-04 23:48:12 -040053python() {
54 # Compute rwfs LEB count and LEB size.
55 page_size = d.getVar('FLASH_PAGE_SIZE', True)
56 nor_overhead_size = d.getVar('FLASH_NOR_UBI_OVERHEAD', True)
57 overhead_size = max(int(page_size), int(nor_overhead_size))
58 peb_size = d.getVar('FLASH_PEB_SIZE', True)
59 leb_size = (int(peb_size) * 1024) - (2 * overhead_size)
60 d.setVar('FLASH_LEB_SIZE', str(leb_size)) # In bytes
61
62 rwfs_size = d.getVar('FLASH_UBI_RWFS_SIZE', True)
63 rwfs_size = int(rwfs_size) * 1024
64 lebs = int((rwfs_size + leb_size - 1) / leb_size) # Rounding up
65 d.setVar('FLASH_UBI_RWFS_LEBS', str(lebs))
66}
67
Brad Bishop19fc4f82017-08-04 23:38:54 -040068# Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However,
69# avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are
70# reserved for the primary image (and setting them currently breaks the build).
71# Instead, prefix the overlay override value with 'rwfs-' to avoid collisions.
72DISTROOVERRIDES .= ":static-rwfs-${OVERLAY_BASETYPE}"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040073DISTROOVERRIDES .= ":ubi-rwfs-${FLASH_UBI_OVERLAY_BASETYPE}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040074
75JFFS2_RWFS_CMD = "mkfs.jffs2 --root=jffs2 --faketime --output=rwfs.jffs2"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040076UBIFS_RWFS_CMD = "mkfs.ubifs -r ubifs -c ${FLASH_UBI_RWFS_LEBS} -m ${FLASH_PAGE_SIZE} -e ${FLASH_LEB_SIZE} rwfs.ubifs"
Brad Bishop19fc4f82017-08-04 23:38:54 -040077
78FLASH_STATIC_RWFS_CMD_static-rwfs-jffs2 = "${JFFS2_RWFS_CMD}"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040079FLASH_UBI_RWFS_CMD_ubi-rwfs-jffs2 = "${JFFS2_RWFS_CMD}"
80FLASH_UBI_RWFS_CMD_ubi-rwfs-ubifs = "${UBIFS_RWFS_CMD}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040081
82mk_nor_image() {
83 image_dst="$1"
84 image_size_kb=$2
85 dd if=/dev/zero bs=1k count=$image_size_kb \
86 | tr '\000' '\377' > $image_dst
87}
88
89make_rwfs() {
90 type=$1
91 cmd=$2
92 shift
93 shift
94 opts="$@"
95
96 rm -f rwfs.$type
97 rm -rf $type
98 mkdir $type
99
100 $cmd $opts
101}
102
103do_generate_rwfs_static() {
104 make_rwfs ${OVERLAY_BASETYPE} "${FLASH_STATIC_RWFS_CMD}" ${OVERLAY_MKFS_OPTS}
105}
106do_generate_rwfs_static[dirs] = " ${S}/static"
107do_generate_rwfs_static[depends] += " \
108 mtd-utils-native:do_populate_sysroot \
109 "
110
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400111do_generate_rwfs_ubi() {
112 make_rwfs ${FLASH_UBI_OVERLAY_BASETYPE} "${FLASH_UBI_RWFS_CMD}"
113}
114do_generate_rwfs_ubi[dirs] = " ${S}/ubi"
115do_generate_rwfs_ubi[depends] += " \
116 mtd-utils-native:do_populate_sysroot \
117 "
118
119add_volume() {
120 config_file=$1
121 vol_id=$2
122 vol_type=$3
123 vol_name=$4
124 image=$5
125 vol_size=$6
126
127 echo \[$vol_name\] >> $config_file
128 echo mode=ubi >> $config_file
129 echo image=$image >> $config_file
130 echo vol_type=$vol_type >> $config_file
131 echo vol_name=$vol_name >> $config_file
132 echo vol_id=$vol_id >> $config_file
133 if [ ! -z $vol_size ]; then
134 echo vol_size=$vol_size >> $config_file
135 fi
136}
137
Saqib Khan41723472017-09-22 10:21:30 -0500138python do_generate_ubi() {
139 version_id = do_get_versionID(d)
140 d.setVar('VERSION_ID', version_id)
141 bb.build.exec_func("do_make_ubi", d)
142}
143do_generate_ubi[dirs] = "${S}/ubi"
144do_generate_ubi[depends] += " \
145 ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
146 virtual/kernel:do_deploy \
147 u-boot:do_populate_sysroot \
148 mtd-utils-native:do_populate_sysroot \
149 "
150
151do_make_ubi() {
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400152 cfg=ubinize-${IMAGE_NAME}.cfg
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400153 rm -f $cfg ubi-img
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400154 # Construct the ubinize config file
Saqib Khan41723472017-09-22 10:21:30 -0500155 add_volume $cfg 0 static kernel-${VERSION_ID} \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400156 ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE}
157
Saqib Khan41723472017-09-22 10:21:30 -0500158 add_volume $cfg 1 static rofs-${VERSION_ID} \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400159 ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_BASETYPE}
160
161 add_volume $cfg 2 dynamic rwfs rwfs.${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_RWFS_TXT_SIZE}
162
163 # Build the ubi partition image
164 ubinize -p ${FLASH_PEB_SIZE}KiB -m ${FLASH_PAGE_SIZE} -o ubi-img $cfg
165
166 # Concatenate the uboot and ubi partitions
167 mk_nor_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd ${FLASH_SIZE}
168 dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
169 if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
170 of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
171 dd bs=1k conv=notrunc seek=${FLASH_UBI_OFFSET} \
172 if=ubi-img \
173 of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
174
175 cd ${IMGDEPLOYDIR}
176 ln -sf ${IMAGE_NAME}.ubi.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubi.mtd
177}
Saqib Khan41723472017-09-22 10:21:30 -0500178do_make_ubi[dirs] = "${S}/ubi"
179do_make_ubi[depends] += " \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400180 ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
181 virtual/kernel:do_deploy \
182 u-boot:do_populate_sysroot \
183 mtd-utils-native:do_populate_sysroot \
184 "
185
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300186do_mk_static_nor_image() {
Brad Bishop19fc4f82017-08-04 23:38:54 -0400187 # Assemble the flash image
188 mk_nor_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd ${FLASH_SIZE}
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300189}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400190
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300191python do_generate_static() {
192 import subprocess
Brad Bishop19fc4f82017-08-04 23:38:54 -0400193
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300194 bb.build.exec_func("do_mk_static_nor_image", d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400195
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300196 nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True),
197 '%s.static.mtd' % d.getVar('IMAGE_NAME', True))
198
199 def _append_image(imgpath, start_kb, finish_kb):
200 imgsize = os.path.getsize(imgpath)
201 if imgsize > (finish_kb - start_kb) * 1024:
202 bb.fatal("Image '%s' is too large!" % imgpath)
203
204 subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc',
205 'seek=%d' % start_kb,
206 'if=%s' % imgpath,
207 'of=%s' % nor_image])
208
209 _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
210 'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
211 int(d.getVar('FLASH_UBOOT_OFFSET', True)),
212 int(d.getVar('FLASH_KERNEL_OFFSET', True)))
213
214 _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
215 d.getVar('FLASH_KERNEL_IMAGE', True)),
216 int(d.getVar('FLASH_KERNEL_OFFSET', True)),
217 int(d.getVar('FLASH_ROFS_OFFSET', True)))
218
219 _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True),
220 '%s.%s' % (
221 d.getVar('IMAGE_LINK_NAME', True),
222 d.getVar('IMAGE_BASETYPE', True))),
223 int(d.getVar('FLASH_ROFS_OFFSET', True)),
224 int(d.getVar('FLASH_RWFS_OFFSET', True)))
225
226 _append_image('rwfs.%s' % d.getVar('OVERLAY_BASETYPE', True),
227 int(d.getVar('FLASH_RWFS_OFFSET', True)),
228 int(d.getVar('FLASH_SIZE', True)))
229
230 bb.build.exec_func("do_mk_static_symlinks", d)
231}
232
233do_mk_static_symlinks() {
Brad Bishop19fc4f82017-08-04 23:38:54 -0400234 # File needed for generating non-standard legacy links below
235 cp rwfs.${OVERLAY_BASETYPE} ${IMGDEPLOYDIR}/rwfs.${OVERLAY_BASETYPE}
236
237 cd ${IMGDEPLOYDIR}
238 ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd
239
240 # Maintain non-standard legacy links
241 ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/flash-${MACHINE}
242 ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/image-bmc
243 ln -sf u-boot.${UBOOT_SUFFIX} ${IMGDEPLOYDIR}/image-u-boot
244 ln -sf ${FLASH_KERNEL_IMAGE} ${IMGDEPLOYDIR}/image-kernel
245 ln -sf ${IMAGE_LINK_NAME}.${IMAGE_BASETYPE} ${IMGDEPLOYDIR}/image-rofs
246 ln -sf rwfs.${OVERLAY_BASETYPE} ${IMGDEPLOYDIR}/image-rwfs
247}
248do_generate_static[dirs] = "${S}/static"
249do_generate_static[depends] += " \
250 ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
251 virtual/kernel:do_deploy \
252 u-boot:do_populate_sysroot \
253 "
254
Lei YUf2072212018-06-20 13:27:34 +0800255make_signatures() {
256 signature_files=""
257 for file in "$@"; do
258 openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file
259 signature_files="${signature_files} ${file}.sig"
260 done
261}
262
Brad Bishop19fc4f82017-08-04 23:38:54 -0400263do_generate_static_alltar() {
Lei YUa4674942018-05-23 14:01:14 +0800264 ln -sf ${S}/MANIFEST MANIFEST
265 ln -sf ${S}/publickey publickey
Brad Bishop19fc4f82017-08-04 23:38:54 -0400266 ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd image-bmc
Lei YUa4674942018-05-23 14:01:14 +0800267
Lei YUf2072212018-06-20 13:27:34 +0800268 make_signatures image-bmc MANIFEST publickey
Lei YUa4674942018-05-23 14:01:14 +0800269
270 tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd.all.tar \
271 image-bmc MANIFEST publickey ${signature_files}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400272
273 cd ${IMGDEPLOYDIR}
274
275 ln -sf ${IMAGE_NAME}.static.mtd.all.tar \
276 ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd.all.tar
277
278 # Maintain non-standard legacy link.
279 ln -sf ${IMAGE_NAME}.static.mtd.all.tar \
280 ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.all.tar
Lei YUa4674942018-05-23 14:01:14 +0800281
Brad Bishop19fc4f82017-08-04 23:38:54 -0400282}
283do_generate_static_alltar[vardepsexclude] = "DATETIME"
284do_generate_static_alltar[dirs] = "${S}/static"
Lei YUa4674942018-05-23 14:01:14 +0800285do_generate_static_alltar[depends] += " \
286 openssl-native:do_populate_sysroot \
287 ${SIGNING_KEY_DEPENDS} \
288 ${PN}:do_copy_signing_pubkey \
289 "
Brad Bishop19fc4f82017-08-04 23:38:54 -0400290
Brad Bishopde659382018-03-30 01:46:16 -0400291make_image_links() {
Brad Bishop19fc4f82017-08-04 23:38:54 -0400292 rwfs=$1
293 rofs=$2
Brad Bishop19fc4f82017-08-04 23:38:54 -0400294 shift
295 shift
Brad Bishop19fc4f82017-08-04 23:38:54 -0400296
Brad Bishopde659382018-03-30 01:46:16 -0400297 # Create some links to help make the tar archive in the format
298 # expected by phosphor-bmc-code-mgmt.
Brad Bishop19fc4f82017-08-04 23:38:54 -0400299 ln -sf ${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} image-u-boot
300 ln -sf ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} image-kernel
301 ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rofs image-rofs
302 ln -sf rwfs.$rwfs image-rwfs
Brad Bishopde659382018-03-30 01:46:16 -0400303}
304
305make_tar_of_images() {
306 type=$1
307 shift
308 extra_files="$@"
Brad Bishop19fc4f82017-08-04 23:38:54 -0400309
310 # Create the tar archive
311 tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type.mtd.tar \
312 image-u-boot image-kernel image-rofs image-rwfs $extra_files
313
314 cd ${IMGDEPLOYDIR}
315 ln -sf ${IMAGE_NAME}.$type.mtd.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.mtd.tar
316}
317
318do_generate_static_tar() {
Lei YUa4674942018-05-23 14:01:14 +0800319 ln -sf ${S}/MANIFEST MANIFEST
320 ln -sf ${S}/publickey publickey
Brad Bishopde659382018-03-30 01:46:16 -0400321 make_image_links ${OVERLAY_BASETYPE} ${IMAGE_BASETYPE}
Lei YUf2072212018-06-20 13:27:34 +0800322 make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
Lei YUa4674942018-05-23 14:01:14 +0800323 make_tar_of_images static MANIFEST publickey ${signature_files}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400324
325 # Maintain non-standard legacy link.
326 cd ${IMGDEPLOYDIR}
327 ln -sf ${IMAGE_NAME}.static.mtd.tar ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.tar
328}
329do_generate_static_tar[dirs] = " ${S}/static"
330do_generate_static_tar[depends] += " \
331 ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
332 virtual/kernel:do_deploy \
333 u-boot:do_populate_sysroot \
Lei YUa4674942018-05-23 14:01:14 +0800334 openssl-native:do_populate_sysroot \
335 ${SIGNING_KEY_DEPENDS} \
336 ${PN}:do_copy_signing_pubkey \
Brad Bishop19fc4f82017-08-04 23:38:54 -0400337 "
338do_generate_static_tar[vardepsexclude] = "DATETIME"
339
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400340do_generate_ubi_tar() {
341 ln -sf ${S}/MANIFEST MANIFEST
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600342 ln -sf ${S}/publickey publickey
Brad Bishopde659382018-03-30 01:46:16 -0400343 make_image_links ${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_BASETYPE}
Lei YUf2072212018-06-20 13:27:34 +0800344 make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
345 make_tar_of_images ubi MANIFEST publickey ${signature_files}
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400346}
347do_generate_ubi_tar[dirs] = " ${S}/ubi"
348do_generate_ubi_tar[depends] += " \
349 ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
350 virtual/kernel:do_deploy \
351 u-boot:do_populate_sysroot \
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600352 openssl-native:do_populate_sysroot \
353 ${SIGNING_KEY_DEPENDS} \
354 ${PN}:do_copy_signing_pubkey \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400355 "
356
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600357def get_pubkey_basedir(d):
358 return os.path.join(
359 d.getVar('STAGING_DIR_TARGET', True),
360 d.getVar('sysconfdir', True).strip(os.sep),
361 'activationdata')
362
363def get_pubkey_type(d):
364 return os.listdir(get_pubkey_basedir(d))[0]
365
366def get_pubkey_path(d):
367 return os.path.join(
368 get_pubkey_basedir(d),
369 get_pubkey_type(d),
370 'publickey')
371
Brad Bishop19fc4f82017-08-04 23:38:54 -0400372python do_generate_phosphor_manifest() {
Saqib Khan41723472017-09-22 10:21:30 -0500373 version = do_get_version(d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400374 with open('MANIFEST', 'w') as fd:
375 fd.write('purpose=xyz.openbmc_project.Software.Version.VersionPurpose.BMC\n')
376 fd.write('version={}\n'.format(version.strip('"')))
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600377 fd.write('KeyType={}\n'.format(get_pubkey_type(d)))
378 fd.write('HashType=RSA-SHA256\n')
Brad Bishop19fc4f82017-08-04 23:38:54 -0400379}
380do_generate_phosphor_manifest[dirs] = "${S}"
381do_generate_phosphor_manifest[depends] += " \
382 os-release:do_populate_sysroot \
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600383 phosphor-image-signing:do_populate_sysroot \
Brad Bishop19fc4f82017-08-04 23:38:54 -0400384 "
385
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600386python do_copy_signing_pubkey() {
387 with open(get_pubkey_path(d), 'r') as read_fd:
388 with open('publickey', 'w') as write_fd:
389 write_fd.write(read_fd.read())
390}
391
392do_copy_signing_pubkey[dirs] = "${S}"
393do_copy_signing_pubkey[depends] += " \
394 phosphor-image-signing:do_populate_sysroot \
395 "
396
397addtask copy_signing_pubkey after do_rootfs
Brad Bishop19fc4f82017-08-04 23:38:54 -0400398addtask generate_phosphor_manifest after do_rootfs
399addtask generate_rwfs_static after do_rootfs
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400400addtask generate_rwfs_ubi after do_rootfs
Brad Bishop19fc4f82017-08-04 23:38:54 -0400401
402python() {
403 types = d.getVar('IMAGE_FSTYPES', True).split()
404
405 if any([x in types for x in ['mtd-static', 'mtd-static-alltar']]):
406 bb.build.addtask(
407 'do_generate_static',
408 'do_image_complete',
409 'do_generate_rwfs_static', d)
410 if 'mtd-static-alltar' in types:
411 bb.build.addtask(
412 'do_generate_static_alltar',
413 'do_image_complete',
Lei YUa4674942018-05-23 14:01:14 +0800414 'do_generate_static do_generate_phosphor_manifest', d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400415 if 'mtd-static-tar' in types:
416 bb.build.addtask(
417 'do_generate_static_tar',
418 'do_image_complete',
Lei YUa4674942018-05-23 14:01:14 +0800419 'do_generate_rwfs_static do_generate_phosphor_manifest', d)
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400420
421 if 'mtd-ubi' in types:
422 bb.build.addtask(
423 'do_generate_ubi',
424 'do_image_complete',
425 'do_generate_rwfs_ubi', d)
426 if 'mtd-ubi-tar' in types:
427 bb.build.addtask(
428 'do_generate_ubi_tar',
429 'do_image_complete',
430 'do_generate_rwfs_ubi do_generate_phosphor_manifest', d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400431}