All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Lechner <david@lechnology.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/5] ARM: legoev3: update boot script to load uEnv.txt and .dtb
Date: Sat, 19 May 2018 23:25:07 -0500	[thread overview]
Message-ID: <20180520042507.22058-6-david@lechnology.com> (raw)
In-Reply-To: <20180520042507.22058-1-david@lechnology.com>

This updates the LEGO MINDSTORMS EV3 boot script to try loading a
uEnv.txt file and a da850-lego-ev3.dtb device tree during boot.

Signed-off-by: David Lechner <david@lechnology.com>
---
 board/lego/ev3/README     | 36 ++++++++++++++++++++++-------
 include/configs/legoev3.h | 48 ++++++++++++++++++++++++++++++---------
 2 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/board/lego/ev3/README b/board/lego/ev3/README
index a356373249..da62a649ba 100644
--- a/board/lego/ev3/README
+++ b/board/lego/ev3/README
@@ -9,14 +9,34 @@ Booting
 =======
 
 The EV3 contains a bootloader in EEPROM that loads u-boot.bin from address 0x0
-of the spi flash memory. Using the default configuration, u-boot will check to
-see if there is a boot.scr file on the first FAT partition of the mmc. If there
-is, it will run the script and boot the kernel from the uImage file also in
-the FAT partition. Otherwise, it will load a kernel and rootfs from the flash.
-The kernel must be stored at address 0x50000 on the flash and have a maximum
-size of 4MiB. The rootfs must be a squasfs image and stored at 0x450000 in the
-flash and have a maximum size of 10MiB. The flash starting at 0xE50000 is
-reserved for user data.
+of the SPI flash memory (with a size of 256KiB!). Because the EEPROM is read-
+only and it takes care of low level configuration (PLL and DDR), we don't use
+U-Boot to produce an SPL image.
+
+Using the default configuration, U-Boot had a boot scrips that works as follows:
+
+* Check to see if microSD card is present
+* If it is, try to load boot.scr from the first FAT partition
+* If loading boot.scr was successful, run it
+* Otherwise, try loading uEnv.txt
+* If loading uEnv.txt was successful, import it
+* If there is a uenvcmd variable (from uEnv.txt), run it
+* Try to load uImage from the first FAT partition
+* If it was successful, try to load da850-lego-ev3.dtb
+* If loading uImage was successful, boot it (DT is optional)
+* If none of the above was successful, try booting from flash
+
+Suggested Flash Memory Layout
+=============================
+
+The following is based on the default U-Boot configuration:
+
+| Image (file)       | Start Addr. | Max. Size         |
++--------------------+-------------+-------------------+
+| u-boot.bin         |         0x0 |  0x40000 (256KiB) |
+| da850-lego-ev3.dtb |     0x40000 |  0x10000 (64KiB)  |
+| uImage             |     0x50000 | 0x400000 (4MiB)   |
+| rootfs (squashfs)  |    0x450000 | 0xa00000 (10MiB)  |
 
 Writing image to flash
 ======================
diff --git a/include/configs/legoev3.h b/include/configs/legoev3.h
index 9eb95bc030..7a0511f88e 100644
--- a/include/configs/legoev3.h
+++ b/include/configs/legoev3.h
@@ -84,34 +84,60 @@
 		"if run loadbootscr; then " \
 			"run bootscript; " \
 		"else " \
+			"if run loadbootenv; then " \
+				"echo Loaded env from ${bootenvfile};" \
+				"run importbootenv;" \
+			"fi;" \
+			"if test -n $uenvcmd; then " \
+				"echo Running uenvcmd...;" \
+				"run uenvcmd;" \
+			"fi;" \
 			"if run loadimage; then " \
 				"run mmcargs; " \
+				"if run loadfdt; then " \
+					"echo Using ${fdtfile}...;" \
+					"run fdtfixup; " \
+					"run fdtboot; "\
+				"fi; " \
 				"run mmcboot; " \
-			"else " \
-				"run flashargs; " \
-				"run flashboot; " \
 			"fi; " \
 		"fi; " \
-	"else " \
-		"run flashargs; " \
-		"run flashboot; " \
-	"fi"
+	"fi; "\
+	"run flashargs; " \
+	"run flashboot"
 #define CONFIG_EXTRA_ENV_SETTINGS \
+	"bootenvfile=uEnv.txt\0" \
+	"fdtfile=da850-lego-ev3.dtb\0" \
 	"memsize=64M\0" \
 	"filesyssize=10M\0" \
 	"verify=n\0" \
 	"console=ttyS1,115200n8\0" \
 	"bootscraddr=0xC0600000\0" \
+	"fdtaddr=0xC0600000\0" \
 	"loadaddr=0xC0007FC0\0" \
 	"filesysaddr=0xC1180000\0" \
 	"fwupdateboot=mw 0xFFFF1FFC 0x5555AAAA; reset\0" \
-	"mmcargs=setenv bootargs mem=${memsize} console=${console} root=/dev/mmcblk0p2 rw rootwait lpj=747520\0" \
+	"importbootenv=echo Importing environment...; " \
+		"env import -t ${loadaddr} ${filesize}\0" \
+	"loadbootenv=fatload mmc 0 ${loadaddr} ${bootenvfile}\0" \
+	"mmcargs=setenv bootargs console=${console} root=/dev/mmcblk0p2 rw " \
+		"rootwait ${optargs}\0" \
 	"mmcboot=bootm ${loadaddr}\0" \
-	"flashargs=setenv bootargs mem=${memsize} initrd=${filesysaddr},${filesyssize} root=/dev/ram0 rw rootfstype=squashfs console=${console} lpj=747520\0" \
-	"flashboot=sf probe 0; sf read ${loadaddr} 0x50000 0x400000; sf read ${filesysaddr} 0x450000 0xA00000; bootm ${loadaddr}\0" \
+	"flashargs=setenv bootargs initrd=${filesysaddr},${filesyssize} " \
+		"root=/dev/ram0 rw rootfstype=squashfs console=${console} " \
+		"${optargs}\0" \
+	"flashboot=sf probe 0; " \
+		"sf read ${fdtaddr} 0x40000 0x10000; " \
+		"sf read ${loadaddr} 0x50000 0x400000; " \
+		"sf read ${filesysaddr} 0x450000 0xA00000; " \
+		"run fdtfixup; " \
+		"run fdtboot\0" \
 	"loadimage=fatload mmc 0 ${loadaddr} uImage\0" \
+	"loadfdt=fatload mmc 0 ${fdtaddr} ${fdtfile}\0" \
+	"fdtfixup=fdt addr ${fdtaddr}; fdt resize; fdt chosen\0" \
+	"fdtboot=bootm ${loadaddr} - ${fdtaddr}\0" \
 	"loadbootscr=fatload mmc 0 ${bootscraddr} boot.scr\0" \
-	"bootscript=source ${bootscraddr}\0" \
+	"bootscript=source ${bootscraddr}\0"
 
 #ifdef CONFIG_CMD_BDI
 #define CONFIG_CLOCKS
-- 
2.17.0

  parent reply	other threads:[~2018-05-20  4:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-20  4:25 [U-Boot] [PATCH 0/5] ARM: legoev3: updates David Lechner
2018-05-20  4:25 ` [U-Boot] [PATCH 1/5] ARM: legoev3: increase flash image sizes David Lechner
2018-06-06 11:15   ` [U-Boot] [U-Boot,1/5] " Tom Rini
2018-05-20  4:25 ` [U-Boot] [PATCH 2/5] ARM: legoev3: Move UART enable to early init David Lechner
2018-06-06 11:15   ` [U-Boot] [U-Boot, " Tom Rini
2018-05-20  4:25 ` [U-Boot] [PATCH 3/5] ARM: legoev3: disable networking David Lechner
2018-06-06 11:15   ` [U-Boot] [U-Boot,3/5] " Tom Rini
2018-05-20  4:25 ` [U-Boot] [PATCH 4/5] ARM: legoev3: remove unused configuration options David Lechner
2018-06-06 11:15   ` [U-Boot] [U-Boot, " Tom Rini
2018-05-20  4:25 ` David Lechner [this message]
2018-06-06 11:15   ` [U-Boot] [U-Boot, 5/5] ARM: legoev3: update boot script to load uEnv.txt and .dtb Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180520042507.22058-6-david@lechnology.com \
    --to=david@lechnology.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.