Brad Bishop | 97cce00 | 2017-07-22 14:49:25 -0400 | [diff] [blame] | 1 | # Base image class extension, inlined into every image. |
| 2 | |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 3 | inherit image_version |
Brad Bishop | 97cce00 | 2017-07-22 14:49:25 -0400 | [diff] [blame] | 4 | |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 5 | FIT_IMAGE_INHERIT="" |
| 6 | FIT_IMAGE_INHERIT:df-obmc-static-norootfs = "fit-image" |
| 7 | inherit ${FIT_IMAGE_INHERIT} |
| 8 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 9 | # Phosphor image types |
| 10 | # |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 11 | # Phosphor OpenBMC supports a fixed partition mtd layout, |
| 12 | # A dynamic mtd with ubi layout, and a tar file for use with |
| 13 | # The reference BMC software update implementation. |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 14 | |
| 15 | # Image composition |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 16 | FLASH_KERNEL_IMAGE ?= "fitImage-${INITRAMFS_IMAGE}-${MACHINE}-${MACHINE}" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 17 | FLASH_KERNEL_IMAGE:df-obmc-ubi-fs ?= "fitImage-${MACHINE}.bin" |
Brad Bishop | 8623bbe | 2018-03-09 00:04:00 -0500 | [diff] [blame] | 18 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 19 | IMAGE_BASETYPE ?= "squashfs-xz" |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 20 | IMAGE_BASETYPE:df-obmc-static-norootfs ?= "cpio" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 21 | OVERLAY_BASETYPE ?= "jffs2" |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 22 | FLASH_UBI_BASETYPE ?= "${IMAGE_BASETYPE}" |
| 23 | FLASH_UBI_OVERLAY_BASETYPE ?= "ubifs" |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 24 | FLASH_EXT4_BASETYPE ?= "ext4" |
Adriana Kobylak | 5a5753a | 2019-07-30 11:27:46 -0500 | [diff] [blame] | 25 | FLASH_EXT4_OVERLAY_BASETYPE ?= "ext4" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 26 | |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 27 | PHOSPHOR_IMAGE_TYPES += " \ |
| 28 | mtd-static \ |
| 29 | mtd-static-alltar \ |
| 30 | mtd-static-tar \ |
| 31 | mtd-static-norootfs \ |
| 32 | mtd-ubi \ |
| 33 | mtd-ubi-tar \ |
| 34 | mmc-ext4-tar \ |
| 35 | " |
| 36 | IMAGE_TYPES += "${PHOSPHOR_IMAGE_TYPES}" |
| 37 | IMAGE_TYPES_MASKED += "${PHOSPHOR_IMAGE_TYPES}" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 38 | |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 39 | IMAGE_TYPEDEP:mtd-static = "${IMAGE_BASETYPE}" |
| 40 | IMAGE_TYPEDEP:mtd-static-tar = "${IMAGE_BASETYPE}" |
| 41 | IMAGE_TYPEDEP:mtd-static-alltar = "mtd-static" |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 42 | IMAGE_TYPEDEP:mtd-static-norootfs = "${IMAGE_BASETYPE}" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 43 | IMAGE_TYPEDEP:mtd-ubi = "${FLASH_UBI_BASETYPE}" |
| 44 | IMAGE_TYPEDEP:mtd-ubi-tar = "${FLASH_UBI_BASETYPE}" |
| 45 | IMAGE_TYPEDEP:mmc-ext4-tar = "${FLASH_EXT4_BASETYPE}" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 46 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 47 | # Flash characteristics in KB unless otherwise noted |
Brad Bishop | dcd861c | 2019-09-24 21:16:09 -0400 | [diff] [blame] | 48 | DISTROOVERRIDES .= ":flash-${FLASH_SIZE}" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 49 | FLASH_SIZE ?= "32768" |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 50 | FLASH_PEB_SIZE ?= "64" |
| 51 | # Flash page and overhead sizes in bytes |
| 52 | FLASH_PAGE_SIZE ?= "1" |
| 53 | FLASH_NOR_UBI_OVERHEAD ?= "64" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 54 | |
| 55 | # Fixed partition offsets |
Adriana Kobylak | e913dd8 | 2020-04-13 13:56:41 -0500 | [diff] [blame] | 56 | FLASH_UBOOT_SPL_SIZE ?= "64" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 57 | FLASH_UBOOT_OFFSET ?= "0" |
Patrick Williams | 2e37529 | 2023-03-10 12:18:56 -0600 | [diff] [blame^] | 58 | FLASH_UBOOT_ENV_OFFSET ?= "384" |
| 59 | FLASH_UBOOT_ENV_OFFSET:flash-65536 ?= "896" |
| 60 | FLASH_UBOOT_ENV_OFFSET:flash-131072 ?= "896" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 61 | FLASH_KERNEL_OFFSET ?= "512" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 62 | FLASH_KERNEL_OFFSET:flash-65536 ?= "1024" |
| 63 | FLASH_KERNEL_OFFSET:flash-131072 ?= "1024" |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 64 | FLASH_UBI_OFFSET ?= "${FLASH_KERNEL_OFFSET}" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 65 | FLASH_ROFS_OFFSET ?= "4864" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 66 | FLASH_ROFS_OFFSET:flash-65536 ?= "10240" |
| 67 | FLASH_ROFS_OFFSET:flash-131072 ?= "10240" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 68 | FLASH_RWFS_OFFSET ?= "28672" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 69 | FLASH_RWFS_OFFSET:flash-65536 ?= "43008" |
| 70 | FLASH_RWFS_OFFSET:flash-131072 ?= "98304" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 71 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 72 | # UBI volume sizes in KB unless otherwise noted. |
Adriana Kobylak | b70005d | 2018-02-14 16:35:30 -0600 | [diff] [blame] | 73 | FLASH_UBI_RWFS_SIZE ?= "6144" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 74 | FLASH_UBI_RWFS_SIZE:flash-131072 ?= "32768" |
Adriana Kobylak | b70005d | 2018-02-14 16:35:30 -0600 | [diff] [blame] | 75 | FLASH_UBI_RWFS_TXT_SIZE ?= "6MiB" |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 76 | FLASH_UBI_RWFS_TXT_SIZE:flash-131072 ?= "32MiB" |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 77 | |
Adriana Kobylak | 45a5795 | 2020-07-01 16:23:11 -0500 | [diff] [blame] | 78 | # eMMC sizes in KB unless otherwise noted. |
Adriana Kobylak | 55681e4 | 2020-11-11 15:06:50 -0600 | [diff] [blame] | 79 | MMC_UBOOT_SIZE ?= "1024" |
Adriana Kobylak | 45a5795 | 2020-07-01 16:23:11 -0500 | [diff] [blame] | 80 | MMC_BOOT_PARTITION_SIZE ?= "65536" |
| 81 | |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 82 | SIGNING_KEY ?= "${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv" |
| 83 | INSECURE_KEY = "${@'${SIGNING_KEY}' == '${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv'}" |
| 84 | SIGNING_KEY_DEPENDS = "${@oe.utils.conditional('INSECURE_KEY', 'True', 'phosphor-insecure-signing-key-native:do_populate_sysroot', '', d)}" |
| 85 | |
Adriana Kobylak | fb62a68 | 2019-10-28 16:03:12 -0500 | [diff] [blame] | 86 | VERSION_PURPOSE ?= "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" |
| 87 | |
Brad Bishop | 3e37d38 | 2018-03-31 12:17:28 -0400 | [diff] [blame] | 88 | UBOOT_SUFFIX ?= "bin" |
| 89 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 90 | python() { |
| 91 | # Compute rwfs LEB count and LEB size. |
| 92 | page_size = d.getVar('FLASH_PAGE_SIZE', True) |
| 93 | nor_overhead_size = d.getVar('FLASH_NOR_UBI_OVERHEAD', True) |
| 94 | overhead_size = max(int(page_size), int(nor_overhead_size)) |
| 95 | peb_size = d.getVar('FLASH_PEB_SIZE', True) |
| 96 | leb_size = (int(peb_size) * 1024) - (2 * overhead_size) |
| 97 | d.setVar('FLASH_LEB_SIZE', str(leb_size)) # In bytes |
| 98 | |
| 99 | rwfs_size = d.getVar('FLASH_UBI_RWFS_SIZE', True) |
| 100 | rwfs_size = int(rwfs_size) * 1024 |
| 101 | lebs = int((rwfs_size + leb_size - 1) / leb_size) # Rounding up |
| 102 | d.setVar('FLASH_UBI_RWFS_LEBS', str(lebs)) |
| 103 | } |
| 104 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 105 | # Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However, |
| 106 | # avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are |
| 107 | # reserved for the primary image (and setting them currently breaks the build). |
| 108 | # Instead, prefix the overlay override value with 'rwfs-' to avoid collisions. |
| 109 | DISTROOVERRIDES .= ":static-rwfs-${OVERLAY_BASETYPE}" |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 110 | DISTROOVERRIDES .= ":ubi-rwfs-${FLASH_UBI_OVERLAY_BASETYPE}" |
Adriana Kobylak | 5a5753a | 2019-07-30 11:27:46 -0500 | [diff] [blame] | 111 | DISTROOVERRIDES .= ":mmc-rwfs-${FLASH_EXT4_OVERLAY_BASETYPE}" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 112 | |
William A. Kennington III | c230ab3 | 2019-09-16 17:44:48 -0700 | [diff] [blame] | 113 | JFFS2_RWFS_CMD = "mkfs.jffs2 --root=jffs2 --faketime --output=${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.jffs2" |
| 114 | UBIFS_RWFS_CMD = "mkfs.ubifs -r ubifs -c ${FLASH_UBI_RWFS_LEBS} -m ${FLASH_PAGE_SIZE} -e ${FLASH_LEB_SIZE} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubifs" |
Adriana Kobylak | 5a5753a | 2019-07-30 11:27:46 -0500 | [diff] [blame] | 115 | EXT4_RWFS_CMD = "mkfs.ext4 -F ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.ext4" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 116 | |
Patrick Williams | 12fc939 | 2021-08-06 09:16:53 -0500 | [diff] [blame] | 117 | FLASH_STATIC_RWFS_CMD:static-rwfs-jffs2 = "${JFFS2_RWFS_CMD}" |
| 118 | FLASH_UBI_RWFS_CMD:ubi-rwfs-jffs2 = "${JFFS2_RWFS_CMD}" |
| 119 | FLASH_UBI_RWFS_CMD:ubi-rwfs-ubifs = "${UBIFS_RWFS_CMD}" |
| 120 | FLASH_EXT4_RWFS_CMD:mmc-rwfs-ext4 = "${EXT4_RWFS_CMD}" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 121 | |
Adriana Kobylak | 661cf39 | 2019-07-29 14:39:00 -0500 | [diff] [blame] | 122 | mk_empty_image() { |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 123 | image_dst="$1" |
| 124 | image_size_kb=$2 |
| 125 | dd if=/dev/zero bs=1k count=$image_size_kb \ |
| 126 | | tr '\000' '\377' > $image_dst |
| 127 | } |
| 128 | |
Adriana Kobylak | 55681e4 | 2020-11-11 15:06:50 -0600 | [diff] [blame] | 129 | mk_empty_image_zeros() { |
| 130 | image_dst="$1" |
| 131 | image_size_kb=$2 |
| 132 | dd if=/dev/zero of=$image_dst bs=1k count=$image_size_kb |
| 133 | } |
| 134 | |
Adriana Kobylak | f494bb5 | 2019-07-29 16:14:11 -0500 | [diff] [blame] | 135 | clean_rwfs() { |
| 136 | type=$1 |
| 137 | shift |
| 138 | |
| 139 | rm -f ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type |
| 140 | rm -rf $type |
| 141 | mkdir $type |
| 142 | } |
| 143 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 144 | make_rwfs() { |
| 145 | type=$1 |
| 146 | cmd=$2 |
| 147 | shift |
| 148 | shift |
| 149 | opts="$@" |
| 150 | |
Adriana Kobylak | f494bb5 | 2019-07-29 16:14:11 -0500 | [diff] [blame] | 151 | mkdir -p $type |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 152 | |
| 153 | $cmd $opts |
| 154 | } |
| 155 | |
| 156 | do_generate_rwfs_static() { |
Adriana Kobylak | f494bb5 | 2019-07-29 16:14:11 -0500 | [diff] [blame] | 157 | clean_rwfs ${OVERLAY_BASETYPE} |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 158 | make_rwfs ${OVERLAY_BASETYPE} "${FLASH_STATIC_RWFS_CMD}" ${OVERLAY_MKFS_OPTS} |
| 159 | } |
| 160 | do_generate_rwfs_static[dirs] = " ${S}/static" |
| 161 | do_generate_rwfs_static[depends] += " \ |
| 162 | mtd-utils-native:do_populate_sysroot \ |
| 163 | " |
| 164 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 165 | do_generate_rwfs_ubi() { |
Adriana Kobylak | f494bb5 | 2019-07-29 16:14:11 -0500 | [diff] [blame] | 166 | clean_rwfs ${FLASH_UBI_OVERLAY_BASETYPE} |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 167 | make_rwfs ${FLASH_UBI_OVERLAY_BASETYPE} "${FLASH_UBI_RWFS_CMD}" |
| 168 | } |
| 169 | do_generate_rwfs_ubi[dirs] = " ${S}/ubi" |
| 170 | do_generate_rwfs_ubi[depends] += " \ |
| 171 | mtd-utils-native:do_populate_sysroot \ |
| 172 | " |
| 173 | |
Adriana Kobylak | 5a5753a | 2019-07-30 11:27:46 -0500 | [diff] [blame] | 174 | do_generate_rwfs_ext4() { |
| 175 | clean_rwfs rwfs.${FLASH_EXT4_OVERLAY_BASETYPE} |
| 176 | mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.ext4 1024 |
| 177 | make_rwfs ${FLASH_EXT4_OVERLAY_BASETYPE} "${FLASH_EXT4_RWFS_CMD}" ${OVERLAY_MKFS_OPTS} |
| 178 | } |
| 179 | do_generate_rwfs_ext4[dirs] = " ${S}/ext4" |
| 180 | do_generate_rwfs_ext4[depends] += " \ |
| 181 | e2fsprogs-native:do_populate_sysroot \ |
| 182 | " |
| 183 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 184 | add_volume() { |
| 185 | config_file=$1 |
| 186 | vol_id=$2 |
| 187 | vol_type=$3 |
| 188 | vol_name=$4 |
| 189 | image=$5 |
| 190 | vol_size=$6 |
| 191 | |
| 192 | echo \[$vol_name\] >> $config_file |
| 193 | echo mode=ubi >> $config_file |
| 194 | echo image=$image >> $config_file |
| 195 | echo vol_type=$vol_type >> $config_file |
| 196 | echo vol_name=$vol_name >> $config_file |
| 197 | echo vol_id=$vol_id >> $config_file |
| 198 | if [ ! -z $vol_size ]; then |
| 199 | echo vol_size=$vol_size >> $config_file |
| 200 | fi |
| 201 | } |
| 202 | |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 203 | python do_generate_ubi() { |
| 204 | version_id = do_get_versionID(d) |
| 205 | d.setVar('VERSION_ID', version_id) |
| 206 | bb.build.exec_func("do_make_ubi", d) |
| 207 | } |
| 208 | do_generate_ubi[dirs] = "${S}/ubi" |
| 209 | do_generate_ubi[depends] += " \ |
| 210 | ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \ |
| 211 | virtual/kernel:do_deploy \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 212 | u-boot:do_deploy \ |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 213 | mtd-utils-native:do_populate_sysroot \ |
| 214 | " |
| 215 | |
| 216 | do_make_ubi() { |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 217 | cfg=ubinize-${IMAGE_NAME}.cfg |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 218 | rm -f $cfg ubi-img |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 219 | # Construct the ubinize config file |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 220 | add_volume $cfg 0 static kernel-${VERSION_ID} \ |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 221 | ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} |
| 222 | |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 223 | add_volume $cfg 1 static rofs-${VERSION_ID} \ |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 224 | ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_BASETYPE} |
| 225 | |
William A. Kennington III | c230ab3 | 2019-09-16 17:44:48 -0700 | [diff] [blame] | 226 | add_volume $cfg 2 dynamic rwfs ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_RWFS_TXT_SIZE} |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 227 | |
| 228 | # Build the ubi partition image |
| 229 | ubinize -p ${FLASH_PEB_SIZE}KiB -m ${FLASH_PAGE_SIZE} -o ubi-img $cfg |
| 230 | |
| 231 | # Concatenate the uboot and ubi partitions |
Adriana Kobylak | 661cf39 | 2019-07-29 14:39:00 -0500 | [diff] [blame] | 232 | mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd ${FLASH_SIZE} |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 233 | dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \ |
| 234 | if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \ |
| 235 | of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd |
| 236 | dd bs=1k conv=notrunc seek=${FLASH_UBI_OFFSET} \ |
| 237 | if=ubi-img \ |
| 238 | of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd |
| 239 | |
| 240 | cd ${IMGDEPLOYDIR} |
| 241 | ln -sf ${IMAGE_NAME}.ubi.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubi.mtd |
| 242 | } |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 243 | do_make_ubi[dirs] = "${S}/ubi" |
| 244 | do_make_ubi[depends] += " \ |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 245 | ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \ |
| 246 | virtual/kernel:do_deploy \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 247 | u-boot:do_deploy \ |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 248 | mtd-utils-native:do_populate_sysroot \ |
| 249 | " |
| 250 | |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 251 | do_mk_static_nor_image() { |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 252 | # Assemble the flash image |
Adriana Kobylak | 661cf39 | 2019-07-29 14:39:00 -0500 | [diff] [blame] | 253 | mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd ${FLASH_SIZE} |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 254 | } |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 255 | |
Adriana Kobylak | f1954f0 | 2020-04-27 15:20:35 -0500 | [diff] [blame] | 256 | do_generate_image_uboot_file() { |
| 257 | image_dst="$1" |
| 258 | uboot_offset=${FLASH_UBOOT_OFFSET} |
| 259 | |
| 260 | if [ ! -z ${SPL_BINARY} ]; then |
| 261 | dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \ |
| 262 | if=${DEPLOY_DIR_IMAGE}/u-boot-spl.${UBOOT_SUFFIX} \ |
| 263 | of=${image_dst} |
| 264 | uboot_offset=${FLASH_UBOOT_SPL_SIZE} |
| 265 | fi |
| 266 | |
| 267 | dd bs=1k conv=notrunc seek=${uboot_offset} \ |
| 268 | if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \ |
| 269 | of=${image_dst} |
| 270 | } |
| 271 | |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 272 | python do_generate_static() { |
| 273 | import subprocess |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 274 | |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 275 | bb.build.exec_func("do_mk_static_nor_image", d) |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 276 | |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 277 | nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True), |
| 278 | '%s.static.mtd' % d.getVar('IMAGE_NAME', True)) |
| 279 | |
| 280 | def _append_image(imgpath, start_kb, finish_kb): |
| 281 | imgsize = os.path.getsize(imgpath) |
Josh Lehan | 0a5ef2a | 2020-02-26 12:11:33 -0800 | [diff] [blame] | 282 | maxsize = (finish_kb - start_kb) * 1024 |
| 283 | bb.debug(1, 'Considering file size=' + str(imgsize) + ' name=' + imgpath) |
| 284 | bb.debug(1, 'Spanning start=' + str(start_kb) + 'K end=' + str(finish_kb) + 'K') |
| 285 | bb.debug(1, 'Compare needed=' + str(imgsize) + ' available=' + str(maxsize) + ' margin=' + str(maxsize - imgsize)) |
| 286 | if imgsize > maxsize: |
Joel Stanley | 909f33e | 2023-01-18 18:56:17 +1030 | [diff] [blame] | 287 | bb.fatal("Image '%s' is %d bytes too large!" % (imgpath, imgsize - maxsize)) |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 288 | |
| 289 | subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc', |
| 290 | 'seek=%d' % start_kb, |
| 291 | 'if=%s' % imgpath, |
| 292 | 'of=%s' % nor_image]) |
| 293 | |
Adriana Kobylak | e913dd8 | 2020-04-13 13:56:41 -0500 | [diff] [blame] | 294 | uboot_offset = int(d.getVar('FLASH_UBOOT_OFFSET', True)) |
| 295 | |
| 296 | spl_binary = d.getVar('SPL_BINARY', True) |
| 297 | if spl_binary: |
| 298 | _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), |
| 299 | 'u-boot-spl.%s' % d.getVar('UBOOT_SUFFIX',True)), |
| 300 | int(d.getVar('FLASH_UBOOT_OFFSET', True)), |
| 301 | int(d.getVar('FLASH_UBOOT_SPL_SIZE', True))) |
| 302 | uboot_offset += int(d.getVar('FLASH_UBOOT_SPL_SIZE', True)) |
| 303 | |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 304 | _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), |
| 305 | 'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)), |
Adriana Kobylak | e913dd8 | 2020-04-13 13:56:41 -0500 | [diff] [blame] | 306 | uboot_offset, |
Patrick Williams | 2e37529 | 2023-03-10 12:18:56 -0600 | [diff] [blame^] | 307 | int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True))) |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 308 | |
| 309 | _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), |
| 310 | d.getVar('FLASH_KERNEL_IMAGE', True)), |
| 311 | int(d.getVar('FLASH_KERNEL_OFFSET', True)), |
| 312 | int(d.getVar('FLASH_ROFS_OFFSET', True))) |
| 313 | |
| 314 | _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True), |
| 315 | '%s.%s' % ( |
| 316 | d.getVar('IMAGE_LINK_NAME', True), |
| 317 | d.getVar('IMAGE_BASETYPE', True))), |
| 318 | int(d.getVar('FLASH_ROFS_OFFSET', True)), |
| 319 | int(d.getVar('FLASH_RWFS_OFFSET', True))) |
| 320 | |
William A. Kennington III | c230ab3 | 2019-09-16 17:44:48 -0700 | [diff] [blame] | 321 | _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True), |
| 322 | '%s.%s' % ( |
| 323 | d.getVar('IMAGE_LINK_NAME', True), |
| 324 | d.getVar('OVERLAY_BASETYPE', True))), |
Alexander Filippov | 3dcf6f9 | 2018-07-17 16:41:37 +0300 | [diff] [blame] | 325 | int(d.getVar('FLASH_RWFS_OFFSET', True)), |
| 326 | int(d.getVar('FLASH_SIZE', True))) |
| 327 | |
| 328 | bb.build.exec_func("do_mk_static_symlinks", d) |
| 329 | } |
| 330 | |
| 331 | do_mk_static_symlinks() { |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 332 | cd ${IMGDEPLOYDIR} |
| 333 | ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd |
| 334 | |
| 335 | # Maintain non-standard legacy links |
Adriana Kobylak | f1954f0 | 2020-04-27 15:20:35 -0500 | [diff] [blame] | 336 | do_generate_image_uboot_file ${IMGDEPLOYDIR}/image-u-boot |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 337 | ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/flash-${MACHINE} |
| 338 | ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/image-bmc |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 339 | ln -sf ${FLASH_KERNEL_IMAGE} ${IMGDEPLOYDIR}/image-kernel |
| 340 | ln -sf ${IMAGE_LINK_NAME}.${IMAGE_BASETYPE} ${IMGDEPLOYDIR}/image-rofs |
William A. Kennington III | c230ab3 | 2019-09-16 17:44:48 -0700 | [diff] [blame] | 341 | ln -sf ${IMAGE_LINK_NAME}.${OVERLAY_BASETYPE} ${IMGDEPLOYDIR}/image-rwfs |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 342 | } |
| 343 | do_generate_static[dirs] = "${S}/static" |
| 344 | do_generate_static[depends] += " \ |
| 345 | ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \ |
| 346 | virtual/kernel:do_deploy \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 347 | u-boot:do_deploy \ |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 348 | " |
| 349 | |
Lei YU | f207221 | 2018-06-20 13:27:34 +0800 | [diff] [blame] | 350 | make_signatures() { |
| 351 | signature_files="" |
| 352 | for file in "$@"; do |
| 353 | openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file |
| 354 | signature_files="${signature_files} ${file}.sig" |
| 355 | done |
George Liu | f0afcf8 | 2020-12-15 09:46:10 +0800 | [diff] [blame] | 356 | |
| 357 | if [ -n "$signature_files" ]; then |
| 358 | sort_signature_files=`echo "$signature_files" | tr ' ' '\n' | sort | tr '\n' ' '` |
| 359 | cat $sort_signature_files > image-full |
| 360 | openssl dgst -sha256 -sign ${SIGNING_KEY} -out image-full.sig image-full |
| 361 | signature_files="${signature_files} image-full.sig" |
George Liu | f0afcf8 | 2020-12-15 09:46:10 +0800 | [diff] [blame] | 362 | fi |
Lei YU | f207221 | 2018-06-20 13:27:34 +0800 | [diff] [blame] | 363 | } |
| 364 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 365 | do_generate_static_alltar() { |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 366 | ln -sf ${S}/MANIFEST MANIFEST |
| 367 | ln -sf ${S}/publickey publickey |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 368 | ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd image-bmc |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 369 | |
Lei YU | f207221 | 2018-06-20 13:27:34 +0800 | [diff] [blame] | 370 | make_signatures image-bmc MANIFEST publickey |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 371 | |
| 372 | tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd.all.tar \ |
| 373 | image-bmc MANIFEST publickey ${signature_files} |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 374 | |
| 375 | cd ${IMGDEPLOYDIR} |
| 376 | |
| 377 | ln -sf ${IMAGE_NAME}.static.mtd.all.tar \ |
| 378 | ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd.all.tar |
| 379 | |
| 380 | # Maintain non-standard legacy link. |
| 381 | ln -sf ${IMAGE_NAME}.static.mtd.all.tar \ |
| 382 | ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.all.tar |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 383 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 384 | } |
| 385 | do_generate_static_alltar[vardepsexclude] = "DATETIME" |
| 386 | do_generate_static_alltar[dirs] = "${S}/static" |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 387 | do_generate_static_alltar[depends] += " \ |
| 388 | openssl-native:do_populate_sysroot \ |
| 389 | ${SIGNING_KEY_DEPENDS} \ |
| 390 | ${PN}:do_copy_signing_pubkey \ |
| 391 | " |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 392 | |
Brad Bishop | de65938 | 2018-03-30 01:46:16 -0400 | [diff] [blame] | 393 | make_image_links() { |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 394 | rwfs=$1 |
| 395 | rofs=$2 |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 396 | shift |
| 397 | shift |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 398 | |
Brad Bishop | de65938 | 2018-03-30 01:46:16 -0400 | [diff] [blame] | 399 | # Create some links to help make the tar archive in the format |
| 400 | # expected by phosphor-bmc-code-mgmt. |
Adriana Kobylak | f1954f0 | 2020-04-27 15:20:35 -0500 | [diff] [blame] | 401 | do_generate_image_uboot_file image-u-boot |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 402 | ln -sf ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} image-kernel |
| 403 | ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rofs image-rofs |
William A. Kennington III | c230ab3 | 2019-09-16 17:44:48 -0700 | [diff] [blame] | 404 | ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rwfs image-rwfs |
Brad Bishop | de65938 | 2018-03-30 01:46:16 -0400 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | make_tar_of_images() { |
| 408 | type=$1 |
| 409 | shift |
| 410 | extra_files="$@" |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 411 | |
| 412 | # Create the tar archive |
Adriana Kobylak | e67e9db | 2019-07-30 11:31:50 -0500 | [diff] [blame] | 413 | tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type.tar \ |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 414 | image-u-boot image-kernel image-rofs image-rwfs $extra_files |
| 415 | |
| 416 | cd ${IMGDEPLOYDIR} |
Adriana Kobylak | e67e9db | 2019-07-30 11:31:50 -0500 | [diff] [blame] | 417 | ln -sf ${IMAGE_NAME}.$type.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.tar |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | do_generate_static_tar() { |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 421 | ln -sf ${S}/MANIFEST MANIFEST |
| 422 | ln -sf ${S}/publickey publickey |
Brad Bishop | de65938 | 2018-03-30 01:46:16 -0400 | [diff] [blame] | 423 | make_image_links ${OVERLAY_BASETYPE} ${IMAGE_BASETYPE} |
Lei YU | f207221 | 2018-06-20 13:27:34 +0800 | [diff] [blame] | 424 | make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey |
Adriana Kobylak | e67e9db | 2019-07-30 11:31:50 -0500 | [diff] [blame] | 425 | make_tar_of_images static.mtd MANIFEST publickey ${signature_files} |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 426 | |
| 427 | # Maintain non-standard legacy link. |
| 428 | cd ${IMGDEPLOYDIR} |
| 429 | ln -sf ${IMAGE_NAME}.static.mtd.tar ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.tar |
| 430 | } |
| 431 | do_generate_static_tar[dirs] = " ${S}/static" |
| 432 | do_generate_static_tar[depends] += " \ |
| 433 | ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \ |
| 434 | virtual/kernel:do_deploy \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 435 | u-boot:do_deploy \ |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 436 | openssl-native:do_populate_sysroot \ |
| 437 | ${SIGNING_KEY_DEPENDS} \ |
| 438 | ${PN}:do_copy_signing_pubkey \ |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 439 | " |
| 440 | do_generate_static_tar[vardepsexclude] = "DATETIME" |
| 441 | |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 442 | python do_generate_static_norootfs() { |
| 443 | import subprocess |
| 444 | |
| 445 | nor_image_basename = '%s.static.mtd' % d.getVar('IMAGE_NAME', True) |
| 446 | nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True), nor_image_basename) |
| 447 | |
| 448 | def _append_image(imgpath, start_kb, finish_kb): |
| 449 | imgsize = os.path.getsize(imgpath) |
| 450 | maxsize = (finish_kb - start_kb) * 1024 |
| 451 | bb.debug(1, 'Considering file size=' + str(imgsize) + ' name=' + imgpath) |
| 452 | bb.debug(1, 'Spanning start=' + str(start_kb) + 'K end=' + str(finish_kb) + 'K') |
| 453 | bb.debug(1, 'Compare needed=' + str(imgsize) + ' available=' + str(maxsize) + ' margin=' + str(maxsize - imgsize)) |
| 454 | if imgsize > maxsize: |
| 455 | bb.fatal("Image '%s' is too large!" % imgpath) |
| 456 | |
| 457 | subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc', |
| 458 | 'seek=%d' % start_kb, |
| 459 | 'if=%s' % imgpath, |
| 460 | 'of=%s' % nor_image]) |
| 461 | uboot_offset = int(d.getVar('FLASH_UBOOT_OFFSET', True)) |
| 462 | |
| 463 | spl_binary = d.getVar('SPL_BINARY', True) |
| 464 | if spl_binary: |
| 465 | _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), |
| 466 | 'u-boot-spl.%s' % d.getVar('UBOOT_SUFFIX',True)), |
| 467 | int(d.getVar('FLASH_UBOOT_OFFSET', True)), |
| 468 | int(d.getVar('FLASH_UBOOT_SPL_SIZE', True))) |
| 469 | uboot_offset += int(d.getVar('FLASH_UBOOT_SPL_SIZE', True)) |
| 470 | |
| 471 | _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), |
| 472 | 'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)), |
| 473 | uboot_offset, |
Patrick Williams | 2e37529 | 2023-03-10 12:18:56 -0600 | [diff] [blame^] | 474 | int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True))) |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 475 | |
| 476 | _append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True), |
| 477 | '%s.cpio.%s.fitImage' % ( |
| 478 | d.getVar('IMAGE_LINK_NAME', True), |
| 479 | d.getVar('INITRAMFS_CTYPE', True))), |
| 480 | int(d.getVar('FLASH_KERNEL_OFFSET', True)), |
| 481 | int(d.getVar('FLASH_RWFS_OFFSET', True))) |
| 482 | |
| 483 | flash_symlink = os.path.join( |
| 484 | d.getVar('IMGDEPLOYDIR', True), |
| 485 | 'flash-%s' % d.getVar('MACHINE', True)) |
| 486 | if os.path.exists(flash_symlink): |
| 487 | os.remove(flash_symlink) |
| 488 | os.symlink(nor_image_basename, flash_symlink) |
| 489 | } |
| 490 | do_generate_static_norootfs[depends] += " \ |
| 491 | ${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \ |
| 492 | u-boot:do_deploy \ |
| 493 | " |
| 494 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 495 | do_generate_ubi_tar() { |
| 496 | ln -sf ${S}/MANIFEST MANIFEST |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 497 | ln -sf ${S}/publickey publickey |
Brad Bishop | de65938 | 2018-03-30 01:46:16 -0400 | [diff] [blame] | 498 | make_image_links ${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_BASETYPE} |
Lei YU | f207221 | 2018-06-20 13:27:34 +0800 | [diff] [blame] | 499 | make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey |
Adriana Kobylak | e67e9db | 2019-07-30 11:31:50 -0500 | [diff] [blame] | 500 | make_tar_of_images ubi.mtd MANIFEST publickey ${signature_files} |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 501 | } |
| 502 | do_generate_ubi_tar[dirs] = " ${S}/ubi" |
| 503 | do_generate_ubi_tar[depends] += " \ |
| 504 | ${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \ |
| 505 | virtual/kernel:do_deploy \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 506 | u-boot:do_deploy \ |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 507 | openssl-native:do_populate_sysroot \ |
| 508 | ${SIGNING_KEY_DEPENDS} \ |
| 509 | ${PN}:do_copy_signing_pubkey \ |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 510 | " |
| 511 | |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 512 | do_generate_ext4_tar() { |
Adriana Kobylak | 45a5795 | 2020-07-01 16:23:11 -0500 | [diff] [blame] | 513 | # Generate the U-Boot image |
Adriana Kobylak | 55681e4 | 2020-11-11 15:06:50 -0600 | [diff] [blame] | 514 | mk_empty_image_zeros image-u-boot ${MMC_UBOOT_SIZE} |
Adriana Kobylak | 45a5795 | 2020-07-01 16:23:11 -0500 | [diff] [blame] | 515 | do_generate_image_uboot_file image-u-boot |
| 516 | |
| 517 | # Generate a compressed ext4 filesystem with the fitImage file in it to be |
| 518 | # flashed to the boot partition of the eMMC |
| 519 | install -d boot-image |
| 520 | install -m 644 ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} boot-image/fitImage |
Adriana Kobylak | 55681e4 | 2020-11-11 15:06:50 -0600 | [diff] [blame] | 521 | mk_empty_image_zeros boot-image.${FLASH_EXT4_BASETYPE} ${MMC_BOOT_PARTITION_SIZE} |
Adriana Kobylak | 45a5795 | 2020-07-01 16:23:11 -0500 | [diff] [blame] | 522 | mkfs.ext4 -F -i 4096 -d boot-image boot-image.${FLASH_EXT4_BASETYPE} |
| 523 | # Error codes 0-3 indicate successfull operation of fsck |
| 524 | fsck.ext4 -pvfD boot-image.${FLASH_EXT4_BASETYPE} || [ $? -le 3 ] |
| 525 | zstd -f -k -T0 -c ${ZSTD_COMPRESSION_LEVEL} boot-image.${FLASH_EXT4_BASETYPE} > boot-image.${FLASH_EXT4_BASETYPE}.zst |
| 526 | |
| 527 | # Generate the compressed ext4 rootfs |
| 528 | zstd -f -k -T0 -c ${ZSTD_COMPRESSION_LEVEL} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE} > ${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE}.zst |
| 529 | |
| 530 | ln -sf boot-image.${FLASH_EXT4_BASETYPE}.zst image-kernel |
| 531 | ln -sf ${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE}.zst image-rofs |
| 532 | ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.${FLASH_EXT4_OVERLAY_BASETYPE} image-rwfs |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 533 | ln -sf ${S}/MANIFEST MANIFEST |
| 534 | ln -sf ${S}/publickey publickey |
Adriana Kobylak | 81846a2 | 2020-07-12 15:12:36 -0500 | [diff] [blame] | 535 | |
| 536 | hostfw_update_file="${DEPLOY_DIR_IMAGE}/hostfw/update/image-hostfw" |
| 537 | if [ -e "${hostfw_update_file}" ]; then |
| 538 | ln -sf "${hostfw_update_file}" image-hostfw |
| 539 | make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey image-hostfw |
| 540 | make_tar_of_images ext4.mmc MANIFEST publickey ${signature_files} image-hostfw |
| 541 | else |
| 542 | make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey |
| 543 | make_tar_of_images ext4.mmc MANIFEST publickey ${signature_files} |
| 544 | fi |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 545 | } |
| 546 | do_generate_ext4_tar[dirs] = " ${S}/ext4" |
| 547 | do_generate_ext4_tar[depends] += " \ |
Adriana Kobylak | 4cc866b | 2020-03-28 13:43:33 -0500 | [diff] [blame] | 548 | zstd-native:do_populate_sysroot \ |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 549 | ${PN}:do_image_${FLASH_EXT4_BASETYPE} \ |
| 550 | virtual/kernel:do_deploy \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 551 | u-boot:do_deploy \ |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 552 | openssl-native:do_populate_sysroot \ |
| 553 | ${SIGNING_KEY_DEPENDS} \ |
| 554 | ${PN}:do_copy_signing_pubkey \ |
Brad Bishop | 209ed52 | 2020-11-02 12:36:04 -0500 | [diff] [blame] | 555 | phosphor-hostfw-image:do_deploy \ |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 556 | " |
| 557 | |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 558 | def get_pubkey_basedir(d): |
| 559 | return os.path.join( |
| 560 | d.getVar('STAGING_DIR_TARGET', True), |
| 561 | d.getVar('sysconfdir', True).strip(os.sep), |
| 562 | 'activationdata') |
| 563 | |
| 564 | def get_pubkey_type(d): |
| 565 | return os.listdir(get_pubkey_basedir(d))[0] |
| 566 | |
| 567 | def get_pubkey_path(d): |
| 568 | return os.path.join( |
| 569 | get_pubkey_basedir(d), |
| 570 | get_pubkey_type(d), |
| 571 | 'publickey') |
| 572 | |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 573 | python do_generate_phosphor_manifest() { |
Adriana Kobylak | fb62a68 | 2019-10-28 16:03:12 -0500 | [diff] [blame] | 574 | purpose = d.getVar('VERSION_PURPOSE', True) |
Saqib Khan | 4172347 | 2017-09-22 10:21:30 -0500 | [diff] [blame] | 575 | version = do_get_version(d) |
Adriana Kobylak | cdd91ad | 2021-10-25 15:58:19 +0000 | [diff] [blame] | 576 | build_id = do_get_buildID(d) |
Vijay Khemka | ae614bd | 2019-09-18 12:28:46 -0700 | [diff] [blame] | 577 | target_machine = d.getVar('MACHINE', True) |
Adriana Kobylak | bde7dbe | 2022-08-04 09:13:26 -0500 | [diff] [blame] | 578 | extended_version = do_get_extended_version(d) |
Justin Ledford | b4de16d | 2022-03-24 17:27:17 -0700 | [diff] [blame] | 579 | compatible_names = d.getVar('OBMC_COMPATIBLE_NAMES', True) |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 580 | with open('MANIFEST', 'w') as fd: |
Adriana Kobylak | fb62a68 | 2019-10-28 16:03:12 -0500 | [diff] [blame] | 581 | fd.write('purpose={}\n'.format(purpose)) |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 582 | fd.write('version={}\n'.format(version.strip('"'))) |
Adriana Kobylak | cdd91ad | 2021-10-25 15:58:19 +0000 | [diff] [blame] | 583 | fd.write('BuildId={}\n'.format(build_id.strip('"'))) |
Justin Ledford | b4de16d | 2022-03-24 17:27:17 -0700 | [diff] [blame] | 584 | if extended_version: |
| 585 | fd.write('ExtendedVersion={}\n'.format(extended_version)) |
| 586 | if compatible_names: |
| 587 | for name in compatible_names.split(): |
| 588 | fd.write('CompatibleName={}\n'.format(name)) |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 589 | fd.write('KeyType={}\n'.format(get_pubkey_type(d))) |
| 590 | fd.write('HashType=RSA-SHA256\n') |
Vijay Khemka | ae614bd | 2019-09-18 12:28:46 -0700 | [diff] [blame] | 591 | fd.write('MachineName={}\n'.format(target_machine)) |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 592 | } |
| 593 | do_generate_phosphor_manifest[dirs] = "${S}" |
| 594 | do_generate_phosphor_manifest[depends] += " \ |
| 595 | os-release:do_populate_sysroot \ |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 596 | phosphor-image-signing:do_populate_sysroot \ |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 597 | " |
| 598 | |
Eddie James | b2b7ff6 | 2018-02-09 11:59:18 -0600 | [diff] [blame] | 599 | python do_copy_signing_pubkey() { |
| 600 | with open(get_pubkey_path(d), 'r') as read_fd: |
| 601 | with open('publickey', 'w') as write_fd: |
| 602 | write_fd.write(read_fd.read()) |
| 603 | } |
| 604 | |
| 605 | do_copy_signing_pubkey[dirs] = "${S}" |
| 606 | do_copy_signing_pubkey[depends] += " \ |
| 607 | phosphor-image-signing:do_populate_sysroot \ |
| 608 | " |
| 609 | |
| 610 | addtask copy_signing_pubkey after do_rootfs |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 611 | addtask generate_phosphor_manifest after do_rootfs |
| 612 | addtask generate_rwfs_static after do_rootfs |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 613 | addtask generate_rwfs_ubi after do_rootfs |
Adriana Kobylak | 5a5753a | 2019-07-30 11:27:46 -0500 | [diff] [blame] | 614 | addtask generate_rwfs_ext4 after do_rootfs |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 615 | |
| 616 | python() { |
| 617 | types = d.getVar('IMAGE_FSTYPES', True).split() |
| 618 | |
| 619 | if any([x in types for x in ['mtd-static', 'mtd-static-alltar']]): |
| 620 | bb.build.addtask( |
| 621 | 'do_generate_static', |
| 622 | 'do_image_complete', |
| 623 | 'do_generate_rwfs_static', d) |
| 624 | if 'mtd-static-alltar' in types: |
| 625 | bb.build.addtask( |
| 626 | 'do_generate_static_alltar', |
| 627 | 'do_image_complete', |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 628 | 'do_generate_static do_generate_phosphor_manifest', d) |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 629 | if 'mtd-static-tar' in types: |
| 630 | bb.build.addtask( |
| 631 | 'do_generate_static_tar', |
| 632 | 'do_image_complete', |
Lei YU | a467494 | 2018-05-23 14:01:14 +0800 | [diff] [blame] | 633 | 'do_generate_rwfs_static do_generate_phosphor_manifest', d) |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 634 | |
Patrick Williams | b9e124c | 2022-12-14 09:10:49 -0600 | [diff] [blame] | 635 | if 'mtd-static-norootfs' in types: |
| 636 | bb.build.addtask( |
| 637 | 'do_generate_static_norootfs', |
| 638 | 'do_image_complete', |
| 639 | 'do_image_cpio', d) |
| 640 | |
Brad Bishop | 3aa1ef6 | 2017-08-04 23:48:12 -0400 | [diff] [blame] | 641 | if 'mtd-ubi' in types: |
| 642 | bb.build.addtask( |
| 643 | 'do_generate_ubi', |
| 644 | 'do_image_complete', |
| 645 | 'do_generate_rwfs_ubi', d) |
| 646 | if 'mtd-ubi-tar' in types: |
| 647 | bb.build.addtask( |
| 648 | 'do_generate_ubi_tar', |
| 649 | 'do_image_complete', |
| 650 | 'do_generate_rwfs_ubi do_generate_phosphor_manifest', d) |
Adriana Kobylak | 9b7197e | 2019-07-29 15:25:33 -0500 | [diff] [blame] | 651 | |
| 652 | if 'mmc-ext4-tar' in types: |
| 653 | bb.build.addtask( |
| 654 | 'do_generate_ext4_tar', |
| 655 | 'do_image_complete', |
| 656 | 'do_generate_rwfs_ext4 do_generate_phosphor_manifest', d) |
Brad Bishop | 19fc4f8 | 2017-08-04 23:38:54 -0400 | [diff] [blame] | 657 | } |