Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1 | inherit kernel-uboot uboot-sign |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2 | |
| 3 | python __anonymous () { |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 4 | kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or "" |
| 5 | if 'fitImage' in kerneltypes.split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | depends = d.getVar("DEPENDS", True) |
| 7 | depends = "%s u-boot-mkimage-native dtc-native" % depends |
| 8 | d.setVar("DEPENDS", depends) |
| 9 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 10 | if d.getVar("UBOOT_ARCH", True) == "x86": |
| 11 | replacementtype = "bzImage" |
| 12 | else: |
| 13 | replacementtype = "zImage" |
| 14 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal |
| 16 | # to kernel.bbclass . We have to override it, since we pack zImage |
| 17 | # (at least for now) into the fitImage . |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 18 | typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or "" |
| 19 | if 'fitImage' in typeformake.split(): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 20 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', replacementtype)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | |
| 22 | image = d.getVar('INITRAMFS_IMAGE', True) |
| 23 | if image: |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 24 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') |
| 25 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 26 | # Verified boot will sign the fitImage and append the public key to |
| 27 | # U-boot dtb. We ensure the U-Boot dtb is deployed before assembling |
| 28 | # the fitImage: |
| 29 | if d.getVar('UBOOT_SIGN_ENABLE', True): |
| 30 | uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot', True) or 'u-boot' |
| 31 | d.appendVarFlag('do_assemble_fitimage', 'depends', ' %s:do_deploy' % uboot_pn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | } |
| 33 | |
Yannick Gicquel | d5813b4 | 2016-04-27 16:20:55 +0200 | [diff] [blame] | 34 | # Options for the device tree compiler passed to mkimage '-D' feature: |
| 35 | UBOOT_MKIMAGE_DTCOPTS ??= "" |
| 36 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | # |
| 38 | # Emit the fitImage ITS header |
| 39 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 40 | # $1 ... .its filename |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | fitimage_emit_fit_header() { |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 42 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 | /dts-v1/; |
| 44 | |
| 45 | / { |
| 46 | description = "U-Boot fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}"; |
| 47 | #address-cells = <1>; |
| 48 | EOF |
| 49 | } |
| 50 | |
| 51 | # |
| 52 | # Emit the fitImage section bits |
| 53 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 54 | # $1 ... .its filename |
| 55 | # $2 ... Section bit type: imagestart - image section start |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | # confstart - configuration section start |
| 57 | # sectend - section end |
| 58 | # fitend - fitimage end |
| 59 | # |
| 60 | fitimage_emit_section_maint() { |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 61 | case $2 in |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | imagestart) |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 63 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | |
| 65 | images { |
| 66 | EOF |
| 67 | ;; |
| 68 | confstart) |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 69 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | |
| 71 | configurations { |
| 72 | EOF |
| 73 | ;; |
| 74 | sectend) |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 75 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | }; |
| 77 | EOF |
| 78 | ;; |
| 79 | fitend) |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 80 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | }; |
| 82 | EOF |
| 83 | ;; |
| 84 | esac |
| 85 | } |
| 86 | |
| 87 | # |
| 88 | # Emit the fitImage ITS kernel section |
| 89 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 90 | # $1 ... .its filename |
| 91 | # $2 ... Image counter |
| 92 | # $3 ... Path to kernel image |
| 93 | # $4 ... Compression type |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | fitimage_emit_section_kernel() { |
| 95 | |
| 96 | kernel_csum="sha1" |
| 97 | |
| 98 | ENTRYPOINT=${UBOOT_ENTRYPOINT} |
| 99 | if test -n "${UBOOT_ENTRYSYMBOL}"; then |
| 100 | ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \ |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 101 | awk '$4=="${UBOOT_ENTRYSYMBOL}" {print $2}'` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 102 | fi |
| 103 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 104 | cat << EOF >> ${1} |
| 105 | kernel@${2} { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 106 | description = "Linux kernel"; |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 107 | data = /incbin/("${3}"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | type = "kernel"; |
| 109 | arch = "${UBOOT_ARCH}"; |
| 110 | os = "linux"; |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 111 | compression = "${4}"; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 | load = <${UBOOT_LOADADDRESS}>; |
| 113 | entry = <${ENTRYPOINT}>; |
| 114 | hash@1 { |
| 115 | algo = "${kernel_csum}"; |
| 116 | }; |
| 117 | }; |
| 118 | EOF |
| 119 | } |
| 120 | |
| 121 | # |
| 122 | # Emit the fitImage ITS DTB section |
| 123 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 124 | # $1 ... .its filename |
| 125 | # $2 ... Image counter |
| 126 | # $3 ... Path to DTB image |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 127 | fitimage_emit_section_dtb() { |
| 128 | |
| 129 | dtb_csum="sha1" |
| 130 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 131 | cat << EOF >> ${1} |
| 132 | fdt@${2} { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 133 | description = "Flattened Device Tree blob"; |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 134 | data = /incbin/("${3}"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 135 | type = "flat_dt"; |
| 136 | arch = "${UBOOT_ARCH}"; |
| 137 | compression = "none"; |
| 138 | hash@1 { |
| 139 | algo = "${dtb_csum}"; |
| 140 | }; |
| 141 | }; |
| 142 | EOF |
| 143 | } |
| 144 | |
| 145 | # |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 146 | # Emit the fitImage ITS setup section |
| 147 | # |
| 148 | # $1 ... .its filename |
| 149 | # $2 ... Image counter |
| 150 | # $3 ... Path to setup image |
| 151 | fitimage_emit_section_setup() { |
| 152 | |
| 153 | setup_csum="sha1" |
| 154 | |
| 155 | cat << EOF >> ${1} |
| 156 | setup@${2} { |
| 157 | description = "Linux setup.bin"; |
| 158 | data = /incbin/("${3}"); |
| 159 | type = "x86_setup"; |
| 160 | arch = "${UBOOT_ARCH}"; |
| 161 | os = "linux"; |
| 162 | compression = "none"; |
| 163 | load = <0x00090000>; |
| 164 | entry = <0x00090000>; |
| 165 | hash@1 { |
| 166 | algo = "${setup_csum}"; |
| 167 | }; |
| 168 | }; |
| 169 | EOF |
| 170 | } |
| 171 | |
| 172 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 173 | # Emit the fitImage ITS ramdisk section |
| 174 | # |
| 175 | # $1 ... .its filename |
| 176 | # $2 ... Image counter |
| 177 | # $3 ... Path to ramdisk image |
| 178 | fitimage_emit_section_ramdisk() { |
| 179 | |
| 180 | ramdisk_csum="sha1" |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 181 | ramdisk_ctype="none" |
Nathan Rossi | b4a4dc0 | 2016-10-21 22:07:27 +1000 | [diff] [blame] | 182 | ramdisk_loadline="" |
| 183 | ramdisk_entryline="" |
| 184 | |
| 185 | if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then |
| 186 | ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;" |
| 187 | fi |
| 188 | if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then |
| 189 | ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;" |
| 190 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 191 | |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 192 | case $3 in |
| 193 | *.gz) |
| 194 | ramdisk_ctype="gzip" |
| 195 | ;; |
| 196 | *.bz2) |
| 197 | ramdisk_ctype="bzip2" |
| 198 | ;; |
| 199 | *.lzma) |
| 200 | ramdisk_ctype="lzma" |
| 201 | ;; |
| 202 | *.lzo) |
| 203 | ramdisk_ctype="lzo" |
| 204 | ;; |
| 205 | *.lz4) |
| 206 | ramdisk_ctype="lz4" |
| 207 | ;; |
| 208 | esac |
| 209 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 210 | cat << EOF >> ${1} |
| 211 | ramdisk@${2} { |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 212 | description = "${INITRAMFS_IMAGE}"; |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 213 | data = /incbin/("${3}"); |
| 214 | type = "ramdisk"; |
| 215 | arch = "${UBOOT_ARCH}"; |
| 216 | os = "linux"; |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 217 | compression = "${ramdisk_ctype}"; |
Nathan Rossi | b4a4dc0 | 2016-10-21 22:07:27 +1000 | [diff] [blame] | 218 | ${ramdisk_loadline} |
| 219 | ${ramdisk_entryline} |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 220 | hash@1 { |
| 221 | algo = "${ramdisk_csum}"; |
| 222 | }; |
| 223 | }; |
| 224 | EOF |
| 225 | } |
| 226 | |
| 227 | # |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | # Emit the fitImage ITS configuration section |
| 229 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 230 | # $1 ... .its filename |
| 231 | # $2 ... Linux kernel ID |
| 232 | # $3 ... DTB image ID |
| 233 | # $4 ... ramdisk ID |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 234 | # $5 ... config ID |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 235 | fitimage_emit_section_config() { |
| 236 | |
| 237 | conf_csum="sha1" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 238 | if [ -n "${UBOOT_SIGN_ENABLE}" ] ; then |
| 239 | conf_sign_keyname="${UBOOT_SIGN_KEYNAME}" |
| 240 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | |
| 242 | # Test if we have any DTBs at all |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 243 | conf_desc="Linux kernel" |
| 244 | kernel_line="kernel = \"kernel@${2}\";" |
| 245 | fdt_line="" |
| 246 | ramdisk_line="" |
| 247 | |
| 248 | if [ -n "${3}" ]; then |
| 249 | conf_desc="${conf_desc}, FDT blob" |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 250 | fdt_line="fdt = \"fdt@${3}\";" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 251 | fi |
| 252 | |
| 253 | if [ -n "${4}" ]; then |
| 254 | conf_desc="${conf_desc}, ramdisk" |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 255 | ramdisk_line="ramdisk = \"ramdisk@${4}\";" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 256 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 257 | |
| 258 | if [ -n "${5}" ]; then |
| 259 | conf_desc="${conf_desc}, setup" |
| 260 | setup_line="setup = \"setup@${5}\";" |
| 261 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 262 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 263 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 264 | default = "conf@1"; |
| 265 | conf@1 { |
| 266 | description = "${conf_desc}"; |
| 267 | ${kernel_line} |
| 268 | ${fdt_line} |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 269 | ${ramdisk_line} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 270 | ${setup_line} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 271 | hash@1 { |
| 272 | algo = "${conf_csum}"; |
| 273 | }; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 274 | EOF |
| 275 | |
| 276 | if [ ! -z "${conf_sign_keyname}" ] ; then |
| 277 | |
| 278 | sign_line="sign-images = \"kernel\"" |
| 279 | |
| 280 | if [ -n "${3}" ]; then |
| 281 | sign_line="${sign_line}, \"fdt\"" |
| 282 | fi |
| 283 | |
| 284 | if [ -n "${4}" ]; then |
| 285 | sign_line="${sign_line}, \"ramdisk\"" |
| 286 | fi |
| 287 | |
| 288 | if [ -n "${5}" ]; then |
| 289 | sign_line="${sign_line}, \"setup\"" |
| 290 | fi |
| 291 | |
| 292 | sign_line="${sign_line};" |
| 293 | |
| 294 | cat << EOF >> ${1} |
| 295 | signature@1 { |
| 296 | algo = "${conf_csum},rsa2048"; |
| 297 | key-name-hint = "${conf_sign_keyname}"; |
| 298 | ${sign_line} |
| 299 | }; |
| 300 | EOF |
| 301 | fi |
| 302 | |
| 303 | cat << EOF >> ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | }; |
| 305 | EOF |
| 306 | } |
| 307 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 308 | # |
| 309 | # Assemble fitImage |
| 310 | # |
| 311 | # $1 ... .its filename |
| 312 | # $2 ... fitImage name |
| 313 | # $3 ... include ramdisk |
| 314 | fitimage_assemble() { |
| 315 | kernelcount=1 |
| 316 | dtbcount="" |
| 317 | ramdiskcount=${3} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 318 | setupcount="" |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 319 | rm -f ${1} arch/${ARCH}/boot/${2} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 320 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 321 | fitimage_emit_fit_header ${1} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 322 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 323 | # |
| 324 | # Step 1: Prepare a kernel image section. |
| 325 | # |
| 326 | fitimage_emit_section_maint ${1} imagestart |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 327 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 328 | uboot_prep_kimage |
| 329 | fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 330 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 331 | # |
| 332 | # Step 2: Prepare a DTB image section |
| 333 | # |
| 334 | if test -n "${KERNEL_DEVICETREE}"; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 335 | dtbcount=1 |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 336 | for DTB in ${KERNEL_DEVICETREE}; do |
| 337 | if echo ${DTB} | grep -q '/dts/'; then |
| 338 | bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." |
| 339 | DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` |
| 340 | fi |
| 341 | DTB_PATH="arch/${ARCH}/boot/dts/${DTB}" |
| 342 | if [ ! -e "${DTB_PATH}" ]; then |
| 343 | DTB_PATH="arch/${ARCH}/boot/${DTB}" |
| 344 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 345 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 346 | fitimage_emit_section_dtb ${1} ${dtbcount} ${DTB_PATH} |
| 347 | dtbcount=`expr ${dtbcount} + 1` |
| 348 | done |
| 349 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 350 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 351 | # |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 352 | # Step 3: Prepare a setup section. (For x86) |
| 353 | # |
| 354 | if test -e arch/${ARCH}/boot/setup.bin ; then |
| 355 | setupcount=1 |
| 356 | fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin |
| 357 | fi |
| 358 | |
| 359 | # |
| 360 | # Step 4: Prepare a ramdisk section. |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 361 | # |
| 362 | if [ "x${ramdiskcount}" = "x1" ] ; then |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 363 | # Find and use the first initramfs image archive type we find |
| 364 | for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.gz cpio; do |
| 365 | initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${img}" |
| 366 | echo "Using $initramfs_path" |
| 367 | if [ -e "${initramfs_path}" ]; then |
| 368 | fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}" |
| 369 | break |
| 370 | fi |
| 371 | done |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 372 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 373 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 374 | fitimage_emit_section_maint ${1} sectend |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 375 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 376 | # Force the first Kernel and DTB in the default config |
| 377 | kernelcount=1 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 378 | if test -n "${dtbcount}"; then |
| 379 | dtbcount=1 |
| 380 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 381 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 382 | # |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 383 | # Step 5: Prepare a configurations section |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 384 | # |
| 385 | fitimage_emit_section_maint ${1} confstart |
| 386 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 387 | fitimage_emit_section_config ${1} "${kernelcount}" "${dtbcount}" "${ramdiskcount}" "${setupcount}" |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 388 | |
| 389 | fitimage_emit_section_maint ${1} sectend |
| 390 | |
| 391 | fitimage_emit_section_maint ${1} fitend |
| 392 | |
| 393 | # |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 394 | # Step 6: Assemble the image |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 395 | # |
| 396 | uboot-mkimage \ |
| 397 | ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ |
| 398 | -f ${1} \ |
| 399 | arch/${ARCH}/boot/${2} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 400 | |
| 401 | # |
| 402 | # Step 7: Sign the image and add public key to U-Boot dtb |
| 403 | # |
| 404 | if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then |
| 405 | uboot-mkimage \ |
| 406 | ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ |
| 407 | -F -k "${UBOOT_SIGN_KEYDIR}" \ |
| 408 | -K "${DEPLOY_DIR_IMAGE}/${UBOOT_DTB_BINARY}" \ |
| 409 | -r arch/${ARCH}/boot/${2} |
| 410 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | do_assemble_fitimage() { |
| 414 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then |
| 415 | cd ${B} |
| 416 | fitimage_assemble fit-image.its fitImage |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 417 | fi |
| 418 | } |
| 419 | |
| 420 | addtask assemble_fitimage before do_install after do_compile |
| 421 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 422 | do_assemble_fitimage_initramfs() { |
| 423 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \ |
| 424 | test -n "${INITRAMFS_IMAGE}" ; then |
| 425 | cd ${B} |
| 426 | fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-${INITRAMFS_IMAGE} 1 |
| 427 | fi |
| 428 | } |
| 429 | |
| 430 | addtask assemble_fitimage_initramfs before do_deploy after do_install |
| 431 | |
| 432 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 433 | kernel_do_deploy[vardepsexclude] = "DATETIME" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 434 | kernel_do_deploy_append() { |
| 435 | # Update deploy directory |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 436 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 437 | cd ${B} |
| 438 | echo "Copying fit-image.its source file..." |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 439 | its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}" |
| 440 | its_symlink_name=fitImage-its-${MACHINE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 441 | install -m 0644 fit-image.its ${DEPLOYDIR}/${its_base_name}.its |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 442 | linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}" |
| 443 | linux_bin_symlink_name=fitImage-linux.bin-${MACHINE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 444 | install -m 0644 linux.bin ${DEPLOYDIR}/${linux_bin_base_name}.bin |
| 445 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 446 | if [ -n "${INITRAMFS_IMAGE}" ]; then |
| 447 | echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." |
Nathan Rossi | 578589a | 2016-10-21 22:07:28 +1000 | [diff] [blame] | 448 | its_initramfs_base_name="fitImage-its-${INITRAMFS_IMAGE}-${PV}-${PR}-${MACHINE}-${DATETIME}" |
| 449 | its_initramfs_symlink_name=fitImage-its-${INITRAMFS_IMAGE}-${MACHINE} |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 450 | install -m 0644 fit-image-${INITRAMFS_IMAGE}.its ${DEPLOYDIR}/${its_initramfs_base_name}.its |
Nathan Rossi | 578589a | 2016-10-21 22:07:28 +1000 | [diff] [blame] | 451 | fit_initramfs_base_name="fitImage-${INITRAMFS_IMAGE}-${PV}-${PR}-${MACHINE}-${DATETIME}" |
| 452 | fit_initramfs_symlink_name=fitImage-${INITRAMFS_IMAGE}-${MACHINE} |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 453 | install -m 0644 arch/${ARCH}/boot/fitImage-${INITRAMFS_IMAGE} ${DEPLOYDIR}/${fit_initramfs_base_name}.bin |
| 454 | fi |
| 455 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 456 | cd ${DEPLOYDIR} |
| 457 | ln -sf ${its_base_name}.its ${its_symlink_name}.its |
| 458 | ln -sf ${linux_bin_base_name}.bin ${linux_bin_symlink_name}.bin |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 459 | |
| 460 | if [ -n "${INITRAMFS_IMAGE}" ]; then |
| 461 | ln -sf ${its_initramfs_base_name}.its ${its_initramfs_symlink_name}.its |
| 462 | ln -sf ${fit_initramfs_base_name}.bin ${fit_initramfs_symlink_name}.bin |
| 463 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 464 | fi |
| 465 | } |