[U-Boot] [RFC] cmd: fdt: memory fixup

Ladislav Michl ladis at linux-mips.org
Tue Jan 31 03:35:51 CET 2017


To get Falcon mode working with zImage is currently non trivial as zImages
do not fit into U-Boot's image concept too well. Fortunately at least for
ARM boards it seems getting memory node right is quite sufficient.
What about changing 'fdt memory' command to update memory node according to
detected memory layout when called without parameters?

	ladis

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 95dd673b95..e08296d51c 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -517,11 +517,23 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	 * memory command
 	 */
 	} else if (strncmp(argv[1], "me", 2) == 0) {
-		uint64_t addr, size;
 		int err;
-		addr = simple_strtoull(argv[2], NULL, 16);
-		size = simple_strtoull(argv[3], NULL, 16);
-		err = fdt_fixup_memory(working_fdt, addr, size);
+		if (argc < 4) {
+			int i;
+			uint64_t start[CONFIG_NR_DRAM_BANKS];
+			uint64_t size[CONFIG_NR_DRAM_BANKS];
+			bd_t *bd = gd->bd;
+			for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+				start[i] = bd->bi_dram[i].start;
+				size[i] = bd->bi_dram[i].size;
+			}
+			err = fdt_fixup_memory_banks(working_fdt, start, size,
+						CONFIG_NR_DRAM_BANKS);
+		} else {
+			uint64_t addr = simple_strtoull(argv[2], NULL, 16);
+			uint64_t size = simple_strtoull(argv[3], NULL, 16);
+			err = fdt_fixup_memory(working_fdt, addr, size);
+		}
 		if (err < 0)
 			return err;
 


More information about the U-Boot mailing list