Hi Roman, On ven., avril 07, 2023 at 11:56, Roman Stratiienko <r.stratiie...@gmail.com> wrote:
> Hi guys, > > I rebased on uboot/master and all is working for me except for the Thanks a lot for confirming that things work for you. > boot image ramdisk concatenation. > Current memcpy logic overwrites its context. Please find a fix that > works for me here: > https://github.com/GloDroidCommunity/raspberry-pi/blob/151fae1c7ddb7d347034dd135631f8f7075c7968/patches-aosp/glodroid/bootloader/u-boot/0006-android-Fix-ramdisk-loading-for-bootimage-v3.patch Thanks as well for reporting this problem. I did not observe any problems with the ramdisk concatenation when I tested on a TI AM62x evk board with these: * https://gitlab.baylibre.com/baylibre/ti/android/aosp/device/ti/am62x/-/merge_requests/29 * https://gitlab.baylibre.com/baylibre/ti/ti-u-boot/-/merge_requests/7 * https://gitlab.baylibre.com/baylibre/ti/ti-linux-kernel/-/merge_requests/75 Note that it's a bit of unfortunate timing for me. I am leaving my office for a month of break. I will have a look at this when I come back after my vacation. Regards, Mattijs > > чт, 9 февр. 2023 г. в 16:35, Mattijs Korpershoek <mkorpersh...@baylibre.com>: >> >> On Mon, Feb 06, 2023 at 00:50, Safae Ouajih <soua...@baylibre.com> wrote: >> >> > Version 3 and 4 of boot image header introduced >> > vendor boot ramdisk: Please check include/android_image.h >> > for details. >> > >> > The ramdisk is now split into a generic ramdisk in boot image >> > and a vendor ramdisk in vendor boot image. >> > >> > Support the new vendor ramdisk. >> > >> > Signed-off-by: Safae Ouajih <soua...@baylibre.com> >> > Reviewed-by: Simon Glass <s...@chromium.org> >> >> Reviewed-by: Mattijs Korpershoek <mkorpersh...@baylibre.com> >> >> > --- >> > boot/image-android.c | 13 +++++++++++-- >> > include/image.h | 4 ++-- >> > 2 files changed, 13 insertions(+), 4 deletions(-) >> > >> > diff --git a/boot/image-android.c b/boot/image-android.c >> > index 712d437766..35243fd5b1 100644 >> > --- a/boot/image-android.c >> > +++ b/boot/image-android.c >> > @@ -25,6 +25,7 @@ static void android_boot_image_v3_v4_parse_hdr(const >> > struct andr_boot_img_hdr_v3 >> > >> > data->kcmdline = hdr->cmdline; >> > data->header_version = hdr->header_version; >> > + data->ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0); >> > >> > /* >> > * The header takes a full page, the remaining components are aligned >> > @@ -322,10 +323,11 @@ ulong android_image_get_kcomp(const struct >> > andr_boot_img_hdr_v0 *hdr, >> > return image_decomp_type(p, sizeof(u32)); >> > } >> > >> > -int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0 *hdr, >> > - const void *vendor_boot_img, ulong *rd_data, >> > ulong *rd_len) >> > +int android_image_get_ramdisk(const void *hdr, const void >> > *vendor_boot_img, >> > + ulong *rd_data, ulong *rd_len) >> > { >> > struct andr_image_data img_data = {0}; >> > + ulong ramdisk_ptr; >> > >> > if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) >> > return -EINVAL; >> > @@ -334,6 +336,13 @@ int android_image_get_ramdisk(const struct >> > andr_boot_img_hdr_v0 *hdr, >> > *rd_data = *rd_len = 0; >> > return -1; >> > } >> > + if (img_data.header_version > 2) { >> > + ramdisk_ptr = img_data.ramdisk_ptr; >> > + memcpy((void *)(ramdisk_ptr), (void >> > *)img_data.vendor_ramdisk_ptr, >> > + img_data.vendor_ramdisk_size); >> > + memcpy((void *)(ramdisk_ptr + img_data.vendor_ramdisk_size), >> > + (void *)img_data.ramdisk_ptr, >> > img_data.boot_ramdisk_size); >> > + } >> > >> > printf("RAM disk load addr 0x%08lx size %u KiB\n", >> > img_data.ramdisk_ptr, DIV_ROUND_UP(img_data.ramdisk_size, >> > 1024)); >> > diff --git a/include/image.h b/include/image.h >> > index c2e751c136..c4d9b1c575 100644 >> > --- a/include/image.h >> > +++ b/include/image.h >> > @@ -1782,8 +1782,8 @@ int android_image_get_kernel(const struct >> > andr_boot_img_hdr_v0 *hdr, >> > * @rd_len: Pointer to a ulong variable, will hold ramdisk length >> > * Return: 0 if succeeded, -1 if ramdisk size is 0 >> > */ >> > -int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0 *hdr, >> > - const void *vendor_boot_img, ulong *rd_data, >> > ulong *rd_len); >> > +int android_image_get_ramdisk(const void *hdr, const void >> > *vendor_boot_img, >> > + ulong *rd_data, ulong *rd_len); >> > >> > /** >> > * android_image_get_second() - Extracts the secondary bootloader address >> > -- >> > 2.34.1