Skip to contentSkip to conversation

fvp: Add support for loading Android boot images via semihosting

PATCH New Peter Collingbourne 4 participants 7 messages Apr 4, 2020 – Apr 24, 2020 1 message not in the archive Arm/versatile express platform

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

---
 configs/vexpress_aemv8a_semi_defconfig |  2 ++
 include/configs/vexpress_aemv8a.h      | 30 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 10 deletions(-)
configs/vexpress_aemv8a_semi_defconfig +2 -0
index f31baab197..b52c761dee 100644
@@ -14,6 +14,8 @@ CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 l
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYS_PROMPT="VExpress64# "
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_CONSOLE is not set
 # CONFIG_CMD_XIMG is not set
 # CONFIG_CMD_EDITENV is not set
include/configs/vexpress_aemv8a.h +20 -10
index 9a9cec414c..4f3a792f49 100644
@@ -177,16 +177,26 @@
 				"initrd_addr=0x88000000\0"	\
 				"fdtfile=devtree.dtb\0"		\
 				"fdt_addr=0x83000000\0"		\
-				"fdt_high=0xffffffffffffffff\0"	\
-				"initrd_high=0xffffffffffffffff\0"
-
-#define CONFIG_BOOTCOMMAND	"smhload ${kernel_name} ${kernel_addr}; " \
-				"smhload ${fdtfile} ${fdt_addr}; " \
-				"smhload ${initrd_name} ${initrd_addr} "\
-				"initrd_end; " \
-				"fdt addr ${fdt_addr}; fdt resize; " \
-				"fdt chosen ${initrd_addr} ${initrd_end}; " \
-				"booti $kernel_addr - $fdt_addr"
+				"boot_name=boot.img\0"		\
+				"boot_addr=0x8007f800\0"
+
+#define CONFIG_BOOTCOMMAND	"if smhload ${boot_name} ${boot_addr}; then " \
+				"  set bootargs; " \
+				"  abootimg addr ${boot_addr}; " \
+				"  abootimg get dtb --index=0 fdt_addr; " \
+				"  bootm ${boot_addr} ${boot_addr} " \
+				"  ${fdt_addr}; " \
+				"else; " \
+				"  set fdt_high 0xffffffffffffffff; " \
+				"  set initrd_high 0xffffffffffffffff; " \
+				"  smhload ${kernel_name} ${kernel_addr}; " \
+				"  smhload ${fdtfile} ${fdt_addr}; " \
+				"  smhload ${initrd_name} ${initrd_addr} "\
+				"  initrd_end; " \
+				"  fdt addr ${fdt_addr}; fdt resize; " \
+				"  fdt chosen ${initrd_addr} ${initrd_end}; " \
+				"  booti $kernel_addr - $fdt_addr; " \
+				"fi"
 
 
 #endif
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
#2 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

In reply to a message not in the archive
Quoted 37 lines · Ryan Harkin

Hi Peter,

This looks good to me, but I have a quick question below.

Quoted 31 lines · Peter Collingbourne

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

---
 configs/vexpress_aemv8a_semi_defconfig |  2 ++
 include/configs/vexpress_aemv8a.h      | 30 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 10 deletions(-)
configs/vexpress_aemv8a_semi_defconfig +0 -0
index f31baab197..b52c761dee 100644
@@ -14,6 +14,8 @@ CONFIG_BOOTARGS="console=ttyAMA0

earlycon=pl011,0x1c090000 debug user_debug=31 l
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_SYS_PROMPT="VExpress64# "

configs/vexpress_aemv8a_semi_defconfig +2 -0
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_CONSOLE is not set
 # CONFIG_CMD_XIMG is not set
 # CONFIG_CMD_EDITENV is not set
include/configs/vexpress_aemv8a.h +0 -0
index 9a9cec414c..4f3a792f49 100644
@@ -177,16 +177,26 @@
                                "initrd_addr=0x88000000\0"      \
Quoted 9 lines

include/configs/vexpress_aemv8a.h line 200

Quoted 5 lines
include/configs/vexpress_aemv8a.h +0 -2
                                "fdtfile=devtree.dtb\0"         \
                                "fdt_addr=0x83000000\0"         \
-                               "fdt_high=0xffffffffffffffff\0" \
-                               "initrd_high=0xffffffffffffffff\0"
 

Why did you move these two inside the 'if' statement below? Is it because you explicitly don't want them set when booting Android?

Yes. We can't have these set when loading an Android boot image because they instruct the bootloader to use the device tree/initrd in place instead of copying them to another location, and since we're already using the kernel in place this may result in the kernel overwriting the device tree or initrd when it initializes its own BSS since they appear right after the kernel in the boot image format.

Peter

Quoted 45 lines
Quoted 45 lines
include/configs/vexpress_aemv8a.h +4 -8
-
-#define CONFIG_BOOTCOMMAND     "smhload ${kernel_name} ${kernel_addr}; "
 \
-                               "smhload ${fdtfile} ${fdt_addr}; " \
-                               "smhload ${initrd_name} ${initrd_addr} "\
-                               "initrd_end; " \
-                               "fdt addr ${fdt_addr}; fdt resize; " \
-                               "fdt chosen ${initrd_addr} ${initrd_end};
 " \
-                               "booti $kernel_addr - $fdt_addr"
+                               "boot_name=boot.img\0"          \
+                               "boot_addr=0x8007f800\0"
+
+#define CONFIG_BOOTCOMMAND     "if smhload ${boot_name} ${boot_addr};

then " \

include/configs/vexpress_aemv8a.h +3 -0
+                               "  set bootargs; " \
+                               "  abootimg addr ${boot_addr}; " \
+                               "  abootimg get dtb --index=0 fdt_addr; "

\

include/configs/vexpress_aemv8a.h +6 -0
+                               "  bootm ${boot_addr} ${boot_addr} " \
+                               "  ${fdt_addr}; " \
+                               "else; " \
+                               "  set fdt_high 0xffffffffffffffff; " \
+                               "  set initrd_high 0xffffffffffffffff; " \
+                               "  smhload ${kernel_name} ${kernel_addr};

" \

include/configs/vexpress_aemv8a.h +2 -0
+                               "  smhload ${fdtfile} ${fdt_addr}; " \
+                               "  smhload ${initrd_name} ${initrd_addr}

"\

include/configs/vexpress_aemv8a.h +3 -0
+                               "  initrd_end; " \
+                               "  fdt addr ${fdt_addr}; fdt resize; " \
+                               "  fdt chosen ${initrd_addr}

${initrd_end}; " \

include/configs/vexpress_aemv8a.h +2 -1
+                               "  booti $kernel_addr - $fdt_addr; " \
+                               "fi"
 
 
 #endif
--

2.26.0.292.g33ef6b2f38-goog

#3 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

Quoted 50 lines · Peter Collingbourne
Quoted 37 lines · Ryan Harkin

Hi Peter,

This looks good to me, but I have a quick question below.

Quoted 31 lines · Peter Collingbourne

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

---
 configs/vexpress_aemv8a_semi_defconfig |  2 ++
 include/configs/vexpress_aemv8a.h      | 30 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 10 deletions(-)
configs/vexpress_aemv8a_semi_defconfig +0 -0
index f31baab197..b52c761dee 100644
@@ -14,6 +14,8 @@ CONFIG_BOOTARGS="console=ttyAMA0

earlycon=pl011,0x1c090000 debug user_debug=31 l
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_SYS_PROMPT="VExpress64# "

configs/vexpress_aemv8a_semi_defconfig +2 -0
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_CONSOLE is not set
 # CONFIG_CMD_XIMG is not set
 # CONFIG_CMD_EDITENV is not set
include/configs/vexpress_aemv8a.h +0 -0
index 9a9cec414c..4f3a792f49 100644
@@ -177,16 +177,26 @@
                                "initrd_addr=0x88000000\0"      \
Quoted 9 lines

include/configs/vexpress_aemv8a.h line 200

Quoted 5 lines
include/configs/vexpress_aemv8a.h +0 -2
                                "fdtfile=devtree.dtb\0"         \
                                "fdt_addr=0x83000000\0"         \
-                               "fdt_high=0xffffffffffffffff\0" \
-                               "initrd_high=0xffffffffffffffff\0"
 

Why did you move these two inside the 'if' statement below? Is it because you explicitly don't want them set when booting Android?

Quoted 7 lines

Yes. We can't have these set when loading an Android boot image because they instruct the bootloader to use the device tree/initrd in place instead of copying them to another location, and since we're already using the kernel in place this may result in the kernel overwriting the device tree or initrd when it initializes its own BSS since they appear right after the kernel in the boot image format.

Ok, thanks for the clarification. That's fine by me.

Quoted 49 lines

Peter

Quoted 46 lines
Quoted 46 lines
include/configs/vexpress_aemv8a.h +4 -8
-
-#define CONFIG_BOOTCOMMAND     "smhload ${kernel_name} ${kernel_addr};
 " \
-                               "smhload ${fdtfile} ${fdt_addr}; " \
-                               "smhload ${initrd_name} ${initrd_addr} "\
-                               "initrd_end; " \
-                               "fdt addr ${fdt_addr}; fdt resize; " \
-                               "fdt chosen ${initrd_addr}
 ${initrd_end}; " \
-                               "booti $kernel_addr - $fdt_addr"
+                               "boot_name=boot.img\0"          \
+                               "boot_addr=0x8007f800\0"
+
+#define CONFIG_BOOTCOMMAND     "if smhload ${boot_name} ${boot_addr};

then " \

include/configs/vexpress_aemv8a.h +3 -0
+                               "  set bootargs; " \
+                               "  abootimg addr ${boot_addr}; " \
+                               "  abootimg get dtb --index=0 fdt_addr;

" \

include/configs/vexpress_aemv8a.h +5 -0
+                               "  bootm ${boot_addr} ${boot_addr} " \
+                               "  ${fdt_addr}; " \
+                               "else; " \
+                               "  set fdt_high 0xffffffffffffffff; " \
+                               "  set initrd_high 0xffffffffffffffff; "

\
+ " smhload ${kernel_name}
${kernel_addr}; " \

include/configs/vexpress_aemv8a.h +2 -0
+                               "  smhload ${fdtfile} ${fdt_addr}; " \
+                               "  smhload ${initrd_name} ${initrd_addr}

"\

include/configs/vexpress_aemv8a.h +3 -0
+                               "  initrd_end; " \
+                               "  fdt addr ${fdt_addr}; fdt resize; " \
+                               "  fdt chosen ${initrd_addr}

${initrd_end}; " \

include/configs/vexpress_aemv8a.h +2 -1
+                               "  booti $kernel_addr - $fdt_addr; " \
+                               "fi"
 
 
 #endif
--

2.26.0.292.g33ef6b2f38-goog

#4 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

Quoted 61 lines · Ryan Harkin
Quoted 50 lines · Peter Collingbourne
Quoted 37 lines · Ryan Harkin

Hi Peter,

This looks good to me, but I have a quick question below.

Quoted 31 lines · Peter Collingbourne

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

---
 configs/vexpress_aemv8a_semi_defconfig |  2 ++
 include/configs/vexpress_aemv8a.h      | 30 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 10 deletions(-)
configs/vexpress_aemv8a_semi_defconfig +0 -0
index f31baab197..b52c761dee 100644
@@ -14,6 +14,8 @@ CONFIG_BOOTARGS="console=ttyAMA0

earlycon=pl011,0x1c090000 debug user_debug=31 l
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_SYS_PROMPT="VExpress64# "

configs/vexpress_aemv8a_semi_defconfig +2 -0
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_CONSOLE is not set
 # CONFIG_CMD_XIMG is not set
 # CONFIG_CMD_EDITENV is not set
include/configs/vexpress_aemv8a.h +0 -0
index 9a9cec414c..4f3a792f49 100644
@@ -177,16 +177,26 @@
                                "initrd_addr=0x88000000\0"      \
Quoted 9 lines

include/configs/vexpress_aemv8a.h line 200

Quoted 5 lines
include/configs/vexpress_aemv8a.h +0 -2
                                "fdtfile=devtree.dtb\0"         \
                                "fdt_addr=0x83000000\0"         \
-                               "fdt_high=0xffffffffffffffff\0" \
-                               "initrd_high=0xffffffffffffffff\0"
 

Why did you move these two inside the 'if' statement below? Is it because you explicitly don't want them set when booting Android?

Quoted 7 lines

Yes. We can't have these set when loading an Android boot image because they instruct the bootloader to use the device tree/initrd in place instead of copying them to another location, and since we're already using the kernel in place this may result in the kernel overwriting the device tree or initrd when it initializes its own BSS since they appear right after the kernel in the boot image format.

Quoted 4 lines

Ok, thanks for the clarification. That's fine by me.

Thanks for the review! Do you know what is the next step for getting this patch landed in master? I read https://www.denx.de/wiki/U-Boot/Patches but unfortunately I did not get a clear idea of what the next step is.

Peter

Quoted 51 lines
Quoted 51 lines

Peter

Quoted 47 lines
Quoted 47 lines
include/configs/vexpress_aemv8a.h +4 -8
-
-#define CONFIG_BOOTCOMMAND     "smhload ${kernel_name} ${kernel_addr};
 " \
-                               "smhload ${fdtfile} ${fdt_addr}; " \
-                               "smhload ${initrd_name} ${initrd_addr}
 "\
-                               "initrd_end; " \
-                               "fdt addr ${fdt_addr}; fdt resize; " \
-                               "fdt chosen ${initrd_addr}
 ${initrd_end}; " \
-                               "booti $kernel_addr - $fdt_addr"
+                               "boot_name=boot.img\0"          \
+                               "boot_addr=0x8007f800\0"
+
+#define CONFIG_BOOTCOMMAND     "if smhload ${boot_name} ${boot_addr};

then " \

include/configs/vexpress_aemv8a.h +3 -0
+                               "  set bootargs; " \
+                               "  abootimg addr ${boot_addr}; " \
+                               "  abootimg get dtb --index=0 fdt_addr;

" \

include/configs/vexpress_aemv8a.h +5 -0
+                               "  bootm ${boot_addr} ${boot_addr} " \
+                               "  ${fdt_addr}; " \
+                               "else; " \
+                               "  set fdt_high 0xffffffffffffffff; " \
+                               "  set initrd_high 0xffffffffffffffff;

" \
+ " smhload ${kernel_name}
${kernel_addr}; " \

include/configs/vexpress_aemv8a.h +2 -0
+                               "  smhload ${fdtfile} ${fdt_addr}; " \
+                               "  smhload ${initrd_name}

${initrd_addr} "\

include/configs/vexpress_aemv8a.h +3 -0
+                               "  initrd_end; " \
+                               "  fdt addr ${fdt_addr}; fdt resize; " \
+                               "  fdt chosen ${initrd_addr}

${initrd_end}; " \

include/configs/vexpress_aemv8a.h +2 -1
+                               "  booti $kernel_addr - $fdt_addr; " \
+                               "fi"
 
 
 #endif
--

2.26.0.292.g33ef6b2f38-goog

#5 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

Quoted 63 lines · Peter Collingbourne
Quoted 61 lines · Ryan Harkin
Quoted 57 lines · Peter Collingbourne
Quoted 37 lines · Ryan Harkin

Hi Peter,

This looks good to me, but I have a quick question below.

Quoted 31 lines · Peter Collingbourne

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

---
 configs/vexpress_aemv8a_semi_defconfig |  2 ++
 include/configs/vexpress_aemv8a.h      | 30 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 10 deletions(-)
configs/vexpress_aemv8a_semi_defconfig +0 -0
index f31baab197..b52c761dee 100644
@@ -14,6 +14,8 @@ CONFIG_BOOTARGS="console=ttyAMA0

earlycon=pl011,0x1c090000 debug user_debug=31 l
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_SYS_PROMPT="VExpress64# "

configs/vexpress_aemv8a_semi_defconfig +2 -0
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_CONSOLE is not set
 # CONFIG_CMD_XIMG is not set
 # CONFIG_CMD_EDITENV is not set
include/configs/vexpress_aemv8a.h +0 -0
index 9a9cec414c..4f3a792f49 100644
@@ -177,16 +177,26 @@
                                "initrd_addr=0x88000000\0"      \
Quoted 9 lines

include/configs/vexpress_aemv8a.h line 200

Quoted 5 lines
include/configs/vexpress_aemv8a.h +0 -2
                                "fdtfile=devtree.dtb\0"         \
                                "fdt_addr=0x83000000\0"         \
-                               "fdt_high=0xffffffffffffffff\0" \
-                               "initrd_high=0xffffffffffffffff\0"
 

Why did you move these two inside the 'if' statement below? Is it because you explicitly don't want them set when booting Android?

Yes. We can't have these set when loading an Android boot image because they instruct the bootloader to use the device tree/initrd in place instead of copying them to another location, and since we're already using the kernel in place this may result in the kernel overwriting the device tree or initrd when it initializes its own BSS since they appear right after the kernel in the boot image format.

Quoted 8 lines
Quoted 4 lines

Ok, thanks for the clarification. That's fine by me.

Thanks for the review! Do you know what is the next step for getting this patch landed in master? I read https://www.denx.de/wiki/U-Boot/Patches but unfortunately I did not get a clear idea of what the next step is.

It's on me to pick up and I will soon, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200414/7ce609e4/attachment.sig>
#6 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

In reply to Peter Collingbourne
Quoted 4 lines · Peter Collingbourne

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

That's very helpful when doing Android development. Thanks for doing this.

Yours,
Linus Walleij

#7 lore raw

PATCH 1/1 fvp: Add support for loading Android boot images via semihosting

In reply to Peter Collingbourne
Quoted 6 lines · Peter Collingbourne

FVP now loads an Android boot image named boot.img if available, otherwise it falls back to the existing code path.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/0538e198/attachment.sig>