[1/4] fix(u-boot-script): use correct ramdisk size

Message ID 20230801093706.1347928-2-felix.moessbauer@siemens.com
State Accepted, archived
Headers show
Series Rework and extend u-boot-script for DT overlays | expand

Commit Message

MOESSBAUER, Felix Aug. 1, 2023, 9:37 a.m. UTC
When booting the kernel via a boot* command, the ramdisk is passed as
address : size. However, the size pointed to the temporary variable
filesize, which denotes the filesize of the last load. When combining
with DT overlays, the overlays are loaded later and by that overwrite
the filesize variable, resulting in a partially passed initrd.

To fix this, we assign the size immediately after loading it to an env
variable and use that when booting.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/recipes-bsp/u-boot-script/files/update-u-boot-script | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Quirin Gylstorff Aug. 3, 2023, 10:22 a.m. UTC | #1
On 8/1/23 11:37, 'Felix Moessbauer' via isar-users wrote:
> When booting the kernel via a boot* command, the ramdisk is passed as
> address : size. However, the size pointed to the temporary variable
> filesize, which denotes the filesize of the last load. When combining
> with DT overlays, the overlays are loaded later and by that overwrite
> the filesize variable, resulting in a partially passed initrd.
> 
> To fix this, we assign the size immediately after loading it to an env
> variable and use that when booting.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>   meta/recipes-bsp/u-boot-script/files/update-u-boot-script | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-bsp/u-boot-script/files/update-u-boot-script b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
> index 39b9fa0f..e9ace15e 100755
> --- a/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
> +++ b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
> @@ -50,7 +50,8 @@ yes|1)
>   	echo "load \${devtype} \${devnum}:\${distro_bootpart}" \
>   	     "\${ramdisk_addr_r} /boot/initrd.img-${KERNEL_VERSION}" \
>   	     >> ${BOOT_CMD}
> -	INITRD_ADDR="\${ramdisk_addr_r}:\${filesize}"
> +	echo "setenv ramdisk_size \${filesize}" >> ${BOOT_CMD}
> +	INITRD_ADDR="\${ramdisk_addr_r}:\${ramdisk_size}"
>   esac
>   
>   if [ -n "${OVERLAYS}" ]; then

I think this patch should be applied separately.
Quirin

Patch

diff --git a/meta/recipes-bsp/u-boot-script/files/update-u-boot-script b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
index 39b9fa0f..e9ace15e 100755
--- a/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
+++ b/meta/recipes-bsp/u-boot-script/files/update-u-boot-script
@@ -50,7 +50,8 @@  yes|1)
 	echo "load \${devtype} \${devnum}:\${distro_bootpart}" \
 	     "\${ramdisk_addr_r} /boot/initrd.img-${KERNEL_VERSION}" \
 	     >> ${BOOT_CMD}
-	INITRD_ADDR="\${ramdisk_addr_r}:\${filesize}"
+	echo "setenv ramdisk_size \${filesize}" >> ${BOOT_CMD}
+	INITRD_ADDR="\${ramdisk_addr_r}:\${ramdisk_size}"
 esac
 
 if [ -n "${OVERLAYS}" ]; then