Skip to contentSkip to conversation

Enable FIT image support and FDT loading for AST2400/AST2500

PATCH Superseded Rick Altherr 3 participants 10 messages Dec 2, 2016 – Dec 5, 2016

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enable FIT image support and FDT loading for AST2400/AST2500

Enable support for loading from FIT images and passing parameters to the Linux kernel via FDT on AST2400/AST2500. Replace a hack that forced ramdisk relocation with a proper fix as the hack was broken with FDT support enabled.

Series was tested under qemu by booting images for Palmetto and Withspoon. Both legacy and FIT images for kernel+dtb were tested. Legacy image was always used for ramdisk.

Cédric Le Goater (1):
aspeed: remove hack loading ramdisk in memory

Rick Altherr (2):
bootm: relocate ramdisk if CONFIG_SYS_BOOT_RAMDISK_HIGH set Enable FIT image support and FDT loading for AST2400/AST2500

 cmd/bootm.c                   |  3 +++
 common/image.c                | 18 ------------------
 configs/ast_g4_ncsi_defconfig |  5 +++++
 configs/ast_g4_phy_defconfig  |  5 +++++
 configs/ast_g5_ncsi_defconfig |  5 +++++
 configs/ast_g5_phy_defconfig  |  5 +++++
 6 files changed, 23 insertions(+), 18 deletions(-)

--
Changes for v2:
- Fix compiler warning caused by ramdisk relocation hack
- Reduce binary size by disabling EFI support

Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v2 1/3 aspeed: remove hack loading ramdisk in memory

From: Cédric Le Goater <[email protected]>

---
 common/image.c | 11 -----------
 1 file changed, 11 deletions(-)
common/image.c +0 -11
index 20c4807..0be09e5 100644
@@ -1069,17 +1069,6 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 				return 1;
 			}
 		}
-/// TODO ... Check Why ..................
-#if  defined(CONFIG_ARCH_ASPEED)
-		/*
-		 * We need to copy the ramdisk to SRAM to let Linux boot
-		 */
-		if (rd_data) {
-			memmove ((void *)rd_load, (uchar *)rd_data, rd_len);
-			rd_data = rd_load;
-		}
-#endif /* CONFIG_ASPEED */
-
 	} else if (images->legacy_hdr_valid &&
 			image_check_type(&images->legacy_hdr_os_copy,
 						IH_TYPE_MULTI)) {
Signature · 1 line
2.8.0.rc3.226.g39d4020
#5 lore raw

PATCH v2 2/3 bootm: relocate ramdisk if CONFIG_SYS_BOOT_RAMDISK_HIGH set

In reply to Rick Altherr

In 35fc84f, bootm was refactored so plain 'bootm' and 'bootm <subcommand>' shared a common implementation.
The 'bootm ramdisk' command implementation is now part of the common implementation but not invoke by plain 'bootm' since the original implementation never did ramdisk relocation. Instead, ramdisk relocation happened in image_setup_linux() which is typically called during the OS portion of 'bootm'.

On ARM, parameters to the Linux kernel can either be passed by FDT or ATAGS. When using FDT, image_setup_linux() is called which also triggers ramdisk relocation. When using ATAGS, image_setup_linux() is _not_ called because it mostly does FDT setup.

Instead of calling image_setup_linux() in both FDT and ATAGS cases, include BOOTM_STATE_RAMDISK in the requested states during a plain 'bootm' if CONFIG_SYS_BOOT_RAMDISK_HIGH is set and remove the ramdisk relocation from image_setup_linux(). This causes ramdisk relocation to happen on any system where CONFIG_SYS_BOOT_RAMDISK_HIGH regardless of the OS being booted.

---
 cmd/bootm.c    | 3 +++
 common/image.c | 7 -------
 2 files changed, 3 insertions(+), 7 deletions(-)
cmd/bootm.c +3 -0
index 16fdea5..8da750e 100644
@@ -131,6 +131,9 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
 		BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
 		BOOTM_STATE_LOADOS |
+#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
+		BOOTM_STATE_RAMDISK |
+#endif
 #if defined(CONFIG_PPC) || defined(CONFIG_MIPS)
 		BOOTM_STATE_OS_CMDLINE |
 #endif
common/image.c +0 -7
index 0be09e5..6584f7f 100644
@@ -1470,13 +1470,6 @@ int image_setup_linux(bootm_headers_t *images)
 			return ret;
 		}
 	}
-	if (IMAGE_ENABLE_RAMDISK_HIGH) {
-		rd_len = images->rd_end - images->rd_start;
-		ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
-				initrd_start, initrd_end);
-		if (ret)
-			return ret;
-	}
 
 	if (IMAGE_ENABLE_OF_LIBFDT) {
 		ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#8 lore raw

PATCH v2 3/3 Enable FIT image support and FDT loading for AST2400/AST2500

In reply to Rick Altherr

FIT is the modern u-boot native image format for kernels, device trees, and ramdisks. Enabling FIT only compiles in support for the image format. For these devices, the kernel+dtb and ramdisk are loaded from separate locations in flash and can be any mix of legacy or FIT images. When using FIT images, the dtb is stored as a separate entry that requires CONFIG_OF_LIBFDT to load it into RAM and pass it to the kernel.

u-boot enables EFI support by default but it only builds once FIT support is enabled. EFI support adds ~13k to the binary and is currently unused for any Aspeed platforms. Explicitly disable EFI support now that FIT support is enabled.

Tested under qemu with both legacy and FIT kernel+dtb images for palmetto and witherspoon.

---
 configs/ast_g4_ncsi_defconfig | 5 +++++
 configs/ast_g4_phy_defconfig  | 5 +++++
 configs/ast_g5_ncsi_defconfig | 5 +++++
 configs/ast_g5_phy_defconfig  | 5 +++++
 4 files changed, 20 insertions(+)
configs/ast_g4_ncsi_defconfig +5 -0
index 4ee71c5..ab4907c 100644
@@ -1,7 +1,12 @@
 CONFIG_ARM=y
 CONFIG_TARGET_AST_G4=y
 CONFIG_SYS_PROMPT="ast# "
+CONFIG_CMD_BOOTEFI=n
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_OF_LIBFDT=y
 CONFIG_SPI_FLASH=y
 CONFIG_SYS_NS16550=y
configs/ast_g4_phy_defconfig +5 -0
index 61fd69b..21a56c4 100644
@@ -2,7 +2,12 @@ CONFIG_ARM=y
 CONFIG_TARGET_AST_G4=y
 CONFIG_ASPEED_NET_PHY=y
 CONFIG_SYS_PROMPT="ast# "
+CONFIG_CMD_BOOTEFI=n
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_OF_LIBFDT=y
 CONFIG_SPI_FLASH=y
 CONFIG_SYS_NS16550=y
configs/ast_g5_ncsi_defconfig +5 -0
index 6d11afb..7cd4fd1 100644
@@ -1,7 +1,12 @@
 CONFIG_ARM=y
 CONFIG_TARGET_AST_G5=y
 CONFIG_SYS_PROMPT="ast# "
+CONFIG_CMD_BOOTEFI=n
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_OF_LIBFDT=y
 CONFIG_SPI_FLASH=y
 CONFIG_SYS_NS16550=y
configs/ast_g5_phy_defconfig +5 -0
index 20f62e0..c686dd2 100644
@@ -2,7 +2,12 @@ CONFIG_ARM=y
 CONFIG_TARGET_AST_G5=y
 CONFIG_ASPEED_NET_PHY=y
 CONFIG_SYS_PROMPT="ast# "
+CONFIG_CMD_BOOTEFI=n
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_OF_LIBFDT=y
 CONFIG_SPI_FLASH=y
 CONFIG_SYS_NS16550=y
Signature · 1 line
2.8.0.rc3.226.g39d4020
Reviewed-by on v2 3/3
#9 lore raw
Quoted 8 lines · Rick Altherr

FIT is the modern u-boot native image format for kernels, device trees, and ramdisks. Enabling FIT only compiles in support for the image format. For these devices, the kernel+dtb and ramdisk are loaded from separate locations in flash and can be any mix of legacy or FIT images. When using FIT images, the dtb is stored as a separate entry that requires CONFIG_OF_LIBFDT to load it into RAM and pass it to the kernel.

u-boot enables EFI support by default but it only builds once FIT

nit: U-Boot

Quoted 7 lines

support is enabled. EFI support adds ~13k to the binary and is currently unused for any Aspeed platforms. Explicitly disable EFI support now that FIT support is enabled.

Tested under qemu with both legacy and FIT kernel+dtb images for palmetto and witherspoon.

Quoted 7 lines
---
 configs/ast_g4_ncsi_defconfig | 5 +++++
 configs/ast_g4_phy_defconfig  | 5 +++++
 configs/ast_g5_ncsi_defconfig | 5 +++++
 configs/ast_g5_phy_defconfig  | 5 +++++
 4 files changed, 20 insertions(+)
Reviewed-by on v2 2/3
#6 lore raw

Re: [PATCH u-boot v2 2/3] bootm: relocate ramdisk if CONFIG_SYS_BOOT_RAMDISK_HIGH set

In reply to Rick Altherr

Hi Rick,

Quoted 20 lines · Rick Altherr

In 35fc84f, bootm was refactored so plain 'bootm' and 'bootm <subcommand>' shared a common implementation.
The 'bootm ramdisk' command implementation is now part of the common implementation but not invoke by plain 'bootm' since the original implementation never did ramdisk relocation. Instead, ramdisk relocation happened in image_setup_linux() which is typically called during the OS portion of 'bootm'.

On ARM, parameters to the Linux kernel can either be passed by FDT or ATAGS. When using FDT, image_setup_linux() is called which also triggers ramdisk relocation. When using ATAGS, image_setup_linux() is _not_ called because it mostly does FDT setup.

Instead of calling image_setup_linux() in both FDT and ATAGS cases, include BOOTM_STATE_RAMDISK in the requested states during a plain 'bootm' if CONFIG_SYS_BOOT_RAMDISK_HIGH is set and remove the ramdisk relocation from image_setup_linux(). This causes ramdisk relocation to happen on any system where CONFIG_SYS_BOOT_RAMDISK_HIGH regardless of the OS being booted.

Quoted 5 lines
---
 cmd/bootm.c    | 3 +++
 common/image.c | 7 -------
 2 files changed, 3 insertions(+), 7 deletions(-)

But why would you still be using ATAGS?

Regards,
Simon

#3 lore raw

Re: [PATCH u-boot v2 1/3] aspeed: remove hack loading ramdisk in memory

In reply to Simon Glass

Hello,

Quoted 11 lines · Simon Glass
Quoted 7 lines · Rick Altherr

From: Cédric Le Goater <[email protected]>

---
 common/image.c | 11 -----------
 1 file changed, 11 deletions(-)

So how do you fix the ramdisk loading ? is using the FIT images enough to work around this problem ?

For legacy type images, this patch seemed to work :

	https://github.com/legoater/u-boot/commit/86fd073a12650ee7fc4e6514f2b0f159be275f29

I am not sure if this is a good approach though.

Thanks,

C.

#4 lore raw

Re: [PATCH u-boot v2 1/3] aspeed: remove hack loading ramdisk in memory

See the next patch in this series. OpenBMC uses ATAGS when building a legacy image. U-Boot ATAGS support wasn't causing ramdisk relocation. It's not really a FIT vs legacy issue so much as a FDT vs ATAGS issue. We could still use legacy images with FDT and the ramdisk would be relocated fine. I fixed the ATAGS support to trigger ramdisk relocation as that's the actual bug.

Quoted 29 lines · Cédric Le Goater

Hello,

Quoted 11 lines · Simon Glass
Quoted 7 lines · Rick Altherr

From: Cédric Le Goater <[email protected]>

---
 common/image.c | 11 -----------
 1 file changed, 11 deletions(-)

So how do you fix the ramdisk loading ? is using the FIT images enough to work around this problem ?

For legacy type images, this patch seemed to work :

https://github.com/legoater/u-boot/commit/
86fd073a12650ee7fc4e6514f2b0f159be275f29

I am not sure if this is a good approach though.

Thanks,

C.

#7 lore raw

Re: [PATCH u-boot v2 2/3] bootm: relocate ramdisk if CONFIG_SYS_BOOT_RAMDISK_HIGH set

In reply to Simon Glass

I think that is an artifact of starting from the Aspeed SDK. Once these changes are in, I plan to propose changing to FIT+FDT.

Quoted 36 lines · Simon Glass

Hi Rick,

Quoted 20 lines · Rick Altherr

In 35fc84f, bootm was refactored so plain 'bootm' and 'bootm <subcommand>' shared a common implementation.
The 'bootm ramdisk' command implementation is now part of the common implementation but not invoke by plain 'bootm' since the original implementation never did ramdisk relocation. Instead, ramdisk relocation happened in image_setup_linux() which is typically called during the OS portion of 'bootm'.

On ARM, parameters to the Linux kernel can either be passed by FDT or ATAGS. When using FDT, image_setup_linux() is called which also triggers ramdisk relocation. When using ATAGS, image_setup_linux() is _not_ called because it mostly does FDT setup.

Instead of calling image_setup_linux() in both FDT and ATAGS cases, include BOOTM_STATE_RAMDISK in the requested states during a plain 'bootm' if CONFIG_SYS_BOOT_RAMDISK_HIGH is set and remove the ramdisk relocation from image_setup_linux(). This causes ramdisk relocation to happen on any system where CONFIG_SYS_BOOT_RAMDISK_HIGH regardless of the OS being booted.

Quoted 5 lines
---
 cmd/bootm.c    | 3 +++
 common/image.c | 7 -------
 2 files changed, 3 insertions(+), 7 deletions(-)

But why would you still be using ATAGS?

Regards,
Simon