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
We are now using an env_ prefix for environment functions. Rename these
two functions for consistency. Also add function comments in common.h.
Quite a few places use getenv() in a condition context, provoking a
warning from checkpatch. These are fixed up in this patch also.
Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
We are now using an env_ prefix for environment functions. Rename setenv()
for consistency. Also add function comments in common.h.
Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Update the Android image header format to the latest version published
in AOSP. The original code moved to a new repository, so this patch also
updates the reference to that path.
Signed-off-by: Alex Deymo <deymo@google.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
We already support iminfo for other images. The idea
of this patch is start to have a minimal support for
android image format. We still need to print id[] array
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
If an Android boot image does not contain a ramdisk, make sure rd_len
and rd_data are returned to indicate no ramdisk rather than just relying
on returning an error.
Signed-off-by: Rob Herring <robh@kernel.org>
The two tools that create android boot images, mkbootimg and the fastboot
client, set the kernel address by default to 0x10008000.
U-boot always honors this field, and will try to relocate the kernel to
whatever value is set in the header, which won't be mapped to the actual RAM on
most platforms, resulting in the kernel obviously not booting.
All the targets in U-Boot right now will download the android boot image to
CONFIG_SYS_LOAD_ADDR, which means that it will already have been downloaded to
some location that is suitable for execution.
In order to have the kernel booting even with the default boot image kernel
address, if that address is used, just execute the kernel where it is.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
This patch makes the following changes:
- Set kernel entry point correctly
- Append bootargs from image to global bootargs instead
of replacing them
- Return end address instead of size from android_image_get_end()
- Give correct parameter to genimg_get_format() in boot_get_ramdisk()
- Move ramdisk message printing from android_image_get_kernel() to
android_image_get_ramdisk()
Signed-off-by: Ahmad Draidi <ar2000jp@gmail.com>
Cc: Tom Rini <trini@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This patch adds support for the Android boot-image format. The header
file is from the Android project and got slightly alterted so the struct +
its defines are not generic but have something like a namespace. The
header file is from bootloader/legacy/include/boot/bootimg.h. The header
parsing has been written from scratch and I looked at
bootloader/legacy/usbloader/usbloader.c for some details.
The image contains the physical address (load address) of the kernel and
ramdisk. This address is considered only for the kernel image.
The "second image" defined in the image header is currently not
supported. I haven't found anything that is creating this.
v3 (Rob Herring):
This is based on http://patchwork.ozlabs.org/patch/126797/ with the
following changes:
- Rebased to current mainline
- Moved android image handling to separate functions in
common/image-android.c
- s/u8/char/ in header to fix string function warnings
- Use SPDX identifiers for licenses
- Cleaned-up file source information:
android_image.h is from file include/boot/bootimg.h in repository:
https://android.googlesource.com/platform/bootable/bootloader/legacy
The git commit hash is 4205b865141ff2e255fe1d3bd16de18e217ef06a
usbloader.c would be from the same commit, but it does not appear
to have been used for any actual code.
v4:
- s/andriod/android/
- Use a separate flag ep_found to track if the entry point has been set
rather than using a magic value.
Cc: Wolfgang Denk <wd@denx.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Tom Rini <trini@ti.com>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>