diff mbox series

[ImageBuilder] uboot-script-gen: fix arm64 xen u-boot image generation

Message ID 20250414081223.1763630-1-grygorii_strashko@epam.com (mailing list archive)
State Superseded
Headers show
Series [ImageBuilder] uboot-script-gen: fix arm64 xen u-boot image generation | expand

Commit Message

Grygorii Strashko April 14, 2025, 8:12 a.m. UTC
From: Grygorii Strashko <grygorii_strashko@epam.com>

The current code in generate_uboot_images() does not detect arm64 properly
and always generates ARM u-boot image. This causes Xen boot issues.

Fix it by searching for "ARM64" for AArch64 binary detection.

- mkimage -l xen.ub
Before:
Image Type:   ARM Linux Kernel Image (uncompressed)

After:
Image Type:   AArch64 Linux Kernel Image (uncompressed)

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
 scripts/uboot-script-gen | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Stefano Stabellini April 16, 2025, 1:03 a.m. UTC | #1
On Mon, 14 Apr 2025, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> The current code in generate_uboot_images() does not detect arm64 properly
> and always generates ARM u-boot image. This causes Xen boot issues.
> 
> Fix it by searching for "ARM64" for AArch64 binary detection.
> 
> - mkimage -l xen.ub
> Before:
> Image Type:   ARM Linux Kernel Image (uncompressed)
> 
> After:
> Image Type:   AArch64 Linux Kernel Image (uncompressed)
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
> ---
>  scripts/uboot-script-gen | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index a9f698f00fd1..c4d26caf5e0e 100755
> --- a/scripts/uboot-script-gen
> +++ b/scripts/uboot-script-gen
> @@ -815,13 +815,13 @@ function linux_config()
>  
>  generate_uboot_images()
>  {
> -    local arch=$(file -L $XEN | grep "ARM")
> +    local arch=$(file -L $XEN | grep -o "ARM64")

My file -L gives:

for arm32: ARM OpenFirmware [...]
for arm64: Aarch64

So the ARM64 grep wouldn't work as intended. Is the version of `file'
that you are using really printing ARM64? If so, we can do:

  file -L $XEN | grep -E 'ARM64|Aarch64'


>      if test "$arch"
>      then
> -        arch=arm
> -    else
>          arch=arm64
> +    else
> +        arch=arm
>      fi
>  
>      mkimage -A $arch -T kernel -C none -a $memaddr -e $memaddr -d $XEN "$XEN".ub
> -- 
> 2.34.1
>
Grygorii Strashko April 16, 2025, 10:44 a.m. UTC | #2
On 16.04.25 04:03, Stefano Stabellini wrote:
> On Mon, 14 Apr 2025, Grygorii Strashko wrote:
>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> The current code in generate_uboot_images() does not detect arm64 properly
>> and always generates ARM u-boot image. This causes Xen boot issues.
>>
>> Fix it by searching for "ARM64" for AArch64 binary detection.
>>
>> - mkimage -l xen.ub
>> Before:
>> Image Type:   ARM Linux Kernel Image (uncompressed)
>>
>> After:
>> Image Type:   AArch64 Linux Kernel Image (uncompressed)
>>
>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
>> ---
>>   scripts/uboot-script-gen | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
>> index a9f698f00fd1..c4d26caf5e0e 100755
>> --- a/scripts/uboot-script-gen
>> +++ b/scripts/uboot-script-gen
>> @@ -815,13 +815,13 @@ function linux_config()
>>   
>>   generate_uboot_images()
>>   {
>> -    local arch=$(file -L $XEN | grep "ARM")
>> +    local arch=$(file -L $XEN | grep -o "ARM64")
> 
> My file -L gives:
> 
> for arm32: ARM OpenFirmware [...]
> for arm64: Aarch64
> 
> So the ARM64 grep wouldn't work as intended. Is the version of `file'
> that you are using really printing ARM64?

Hm, yes.

	file -L xen
	xen: Linux kernel ARM64 boot executable Image, little-endian, 4K pages

	file -v
	file-5.41

u-boot boot command:
	 bootm 0x4EA00000 - 0x4EE00000


  If so, we can do:
> 
>    file -L $XEN | grep -E 'ARM64|Aarch64'

sure. I'll update.

> 
> 
>>       if test "$arch"
>>       then
>> -        arch=arm
>> -    else
>>           arch=arm64
>> +    else
>> +        arch=arm
>>       fi
>>   
>>       mkimage -A $arch -T kernel -C none -a $memaddr -e $memaddr -d $XEN "$XEN".ub
>> -- 
>> 2.34.1
>>
Alejandro Vallejo April 16, 2025, 2:26 p.m. UTC | #3
On Wed Apr 16, 2025 at 11:44 AM BST, Grygorii Strashko wrote:
>
>
> On 16.04.25 04:03, Stefano Stabellini wrote:
>> On Mon, 14 Apr 2025, Grygorii Strashko wrote:
>>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>>
>>> The current code in generate_uboot_images() does not detect arm64 properly
>>> and always generates ARM u-boot image. This causes Xen boot issues.
>>>
>>> Fix it by searching for "ARM64" for AArch64 binary detection.
>>>
>>> - mkimage -l xen.ub
>>> Before:
>>> Image Type:   ARM Linux Kernel Image (uncompressed)
>>>
>>> After:
>>> Image Type:   AArch64 Linux Kernel Image (uncompressed)
>>>
>>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
>>> ---
>>>   scripts/uboot-script-gen | 6 +++---
>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
>>> index a9f698f00fd1..c4d26caf5e0e 100755
>>> --- a/scripts/uboot-script-gen
>>> +++ b/scripts/uboot-script-gen
>>> @@ -815,13 +815,13 @@ function linux_config()
>>>   
>>>   generate_uboot_images()
>>>   {
>>> -    local arch=$(file -L $XEN | grep "ARM")
>>> +    local arch=$(file -L $XEN | grep -o "ARM64")
>> 
>> My file -L gives:
>> 
>> for arm32: ARM OpenFirmware [...]
>> for arm64: Aarch64
>> 
>> So the ARM64 grep wouldn't work as intended. Is the version of `file'
>> that you are using really printing ARM64?
>
> Hm, yes.
>
> 	file -L xen
> 	xen: Linux kernel ARM64 boot executable Image, little-endian, 4K pages
>
> 	file -v
> 	file-5.41
>
> u-boot boot command:
> 	 bootm 0x4EA00000 - 0x4EE00000
>
>
>   If so, we can do:
>> 
>>    file -L $XEN | grep -E 'ARM64|Aarch64'
>
> sure. I'll update.

Missing escape? I think it's needed even with single quotes.

  file -L $XEN | grep -E 'ARM64\|Aarch64'

Cheers,
Alejandro
Grygorii Strashko April 16, 2025, 4:10 p.m. UTC | #4
On 16.04.25 17:26, Alejandro Vallejo wrote:
> On Wed Apr 16, 2025 at 11:44 AM BST, Grygorii Strashko wrote:
>>
>>
>> On 16.04.25 04:03, Stefano Stabellini wrote:
>>> On Mon, 14 Apr 2025, Grygorii Strashko wrote:
>>>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>>>
>>>> The current code in generate_uboot_images() does not detect arm64 properly
>>>> and always generates ARM u-boot image. This causes Xen boot issues.
>>>>
>>>> Fix it by searching for "ARM64" for AArch64 binary detection.
>>>>
>>>> - mkimage -l xen.ub
>>>> Before:
>>>> Image Type:   ARM Linux Kernel Image (uncompressed)
>>>>
>>>> After:
>>>> Image Type:   AArch64 Linux Kernel Image (uncompressed)
>>>>
>>>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
>>>> ---
>>>>    scripts/uboot-script-gen | 6 +++---
>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
>>>> index a9f698f00fd1..c4d26caf5e0e 100755
>>>> --- a/scripts/uboot-script-gen
>>>> +++ b/scripts/uboot-script-gen
>>>> @@ -815,13 +815,13 @@ function linux_config()
>>>>    
>>>>    generate_uboot_images()
>>>>    {
>>>> -    local arch=$(file -L $XEN | grep "ARM")
>>>> +    local arch=$(file -L $XEN | grep -o "ARM64")
>>>
>>> My file -L gives:
>>>
>>> for arm32: ARM OpenFirmware [...]
>>> for arm64: Aarch64
>>>
>>> So the ARM64 grep wouldn't work as intended. Is the version of `file'
>>> that you are using really printing ARM64?
>>
>> Hm, yes.
>>
>> 	file -L xen
>> 	xen: Linux kernel ARM64 boot executable Image, little-endian, 4K pages
>>
>> 	file -v
>> 	file-5.41
>>
>> u-boot boot command:
>> 	 bootm 0x4EA00000 - 0x4EE00000
>>
>>
>>    If so, we can do:
>>>
>>>     file -L $XEN | grep -E 'ARM64|Aarch64'
>>
>> sure. I'll update.
> 
> Missing escape? I think it's needed even with single quotes.
> 
>    file -L $XEN | grep -E 'ARM64\|Aarch64'

No. It's extended regular expressions ("-E") no need for escape.
Also it works with both '' and "".
Alejandro Vallejo April 17, 2025, 12:29 p.m. UTC | #5
On Wed Apr 16, 2025 at 5:10 PM BST, Grygorii Strashko wrote:
>
>
> On 16.04.25 17:26, Alejandro Vallejo wrote:
>> On Wed Apr 16, 2025 at 11:44 AM BST, Grygorii Strashko wrote:
>>>
>>>
>>> On 16.04.25 04:03, Stefano Stabellini wrote:
>>>> On Mon, 14 Apr 2025, Grygorii Strashko wrote:
>>>>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>>>>
>>>>> The current code in generate_uboot_images() does not detect arm64 properly
>>>>> and always generates ARM u-boot image. This causes Xen boot issues.
>>>>>
>>>>> Fix it by searching for "ARM64" for AArch64 binary detection.
>>>>>
>>>>> - mkimage -l xen.ub
>>>>> Before:
>>>>> Image Type:   ARM Linux Kernel Image (uncompressed)
>>>>>
>>>>> After:
>>>>> Image Type:   AArch64 Linux Kernel Image (uncompressed)
>>>>>
>>>>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
>>>>> ---
>>>>>    scripts/uboot-script-gen | 6 +++---
>>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
>>>>> index a9f698f00fd1..c4d26caf5e0e 100755
>>>>> --- a/scripts/uboot-script-gen
>>>>> +++ b/scripts/uboot-script-gen
>>>>> @@ -815,13 +815,13 @@ function linux_config()
>>>>>    
>>>>>    generate_uboot_images()
>>>>>    {
>>>>> -    local arch=$(file -L $XEN | grep "ARM")
>>>>> +    local arch=$(file -L $XEN | grep -o "ARM64")
>>>>
>>>> My file -L gives:
>>>>
>>>> for arm32: ARM OpenFirmware [...]
>>>> for arm64: Aarch64
>>>>
>>>> So the ARM64 grep wouldn't work as intended. Is the version of `file'
>>>> that you are using really printing ARM64?
>>>
>>> Hm, yes.
>>>
>>> 	file -L xen
>>> 	xen: Linux kernel ARM64 boot executable Image, little-endian, 4K pages
>>>
>>> 	file -v
>>> 	file-5.41
>>>
>>> u-boot boot command:
>>> 	 bootm 0x4EA00000 - 0x4EE00000
>>>
>>>
>>>    If so, we can do:
>>>>
>>>>     file -L $XEN | grep -E 'ARM64|Aarch64'
>>>
>>> sure. I'll update.
>> 
>> Missing escape? I think it's needed even with single quotes.
>> 
>>    file -L $XEN | grep -E 'ARM64\|Aarch64'
>
> No. It's extended regular expressions ("-E") no need for escape.
> Also it works with both '' and "".

Ah, fair enough. My brain escaped the -E :)

Cheers,
Alejandro
diff mbox series

Patch

diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index a9f698f00fd1..c4d26caf5e0e 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -815,13 +815,13 @@  function linux_config()
 
 generate_uboot_images()
 {
-    local arch=$(file -L $XEN | grep "ARM")
+    local arch=$(file -L $XEN | grep -o "ARM64")
 
     if test "$arch"
     then
-        arch=arm
-    else
         arch=arm64
+    else
+        arch=arm
     fi
 
     mkimage -A $arch -T kernel -C none -a $memaddr -e $memaddr -d $XEN "$XEN".ub