Skip to contentSkip to conversation

Enable FIT image support and FDT loading for AST2400/AST2500

PATCH Superseded Rick Altherr 3 participants 6 messages Dec 5, 2016 – Dec 7, 2016

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 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 +++++
 include/image.h               |  6 ------
 7 files changed, 23 insertions(+), 24 deletions(-)

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

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

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

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

PATCH v3 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().

---
 cmd/bootm.c     | 3 +++
 common/image.c  | 7 -------
 include/image.h | 6 ------
 3 files changed, 3 insertions(+), 13 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);
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
Reviewed-by on v3 2/3
#3 lore raw

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

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
---
 cmd/bootm.c     | 3 +++
 common/image.c  | 7 -------
 include/image.h | 6 ------
 3 files changed, 3 insertions(+), 13 deletions(-)

(when you send a new version you should put any review tags in your commit, unless you make changes that you want re-reviewed)

#4 lore raw

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

In reply to Rick Altherr
Quoted 47 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().

---
 cmd/bootm.c     | 3 +++
 common/image.c  | 7 -------
 include/image.h | 6 ------
 3 files changed, 3 insertions(+), 13 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 -0
index 0be09e5..6584f7f 100644

common/image.c int image_setup_linux(bootm_headers_t *images) · line 1479

Quoted 10 lines
common/image.c +0 -7
@@ -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;
-	}

you might to clean up these warnings first:

../common/image.c: In function 'image_setup_linux':
../common/image.c:1543:8: warning: unused variable 'rd_len' [-Wunused-variable]

  ulong rd_len;
        ^~~~~~
../common/image.c:1541:9: warning: unused variable 'initrd_end' [-Wunused-variable]
  ulong *initrd_end = &images->initrd_end;
         ^~~~~~~~~~
../common/image.c:1540:9: warning: unused variable 'initrd_start' [-Wunused-variable]
  ulong *initrd_start = &images->initrd_start;
         ^~~~~~~~~~~~

Thanks,

C.

Quoted 21 lines
common/image.c +0 -0
 	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
#5 lore raw

PATCH v3 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