We call crypto to verify dtb alone, so move the crypto_sha_init()
after load IMG_RK_DTB when begin another hash verification.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I12f36172a5d03fa8baa0236503be5627fa18adf0
if not set ctx.length, you will get zero length hash value.
Change-Id: I9e653c845a36b4caea986c328c48ea8b2835da75
Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
Android Header v3 and vendor boot partition are introduced
from Android-11(R).
Header populate:
Header v3 is no longer compatible with v0/1/2 header, we
add populate_andr_img_hdr() to merge boot and vendor_boot
partition header into struct andr_img_hdr in order to
compatible with v0/1/2 header.
resource.img:
The second_addr and second_size fields are removed in v3,
so we require resource partition to restore resource.img.
A/B system:
If not A/B system, the boot.img header version is 3 and
recovery header is version 2.
AVB load image:
- If allow verification error: the image is loaded by
ops->get_preloaded_partition() which auto populates
boot_img_hdr_v3.
- If not allow verification error: the image is full loaded
by ops->read_from_partition() which doesn't populate
boot_img_hdr_v3, we need to fix it.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2afce53c43d782fc57baa01acf9c05518b580840
The page size should be reserved before kernel load address.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Iaa13fbc9a7a2872c5fb32a388ce96dd94654fc3d
blk_read() may return error code if image size is 0, it depends
on block layer implementation.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I29bab10835e9029780a957e871a600a6fbdf6068
Unify single image load/memcpy to image_read(), containing
sha1 update.
Not support verify image by RK legacy mkbootimg tools.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Ide88d2dda79f3335a6c34e41bdce56eac0d66408
Since this feature is stable and helpful to save boot time,
let't make it mandory.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I36f244c6d319d6b54ed3d54730352c8d5b4cc6bd
Rockchip platforms defines BCB message at the 16KB offset of
misc partition while the Google defines it at 0x0 offset.
From Android-Q, the 0x0 offset is mandary on Google VTS.
Change-Id: Iac36d421ed605684353c30bfe0e9982bdd5de065
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This issue happens on the SDK version < 8.1. The reason is we don't
read enough blocks from storage for kernel compressed type validation.
ANDROID_ROCKCHIP_LEGACY_PAGE_SIZE(16KB) is defined by rockchip legacy
mkboot tool(SDK version < 8.1) and larger than Google defined.
To compatible this, we malloc enough buffer but only read android
header and kernel image(1 block) from storage.
Change-Id: I9800e4150985adcd5dbd78c28c471604eb403eae
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
- mkbootimg tool always use SHA1 for images;
- make the the crypto higher priority;
- AVB images does not need this verify;
Change-Id: I543a3a53da61b920b83ba464a71959518437c436
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This is a encapsulation of android_image_load_separate(). It is used
for AVB boot/recovery.img which has been loaded to ram by AVB bootflow,
and we memcpy kernel/ramdisk/dtb to where we expect.
Change-Id: Iea4ea3404b84e9d3c091954ab27fb8c9d2ad84bc
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
The fdt load addr doesn't make any sense from android hdr,
and it's easy to make user to be confused with "fdt_addr_r".
Change-Id: I20c9047a1a3cef6987d3a1a1c85b6a0f3af15ad2
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
The hdr->page_size should be included.
fixes: 503a892f5a
(common: android: avb support load android image separate)
Change-Id: I2de2c9957fd47c7f95bf863f7b0c679cc64633d9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Skip fdt and ramdisk relocation to save boot time.
Change-Id: I56fd2fca97fa7795024aa542f0a45d0512be01d4
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
android_image_parse_kernel_comp() doesn't return valid os
compressed type after android_image_set_kload(), so we add
the env "os_comp" to record compressed type.
Change-Id: Ie175649d348c0578ce78e139bdbbf4b6f9ea1101
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
If there is not "kernel_addr_c", using "kernel_addr_r" for Image/zImage
on 32-bit platform.
If there is not "kernel_addr_c", adjust load address to promise compressed
kernel can normal boot on 64-bit platform.
Change-Id: I42cc3c9074eb8f1caaa44d9256d2abdae6cd97b8
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
- import memblk id to manage memory blocks;
- change "sysmem_property" to generic "memblock";
- use alloc instead of reserve for all memory blocks;
- clean up and fix some logic;
- add U-Boot cmd for sysmem;
Change-Id: I614223ce3bf97a7b3566412a9d1864fb30b68fd8
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Sometimes, framework or user would call fdt_increase_size() to update
fdt size, it's better reserve more space to avoid sysmem gives the fdt
region overflow report.
The CONFIG_SYS_FDT_PAD default value is sync with bootm framework
in: common/image-fdt.c
Change-Id: I363e9a4182e13b1628a76666acd8272d25db659d
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
- add interface to get android avb enable state;
- get ramdisk from "ramdisk_addr_r" only when android avb disabled
and CONFIG_ANDROID_BOOT_IMAGE_SEPARATE is enabled;
(fixes: 644e344 android: support loading android image separate)
Change-Id: I7280f911a0c5db851d119acb458b3f335dc28bce
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This patch support loading android image separate for the
kernel/ramdisk/second images. It is disabled when android
AVB is enabled, because AVB need verify the full android image.
It brings some benefits, mainly for saving a lot of boot time:
- allow skip load second content when kernel dtb is enabled;
- allow skip fdt and ramdisk relocation during bootm boot flow;
- allow loading fdt/ramdisk to "fdt_addr_r"/"ramdisk_addr_r";
- avoid android image too large when load to ram;
Change-Id: Ia040b3031307a8a7c98b011ce038ec61fee6804a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
this patch fixes zboot.img boot up failed due to getting kernel
compress type failed(reading IH_COMP_NONE).
we need to read a few kernel image info, i.e. compress type.
Assume 2 blocks maybe enough.
fixes: ee465021fe
(android: support boot images packed with rockchip android hdr)
Change-Id: I140832a899102984aebaad160a3902cfc483bfeb
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
For some legacy reasons, rockchip use mkbootimg tool to pack android
images with special pack parameters(SDK version lower than 8.1) to
assign kernel/ramdisk/seconds address and page size.
Android hdr on RK3399 SDK-7.1:
kernel size: 1299808
kernel address: 60408000
ramdisk size: 1e6b80
ramdisk addrress: 62000000
second size: 41c00
second address: 60f00000
tags address: 60088000
page size: 4000
header_version: 0
os_version: e041114 (ver: 1.7.2, level: 2017.4)
name:
cmdline: buildvariant=userdebug
The kernel/ramdisk/seconds address base is not from 0x10000000 and
page size is not 0x800!
This patch makes bootflow to compatible with above legacy packing.
Change-Id: I663a0d1386694658c97586706ff21ed887d6a2e7
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
We may have special operations for fdt(optional):
- apply fdt overlay;
- select fdt by adc or gpio;
We can't read default rk-kernel.dtb and pass it to kernel,
call rockchip_read_dtb_file() to get dtb.
Change-Id: I3aba002b0cfe324cc7c3852bf8b9561575590fd4
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
- read dtbo from recovery or dtbo partition;
- append "androidboot.dtbo_idx" to cmdline;
- apply dtb overlay when first read kernel dtb;
- pass dtb that first time read to kernel;
Change-Id: Iba5c02c1307d3dad69ef96d3b3b0927fb507be8f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
We shouldn't go on with the compress/decompress flow
when we get a invalid andoird image.
Change-Id: Ied7266b8791fe571c670cacafffdd393161c8189
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
This patch add auto parse the compress format of kernel image.
Then decompress the compressed kernel image for arm64, as for
arm32 zImage, we only need to load it to a higher memory, then
the kernel will handle the decompress itself.
Test on RK3308 AARCH64 mode (Cortex A35 816 MHZ) boot with eMMC:
------------------------------------------------------------------
Format | Size(Byte) | Ratio | Decomp time(ms) | Boot time(ms) |
-------------------------------------------------------------------
Image | 7720968 | | | 488 |
-------------------------------------------------------------------
Image.lz4 | 4119448 | 53% | 59 | 455 |
-------------------------------------------------------------------
Image.lzo | 3858322 | 49% | 141 | 536 |
-------------------------------------------------------------------
Image.gz | 3529108 | 45% | 222 | 609 |
-------------------------------------------------------------------
Image.bz2 | 3295914 | 42% | 2940 | |
-------------------------------------------------------------------
Image.lzma| 2683750 | 34% | | |
-------------------------------------------------------------------
Note: the boot time is counted from first ddr init log to first Kernel log.
Change-Id: I73b12ec944fbc8238b0e061a37e2f31aa3093231
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Get the dtb file from boot img second position or inside resource for
Rockchip image.
Change-Id: I843366b32f79ea8fb320d695d79420607a496d68
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This patch moves the Android Image loading logic from the load_android
command to a new android_load_image() function in image-android.c so it
can be re-used from other commands.
Bug: 32707546
Test: Booted the rpi3 with this patch.
Signed-off-by: Alex Deymo <deymo@google.com>
Change-Id: I12d206141ead1b94ebbcc90ee05512a276c7595a