Skip to contentSkip to conversation

Enable FIT image support and FDT loading for AST2400/AST2500

PATCH In review Rick Altherr 3 participants 10 messages Dec 7, 2016

lore
Share & tools
lore
#0 lore raw

v4 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.

Changes in v4:
- Remove unused variables from image_setup_linux()

Changes in v3:
- Remove unused #define IMAGE_ENABLE_RAMDISK_HIGH
- Fix capitalization of U-Boot in commit messages

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

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                | 21 ---------------------
 configs/ast_g4_ncsi_defconfig |  5 +++++
 configs/ast_g4_phy_defconfig  |  5 +++++
 configs/ast_g5_ncsi_defconfig |  5 +++++
 configs/ast_g5_phy_defconfig  |  5 +++++
 include/image.h               |  6 ------
 7 files changed, 23 insertions(+), 27 deletions(-)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

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

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

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 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
#2 lore raw

PATCH v4 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. Also remove IMAGE_ENABLE_RAMDISK_HIGH as it was only used by the now-removed code from image_setup_linux().

---

Changes in v4:
- Remove unused variables from image_setup_linux()

Changes in v3:
- Remove unused #define IMAGE_ENABLE_RAMDISK_HIGH

Changes in v2:
- Fix compiler warning caused by ramdisk relocation hack

 cmd/bootm.c     |  3 +++
 common/image.c  | 10 ----------
 include/image.h |  6 ------
 3 files changed, 3 insertions(+), 16 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 -10
index 0be09e5..f9ee9d5 100644
@@ -1453,10 +1453,7 @@ int image_setup_linux(bootm_headers_t *images)
 {
 	ulong of_size = images->ft_len;
 	char **of_flat_tree = &images->ft_addr;
-	ulong *initrd_start = &images->initrd_start;
-	ulong *initrd_end = &images->initrd_end;
 	struct lmb *lmb = &images->lmb;
-	ulong rd_len;
 	int ret;
 
 	if (IMAGE_ENABLE_OF_LIBFDT)
@@ -1470,13 +1467,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);
include/image.h +0 -6
index d788c26..a16187f 100644
@@ -99,12 +99,6 @@ struct lmb;
 
 #endif /* IMAGE_ENABLE_FIT */
 
-#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
-# define IMAGE_ENABLE_RAMDISK_HIGH	1
-#else
-# define IMAGE_ENABLE_RAMDISK_HIGH	0
-#endif
-
 #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
 # define IMAGE_BOOT_GET_CMDLINE		1
 #else
Signature · 1 line
2.8.0.rc3.226.g39d4020
#5 lore raw

PATCH v4 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.

---

Changes in v4: None
Changes in v3:
- Fix capitalization of U-Boot in commit messages

Changes in v2:
- Reduce binary size by disabling EFI support

 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 v4 3/3
#6 lore raw
Quoted 12 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 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.

Quoted 5 lines

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

Thanks,

C.

Quoted 84 lines

---

Changes in v4: None
Changes in v3:
- Fix capitalization of U-Boot in commit messages

Changes in v2:
- Reduce binary size by disabling EFI support

 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
Reviewed-by on v4 2/3
#3 lore raw

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

In reply to Rick Altherr
Quoted 21 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. Also remove IMAGE_ENABLE_RAMDISK_HIGH as it was only used by the now-removed code from image_setup_linux().

Quoted 2 lines

looks good.

Thanks,

C.

Quoted 77 lines

---

Changes in v4:
- Remove unused variables from image_setup_linux()

Changes in v3:
- Remove unused #define IMAGE_ENABLE_RAMDISK_HIGH

Changes in v2:
- Fix compiler warning caused by ramdisk relocation hack

 cmd/bootm.c     |  3 +++
 common/image.c  | 10 ----------
 include/image.h |  6 ------
 3 files changed, 3 insertions(+), 16 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 -10
index 0be09e5..f9ee9d5 100644
@@ -1453,10 +1453,7 @@ int image_setup_linux(bootm_headers_t *images)
 {
 	ulong of_size = images->ft_len;
 	char **of_flat_tree = &images->ft_addr;
-	ulong *initrd_start = &images->initrd_start;
-	ulong *initrd_end = &images->initrd_end;
 	struct lmb *lmb = &images->lmb;
-	ulong rd_len;
 	int ret;
 
 	if (IMAGE_ENABLE_OF_LIBFDT)
@@ -1470,13 +1467,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);
include/image.h +0 -6
index d788c26..a16187f 100644
@@ -99,12 +99,6 @@ struct lmb;
 
 #endif /* IMAGE_ENABLE_FIT */
 
-#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
-# define IMAGE_ENABLE_RAMDISK_HIGH	1
-#else
-# define IMAGE_ENABLE_RAMDISK_HIGH	0
-#endif
-
 #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
 # define IMAGE_BOOT_GET_CMDLINE		1
 #else
#7 lore raw
In reply to Cédric Le Goater
Quoted 3 lines · Cédric Le Goater

configs/ast_g4_ncsi_defconfig line 9

Quoted 3 lines
configs/ast_g4_ncsi_defconfig +3 -0
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y

Are we sure we want verbose to be enabled?

Cheers,

Joel

Reviewed-by
#4 lore raw

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

In reply to Cédric Le Goater
Quoted 22 lines · Cédric Le Goater
Quoted 21 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. Also remove IMAGE_ENABLE_RAMDISK_HIGH as it was only used by the now-removed code from image_setup_linux().

Quoted 6 lines
Quoted 2 lines

looks good.

Rick, can you please submit this one upstream too?

Please keep all of our reviewed-by tags but drop the version when you do so.

Cheers,

Joel

#8 lore raw
In reply to Joel Stanley

It turns on a few error messages when encountering situations not supported with FIT images. Binary size increase is small and it doesn't generate any output during normal use. I'm OK either way. What do you recommend?

Quoted 12 lines · Joel Stanley
Quoted 3 lines · Cédric Le Goater

configs/ast_g4_ncsi_defconfig line 9

Quoted 3 lines
configs/ast_g4_ncsi_defconfig +3 -0
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y

Are we sure we want verbose to be enabled?

Cheers,

Joel

#9 lore raw
Quoted 9 lines · Rick Altherr
Quoted 6 lines
Quoted 3 lines

configs/ast_g4_ncsi_defconfig line 9

Quoted 3 lines
configs/ast_g4_ncsi_defconfig +3 -0
+CONFIG_EFI_LOADER=n
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y

Are we sure we want verbose to be enabled?

It turns on a few error messages when encountering situations not supported with FIT images. Binary size increase is small and it doesn't generate any output during normal use. I'm OK either way. What do you recommend?

That's enough justification for me.

We can always revisit later if users are confused by the extra output.