* [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg
@ 2025-05-05 9:17 George Chan via B4 Relay
2025-05-05 9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: George Chan via B4 Relay @ 2025-05-05 9:17 UTC (permalink / raw)
To: Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly,
Neil Armstrong, Sumit Garg, Rayagonda Kokatanur
Cc: u-boot, u-boot-qcom, George Chan
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 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.
Patch #3 optionally introduce new kconfig and env_var to get hold of legacy
OS boot param for boot compatibility. It is designed initially for
booting legacy Android, but newer AOSP greatly dependent on kernel
bootconfig feature with vendor_boot partition so not very useful for new
AOSP based OS.
Patch #4 is an example for #3 with snapdragon soc env file
Patch #5 is oprtional to default enable #1 for snapdragon machine.
Worth mentioning a patch[1] to enable EL1 chainloading kernel is needed.
[1] https://lists.denx.de/pipermail/u-boot/2025-April/585995.html
To: Tom Rini <trini@konsulko.com>
To: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Simon Glass <sjg@chromium.org>
To: Casey Connolly <casey.connolly@linaro.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
To: Sumit Garg <sumit.garg@kernel.org>
To: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Cc: u-boot@lists.denx.de
Cc: u-boot-qcom@groups.io
Signed-off-by: George Chan <gchan9527@gmail.com>
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/20250427-android-boot-v1-0-bb6b37c9c9f1@gmail.com
---
George Chan (5):
boot/image-android: Workaround kernel/ramdisk invalid addr
mach-snapdragon: Enhance android image handling memory footprint
fdt_support: Add support for extra var for bootargs
qcom-phone.env: Example of new env var legacy_os_boot_param
mach-snapdragon: Enable workaround of ignoring androidboot addr
arch/arm/Kconfig | 1 +
arch/arm/mach-snapdragon/board.c | 8 ++++++--
board/qualcomm/qcom-phone.env | 4 ++++
boot/Kconfig | 15 +++++++++++++++
boot/fdt_support.c | 20 +++++++++++++++++++-
boot/image-android.c | 9 ++++++---
6 files changed, 51 insertions(+), 6 deletions(-)
---
base-commit: 5a0a93a768487e55ebe50a34cc90d751bf99cc56
change-id: 20250427-android-boot-ecbb768cda72
Best regards,
--
George Chan <gchan9527@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr 2025-05-05 9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay @ 2025-05-05 9:17 ` George Chan via B4 Relay 2025-05-05 12:22 ` Neil Armstrong 2025-05-07 7:47 ` Mattijs Korpershoek 2025-05-05 9:17 ` [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint George Chan via B4 Relay ` (3 subsequent siblings) 4 siblings, 2 replies; 13+ messages in thread From: George Chan via B4 Relay @ 2025-05-05 9:17 UTC (permalink / raw) To: Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom, George Chan From: George Chan <gchan9527@gmail.com> Some androidboot image have invalid kernel/ramdisk load addr, force to ignore those value and use loadaddr instead. Suggested-by: Casey Connolly <casey.connolly@linaro.org> Signed-off-by: George Chan <gchan9527@gmail.com> --- boot/Kconfig | 6 ++++++ boot/image-android.c | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index fb37d912bc9..4bdac384181 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -11,6 +11,12 @@ 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. + config TIMESTAMP bool "Show image date and time when displaying image information" default y if CMD_DATE diff --git a/boot/image-android.c b/boot/image-android.c index 1746b018900..7b8eb6a4f64 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -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; -- 2.43.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr 2025-05-05 9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay @ 2025-05-05 12:22 ` Neil Armstrong 2025-05-07 9:30 ` Mattijs Korpershoek 2025-05-07 7:47 ` Mattijs Korpershoek 1 sibling, 1 reply; 13+ messages in thread From: Neil Armstrong @ 2025-05-05 12:22 UTC (permalink / raw) To: gchan9527, Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom On 05/05/2025 11:17, George Chan via B4 Relay wrote: > From: George Chan <gchan9527@gmail.com> > > Some androidboot image have invalid kernel/ramdisk load addr, > force to ignore those value and use loadaddr instead. > > Suggested-by: Casey Connolly <casey.connolly@linaro.org> > Signed-off-by: George Chan <gchan9527@gmail.com> > --- > boot/Kconfig | 6 ++++++ > boot/image-android.c | 9 ++++++--- > 2 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/boot/Kconfig b/boot/Kconfig > index fb37d912bc9..4bdac384181 100644 > --- a/boot/Kconfig > +++ b/boot/Kconfig > @@ -11,6 +11,12 @@ 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. > + > config TIMESTAMP > bool "Show image date and time when displaying image information" > default y if CMD_DATE > diff --git a/boot/image-android.c b/boot/image-android.c > index 1746b018900..7b8eb6a4f64 100644 > --- a/boot/image-android.c > +++ b/boot/image-android.c > @@ -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; > I like this and should be the default except rare cases, exposing the whole memory to image loading sound really dangerous.. Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> @Mattijs would this still work on Amlogic board if we set loadaddr to the address curently used in the boot images ? Neil Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr 2025-05-05 12:22 ` Neil Armstrong @ 2025-05-07 9:30 ` Mattijs Korpershoek 0 siblings, 0 replies; 13+ messages in thread From: Mattijs Korpershoek @ 2025-05-07 9:30 UTC (permalink / raw) To: Neil Armstrong, gchan9527, Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom Hi Neil, On lun., mai 05, 2025 at 14:22, Neil Armstrong <neil.armstrong@linaro.org> wrote: > On 05/05/2025 11:17, George Chan via B4 Relay wrote: >> From: George Chan <gchan9527@gmail.com> >> >> Some androidboot image have invalid kernel/ramdisk load addr, >> force to ignore those value and use loadaddr instead. >> >> Suggested-by: Casey Connolly <casey.connolly@linaro.org> >> Signed-off-by: George Chan <gchan9527@gmail.com> >> --- >> boot/Kconfig | 6 ++++++ >> boot/image-android.c | 9 ++++++--- >> 2 files changed, 12 insertions(+), 3 deletions(-) >> >> diff --git a/boot/Kconfig b/boot/Kconfig >> index fb37d912bc9..4bdac384181 100644 >> --- a/boot/Kconfig >> +++ b/boot/Kconfig >> @@ -11,6 +11,12 @@ 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. >> + >> config TIMESTAMP >> bool "Show image date and time when displaying image information" >> default y if CMD_DATE >> diff --git a/boot/image-android.c b/boot/image-android.c >> index 1746b018900..7b8eb6a4f64 100644 >> --- a/boot/image-android.c >> +++ b/boot/image-android.c >> @@ -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; >> > > I like this and should be the default except rare cases, exposing the whole memory > to image loading sound really dangerous.. > > Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> > > @Mattijs would this still work on Amlogic board if we set loadaddr to the address > curently used in the boot images ? TLDR, yes, it would still work on Amlogic if we: - Set CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR=y - setenv kernel_addr_r 0x11080000 - setenv ramdisk_addr_r 0x11000000 Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org> I've experimented a bit with an old boot.img. Some details below NOTE: newer boot.img have different addresses, see: https://android-review.googlesource.com/c/device/amlogic/yukawa/+/3290364 Before sending a patch for this, make sure to use the latest ramdisk_addr_r variable This is the original boot.img I have: $ unpack_bootimg --format info --boot_img boot.img boot magic: ANDROID! kernel_size: 19022293 kernel load address: 0x11080000 ramdisk size: 1751539 ramdisk load address: 0x11000000 second bootloader size: 0 second bootloader load address: 0x00000000 kernel tags load address: 0x10000100 page size: 2048 os version: 13.0.0 os patch level: 2023-05 boot image header version: 2 product name: command line args: no_console_suspend console=ttyAML0,115200 earlycon printk.devkmsg=on androidboot.boot_devices=soc/ffe07000.mmc init=/init firmware_class.path=/vendor/firmware androidboot.hardware=yukawa androidboot.selinux=permissive additional command line args: recovery dtbo size: 0 recovery dtbo offset: 0x0000000000000000 boot header size: 1660 dtb size: 295778 dtb address: 0x0000000011f00000 I can unpack/repack it to change "kernel load address" and "ramdisk load address" with: $ unpack_bootimg --boot_img boot.img --out out --format=mkbootimg | tee mkbootimg_args # edit mkbootimg_args to change both --kernel_offset and --ramdisk_offset to 0x0 $ sh -c "mkbootimg $(cat mkbootimg_args) --output boot_repacked.img" $ unpack_bootimg --format info --boot_img boot_repacked.img | grep 'load address' kernel load address: 0x00000000 ramdisk load address: 0x00000000 Reflashing the boot partition with: $ fastboot flash boot boot_repacked.img Without modification, this does not boot, as expected: U-Boot 2025.07-rc1-g8ea79fc630ac (May 07 2025 - 09:30:45 +0200) khadas-vim3 Model: Khadas VIM3 SoC: Amlogic Meson G12B (A311D) Revision 29:b (10:2) DRAM: 2 GiB (total 3.8 GiB) Core: 407 devices, 36 uclasses, devicetree: separate MMC: mmc@ffe03000: 0, mmc@ffe05000: 1, mmc@ffe07000: 2 Loading Environment from MMC... MMC Device -1 not found *** Warning - No MMC card found, using default environment In: usbkbd,serial Out: vidconsole,serial Err: vidconsole,serial Net: eth0: ethernet@ff3f0000 Hit any key to stop autoboot: 0 Card did not respond to voltage select! : -110 fs uses incompatible features: 00020000, ignoring ** Booting bootflow 'mmc@ffe07000.bootdev.whole' with android avb_slot_verify.c:428: ERROR: boot: Hash of data does not match digest in descriptor. ## Booting Android Image at 0x01080000 ... Kernel load addr 0x01080000 size 18577 KiB Kernel command line: no_console_suspend console=ttyAML0,115200 earlycon printk.devkmsg=on androidboot.boot_devices=soc/ffe07000.mmc init=/init firmware_class.path=/vendor/firmware androidboot.hardware=yukawa androidboot.selinux=permissive RAM disk load addr 0x022a5000 size 1711 KiB Working FDT set to 2486baf Uncompressing Kernel Image to 1080000 lz4 compressed: uncompress error -71 Must RESET board to recover Resetting the board... bl31 reboot reason: 0xd bl31 reboot reason: 0x0 system cmd 1. With the environment variables updated, it boots fine: U-Boot 2025.07-rc1-g31837b1f1d1d (May 07 2025 - 11:25:40 +0200) khadas-vim3 Model: Khadas VIM3 SoC: Amlogic Meson G12B (A311D) Revision 29:b (10:2) DRAM: 2 GiB (total 3.8 GiB) Core: 407 devices, 36 uclasses, devicetree: separate MMC: mmc@ffe03000: 0, mmc@ffe05000: 1, mmc@ffe07000: 2 Loading Environment from MMC... MMC Device -1 not found *** Warning - No MMC card found, using default environment In: usbkbd,serial Out: vidconsole,serial Err: vidconsole,serial Net: eth0: ethernet@ff3f0000 Hit any key to stop autoboot: 0 => setenv kernel_addr_r 0x11080000 => setenv ramdisk_addr_r 0x11000000 => run bootcmd Card did not respond to voltage select! : -110 fs uses incompatible features: 00020000, ignoring ** Booting bootflow 'mmc@ffe07000.bootdev.whole' with android avb_slot_verify.c:428: ERROR: boot: Hash of data does not match digest in descriptor. ## Booting Android Image at 0x01080000 ... Kernel load addr 0x11080000 size 18577 KiB Kernel command line: no_console_suspend console=ttyAML0,115200 earlycon printk.devkmsg=on androidboot.boot_devices=soc/ffe07000.mmc init=/init firmware_class.path=/vendor/firmware androidboot.hardware=yukawa androidboot.selinux=permissive RAM disk load addr 0x022a5000 size 1711 KiB Working FDT set to 2486baf Uncompressing Kernel Image to 11080000 Loading Ramdisk to 7fe54000, end 7ffff9f3 ... OK Loading Device Tree to 000000007fe3e000, end 000000007fe537b2 ... OK Working FDT set to 7fe3e000 Thanks, Mattijs > > Neil > > > Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr 2025-05-05 9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay 2025-05-05 12:22 ` Neil Armstrong @ 2025-05-07 7:47 ` Mattijs Korpershoek 2025-05-08 4:22 ` george chan 1 sibling, 1 reply; 13+ messages in thread From: Mattijs Korpershoek @ 2025-05-07 7:47 UTC (permalink / raw) To: George Chan via B4 Relay, Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom, George Chan Hi George, Thank you for the patch. I really prefer this solution to the one proposed in v1. I have tested this on Khadas VIM3 board (using khadas-vim3_android_defconfig) I have a couple of small remarks below. On lun., mai 05, 2025 at 17:17, George Chan via B4 Relay <devnull+gchan9527.gmail.com@kernel.org> wrote: > From: George Chan <gchan9527@gmail.com> > > Some androidboot image have invalid kernel/ramdisk load addr, > force to ignore those value and use loadaddr instead. Can we please elaborate a bit more in the commit message? We have not explained/justified why repacking a boot image with proper kernel ramdisk/load addr is not possible. Is the following an acceptable justification for you? """ Since it's not always possible to change the load addr by repacking the boot.img (due to AVB signature mismatch/<or_another_justification>), we need a way to use kernel_addr_r and ramdisk_addr_r. """ Feel free to reformulate the above. > > Suggested-by: Casey Connolly <casey.connolly@linaro.org> > Signed-off-by: George Chan <gchan9527@gmail.com> > --- > boot/Kconfig | 6 ++++++ > boot/image-android.c | 9 ++++++--- > 2 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/boot/Kconfig b/boot/Kconfig > index fb37d912bc9..4bdac384181 100644 > --- a/boot/Kconfig > +++ b/boot/Kconfig > @@ -11,6 +11,12 @@ 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. Please add a bit more context here, checkpatch.pl reports issues: $ ./scripts/checkpatch.pl --u-boot --git master..HEAD WARNING: please write a paragraph that describes the config symbol fully #27: FILE: boot/Kconfig:14: +config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR > + > config TIMESTAMP > bool "Show image date and time when displaying image information" > default y if CMD_DATE > diff --git a/boot/image-android.c b/boot/image-android.c > index 1746b018900..7b8eb6a4f64 100644 > --- a/boot/image-android.c > +++ b/boot/image-android.c > @@ -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)) { Please fix indentation, should be: + if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR || + IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR)) { (checkpatch.pl reports this) > 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))) { Same here. Also, can we please drop the leading parenthesis (IS_ENABLED( -> IS_ENABLED( to be consistent with the previous code change? > 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))) { Same here. Also, can we please drop the leading parenthesis (IS_ENABLED( -> IS_ENABLED( to be consistent with the previous code change? > *rd_data = img_data.ramdisk_ptr; > } else { > ramdisk_ptr = img_data.ramdisk_addr; > > -- > 2.43.0 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr 2025-05-07 7:47 ` Mattijs Korpershoek @ 2025-05-08 4:22 ` george chan 2025-05-09 14:22 ` Mattijs Korpershoek 0 siblings, 1 reply; 13+ messages in thread From: george chan @ 2025-05-08 4:22 UTC (permalink / raw) To: Mattijs Korpershoek Cc: George Chan via B4 Relay, Tom Rini, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur, u-boot, u-boot-qcom Hi Mattijs, Thx for feedback. 在 2025年5月7日週三 15:47,Mattijs Korpershoek <mkorpershoek@kernel.org> 寫道: > Hi George, > > Thank you for the patch. > I really prefer this solution to the one proposed in v1. > > I have tested this on Khadas VIM3 board (using > khadas-vim3_android_defconfig) > > I have a couple of small remarks below. > > On lun., mai 05, 2025 at 17:17, George Chan via B4 Relay < > devnull+gchan9527.gmail.com@kernel.org> wrote: > > > From: George Chan <gchan9527@gmail.com> > > > > Some androidboot image have invalid kernel/ramdisk load addr, > > force to ignore those value and use loadaddr instead. > > Can we please elaborate a bit more in the commit message? > We have not explained/justified why repacking a boot image with proper > kernel ramdisk/load addr is not possible. > > Is the following an acceptable justification for you? > """ > Since it's not always possible to change the load addr by repacking > the boot.img (due to AVB signature mismatch/<or_another_justification>), > we need a way to use kernel_addr_r and ramdisk_addr_r. > """ > > Feel free to reformulate the above. > Thx. let me sum up as below 2 reasons. 1. there is a concern on exposing the whole memory to image loading is dangerous 2. 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. > > > > Suggested-by: Casey Connolly <casey.connolly@linaro.org> > > Signed-off-by: George Chan <gchan9527@gmail.com> > > --- > > boot/Kconfig | 6 ++++++ > > boot/image-android.c | 9 ++++++--- > > 2 files changed, 12 insertions(+), 3 deletions(-) > > > > diff --git a/boot/Kconfig b/boot/Kconfig > > index fb37d912bc9..4bdac384181 100644 > > --- a/boot/Kconfig > > +++ b/boot/Kconfig > > @@ -11,6 +11,12 @@ 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. > > Please add a bit more context here, checkpatch.pl reports issues: > $ ./scripts/checkpatch.pl --u-boot --git master..HEAD > > WARNING: please write a paragraph that describes the config symbol fully > #27: FILE: boot/Kconfig:14: > +config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR > same as above. > > > + > > config TIMESTAMP > > bool "Show image date and time when displaying image information" > > default y if CMD_DATE > > diff --git a/boot/image-android.c b/boot/image-android.c > > index 1746b018900..7b8eb6a4f64 100644 > > --- a/boot/image-android.c > > +++ b/boot/image-android.c > > @@ -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)) { > > Please fix indentation, should be: > > + if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR || > + IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR)) { > > (checkpatch.pl reports this) > ack. > > 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))) { > > Same here. Also, can we please drop the leading parenthesis (IS_ENABLED( > -> IS_ENABLED( to be consistent with the previous code change? > ack. > > 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))) { > > Same here. Also, can we please drop the leading parenthesis (IS_ENABLED( > -> IS_ENABLED( to be consistent with the previous code change? > ack. l planed to release v3 later around end of next week and contain only patch #1 #2 and #5 to ease maintainer processing. please feel free to comment on any idea, i will include into next version. regards, George > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr 2025-05-08 4:22 ` george chan @ 2025-05-09 14:22 ` Mattijs Korpershoek 0 siblings, 0 replies; 13+ messages in thread From: Mattijs Korpershoek @ 2025-05-09 14:22 UTC (permalink / raw) To: george chan, Mattijs Korpershoek Cc: George Chan via B4 Relay, Tom Rini, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur, u-boot, u-boot-qcom Hi George, On jeu., mai 08, 2025 at 12:22, george chan <gchan9527@gmail.com> wrote: > Hi Mattijs, > > Thx for feedback. > > 在 2025年5月7日週三 15:47,Mattijs Korpershoek <mkorpershoek@kernel.org> 寫道: > >> Hi George, >> >> Thank you for the patch. >> I really prefer this solution to the one proposed in v1. >> >> I have tested this on Khadas VIM3 board (using >> khadas-vim3_android_defconfig) >> >> I have a couple of small remarks below. >> >> On lun., mai 05, 2025 at 17:17, George Chan via B4 Relay < >> devnull+gchan9527.gmail.com@kernel.org> wrote: >> >> > From: George Chan <gchan9527@gmail.com> >> > >> > Some androidboot image have invalid kernel/ramdisk load addr, >> > force to ignore those value and use loadaddr instead. >> >> Can we please elaborate a bit more in the commit message? >> We have not explained/justified why repacking a boot image with proper >> kernel ramdisk/load addr is not possible. >> >> Is the following an acceptable justification for you? >> """ >> Since it's not always possible to change the load addr by repacking >> the boot.img (due to AVB signature mismatch/<or_another_justification>), >> we need a way to use kernel_addr_r and ramdisk_addr_r. >> """ >> >> Feel free to reformulate the above. >> > > Thx. let me sum up as below 2 reasons. > > 1. there is a concern on exposing the whole memory to image loading is > dangerous > > 2. 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. That's good summary. Please include it in the commit message for v3. > > >> > >> > Suggested-by: Casey Connolly <casey.connolly@linaro.org> >> > Signed-off-by: George Chan <gchan9527@gmail.com> >> > --- >> > boot/Kconfig | 6 ++++++ >> > boot/image-android.c | 9 ++++++--- >> > 2 files changed, 12 insertions(+), 3 deletions(-) >> > >> > diff --git a/boot/Kconfig b/boot/Kconfig >> > index fb37d912bc9..4bdac384181 100644 >> > --- a/boot/Kconfig >> > +++ b/boot/Kconfig >> > @@ -11,6 +11,12 @@ 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. >> >> Please add a bit more context here, checkpatch.pl reports issues: >> $ ./scripts/checkpatch.pl --u-boot --git master..HEAD >> >> WARNING: please write a paragraph that describes the config symbol fully >> #27: FILE: boot/Kconfig:14: >> +config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR >> > > same as above. > >> >> > + >> > config TIMESTAMP >> > bool "Show image date and time when displaying image information" >> > default y if CMD_DATE >> > diff --git a/boot/image-android.c b/boot/image-android.c >> > index 1746b018900..7b8eb6a4f64 100644 >> > --- a/boot/image-android.c >> > +++ b/boot/image-android.c >> > @@ -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)) { >> >> Please fix indentation, should be: >> >> + if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR || >> + IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR)) { >> >> (checkpatch.pl reports this) >> > > ack. > > >> > 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))) { >> >> Same here. Also, can we please drop the leading parenthesis (IS_ENABLED( >> -> IS_ENABLED( to be consistent with the previous code change? >> > > ack. > > >> > 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))) { >> >> Same here. Also, can we please drop the leading parenthesis (IS_ENABLED( >> -> IS_ENABLED( to be consistent with the previous code change? >> > > ack. > > l planed to release v3 later around end of next week and contain only patch > #1 #2 and #5 to ease maintainer processing. please feel free to comment on > any idea, i will include into next version. > > regards, > George > >> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint 2025-05-05 9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay @ 2025-05-05 9:17 ` George Chan via B4 Relay 2025-05-05 12:23 ` Neil Armstrong 2025-05-05 9:17 ` [PATCH v2 3/5] fdt_support: Add support for extra var for bootargs George Chan via B4 Relay ` (2 subsequent siblings) 4 siblings, 1 reply; 13+ messages in thread From: George Chan via B4 Relay @ 2025-05-05 9:17 UTC (permalink / raw) To: Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom, George Chan From: George Chan <gchan9527@gmail.com> In 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. Signed-off-by: George Chan <gchan9527@gmail.com> --- arch/arm/mach-snapdragon/board.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c index deae4d32378..3ee0933d962 100644 --- a/arch/arm/mach-snapdragon/board.c +++ b/arch/arm/mach-snapdragon/board.c @@ -500,8 +500,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); -- 2.43.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint 2025-05-05 9:17 ` [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint George Chan via B4 Relay @ 2025-05-05 12:23 ` Neil Armstrong 0 siblings, 0 replies; 13+ messages in thread From: Neil Armstrong @ 2025-05-05 12:23 UTC (permalink / raw) To: gchan9527, Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom On 05/05/2025 11:17, George Chan via B4 Relay wrote: > From: George Chan <gchan9527@gmail.com> > > In 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. > > Signed-off-by: George Chan <gchan9527@gmail.com> > --- > arch/arm/mach-snapdragon/board.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c > index deae4d32378..3ee0933d962 100644 > --- a/arch/arm/mach-snapdragon/board.c > +++ b/arch/arm/mach-snapdragon/board.c > @@ -500,8 +500,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); I wouldn't make it conditional on fastboot > + } > 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); > Anyway Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 3/5] fdt_support: Add support for extra var for bootargs 2025-05-05 9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint George Chan via B4 Relay @ 2025-05-05 9:17 ` George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 4/5] qcom-phone.env: Example of new env var legacy_os_boot_param George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr George Chan via B4 Relay 4 siblings, 0 replies; 13+ messages in thread From: George Chan via B4 Relay @ 2025-05-05 9:17 UTC (permalink / raw) To: Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom, George Chan From: George Chan <gchan9527@gmail.com> Introduce a new env var 'legacy_os_boot_param' to hold legacy OS dependent boot param. Signed-off-by: George Chan <gchan9527@gmail.com> --- boot/Kconfig | 9 +++++++++ boot/fdt_support.c | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/boot/Kconfig b/boot/Kconfig index 4bdac384181..80bb2eb7e77 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -17,6 +17,15 @@ config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR help This ignore kernel/ramdisk load addr specified in androidboot header. +config SUPPORT_LEGACY_OS_BOOTPARAM + bool "Extra var to append bootargs" + default n + help + This introduce env_var 'legacy_os_boot_param' to hold extra OS + dependent kernel boot param, and append to fdt bootargs when bootm + execute. The value is supposed to obtain from env file at compile time. + Board dependent callback will override it completely. + config TIMESTAMP bool "Show image date and time when displaying image information" default y if CMD_DATE diff --git a/boot/fdt_support.c b/boot/fdt_support.c index 92f2f534ee0..cc4d808eaf1 100644 --- a/boot/fdt_support.c +++ b/boot/fdt_support.c @@ -322,9 +322,27 @@ int fdt_kaslrseed(void *fdt, bool overwrite) * board_fdt_chosen_bootargs - boards may override this function to use * alternative kernel command line arguments */ +#define COMMAND_LINE_SIZE 1024 +static char bootargs[COMMAND_LINE_SIZE] = { 0 }; __weak const char *board_fdt_chosen_bootargs(const struct fdt_property *fdt_ba) { - return env_get("bootargs"); + if (IS_ENABLED(CONFIG_SUPPORT_LEGACY_OS_BOOTPARAM)) { + int j; + snprintf(bootargs, COMMAND_LINE_SIZE - 2, "%s %s", + env_get("bootargs"), + env_get("legacy_os_boot_param")); + + /* remove all carriage return */ + for (j = 0; j < COMMAND_LINE_SIZE; j++) { + if (bootargs[j] == '\0') + break; + + if ((bootargs[j] == '\n') || (bootargs[j] == '\r')) + bootargs[j] = ' '; + } + return bootargs; + } else + return env_get("bootargs"); } int fdt_chosen(void *fdt) -- 2.43.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/5] qcom-phone.env: Example of new env var legacy_os_boot_param 2025-05-05 9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay ` (2 preceding siblings ...) 2025-05-05 9:17 ` [PATCH v2 3/5] fdt_support: Add support for extra var for bootargs George Chan via B4 Relay @ 2025-05-05 9:17 ` George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr George Chan via B4 Relay 4 siblings, 0 replies; 13+ messages in thread From: George Chan via B4 Relay @ 2025-05-05 9:17 UTC (permalink / raw) To: Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom, George Chan From: George Chan <gchan9527@gmail.com> This is an example for newly introduced env_var legacy_os_boot_param that will append 'console=ramoops' to fdt bootargs. Signed-off-by: George Chan <gchan9527@gmail.com> --- board/qualcomm/qcom-phone.env | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/board/qualcomm/qcom-phone.env b/board/qualcomm/qcom-phone.env index e91ae3ecdfb..536467921d8 100644 --- a/board/qualcomm/qcom-phone.env +++ b/board/qualcomm/qcom-phone.env @@ -4,6 +4,10 @@ stdin=serial,button-kbd stdout=serial,vidconsole stderr=serial,vidconsole +# Introduce var to hold legacy boot param, it will be append +# to bootargs automatically +legacy_os_boot_param=console=ramoops + # Fastboot is keen to use the address from kconfig, but we # allocate its buffer at runtime. fastboot=fastboot -l $fastboot_addr_r usb 0 -- 2.43.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr 2025-05-05 9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay ` (3 preceding siblings ...) 2025-05-05 9:17 ` [PATCH v2 4/5] qcom-phone.env: Example of new env var legacy_os_boot_param George Chan via B4 Relay @ 2025-05-05 9:17 ` George Chan via B4 Relay 2025-05-05 12:23 ` Neil Armstrong 4 siblings, 1 reply; 13+ messages in thread From: George Chan via B4 Relay @ 2025-05-05 9:17 UTC (permalink / raw) To: Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Neil Armstrong, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom, George Chan From: George Chan <gchan9527@gmail.com> Enable the workaround for whole snapdragon family. Suggested-by: Casey Connolly <casey.connolly@linaro.org> Signed-off-by: George Chan <gchan9527@gmail.com> --- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index df373d38a55..249bd4b5bf3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -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 -- 2.43.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr 2025-05-05 9:17 ` [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr George Chan via B4 Relay @ 2025-05-05 12:23 ` Neil Armstrong 0 siblings, 0 replies; 13+ messages in thread From: Neil Armstrong @ 2025-05-05 12:23 UTC (permalink / raw) To: gchan9527, Tom Rini, Mattijs Korpershoek, Simon Glass, Casey Connolly, Sumit Garg, Rayagonda Kokatanur Cc: u-boot, u-boot-qcom On 05/05/2025 11:17, George Chan via B4 Relay wrote: > From: George Chan <gchan9527@gmail.com> > > Enable the workaround for whole snapdragon family. > > Suggested-by: Casey Connolly <casey.connolly@linaro.org> > Signed-off-by: George Chan <gchan9527@gmail.com> > --- > arch/arm/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index df373d38a55..249bd4b5bf3 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -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 > Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-05-09 14:22 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-05 9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay 2025-05-05 12:22 ` Neil Armstrong 2025-05-07 9:30 ` Mattijs Korpershoek 2025-05-07 7:47 ` Mattijs Korpershoek 2025-05-08 4:22 ` george chan 2025-05-09 14:22 ` Mattijs Korpershoek 2025-05-05 9:17 ` [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint George Chan via B4 Relay 2025-05-05 12:23 ` Neil Armstrong 2025-05-05 9:17 ` [PATCH v2 3/5] fdt_support: Add support for extra var for bootargs George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 4/5] qcom-phone.env: Example of new env var legacy_os_boot_param George Chan via B4 Relay 2025-05-05 9:17 ` [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr George Chan via B4 Relay 2025-05-05 12:23 ` Neil Armstrong
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox