u-boot chain-loading LineageOS bootimg
Subsystems (2)
v3 cover u-boot chain-loading LineageOS bootimg
This is a series of patches to enable chainloading LineageOS on qcom SOC.
Patch #1 introduce kconfig to ignore those default value and use loadaddr instead. That workaround some androidboot image have invalid kernel/ramdisk loadaddr.
Patch #2 enable #1 for snapdragon machine.
Patch #3 override qcom soc loadaddr with fastboot_addr_r as a band-aid. Casey confirmed loadaddr and kernel_addr_r are purposely set to same address for memory-constrain case. A proper fix is far from get ready so this patch can work as a band-aid for maintainer atm.
Remain as unchanged to make it conditional on CONFIG_FASTBOOT is because that also imply CONFIG_ANDROID_BOOT_IMAGE set y.
To: Tom Rini <[email protected]>
To: Mattijs Korpershoek <[email protected]>
To: Simon Glass <[email protected]>
To: Casey Connolly <[email protected]>
To: Neil Armstrong <[email protected]>
To: Sumit Garg <[email protected]>
To: Rayagonda Kokatanur <[email protected]>
Changes in v3:
- Rebase to origin/master
- Drop optional patches, leaving those acked patches.
- Gone through checkpatch.pl
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Revised patch #1 to control by kconfig, suggested by Casey
- Split old #1 into new #1 and #5 for maintainer to choose.
- Revised Casey's approach for #2 and make it as band-aid atm.
- Revised Casey's approach for #3 and leave user to bake their own param set.
- Introduce example for #1
- Introduce kconfig default for #1 with snapdragon soc, suggested by Casey
- Link to v1: https://lore.kernel.org/r/[email protected]
---
George Chan (3):
boot/image-android: Workaround kernel/ramdisk invalid addr
mach-snapdragon: Enable workaround of ignoring androidboot addr
mach-snapdragon: Enhance android image handling memory footprint
arch/arm/Kconfig | 1 + arch/arm/mach-snapdragon/board.c | 8 ++++++-- boot/Kconfig | 11 +++++++++++ boot/image-android.c | 9 ++++++--- 4 files changed, 24 insertions(+), 5 deletions(-)
---
base-commit: 126a88d49bcae04bbfc0d6723097cd6341355ade
change-id: 20250427-android-boot-ecbb768cda72
Best regards,
Signature · 1 line
George Chan <[email protected]>
PATCH v3 1/3 boot/image-android: Workaround kernel/ramdisk invalid addr
Some androidboot image have invalid kernel/ramdisk load addr, force to ignore those value and use loadaddr instead.
There is a concern on exposing the whole memory to image loading is dangerous. Also, since it's not always possible to change the load addr by repacking the boot.img (mainly due to AVB signature mismatch), we need a way to use kernel_addr_r and ramdisk_addr_r.
--- boot/Kconfig | 11 +++++++++++ boot/image-android.c | 9 ++++++--- 2 files changed, 17 insertions(+), 3 deletions(-)
boot/Kconfig +11 -0
@@ -11,6 +11,17 @@ config ANDROID_BOOT_IMAGE This enables support for booting images which use the Android image format header. +config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR + bool "Android Boot Image ignore addr" + default n + help + This ignore kernel/ramdisk load addr specified in androidboot header. + + There is a concern on exposing the whole memory to image loading is + dangerous. Also, since it's not always possible to change the load + addr by repacking the boot.img (mainly due to AVB signature mismatch), + we need a way to use kernel_addr_r and ramdisk_addr_r. + config TIMESTAMP bool "Show image date and time when displaying image information" default y if CMD_DATE
boot/image-android.c +6 -3
@@ -268,7 +268,8 @@ static ulong android_image_get_kernel_addr(struct andr_image_data *img_data,* * Otherwise, we will return the actual value set by the user. */ -if (img_data->kernel_addr ==ANDROID_IMAGE_DEFAULT_KERNEL_ADDR ) { +if (img_data->kernel_addr ==ANDROID_IMAGE_DEFAULT_KERNEL_ADDR || +IS_ENABLED (CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR )) {if (comp ==IH_COMP_NONE )return img_data->kernel_ptr;return env_get_ulong ("kernel_addr_r" ,16 ,0 );
@@ -464,7 +465,8 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,*/ if (img_data.header_version >2 ) {/* Ramdisk can't be used in-place, copy it to ramdisk_addr_r */ -if (img_data.ramdisk_addr ==ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR ) { +if (img_data.ramdisk_addr ==ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR || +IS_ENABLED (CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR )) { ramdisk_ptr =env_get_ulong ("ramdisk_addr_r" ,16 ,0 );if (!ramdisk_ptr) {printf ("Invalid ramdisk_addr_r to copy ramdisk into\n" );
@@ -488,7 +490,8 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, }else {/* Ramdisk can be used in-place, use current ptr */ if (img_data.ramdisk_addr ==0 || - img_data.ramdisk_addr ==ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR ) { + img_data.ramdisk_addr ==ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR || +IS_ENABLED (CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR )) { *rd_data = img_data.ramdisk_ptr; }else { ramdisk_ptr = img_data.ramdisk_addr;
Signature · 1 line
2.43.0
PATCH v3 2/3 mach-snapdragon: Enable workaround of ignoring androidboot addr
In reply to George ChanEnable the workaround for whole snapdragon family.
--- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/Kconfig +1 -0
@@ -1124,6 +1124,7 @@ config ARCH_SNAPDRAGON select LINUX_KERNEL_IMAGE_HEADER if !ENABLE_ARM_SOC_BOOT0_HOOK select SYSRESET select SYSRESET_PSCI + select ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR imply OF_UPSTREAM imply CMD_DM imply DM_USB_GADGET
Signature · 1 line
2.43.0
PATCH v3 3/3 mach-snapdragon: Enhance android image handling memory footprint
In reply to George ChanIn order to unzipped kernel from androidboot img, extra memory for loadaddr is needed. So once fastboot is enabled fastboot memory also share with loadaddr.
That can balance with memory constrain soc and android usecase.
--- arch/arm/mach-snapdragon/board.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/mach-snapdragon/board.c +6 -2
@@ -499,8 +499,12 @@ int board_late_init(void) status |=env_set_hex ("ramdisk_addr_r" ,addr_alloc (SZ_128M )); status |=env_set_hex ("kernel_comp_addr_r" ,addr_alloc (KERNEL_COMP_SIZE )); status |=env_set_hex ("kernel_comp_size" ,KERNEL_COMP_SIZE ); -if (IS_ENABLED (CONFIG_FASTBOOT )) - status |=env_set_hex ("fastboot_addr_r" ,addr_alloc (FASTBOOT_BUF_SIZE )); +if (IS_ENABLED (CONFIG_FASTBOOT )) { + addr =addr_alloc (FASTBOOT_BUF_SIZE ); + status |=env_set_hex ("fastboot_addr_r" , addr); +/* override loadaddr for memory rich soc */ + status |=env_set_hex ("loadaddr" , addr); + } status |=env_set_hex ("scriptaddr" ,addr_alloc (SZ_4M )); status |=env_set_hex ("pxefile_addr_r" ,addr_alloc (SZ_4M )); addr =addr_alloc (SZ_2M );
Signature · 1 line
2.43.0
Quoted 23 lines · On 5/18/25 13:16, George Chan via B4 Relay wrote:
This is a series of patches to enable chainloading LineageOS on qcom SOC.
Patch #1 introduce kconfig to ignore those default value and use loadaddr instead. That workaround some androidboot image have invalid kernel/ramdisk loadaddr.
Patch #2 enable #1 for snapdragon machine.
Patch #3 override qcom soc loadaddr with
fastboot_addr_ras a band-aid. Casey confirmed loadaddr andkernel_addr_rare purposely set to same address for memory-constrain case. A proper fix is far from get ready so this patch can work as a band-aid for maintainer atm.Remain as unchanged to make it conditional on
CONFIG_FASTBOOTis because that also implyCONFIG_ANDROID_BOOT_IMAGEset y.To: Tom Rini <[email protected]>
To: Mattijs Korpershoek <[email protected]>
To: Simon Glass <[email protected]>
To: Casey Connolly <[email protected]>
To: Neil Armstrong <[email protected]>
To: Sumit Garg <[email protected]>
To: Rayagonda Kokatanur <[email protected]>
Quoted 3 lines
Thanks for sticking with us on this. It's really awesome to see you have LineageOS booting! If you'd be interested in documenting how you got this working (either in U-Boot docs or elsewhere) I think it would be super interesting to read about :)
Kind regards,>
Quoted 31 lines
Changes in v3:
- Rebase to origin/master
- Drop optional patches, leaving those acked patches.
- Gone through checkpatch.pl
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Revised patch #1 to control by kconfig, suggested by Casey
- Split old #1 into new #1 and #5 for maintainer to choose.
- Revised Casey's approach for #2 and make it as band-aid atm.
- Revised Casey's approach for #3 and leave user to bake their own param set.
- Introduce example for #1
- Introduce kconfig default for #1 with snapdragon soc, suggested by Casey
- Link to v1: https://lore.kernel.org/r/[email protected]---
George Chan (3):
boot/image-android: Workaround kernel/ramdisk invalid addr
mach-snapdragon: Enable workaround of ignoring androidboot addr
mach-snapdragon: Enhance android image handling memory footprintarch/arm/Kconfig | 1 + arch/arm/mach-snapdragon/board.c | 8 ++++++-- boot/Kconfig | 11 +++++++++++ boot/image-android.c | 9 ++++++--- 4 files changed, 24 insertions(+), 5 deletions(-)---
base-commit:126a88d49bcae04bbfc0d6723097cd6341355ade
change-id: 20250427-android-boot-ecbb768cda72Best regards,
Signature · 1 line
Casey (she/they)