blob: dea8c3c1257b196b8d4bb80e9de7a80d44594bcc [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 Bishopdcd861c2019-09-24 21:16:09 -040030DISTROOVERRIDES .= ":flash-${FLASH_SIZE}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040031FLASH_SIZE ?= "32768"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040032FLASH_PEB_SIZE ?= "64"
33# Flash page and overhead sizes in bytes
34FLASH_PAGE_SIZE ?= "1"
35FLASH_NOR_UBI_OVERHEAD ?= "64"
Brad Bishop19fc4f82017-08-04 23:38:54 -040036
37# Fixed partition offsets
38FLASH_UBOOT_OFFSET ?= "0"
39FLASH_KERNEL_OFFSET ?= "512"
Brad Bishopdcd861c2019-09-24 21:16:09 -040040FLASH_KERNEL_OFFSET_flash-131072 ?= "1024"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040041FLASH_UBI_OFFSET ?= "${FLASH_KERNEL_OFFSET}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040042FLASH_ROFS_OFFSET ?= "4864"
Brad Bishopdcd861c2019-09-24 21:16:09 -040043FLASH_ROFS_OFFSET_flash-131072 ?= "10240"
Brad Bishop19fc4f82017-08-04 23:38:54 -040044FLASH_RWFS_OFFSET ?= "28672"
Brad Bishopdcd861c2019-09-24 21:16:09 -040045FLASH_RWFS_OFFSET_flash-131072 ?= "98304"
Brad Bishop19fc4f82017-08-04 23:38:54 -040046
Brad Bishop3aa1ef62017-08-04 23:48:12 -040047# UBI volume sizes in KB unless otherwise noted.
Adriana Kobylakb70005d2018-02-14 16:35:30 -060048FLASH_UBI_RWFS_SIZE ?= "6144"
Brad Bishopdcd861c2019-09-24 21:16:09 -040049FLASH_UBI_RWFS_SIZE_flash-131072 ?= "32768"
Adriana Kobylakb70005d2018-02-14 16:35:30 -060050FLASH_UBI_RWFS_TXT_SIZE ?= "6MiB"
Brad Bishopdcd861c2019-09-24 21:16:09 -040051FLASH_UBI_RWFS_TXT_SIZE_flash-131072 ?= "32MiB"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040052
Eddie Jamesb2b7ff62018-02-09 11:59:18 -060053SIGNING_KEY ?= "${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv"
54INSECURE_KEY = "${@'${SIGNING_KEY}' == '${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv'}"
55SIGNING_KEY_DEPENDS = "${@oe.utils.conditional('INSECURE_KEY', 'True', 'phosphor-insecure-signing-key-native:do_populate_sysroot', '', d)}"
56
Brad Bishop3e37d382018-03-31 12:17:28 -040057UBOOT_SUFFIX ?= "bin"
58
Brad Bishop3aa1ef62017-08-04 23:48:12 -040059python() {
60 # Compute rwfs LEB count and LEB size.
61 page_size = d.getVar('FLASH_PAGE_SIZE', True)
62 nor_overhead_size = d.getVar('FLASH_NOR_UBI_OVERHEAD', True)
63 overhead_size = max(int(page_size), int(nor_overhead_size))
64 peb_size = d.getVar('FLASH_PEB_SIZE', True)
65 leb_size = (int(peb_size) * 1024) - (2 * overhead_size)
66 d.setVar('FLASH_LEB_SIZE', str(leb_size)) # In bytes
67
68 rwfs_size = d.getVar('FLASH_UBI_RWFS_SIZE', True)
69 rwfs_size = int(rwfs_size) * 1024
70 lebs = int((rwfs_size + leb_size - 1) / leb_size) # Rounding up
71 d.setVar('FLASH_UBI_RWFS_LEBS', str(lebs))
72}
73
Brad Bishop19fc4f82017-08-04 23:38:54 -040074# Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However,
75# avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are
76# reserved for the primary image (and setting them currently breaks the build).
77# Instead, prefix the overlay override value with 'rwfs-' to avoid collisions.
78DISTROOVERRIDES .= ":static-rwfs-${OVERLAY_BASETYPE}"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040079DISTROOVERRIDES .= ":ubi-rwfs-${FLASH_UBI_OVERLAY_BASETYPE}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040080
William A. Kennington IIIc230ab32019-09-16 17:44:48 -070081JFFS2_RWFS_CMD = "mkfs.jffs2 --root=jffs2 --faketime --output=${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.jffs2"
82UBIFS_RWFS_CMD = "mkfs.ubifs -r ubifs -c ${FLASH_UBI_RWFS_LEBS} -m ${FLASH_PAGE_SIZE} -e ${FLASH_LEB_SIZE} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubifs"
Brad Bishop19fc4f82017-08-04 23:38:54 -040083
84FLASH_STATIC_RWFS_CMD_static-rwfs-jffs2 = "${JFFS2_RWFS_CMD}"
Brad Bishop3aa1ef62017-08-04 23:48:12 -040085FLASH_UBI_RWFS_CMD_ubi-rwfs-jffs2 = "${JFFS2_RWFS_CMD}"
86FLASH_UBI_RWFS_CMD_ubi-rwfs-ubifs = "${UBIFS_RWFS_CMD}"
Brad Bishop19fc4f82017-08-04 23:38:54 -040087
Adriana Kobylak661cf392019-07-29 14:39:00 -050088mk_empty_image() {
Brad Bishop19fc4f82017-08-04 23:38:54 -040089 image_dst="$1"
90 image_size_kb=$2
91 dd if=/dev/zero bs=1k count=$image_size_kb \
92 | tr '\000' '\377' > $image_dst
93}
94
Adriana Kobylakf494bb52019-07-29 16:14:11 -050095clean_rwfs() {
96 type=$1
97 shift
98
99 rm -f ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type
100 rm -rf $type
101 mkdir $type
102}
103
Brad Bishop19fc4f82017-08-04 23:38:54 -0400104make_rwfs() {
105 type=$1
106 cmd=$2
107 shift
108 shift
109 opts="$@"
110
Adriana Kobylakf494bb52019-07-29 16:14:11 -0500111 mkdir -p $type
Brad Bishop19fc4f82017-08-04 23:38:54 -0400112
113 $cmd $opts
114}
115
116do_generate_rwfs_static() {
Adriana Kobylakf494bb52019-07-29 16:14:11 -0500117 clean_rwfs ${OVERLAY_BASETYPE}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400118 make_rwfs ${OVERLAY_BASETYPE} "${FLASH_STATIC_RWFS_CMD}" ${OVERLAY_MKFS_OPTS}
119}
120do_generate_rwfs_static[dirs] = " ${S}/static"
121do_generate_rwfs_static[depends] += " \
122 mtd-utils-native:do_populate_sysroot \
123 "
124
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400125do_generate_rwfs_ubi() {
Adriana Kobylakf494bb52019-07-29 16:14:11 -0500126 clean_rwfs ${FLASH_UBI_OVERLAY_BASETYPE}
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400127 make_rwfs ${FLASH_UBI_OVERLAY_BASETYPE} "${FLASH_UBI_RWFS_CMD}"
128}
129do_generate_rwfs_ubi[dirs] = " ${S}/ubi"
130do_generate_rwfs_ubi[depends] += " \
131 mtd-utils-native:do_populate_sysroot \
132 "
133
134add_volume() {
135 config_file=$1
136 vol_id=$2
137 vol_type=$3
138 vol_name=$4
139 image=$5
140 vol_size=$6
141
142 echo \[$vol_name\] >> $config_file
143 echo mode=ubi >> $config_file
144 echo image=$image >> $config_file
145 echo vol_type=$vol_type >> $config_file
146 echo vol_name=$vol_name >> $config_file
147 echo vol_id=$vol_id >> $config_file
148 if [ ! -z $vol_size ]; then
149 echo vol_size=$vol_size >> $config_file
150 fi
151}
152
Saqib Khan41723472017-09-22 10:21:30 -0500153python do_generate_ubi() {
154 version_id = do_get_versionID(d)
155 d.setVar('VERSION_ID', version_id)
156 bb.build.exec_func("do_make_ubi", d)
157}
158do_generate_ubi[dirs] = "${S}/ubi"
159do_generate_ubi[depends] += " \
160 ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
161 virtual/kernel:do_deploy \
162 u-boot:do_populate_sysroot \
163 mtd-utils-native:do_populate_sysroot \
164 "
165
166do_make_ubi() {
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400167 cfg=ubinize-${IMAGE_NAME}.cfg
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400168 rm -f $cfg ubi-img
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400169 # Construct the ubinize config file
Saqib Khan41723472017-09-22 10:21:30 -0500170 add_volume $cfg 0 static kernel-${VERSION_ID} \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400171 ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE}
172
Saqib Khan41723472017-09-22 10:21:30 -0500173 add_volume $cfg 1 static rofs-${VERSION_ID} \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400174 ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_BASETYPE}
175
William A. Kennington IIIc230ab32019-09-16 17:44:48 -0700176 add_volume $cfg 2 dynamic rwfs ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_RWFS_TXT_SIZE}
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400177
178 # Build the ubi partition image
179 ubinize -p ${FLASH_PEB_SIZE}KiB -m ${FLASH_PAGE_SIZE} -o ubi-img $cfg
180
181 # Concatenate the uboot and ubi partitions
Adriana Kobylak661cf392019-07-29 14:39:00 -0500182 mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd ${FLASH_SIZE}
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400183 dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
184 if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
185 of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
186 dd bs=1k conv=notrunc seek=${FLASH_UBI_OFFSET} \
187 if=ubi-img \
188 of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
189
190 cd ${IMGDEPLOYDIR}
191 ln -sf ${IMAGE_NAME}.ubi.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubi.mtd
192}
Saqib Khan41723472017-09-22 10:21:30 -0500193do_make_ubi[dirs] = "${S}/ubi"
194do_make_ubi[depends] += " \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400195 ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
196 virtual/kernel:do_deploy \
197 u-boot:do_populate_sysroot \
198 mtd-utils-native:do_populate_sysroot \
199 "
200
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300201do_mk_static_nor_image() {
Brad Bishop19fc4f82017-08-04 23:38:54 -0400202 # Assemble the flash image
Adriana Kobylak661cf392019-07-29 14:39:00 -0500203 mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd ${FLASH_SIZE}
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300204}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400205
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300206python do_generate_static() {
207 import subprocess
Brad Bishop19fc4f82017-08-04 23:38:54 -0400208
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300209 bb.build.exec_func("do_mk_static_nor_image", d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400210
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300211 nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True),
212 '%s.static.mtd' % d.getVar('IMAGE_NAME', True))
213
214 def _append_image(imgpath, start_kb, finish_kb):
215 imgsize = os.path.getsize(imgpath)
216 if imgsize > (finish_kb - start_kb) * 1024:
217 bb.fatal("Image '%s' is too large!" % imgpath)
218
219 subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc',
220 'seek=%d' % start_kb,
221 'if=%s' % imgpath,
222 'of=%s' % nor_image])
223
224 _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
225 'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
226 int(d.getVar('FLASH_UBOOT_OFFSET', True)),
227 int(d.getVar('FLASH_KERNEL_OFFSET', True)))
228
229 _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
230 d.getVar('FLASH_KERNEL_IMAGE', True)),
231 int(d.getVar('FLASH_KERNEL_OFFSET', True)),
232 int(d.getVar('FLASH_ROFS_OFFSET', True)))
233
234 _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True),
235 '%s.%s' % (
236 d.getVar('IMAGE_LINK_NAME', True),
237 d.getVar('IMAGE_BASETYPE', True))),
238 int(d.getVar('FLASH_ROFS_OFFSET', True)),
239 int(d.getVar('FLASH_RWFS_OFFSET', True)))
240
William A. Kennington IIIc230ab32019-09-16 17:44:48 -0700241 _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True),
242 '%s.%s' % (
243 d.getVar('IMAGE_LINK_NAME', True),
244 d.getVar('OVERLAY_BASETYPE', True))),
Alexander Filippov3dcf6f92018-07-17 16:41:37 +0300245 int(d.getVar('FLASH_RWFS_OFFSET', True)),
246 int(d.getVar('FLASH_SIZE', True)))
247
248 bb.build.exec_func("do_mk_static_symlinks", d)
249}
250
251do_mk_static_symlinks() {
Brad Bishop19fc4f82017-08-04 23:38:54 -0400252 cd ${IMGDEPLOYDIR}
253 ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd
254
255 # Maintain non-standard legacy links
256 ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/flash-${MACHINE}
257 ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/image-bmc
258 ln -sf u-boot.${UBOOT_SUFFIX} ${IMGDEPLOYDIR}/image-u-boot
259 ln -sf ${FLASH_KERNEL_IMAGE} ${IMGDEPLOYDIR}/image-kernel
260 ln -sf ${IMAGE_LINK_NAME}.${IMAGE_BASETYPE} ${IMGDEPLOYDIR}/image-rofs
William A. Kennington IIIc230ab32019-09-16 17:44:48 -0700261 ln -sf ${IMAGE_LINK_NAME}.${OVERLAY_BASETYPE} ${IMGDEPLOYDIR}/image-rwfs
Brad Bishop19fc4f82017-08-04 23:38:54 -0400262}
263do_generate_static[dirs] = "${S}/static"
264do_generate_static[depends] += " \
265 ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
266 virtual/kernel:do_deploy \
267 u-boot:do_populate_sysroot \
268 "
269
Lei YUf2072212018-06-20 13:27:34 +0800270make_signatures() {
271 signature_files=""
272 for file in "$@"; do
273 openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file
274 signature_files="${signature_files} ${file}.sig"
275 done
276}
277
Brad Bishop19fc4f82017-08-04 23:38:54 -0400278do_generate_static_alltar() {
Lei YUa4674942018-05-23 14:01:14 +0800279 ln -sf ${S}/MANIFEST MANIFEST
280 ln -sf ${S}/publickey publickey
Brad Bishop19fc4f82017-08-04 23:38:54 -0400281 ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd image-bmc
Lei YUa4674942018-05-23 14:01:14 +0800282
Lei YUf2072212018-06-20 13:27:34 +0800283 make_signatures image-bmc MANIFEST publickey
Lei YUa4674942018-05-23 14:01:14 +0800284
285 tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd.all.tar \
286 image-bmc MANIFEST publickey ${signature_files}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400287
288 cd ${IMGDEPLOYDIR}
289
290 ln -sf ${IMAGE_NAME}.static.mtd.all.tar \
291 ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd.all.tar
292
293 # Maintain non-standard legacy link.
294 ln -sf ${IMAGE_NAME}.static.mtd.all.tar \
295 ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.all.tar
Lei YUa4674942018-05-23 14:01:14 +0800296
Brad Bishop19fc4f82017-08-04 23:38:54 -0400297}
298do_generate_static_alltar[vardepsexclude] = "DATETIME"
299do_generate_static_alltar[dirs] = "${S}/static"
Lei YUa4674942018-05-23 14:01:14 +0800300do_generate_static_alltar[depends] += " \
301 openssl-native:do_populate_sysroot \
302 ${SIGNING_KEY_DEPENDS} \
303 ${PN}:do_copy_signing_pubkey \
304 "
Brad Bishop19fc4f82017-08-04 23:38:54 -0400305
Brad Bishopde659382018-03-30 01:46:16 -0400306make_image_links() {
Brad Bishop19fc4f82017-08-04 23:38:54 -0400307 rwfs=$1
308 rofs=$2
Brad Bishop19fc4f82017-08-04 23:38:54 -0400309 shift
310 shift
Brad Bishop19fc4f82017-08-04 23:38:54 -0400311
Brad Bishopde659382018-03-30 01:46:16 -0400312 # Create some links to help make the tar archive in the format
313 # expected by phosphor-bmc-code-mgmt.
Brad Bishop19fc4f82017-08-04 23:38:54 -0400314 ln -sf ${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} image-u-boot
315 ln -sf ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} image-kernel
316 ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rofs image-rofs
William A. Kennington IIIc230ab32019-09-16 17:44:48 -0700317 ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rwfs image-rwfs
Brad Bishopde659382018-03-30 01:46:16 -0400318}
319
320make_tar_of_images() {
321 type=$1
322 shift
323 extra_files="$@"
Brad Bishop19fc4f82017-08-04 23:38:54 -0400324
325 # Create the tar archive
Adriana Kobylake67e9db2019-07-30 11:31:50 -0500326 tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type.tar \
Brad Bishop19fc4f82017-08-04 23:38:54 -0400327 image-u-boot image-kernel image-rofs image-rwfs $extra_files
328
329 cd ${IMGDEPLOYDIR}
Adriana Kobylake67e9db2019-07-30 11:31:50 -0500330 ln -sf ${IMAGE_NAME}.$type.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.tar
Brad Bishop19fc4f82017-08-04 23:38:54 -0400331}
332
333do_generate_static_tar() {
Lei YUa4674942018-05-23 14:01:14 +0800334 ln -sf ${S}/MANIFEST MANIFEST
335 ln -sf ${S}/publickey publickey
Brad Bishopde659382018-03-30 01:46:16 -0400336 make_image_links ${OVERLAY_BASETYPE} ${IMAGE_BASETYPE}
Lei YUf2072212018-06-20 13:27:34 +0800337 make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
Adriana Kobylake67e9db2019-07-30 11:31:50 -0500338 make_tar_of_images static.mtd MANIFEST publickey ${signature_files}
Brad Bishop19fc4f82017-08-04 23:38:54 -0400339
340 # Maintain non-standard legacy link.
341 cd ${IMGDEPLOYDIR}
342 ln -sf ${IMAGE_NAME}.static.mtd.tar ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.tar
343}
344do_generate_static_tar[dirs] = " ${S}/static"
345do_generate_static_tar[depends] += " \
346 ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
347 virtual/kernel:do_deploy \
348 u-boot:do_populate_sysroot \
Lei YUa4674942018-05-23 14:01:14 +0800349 openssl-native:do_populate_sysroot \
350 ${SIGNING_KEY_DEPENDS} \
351 ${PN}:do_copy_signing_pubkey \
Brad Bishop19fc4f82017-08-04 23:38:54 -0400352 "
353do_generate_static_tar[vardepsexclude] = "DATETIME"
354
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400355do_generate_ubi_tar() {
356 ln -sf ${S}/MANIFEST MANIFEST
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600357 ln -sf ${S}/publickey publickey
Brad Bishopde659382018-03-30 01:46:16 -0400358 make_image_links ${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_BASETYPE}
Lei YUf2072212018-06-20 13:27:34 +0800359 make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
Adriana Kobylake67e9db2019-07-30 11:31:50 -0500360 make_tar_of_images ubi.mtd MANIFEST publickey ${signature_files}
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400361}
362do_generate_ubi_tar[dirs] = " ${S}/ubi"
363do_generate_ubi_tar[depends] += " \
364 ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
365 virtual/kernel:do_deploy \
366 u-boot:do_populate_sysroot \
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600367 openssl-native:do_populate_sysroot \
368 ${SIGNING_KEY_DEPENDS} \
369 ${PN}:do_copy_signing_pubkey \
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400370 "
371
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600372def get_pubkey_basedir(d):
373 return os.path.join(
374 d.getVar('STAGING_DIR_TARGET', True),
375 d.getVar('sysconfdir', True).strip(os.sep),
376 'activationdata')
377
378def get_pubkey_type(d):
379 return os.listdir(get_pubkey_basedir(d))[0]
380
381def get_pubkey_path(d):
382 return os.path.join(
383 get_pubkey_basedir(d),
384 get_pubkey_type(d),
385 'publickey')
386
Brad Bishop19fc4f82017-08-04 23:38:54 -0400387python do_generate_phosphor_manifest() {
Saqib Khan41723472017-09-22 10:21:30 -0500388 version = do_get_version(d)
Vijay Khemkaae614bd2019-09-18 12:28:46 -0700389 target_machine = d.getVar('MACHINE', True)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400390 with open('MANIFEST', 'w') as fd:
391 fd.write('purpose=xyz.openbmc_project.Software.Version.VersionPurpose.BMC\n')
392 fd.write('version={}\n'.format(version.strip('"')))
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600393 fd.write('KeyType={}\n'.format(get_pubkey_type(d)))
394 fd.write('HashType=RSA-SHA256\n')
Vijay Khemkaae614bd2019-09-18 12:28:46 -0700395 fd.write('MachineName={}\n'.format(target_machine))
Brad Bishop19fc4f82017-08-04 23:38:54 -0400396}
397do_generate_phosphor_manifest[dirs] = "${S}"
398do_generate_phosphor_manifest[depends] += " \
399 os-release:do_populate_sysroot \
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600400 phosphor-image-signing:do_populate_sysroot \
Brad Bishop19fc4f82017-08-04 23:38:54 -0400401 "
402
Eddie Jamesb2b7ff62018-02-09 11:59:18 -0600403python do_copy_signing_pubkey() {
404 with open(get_pubkey_path(d), 'r') as read_fd:
405 with open('publickey', 'w') as write_fd:
406 write_fd.write(read_fd.read())
407}
408
409do_copy_signing_pubkey[dirs] = "${S}"
410do_copy_signing_pubkey[depends] += " \
411 phosphor-image-signing:do_populate_sysroot \
412 "
413
414addtask copy_signing_pubkey after do_rootfs
Brad Bishop19fc4f82017-08-04 23:38:54 -0400415addtask generate_phosphor_manifest after do_rootfs
416addtask generate_rwfs_static after do_rootfs
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400417addtask generate_rwfs_ubi after do_rootfs
Brad Bishop19fc4f82017-08-04 23:38:54 -0400418
419python() {
420 types = d.getVar('IMAGE_FSTYPES', True).split()
421
422 if any([x in types for x in ['mtd-static', 'mtd-static-alltar']]):
423 bb.build.addtask(
424 'do_generate_static',
425 'do_image_complete',
426 'do_generate_rwfs_static', d)
427 if 'mtd-static-alltar' in types:
428 bb.build.addtask(
429 'do_generate_static_alltar',
430 'do_image_complete',
Lei YUa4674942018-05-23 14:01:14 +0800431 'do_generate_static do_generate_phosphor_manifest', d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400432 if 'mtd-static-tar' in types:
433 bb.build.addtask(
434 'do_generate_static_tar',
435 'do_image_complete',
Lei YUa4674942018-05-23 14:01:14 +0800436 'do_generate_rwfs_static do_generate_phosphor_manifest', d)
Brad Bishop3aa1ef62017-08-04 23:48:12 -0400437
438 if 'mtd-ubi' in types:
439 bb.build.addtask(
440 'do_generate_ubi',
441 'do_image_complete',
442 'do_generate_rwfs_ubi', d)
443 if 'mtd-ubi-tar' in types:
444 bb.build.addtask(
445 'do_generate_ubi_tar',
446 'do_image_complete',
447 'do_generate_rwfs_ubi do_generate_phosphor_manifest', d)
Brad Bishop19fc4f82017-08-04 23:38:54 -0400448}