Patchwork [U-Boot,2/2] am335x_evm: Update, document Falcon Mode support

login
register
mail settings
Submitter Tom Rini
Date July 3, 2013, 8:09 p.m.
Message ID <1372882163-9299-3-git-send-email-trini@ti.com>
Download mbox | patch
Permalink /patch/256735/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Tom Rini - July 3, 2013, 8:09 p.m.
- Update Falcon Mode support so that the offsets used in eMMC (or a raw
  SD card) would allow for enough room for a device tree to be used
  rather than an ATAGS blob as well as environment to be saved in eMMC.
- Add board/ti/am335x/README which covers a few basic items, and
  provides an example of Falcon Mode for eMMC, FAT SD card and NAND.
- Round up the size of u-boot.img.raw to match these use-cases, and add
  the entries for Falcon Mode to DFU for eMMC, FAT SD cards and NAND
- Correct CONFIG_CMD_SPL_WRITE_SIZE size (eraseblocks are 128KiB)

Signed-off-by: Tom Rini <trini@ti.com>
---
 board/ti/am335x/README       |  123 ++++++++++++++++++++++++++++++++++++++++++
 include/configs/am335x_evm.h |   19 ++++---
 2 files changed, 135 insertions(+), 7 deletions(-)
 create mode 100644 board/ti/am335x/README
Peter Korsgaard - July 3, 2013, 9:28 p.m.
>>>>> "Tom" == Tom Rini <trini@ti.com> writes:

 Tom> - Update Falcon Mode support so that the offsets used in eMMC (or a raw
 Tom>   SD card) would allow for enough room for a device tree to be used
 Tom>   rather than an ATAGS blob as well as environment to be saved in eMMC.
 Tom> - Add board/ti/am335x/README which covers a few basic items, and
 Tom>   provides an example of Falcon Mode for eMMC, FAT SD card and NAND.
 Tom> - Round up the size of u-boot.img.raw to match these use-cases, and add
 Tom>   the entries for Falcon Mode to DFU for eMMC, FAT SD cards and NAND
 Tom> - Correct CONFIG_CMD_SPL_WRITE_SIZE size (eraseblocks are 128KiB)

It looks to me like this should be 4 (or 3) seperate commits then?


 Tom> Signed-off-by: Tom Rini <trini@ti.com>
 Tom> ---
 Tom>  board/ti/am335x/README       |  123 ++++++++++++++++++++++++++++++++++++++++++
 Tom>  include/configs/am335x_evm.h |   19 ++++---
 Tom>  2 files changed, 135 insertions(+), 7 deletions(-)
 Tom>  create mode 100644 board/ti/am335x/README

 Tom> diff --git a/board/ti/am335x/README b/board/ti/am335x/README
 Tom> new file mode 100644
 Tom> index 0000000..565f18c
 Tom> --- /dev/null
 Tom> +++ b/board/ti/am335x/README
 Tom> @@ -0,0 +1,123 @@
 Tom> +Summary
 Tom> +=======
 Tom> +
 Tom> +This document covers various features of the 'am335x_evm' build, and some of
 Tom> +the related build targets (am335x_evm_uartN, etc).
 Tom> +
 Tom> +Hardware
 Tom> +========
 Tom> +
 Tom> +The binary produced by this board supports, based on parsing of the EEPROM
 Tom> +doumentd in TI's reference designs:

documented

 Tom> +Note that when we run 'spl export' it will prepare to boot the kernel.
 Tom> +This includes relocation of the uImage from where we loaded it to the entry
 Tom> +point defined in the head.  As these locations overlap by default, it would

header


 Tom> +A further word of warning about using eMMC and partition tables.  When
 Tom> +working with SD cards we can get away with erasing small areas at a time,
 Tom> +however on eMMC we must keep erases aligned to eraseblocks and thus the
 Tom> +first erase we issue will erase the partition table.

Really? I thought eMMC behaved just like SD cards?

 Tom> +# Ensure are able to talk with this mmc device, erase most previous contents

Ensure we are
Tom Rini - July 3, 2013, 10:30 p.m.
On Wed, Jul 03, 2013 at 11:28:36PM +0200, Peter Korsgaard wrote:
> >>>>> "Tom" == Tom Rini <trini@ti.com> writes:
> 
>  Tom> - Update Falcon Mode support so that the offsets used in eMMC (or a raw
>  Tom>   SD card) would allow for enough room for a device tree to be used
>  Tom>   rather than an ATAGS blob as well as environment to be saved in eMMC.
>  Tom> - Add board/ti/am335x/README which covers a few basic items, and
>  Tom>   provides an example of Falcon Mode for eMMC, FAT SD card and NAND.
>  Tom> - Round up the size of u-boot.img.raw to match these use-cases, and add
>  Tom>   the entries for Falcon Mode to DFU for eMMC, FAT SD cards and NAND
>  Tom> - Correct CONFIG_CMD_SPL_WRITE_SIZE size (eraseblocks are 128KiB)
> 
> It looks to me like this should be 4 (or 3) seperate commits then?

I suppose we can go that way, I'll split things up Monday.

>  Tom> Signed-off-by: Tom Rini <trini@ti.com>
>  Tom> ---
>  Tom>  board/ti/am335x/README       |  123 ++++++++++++++++++++++++++++++++++++++++++
>  Tom>  include/configs/am335x_evm.h |   19 ++++---
>  Tom>  2 files changed, 135 insertions(+), 7 deletions(-)
>  Tom>  create mode 100644 board/ti/am335x/README
> 
>  Tom> diff --git a/board/ti/am335x/README b/board/ti/am335x/README
>  Tom> new file mode 100644
>  Tom> index 0000000..565f18c
>  Tom> --- /dev/null
>  Tom> +++ b/board/ti/am335x/README
>  Tom> @@ -0,0 +1,123 @@
>  Tom> +Summary
>  Tom> +=======
>  Tom> +
>  Tom> +This document covers various features of the 'am335x_evm' build, and some of
>  Tom> +the related build targets (am335x_evm_uartN, etc).
>  Tom> +
>  Tom> +Hardware
>  Tom> +========
>  Tom> +
>  Tom> +The binary produced by this board supports, based on parsing of the EEPROM
>  Tom> +doumentd in TI's reference designs:
> 
> documented
> 
>  Tom> +Note that when we run 'spl export' it will prepare to boot the kernel.
>  Tom> +This includes relocation of the uImage from where we loaded it to the entry
>  Tom> +point defined in the head.  As these locations overlap by default, it would
> 
> header

Whoops.

>  Tom> +A further word of warning about using eMMC and partition tables.  When
>  Tom> +working with SD cards we can get away with erasing small areas at a time,
>  Tom> +however on eMMC we must keep erases aligned to eraseblocks and thus the
>  Tom> +first erase we issue will erase the partition table.
> 
> Really? I thought eMMC behaved just like SD cards?

Yes, really.  We know what the erase block size is, and round our
commands, probably because we really have to.  SD cards take care of
things for us, for better or worse.

>  Tom> +# Ensure are able to talk with this mmc device, erase most previous contents
> 
> Ensure we are

Also fixed.
Romain Izard - July 4, 2013, 7:39 a.m.
Tom> +A further word of warning about using eMMC and partition tables.  When
Tom> +working with SD cards we can get away with erasing small areas at a time,
Tom> +however on eMMC we must keep erases aligned to eraseblocks and thus the
Tom> +first erase we issue will erase the partition table.

Peter> Really? I thought eMMC behaved just like SD cards?

Tom> Yes, really.  We know what the erase block size is, and round our
Tom> commands, probably because we really have to.  SD cards take care of
Tom> things for us, for better or worse.

But why do we bother with erasing the eMMC in the first place? The erase
commands are wholly optional, and only make sense as a TRIM mechanism,
which is not our case as we will fill the memory as soon as it has been
erased.

There is no problem in writing directly in the memory, even if it has
not been erased previously. Or is it a measure to detect interrupted
writes ?

Best regards,
Tom Rini - July 5, 2013, 12:51 p.m.
On Thu, Jul 04, 2013 at 07:39:48AM +0000, Romain Izard wrote:
> Tom> +A further word of warning about using eMMC and partition tables.  When
> Tom> +working with SD cards we can get away with erasing small areas at a time,
> Tom> +however on eMMC we must keep erases aligned to eraseblocks and thus the
> Tom> +first erase we issue will erase the partition table.
> 
> Peter> Really? I thought eMMC behaved just like SD cards?
> 
> Tom> Yes, really.  We know what the erase block size is, and round our
> Tom> commands, probably because we really have to.  SD cards take care of
> Tom> things for us, for better or worse.
> 
> But why do we bother with erasing the eMMC in the first place? The erase
> commands are wholly optional, and only make sense as a TRIM mechanism,
> which is not our case as we will fill the memory as soon as it has been
> erased.
> 
> There is no problem in writing directly in the memory, even if it has
> not been erased previously. Or is it a measure to detect interrupted
> writes ?

I hadn't thought of it like that, I had been thinking of it like NAND
for some reason.  I'll update the instructions (and write a bunch of
garbage first) and re-confirm things.  Thanks!

Patch

diff --git a/board/ti/am335x/README b/board/ti/am335x/README
new file mode 100644
index 0000000..565f18c
--- /dev/null
+++ b/board/ti/am335x/README
@@ -0,0 +1,123 @@ 
+Summary
+=======
+
+This document covers various features of the 'am335x_evm' build, and some of
+the related build targets (am335x_evm_uartN, etc).
+
+Hardware
+========
+
+The binary produced by this board supports, based on parsing of the EEPROM
+doumentd in TI's reference designs:
+- AM335x GP EVM
+- AM335x EVM SK
+- Beaglebone White
+- Beaglebone Black
+
+Falcon Mode
+===========
+
+The default build includes "Falcon Mode" (see doc/README.falcon) via NAND,
+eMMC (or raw SD cards) and FAT SD cards.  Our default behavior currently is
+to read a 'c' on the console while in SPL at any point prior to loading the
+OS payload (so as soon as possible) to opt to booting full U-Boot.  Also
+note that while one can program Falcon Mode "in place" great care needs to
+be taken by the user to not 'brick' their setup.  As these are all eval
+boards with multiple boot methods, recovery should not be an issue in this
+worst-case however.
+
+Falcon Mode: eMMC
+=================
+
+The recommended layout in this case is:
+
+MMC BLOCKS      |--------------------------------| LOCATION IN BYTES
+0x0000 - 0x007F : MBR or GPT table               : 0x000000 - 0x020000
+0x0080 - 0x00FF : ARGS or FDT file               : 0x010000 - 0x020000
+0x0100 - 0x01FF : SPL.backup1 (first copy used)  : 0x020000 - 0x040000
+0x0200 - 0x02FF : SPL.backup2 (second copy used) : 0x040000 - 0x060000
+0x0300 - 0x06FF : U-Boot                         : 0x060000 - 0x0e0000
+0x0700 - 0x08FF : U-Boot Env + Redundant         : 0x0e0000 - 0x120000
+0x0900 - 0x28FF : Kernel                         : 0x120000 - 0x520000
+
+Note that when we run 'spl export' it will prepare to boot the kernel.
+This includes relocation of the uImage from where we loaded it to the entry
+point defined in the head.  As these locations overlap by default, it would
+leave us with an image that if written to MMC will not boot, so instead of
+using the loadaddr variable we use 0x81000000 in the following example.  In
+this example we are loading from the network, for simplicity, and assume a
+valid partition table already exists and 'mmc dev' has already been run to
+select the correct device.  Also note that if you previously had a FAT
+partition (such as on a Beaglebone Black) it is not enough to write garbage
+into the area, you must delete it from the partition table first.
+
+A further word of warning about using eMMC and partition tables.  When
+working with SD cards we can get away with erasing small areas at a time,
+however on eMMC we must keep erases aligned to eraseblocks and thus the
+first erase we issue will erase the partition table.  If you have an
+existing table you wish to re-use you must use 'mmc read' to save it.  If
+you wish to create a new table, U-Boot supports (but this build does not
+enable) creating GPT-style tables.  For more information about that see
+doc/README.gpt
+
+# Ensure are able to talk with this mmc device, erase most previous contents
+U-Boot # mmc rescan
+U-Boot # mmc erase 80 680
+U-Boot # tftp 81000000 am335x/MLO
+# Write to two of the backup locations ROM uses
+U-Boot # mmc write 81000000 100 100
+U-Boot # mmc write 81000000 200 100
+# Write U-Boot to the location set in the config
+U-Boot # tftp 81000000 am335x/u-boot.img
+U-Boot # mmc write 81000000 300 400
+# Load kernel and device tree into memory, perform export
+U-Boot # tftp 81000000 am335x/uImage
+U-Boot # run findfdt
+U-Boot # tftp ${fdtaddr} am335x/${fdtfile}
+U-Boot # run mmcargs
+U-Boot # spl export fdt 81000000 - ${fdtaddr}
+# Write the updated device tree to MMC
+U-Boot # mmc write ${fdtaddr} 80 80
+U-Boot # mmc erase 900 2000
+# Write the uImage to MMC
+U-Boot # mmc write 81000000 900 2000
+
+Falcon Mode: FAT SD cards
+=========================
+
+In this case the additional file is written to the filesystem.  In this
+example we assume that the uImage and device tree to be used are already on
+the FAT filesystem (only the uImage MUST be for this to function
+afterwards) along with a Falcon Mode aware MLO and the FAT partition has
+already been created and marked bootable:
+
+U-Boot # mmc rescan
+# Load kernel and device tree into memory, perform export
+U-Boot # load mmc 0:1 ${loadaddr} uImage
+U-Boot # run findfdt
+U-Boot # load mmc 0:1 ${fdtaddr} ${fdtfile}
+U-Boot # run mmcargs
+U-Boot # spl export fdt ${loadaddr} - ${fdtaddr}
+
+This will print a number of lines and then end with something like:
+   Using Device Tree in place at 80f80000, end 80f85928
+   Using Device Tree in place at 80f80000, end 80f88928
+So then you:
+
+U-Boot # fatwrite mmc 0:1 0x80f80000 args 8928
+
+Falcon Mode: NAND
+=================
+
+In this case the additional data is written to another partition of the
+NAND.  In this example we assume that the uImage and device tree to be are
+already located on the NAND somewhere (such as fileystem or mtd partition)
+along with a Falcon Mode aware MLO written to the correct locations for
+booting and mtdparts have been configured correctly for the board:
+
+U-Boot # nand read ${loadaddr} kernel
+U-Boot # load nand rootfs ${fdtaddr} /boot/am335x-evm.dtb
+U-Boot # run nandargs
+U-Boot # spl export fdt ${loadaddr} - ${fdtaddr}
+U-Boot # nand erase.part u-boot-spl-os
+U-Boot # nand write ${fdtaddr} u-boot-spl-os
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index c5a6d4b..0f12c75 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -238,7 +238,11 @@ 
 	"rootfs part 0 2;" \
 	"MLO fat 0 1;" \
 	"MLO.raw mmc 100 100;" \
-	"u-boot.img.raw mmc 300 3C0;" \
+	"u-boot.img.raw mmc 300 400;" \
+	"spl-os-args.raw mmc 80 80;" \
+	"spl-os-image.raw mmc 900 2000;" \
+	"spl-os-args fat 0 1;" \
+	"spl-os-image fat 0 1;" \
 	"u-boot.img fat 0 1;" \
 	"uEnv.txt fat 0 1"
 #define DFU_ALT_INFO_NAND \
@@ -247,8 +251,9 @@ 
 	"SPL.backup2 part 0 3;" \
 	"SPL.backup3 part 0 4;" \
 	"u-boot part 0 5;" \
-	"kernel part 0 7;" \
-	"rootfs part 0 8"
+	"u-boot-spl-os part 0 6;" \
+	"kernel part 0 8;" \
+	"rootfs part 0 9"
 
  /* Physical Memory Map */
 #define CONFIG_NR_DRAM_BANKS		1		/*  1 bank of DRAM */
@@ -332,14 +337,14 @@ 
 #define CONFIG_SYS_SPL_ARGS_ADDR		(PHYS_DRAM_1 + 0x100)
 
 /* raw mmc */
-#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR	0x500 /* address 0xa0000 */
-#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR	0x8   /* address 0x1000 */
-#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS	8     /* 4KB */
+#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR	0x900	/* address 0x120000 */
+#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR	0x80	/* address 0x10000 */
+#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS	0x80	/* 64KiB */
 
 /* nand */
 #define CONFIG_CMD_SPL_NAND_OFS			0x240000 /* end of u-boot */
 #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS		0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE		0x1000
+#define CONFIG_CMD_SPL_WRITE_SIZE		0x2000
 
 /* spl export command */
 #define CONFIG_CMD_SPL