1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 #include <image-android-dt.h>
10 #include <android_image.h>
13 #include <asm/unaligned.h>
15 #include <linux/libfdt.h>
17 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000
19 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
21 static ulong checksum(const unsigned char *buffer, ulong size)
25 for (ulong i = 0; i < size; i++)
30 static bool is_trailer_present(ulong bootconfig_end_addr)
32 return !strncmp((char *)(bootconfig_end_addr - BOOTCONFIG_MAGIC_SIZE),
33 BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_SIZE);
36 static ulong add_trailer(ulong bootconfig_start_addr, ulong bootconfig_size)
41 if (!bootconfig_start_addr)
46 end = bootconfig_start_addr + bootconfig_size;
47 if (is_trailer_present(end))
50 memcpy((void *)(end), &bootconfig_size, BOOTCONFIG_SIZE_SIZE);
51 sum = checksum((unsigned char *)bootconfig_start_addr, bootconfig_size);
52 memcpy((void *)(end + BOOTCONFIG_SIZE_SIZE), &sum,
53 BOOTCONFIG_CHECKSUM_SIZE);
54 memcpy((void *)(end + BOOTCONFIG_SIZE_SIZE + BOOTCONFIG_CHECKSUM_SIZE),
55 BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_SIZE);
57 return BOOTCONFIG_TRAILER_SIZE;
60 static void android_boot_image_v3_v4_parse_hdr(const struct andr_boot_img_hdr_v3 *hdr,
61 struct andr_image_data *data)
65 data->kcmdline = hdr->cmdline;
66 data->header_version = hdr->header_version;
67 data->ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0);
70 * The header takes a full page, the remaining components are aligned
74 end += ANDR_GKI_PAGE_SIZE;
75 data->kernel_ptr = end;
76 data->kernel_size = hdr->kernel_size;
77 end += ALIGN(hdr->kernel_size, ANDR_GKI_PAGE_SIZE);
78 data->ramdisk_size = hdr->ramdisk_size;
79 data->boot_ramdisk_size = hdr->ramdisk_size;
80 end += ALIGN(hdr->ramdisk_size, ANDR_GKI_PAGE_SIZE);
82 if (hdr->header_version > 3)
83 end += ALIGN(hdr->signature_size, ANDR_GKI_PAGE_SIZE);
85 data->boot_img_total_size = end - (ulong)hdr;
88 static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vnd_boot_img_hdr
89 *hdr, struct andr_image_data *data)
94 * The header takes a full page, the remaining components are aligned
97 data->kcmdline_extra = hdr->cmdline;
98 data->tags_addr = hdr->tags_addr;
99 data->image_name = hdr->name;
100 data->kernel_addr = hdr->kernel_addr;
101 data->ramdisk_addr = hdr->ramdisk_addr;
102 data->dtb_load_addr = hdr->dtb_addr;
103 data->bootconfig_size = hdr->bootconfig_size;
105 end += hdr->page_size;
106 if (hdr->vendor_ramdisk_size) {
107 data->vendor_ramdisk_ptr = end;
108 data->vendor_ramdisk_size = hdr->vendor_ramdisk_size;
109 data->ramdisk_size += hdr->vendor_ramdisk_size;
110 end += ALIGN(hdr->vendor_ramdisk_size, hdr->page_size);
114 data->dtb_size = hdr->dtb_size;
116 end += ALIGN(hdr->dtb_size, hdr->page_size);
117 end += ALIGN(hdr->vendor_ramdisk_table_size, hdr->page_size);
118 data->bootconfig_addr = end;
119 if (hdr->bootconfig_size) {
120 data->bootconfig_size += add_trailer(data->bootconfig_addr,
121 data->bootconfig_size);
122 data->ramdisk_size += data->bootconfig_size;
124 end += ALIGN(data->bootconfig_size, hdr->page_size);
125 data->vendor_boot_img_total_size = end - (ulong)hdr;
128 static void android_boot_image_v0_v1_v2_parse_hdr(const struct andr_boot_img_hdr_v0 *hdr,
129 struct andr_image_data *data)
133 data->image_name = hdr->name;
134 data->kcmdline = hdr->cmdline;
135 data->kernel_addr = hdr->kernel_addr;
136 data->ramdisk_addr = hdr->ramdisk_addr;
137 data->header_version = hdr->header_version;
138 data->dtb_load_addr = hdr->dtb_addr;
143 * The header takes a full page, the remaining components are aligned
147 end += hdr->page_size;
149 data->kernel_ptr = end;
150 data->kernel_size = hdr->kernel_size;
151 end += ALIGN(hdr->kernel_size, hdr->page_size);
153 data->ramdisk_ptr = end;
154 data->ramdisk_size = hdr->ramdisk_size;
155 end += ALIGN(hdr->ramdisk_size, hdr->page_size);
157 data->second_ptr = end;
158 data->second_size = hdr->second_size;
159 end += ALIGN(hdr->second_size, hdr->page_size);
161 if (hdr->header_version >= 1) {
162 data->recovery_dtbo_ptr = end;
163 data->recovery_dtbo_size = hdr->recovery_dtbo_size;
164 end += ALIGN(hdr->recovery_dtbo_size, hdr->page_size);
167 if (hdr->header_version >= 2) {
169 data->dtb_size = hdr->dtb_size;
170 end += ALIGN(hdr->dtb_size, hdr->page_size);
173 data->boot_img_total_size = end - (ulong)hdr;
176 bool android_image_get_data(const void *boot_hdr, const void *vendor_boot_hdr,
177 struct andr_image_data *data)
179 if (!boot_hdr || !data) {
180 printf("boot_hdr or data params can't be NULL\n");
184 if (!is_android_boot_image_header(boot_hdr)) {
185 printf("Incorrect boot image header\n");
189 if (((struct andr_boot_img_hdr_v0 *)boot_hdr)->header_version > 2) {
190 if (!vendor_boot_hdr) {
191 printf("For boot header v3+ vendor boot image has to be provided\n");
194 if (!is_android_vendor_boot_image_header(vendor_boot_hdr)) {
195 printf("Incorrect vendor boot image header\n");
198 android_boot_image_v3_v4_parse_hdr(boot_hdr, data);
199 android_vendor_boot_image_v3_v4_parse_hdr(vendor_boot_hdr, data);
201 android_boot_image_v0_v1_v2_parse_hdr(boot_hdr, data);
207 static ulong android_image_get_kernel_addr(struct andr_image_data *img_data)
210 * All the Android tools that generate a boot.img use this
211 * address as the default.
213 * Even though it doesn't really make a lot of sense, and it
214 * might be valid on some platforms, we treat that adress as
215 * the default value for this field, and try to execute the
216 * kernel in place in such a case.
218 * Otherwise, we will return the actual value set by the user.
220 if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR)
221 return img_data->kernel_ptr;
224 * abootimg creates images where all load addresses are 0
225 * and we need to fix them.
227 if (img_data->kernel_addr == 0 && img_data->ramdisk_addr == 0)
228 return env_get_ulong("kernel_addr_r", 16, 0);
230 return img_data->kernel_addr;
234 * android_image_get_kernel() - processes kernel part of Android boot images
235 * @hdr: Pointer to boot image header, which is at the start
237 * @vendor_boot_img: Pointer to vendor boot image header, which is at the
238 * start of the image.
239 * @verify: Checksum verification flag. Currently unimplemented.
240 * @os_data: Pointer to a ulong variable, will hold os data start
242 * @os_len: Pointer to a ulong variable, will hold os data length.
244 * This function returns the os image's start address and length. Also,
245 * it appends the kernel command line to the bootargs env variable.
247 * Return: Zero, os start address and length on success,
248 * otherwise on failure.
250 int android_image_get_kernel(const void *hdr,
251 const void *vendor_boot_img, int verify,
252 ulong *os_data, ulong *os_len)
254 struct andr_image_data img_data = {0};
256 const struct legacy_img_hdr *ihdr;
258 if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
261 kernel_addr = android_image_get_kernel_addr(&img_data);
262 ihdr = (const struct legacy_img_hdr *)img_data.kernel_ptr;
265 * Not all Android tools use the id field for signing the image with
266 * sha1 (or anything) so we don't check it. It is not obvious that the
267 * string is null terminated so we take care of this.
269 strlcpy(andr_tmp_str, img_data.image_name, ANDR_BOOT_NAME_SIZE);
270 andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
271 if (strlen(andr_tmp_str))
272 printf("Android's image name: %s\n", andr_tmp_str);
274 printf("Kernel load addr 0x%08x size %u KiB\n",
275 kernel_addr, DIV_ROUND_UP(img_data.kernel_size, 1024));
278 if (*img_data.kcmdline) {
279 printf("Kernel command line: %s\n", img_data.kcmdline);
280 len += strlen(img_data.kcmdline);
283 if (img_data.kcmdline_extra) {
284 printf("Kernel extra command line: %s\n", img_data.kcmdline_extra);
285 len += strlen(img_data.kcmdline_extra);
288 char *bootargs = env_get("bootargs");
290 len += strlen(bootargs);
292 char *newbootargs = malloc(len + 2);
294 puts("Error: malloc in android_image_get_kernel failed!\n");
300 strcpy(newbootargs, bootargs);
301 strcat(newbootargs, " ");
304 if (*img_data.kcmdline)
305 strcat(newbootargs, img_data.kcmdline);
307 if (img_data.kcmdline_extra) {
308 strcat(newbootargs, " ");
309 strcat(newbootargs, img_data.kcmdline_extra);
312 env_set("bootargs", newbootargs);
315 if (image_get_magic(ihdr) == IH_MAGIC) {
316 *os_data = image_get_data(ihdr);
318 *os_data = img_data.kernel_ptr;
322 if (image_get_magic(ihdr) == IH_MAGIC)
323 *os_len = image_get_data_size(ihdr);
325 *os_len = img_data.kernel_size;
330 bool is_android_vendor_boot_image_header(const void *vendor_boot_img)
332 return !memcmp(VENDOR_BOOT_MAGIC, vendor_boot_img, ANDR_VENDOR_BOOT_MAGIC_SIZE);
335 bool is_android_boot_image_header(const void *hdr)
337 return !memcmp(ANDR_BOOT_MAGIC, hdr, ANDR_BOOT_MAGIC_SIZE);
340 ulong android_image_get_end(const struct andr_boot_img_hdr_v0 *hdr,
341 const void *vendor_boot_img)
343 struct andr_image_data img_data;
345 if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
348 if (img_data.header_version > 2)
351 return img_data.boot_img_total_size;
354 ulong android_image_get_kload(const void *hdr,
355 const void *vendor_boot_img)
357 struct andr_image_data img_data;
359 if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
362 return android_image_get_kernel_addr(&img_data);
365 ulong android_image_get_kcomp(const void *hdr,
366 const void *vendor_boot_img)
368 struct andr_image_data img_data;
371 if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
374 p = (const void *)img_data.kernel_ptr;
375 if (image_get_magic((struct legacy_img_hdr *)p) == IH_MAGIC)
376 return image_get_comp((struct legacy_img_hdr *)p);
377 else if (get_unaligned_le32(p) == LZ4F_MAGIC)
380 return image_decomp_type(p, sizeof(u32));
383 int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
384 ulong *rd_data, ulong *rd_len)
386 struct andr_image_data img_data = {0};
389 if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
392 if (!img_data.ramdisk_size) {
393 *rd_data = *rd_len = 0;
396 if (img_data.header_version > 2) {
397 ramdisk_ptr = img_data.ramdisk_ptr;
398 memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr,
399 img_data.vendor_ramdisk_size);
400 memcpy((void *)(ramdisk_ptr + img_data.vendor_ramdisk_size),
401 (void *)img_data.ramdisk_ptr,
402 img_data.boot_ramdisk_size);
403 if (img_data.bootconfig_size) {
405 (ramdisk_ptr + img_data.vendor_ramdisk_size +
406 img_data.boot_ramdisk_size),
407 (void *)img_data.bootconfig_addr,
408 img_data.bootconfig_size);
412 printf("RAM disk load addr 0x%08lx size %u KiB\n",
413 img_data.ramdisk_ptr, DIV_ROUND_UP(img_data.ramdisk_size, 1024));
415 *rd_data = img_data.ramdisk_ptr;
417 *rd_len = img_data.ramdisk_size;
421 int android_image_get_second(const void *hdr, ulong *second_data, ulong *second_len)
423 struct andr_image_data img_data;
425 if (!android_image_get_data(hdr, NULL, &img_data))
428 if (img_data.header_version > 2) {
429 printf("Second stage bootloader is only supported for boot image version <= 2\n");
433 if (!img_data.second_size) {
434 *second_data = *second_len = 0;
438 *second_data = img_data.second_ptr;
440 printf("second address is 0x%lx\n",*second_data);
442 *second_len = img_data.second_size;
447 * android_image_get_dtbo() - Get address and size of recovery DTBO image.
448 * @hdr_addr: Boot image header address
449 * @addr: If not NULL, will contain address of recovery DTBO image
450 * @size: If not NULL, will contain size of recovery DTBO image
452 * Get the address and size of DTBO image in "Recovery DTBO" area of Android
453 * Boot Image in RAM. The format of this image is Android DTBO (see
454 * corresponding "DTB/DTBO Partitions" AOSP documentation for details). Once
455 * the address is obtained from this function, one can use 'adtimg' U-Boot
456 * command or android_dt_*() functions to extract desired DTBO blob.
458 * This DTBO (included in boot image) is only needed for non-A/B devices, and it
459 * only can be found in recovery image. On A/B devices we can always rely on
460 * "dtbo" partition. See "Including DTBO in Recovery for Non-A/B Devices" in
461 * AOSP documentation for details.
463 * Return: true on success or false on error.
465 bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size)
467 const struct andr_boot_img_hdr_v0 *hdr;
471 hdr = map_sysmem(hdr_addr, sizeof(*hdr));
472 if (!is_android_boot_image_header(hdr)) {
473 printf("Error: Boot Image header is incorrect\n");
478 if (hdr->header_version != 1 && hdr->header_version != 2) {
479 printf("Error: header version must be >= 1 and <= 2 to get dtbo\n");
484 if (hdr->recovery_dtbo_size == 0) {
485 printf("Error: recovery_dtbo_size is 0\n");
490 /* Calculate the address of DTB area in boot image */
491 dtbo_img_addr = hdr_addr;
492 dtbo_img_addr += hdr->page_size;
493 dtbo_img_addr += ALIGN(hdr->kernel_size, hdr->page_size);
494 dtbo_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size);
495 dtbo_img_addr += ALIGN(hdr->second_size, hdr->page_size);
498 *addr = dtbo_img_addr;
500 *size = hdr->recovery_dtbo_size;
508 * android_image_get_dtb_img_addr() - Get the address of DTB area in boot image.
509 * @hdr_addr: Boot image header address
510 * @vhdr_addr: Vendor Boot image header address
511 * @addr: Will contain the address of DTB area in boot image
513 * Return: true on success or false on fail.
515 static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong vhdr_addr, ulong *addr)
517 const struct andr_boot_img_hdr_v0 *hdr;
518 const struct andr_vnd_boot_img_hdr *v_hdr;
522 hdr = map_sysmem(hdr_addr, sizeof(*hdr));
523 if (!is_android_boot_image_header(hdr)) {
524 printf("Error: Boot Image header is incorrect\n");
529 if (hdr->header_version < 2) {
530 printf("Error: header_version must be >= 2 to get dtb\n");
535 if (hdr->header_version == 2) {
536 if (!hdr->dtb_size) {
537 printf("Error: dtb_size is 0\n");
541 /* Calculate the address of DTB area in boot image */
542 dtb_img_addr = hdr_addr;
543 dtb_img_addr += hdr->page_size;
544 dtb_img_addr += ALIGN(hdr->kernel_size, hdr->page_size);
545 dtb_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size);
546 dtb_img_addr += ALIGN(hdr->second_size, hdr->page_size);
547 dtb_img_addr += ALIGN(hdr->recovery_dtbo_size, hdr->page_size);
549 *addr = dtb_img_addr;
552 if (hdr->header_version > 2) {
553 v_hdr = map_sysmem(vhdr_addr, sizeof(*v_hdr));
554 if (!v_hdr->dtb_size) {
555 printf("Error: dtb_size is 0\n");
560 /* Calculate the address of DTB area in boot image */
561 dtb_img_addr = vhdr_addr;
562 dtb_img_addr += v_hdr->page_size;
563 if (v_hdr->vendor_ramdisk_size)
564 dtb_img_addr += ALIGN(v_hdr->vendor_ramdisk_size, v_hdr->page_size);
565 *addr = dtb_img_addr;
575 * android_image_get_dtb_by_index() - Get address and size of blob in DTB area.
576 * @hdr_addr: Boot image header address
577 * @vendor_boot_img: Pointer to vendor boot image header, which is at the start of the image.
578 * @index: Index of desired DTB in DTB area (starting from 0)
579 * @addr: If not NULL, will contain address to specified DTB
580 * @size: If not NULL, will contain size of specified DTB
582 * Get the address and size of DTB blob by its index in DTB area of Android
585 * Return: true on success or false on error.
587 bool android_image_get_dtb_by_index(ulong hdr_addr, ulong vendor_boot_img,
588 u32 index, ulong *addr, u32 *size)
590 struct andr_image_data img_data;
591 const struct andr_boot_img_hdr_v0 *hdr;
592 const struct andr_vnd_boot_img_hdr *vhdr;
594 hdr = map_sysmem(hdr_addr, sizeof(*hdr));
595 if (vendor_boot_img != -1)
596 vhdr = map_sysmem(vendor_boot_img, sizeof(*vhdr));
597 if (!android_image_get_data(hdr, vhdr, &img_data)) {
598 if (vendor_boot_img != -1)
603 if (vendor_boot_img != -1)
607 ulong dtb_img_addr; /* address of DTB part in boot image */
608 u32 dtb_img_size; /* size of DTB payload in boot image */
609 ulong dtb_addr; /* address of DTB blob with specified index */
610 u32 i; /* index iterator */
612 android_image_get_dtb_img_addr(hdr_addr, vendor_boot_img, &dtb_img_addr);
613 /* Check if DTB area of boot image is in DTBO format */
614 if (android_dt_check_header(dtb_img_addr)) {
615 return android_dt_get_fdt_by_index(dtb_img_addr, index, addr,
619 /* Find out the address of DTB with specified index in concat blobs */
620 dtb_img_size = img_data.dtb_size;
622 dtb_addr = dtb_img_addr;
623 while (dtb_addr < dtb_img_addr + dtb_img_size) {
624 const struct fdt_header *fdt;
627 fdt = map_sysmem(dtb_addr, sizeof(*fdt));
628 if (fdt_check_header(fdt) != 0) {
630 printf("Error: Invalid FDT header for index %u\n", i);
634 dtb_size = fdt_totalsize(fdt);
645 dtb_addr += dtb_size;
649 printf("Error: Index is out of bounds (%u/%u)\n", index, i);
653 #if !defined(CONFIG_SPL_BUILD)
655 * android_print_contents - prints out the contents of the Android format image
656 * @hdr: pointer to the Android format image header
658 * android_print_contents() formats a multi line Android image contents
660 * The routine prints out Android image properties
663 * no returned results
665 void android_print_contents(const struct andr_boot_img_hdr_v0 *hdr)
667 if (hdr->header_version >= 3) {
668 printf("Content print is not supported for boot image header version > 2");
671 const char * const p = IMAGE_INDENT_STRING;
672 /* os_version = ver << 11 | lvl */
673 u32 os_ver = hdr->os_version >> 11;
674 u32 os_lvl = hdr->os_version & ((1U << 11) - 1);
676 printf("%skernel size: %x\n", p, hdr->kernel_size);
677 printf("%skernel address: %x\n", p, hdr->kernel_addr);
678 printf("%sramdisk size: %x\n", p, hdr->ramdisk_size);
679 printf("%sramdisk address: %x\n", p, hdr->ramdisk_addr);
680 printf("%ssecond size: %x\n", p, hdr->second_size);
681 printf("%ssecond address: %x\n", p, hdr->second_addr);
682 printf("%stags address: %x\n", p, hdr->tags_addr);
683 printf("%spage size: %x\n", p, hdr->page_size);
684 /* ver = A << 14 | B << 7 | C (7 bits for each of A, B, C)
685 * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M) */
686 printf("%sos_version: %x (ver: %u.%u.%u, level: %u.%u)\n",
688 (os_ver >> 7) & 0x7F, (os_ver >> 14) & 0x7F, os_ver & 0x7F,
689 (os_lvl >> 4) + 2000, os_lvl & 0x0F);
690 printf("%sname: %s\n", p, hdr->name);
691 printf("%scmdline: %s\n", p, hdr->cmdline);
692 printf("%sheader_version: %d\n", p, hdr->header_version);
694 if (hdr->header_version >= 1) {
695 printf("%srecovery dtbo size: %x\n", p,
696 hdr->recovery_dtbo_size);
697 printf("%srecovery dtbo offset: %llx\n", p,
698 hdr->recovery_dtbo_offset);
699 printf("%sheader size: %x\n", p,
703 if (hdr->header_version == 2) {
704 printf("%sdtb size: %x\n", p, hdr->dtb_size);
705 printf("%sdtb addr: %llx\n", p, hdr->dtb_addr);
710 * android_image_print_dtb_info - Print info for one DTB blob in DTB area.
712 * @index: Number of DTB blob in DTB area.
714 * Return: true on success or false on error.
716 static bool android_image_print_dtb_info(const struct fdt_header *fdt,
722 const char *compatible;
724 root_node_off = fdt_path_offset(fdt, "/");
725 if (root_node_off < 0) {
726 printf("Error: Root node not found\n");
730 fdt_size = fdt_totalsize(fdt);
731 compatible = fdt_getprop(fdt, root_node_off, "compatible",
733 model = fdt_getprop(fdt, root_node_off, "model", NULL);
735 printf(" - DTB #%u:\n", index);
736 printf(" (DTB)size = %d\n", fdt_size);
737 printf(" (DTB)model = %s\n", model ? model : "(unknown)");
738 printf(" (DTB)compatible = %s\n",
739 compatible ? compatible : "(unknown)");
745 * android_image_print_dtb_contents() - Print info for DTB blobs in DTB area.
746 * @hdr_addr: Boot image header address
748 * DTB payload in Android Boot Image v2+ can be in one of following formats:
749 * 1. Concatenated DTB blobs
750 * 2. Android DTBO format (see CONFIG_CMD_ADTIMG for details)
752 * This function does next:
753 * 1. Prints out the format used in DTB area
754 * 2. Iterates over all DTB blobs in DTB area and prints out the info for
757 * Return: true on success or false on error.
759 bool android_image_print_dtb_contents(ulong hdr_addr)
761 const struct andr_boot_img_hdr_v0 *hdr;
763 ulong dtb_img_addr; /* address of DTB part in boot image */
764 u32 dtb_img_size; /* size of DTB payload in boot image */
765 ulong dtb_addr; /* address of DTB blob with specified index */
766 u32 i; /* index iterator */
768 res = android_image_get_dtb_img_addr(hdr_addr, 0, &dtb_img_addr);
772 /* Check if DTB area of boot image is in DTBO format */
773 if (android_dt_check_header(dtb_img_addr)) {
774 printf("## DTB area contents (DTBO format):\n");
775 android_dt_print_contents(dtb_img_addr);
779 printf("## DTB area contents (concat format):\n");
781 /* Iterate over concatenated DTB blobs */
782 hdr = map_sysmem(hdr_addr, sizeof(*hdr));
783 dtb_img_size = hdr->dtb_size;
786 dtb_addr = dtb_img_addr;
787 while (dtb_addr < dtb_img_addr + dtb_img_size) {
788 const struct fdt_header *fdt;
791 fdt = map_sysmem(dtb_addr, sizeof(*fdt));
792 if (fdt_check_header(fdt) != 0) {
794 printf("Error: Invalid FDT header for index %u\n", i);
798 res = android_image_print_dtb_info(fdt, i);
804 dtb_size = fdt_totalsize(fdt);
806 dtb_addr += dtb_size;