Commit 4d73a26bba413bb0040283f37d2dd5928dc80b0d
1 parent
8cb9cd7e43
Exists in
smarc_8mq-imx_v2020.04_5.4.24_2.1.0
and in
1 other branch
MA-16594-1 Set dtb load offset in bootloader
We use the 'second_addr' in boot image header to store the fdt load address which is set by '--second_offset' parameter, but actually we don't pass any 'second' image to it. Now the mkbootimg.py will check the 'second' image size and set the 'second_addr' as 0x0 if no 'second' image is specified. Since we don't store dtbs in the boot.img (except recovery dtb for legacy platforms), so set the dtb load offset in bootloader. The dtb load address will be 'kernel_addr + FDT_OFFSET_TO_KERNEL' (48MB memory reserved). Test: Boots on imx8mq. Change-Id: Ie597731992107ec2343e5ab6db0cab0e123f009c Signed-off-by: Ji Luo <ji.luo@nxp.com> (cherry picked from commit efb9b0c9322f531c15ceedccd2fa9c6c170003a2)
Showing 1 changed file with 15 additions and 14 deletions Side-by-side Diff
drivers/fastboot/fb_fsl/fb_fsl_boot.c
... | ... | @@ -57,6 +57,8 @@ |
57 | 57 | #define ZIMAGE_START_ADDR 10 |
58 | 58 | #define ZIMAGE_END_ADDR 11 |
59 | 59 | |
60 | +#define FDT_OFFSET_TO_KERNEL 0x3000000 /* device tree blob offset to the kernel image */ | |
61 | + | |
60 | 62 | /* Boot metric variables */ |
61 | 63 | boot_metric metrics = { |
62 | 64 | .bll_1 = 0, |
63 | 65 | |
... | ... | @@ -737,10 +739,12 @@ |
737 | 739 | |
738 | 740 | #ifdef CONFIG_OF_LIBFDT |
739 | 741 | /* load the dtb file */ |
742 | + u32 fdt_addr = 0; | |
740 | 743 | u32 fdt_size = 0; |
741 | 744 | struct dt_table_header *dt_img = NULL; |
742 | 745 | |
743 | 746 | if (is_load_fdt_from_part()) { |
747 | + fdt_addr = (ulong)((ulong)(hdr->kernel_addr) + FDT_OFFSET_TO_KERNEL); | |
744 | 748 | #ifdef CONFIG_ANDROID_THINGS_SUPPORT |
745 | 749 | if (find_partition_data_by_name("oem_bootloader", |
746 | 750 | avb_out_data, &avb_loadpart)) { |
747 | 751 | |
748 | 752 | |
... | ... | @@ -785,15 +789,17 @@ |
785 | 789 | dt_entry = (struct dt_table_entry *)((ulong)dt_img + |
786 | 790 | be32_to_cpu(dt_img->dt_entries_offset)); |
787 | 791 | fdt_size = be32_to_cpu(dt_entry->dt_size); |
788 | - memcpy((void *)(ulong)hdr->second_addr, (void *)((ulong)dt_img + | |
792 | + memcpy((void *)fdt_addr, (void *)((ulong)dt_img + | |
789 | 793 | be32_to_cpu(dt_entry->dt_offset)), fdt_size); |
790 | 794 | } else { |
791 | - if (hdr->second_size && hdr->second_addr) { | |
792 | - memcpy((void *)(ulong)hdr->second_addr, | |
795 | + fdt_addr = (ulong)(hdr->second_addr); | |
796 | + fdt_size = (ulong)(hdr->second_size); | |
797 | + if (fdt_size && fdt_addr) { | |
798 | + memcpy((void *)(ulong)fdt_addr, | |
793 | 799 | (void *)(ulong)hdr + hdr->page_size |
794 | 800 | + ALIGN(hdr->kernel_size, hdr->page_size) |
795 | 801 | + ALIGN(hdr->ramdisk_size, hdr->page_size), |
796 | - hdr->second_size); | |
802 | + fdt_size); | |
797 | 803 | } |
798 | 804 | } |
799 | 805 | #endif /*CONFIG_OF_LIBFDT*/ |
800 | 806 | |
801 | 807 | |
... | ... | @@ -807,20 +813,15 @@ |
807 | 813 | printf("kernel @ %08x (%d)\n", hdr->kernel_addr, hdr->kernel_size); |
808 | 814 | printf("ramdisk @ %08x (%d)\n", hdr->ramdisk_addr, hdr->ramdisk_size); |
809 | 815 | #ifdef CONFIG_OF_LIBFDT |
810 | - if (is_load_fdt_from_part()) { | |
811 | - if (fdt_size) | |
812 | - printf("fdt @ %08x (%d)\n", hdr->second_addr, fdt_size); | |
813 | - } else { | |
814 | - if (hdr->second_size) | |
815 | - printf("fdt @ %08x (%d)\n", hdr->second_addr, hdr->second_size); | |
816 | - } | |
816 | + if (fdt_size) | |
817 | + printf("fdt @ %08x (%d)\n", fdt_addr, fdt_size); | |
817 | 818 | #endif /*CONFIG_OF_LIBFDT*/ |
818 | 819 | |
819 | 820 | char boot_addr_start[12]; |
820 | 821 | char ramdisk_addr[25]; |
821 | - char fdt_addr[12]; | |
822 | + char fdt_addr_start[12]; | |
822 | 823 | |
823 | - char *boot_args[] = { NULL, boot_addr_start, ramdisk_addr, fdt_addr}; | |
824 | + char *boot_args[] = { NULL, boot_addr_start, ramdisk_addr, fdt_addr_start}; | |
824 | 825 | if (check_image_arm64) |
825 | 826 | boot_args[0] = "booti"; |
826 | 827 | else |
... | ... | @@ -828,7 +829,7 @@ |
828 | 829 | |
829 | 830 | sprintf(boot_addr_start, "0x%lx", addr); |
830 | 831 | sprintf(ramdisk_addr, "0x%x:0x%x", hdr->ramdisk_addr, hdr->ramdisk_size); |
831 | - sprintf(fdt_addr, "0x%x", hdr->second_addr); | |
832 | + sprintf(fdt_addr_start, "0x%x", fdt_addr); | |
832 | 833 | |
833 | 834 | /* when CONFIG_SYSTEM_RAMDISK_SUPPORT is enabled and it's for Android Auto, if it's not recovery mode |
834 | 835 | * do not pass ramdisk addr*/ |