[U-Boot] [PATCH 0/5] ARM: legoev3: updates

This series contains some updates for LEGO MINDSTORMS EV3. There are a couple of cleanups, a fix for some console messages not printing and device tree support.
David Lechner (5): ARM: legoev3: increase flash image sizes ARM: legoev3: Move UART enable to early init ARM: legoev3: disable networking ARM: legoev3: remove unused configuration options ARM: legoev3: update boot script to load uEnv.txt and .dtb
board/lego/ev3/README | 36 ++++++++++--- board/lego/ev3/legoev3.c | 14 +++-- configs/legoev3_defconfig | 4 +- include/configs/legoev3.h | 104 ++++++++++++++------------------------ 4 files changed, 72 insertions(+), 86 deletions(-)

This increases the kernel image to 4M and the rootfs image to 10M.
It is getting hard to get a kernel image to fit in 3M.
Signed-off-by: David Lechner david@lechnology.com --- board/lego/ev3/README | 4 ++-- include/configs/legoev3.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/board/lego/ev3/README b/board/lego/ev3/README index 1a50ca9d03..a356373249 100644 --- a/board/lego/ev3/README +++ b/board/lego/ev3/README @@ -14,8 +14,8 @@ 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 3MiB. The rootfs must be a squasfs image and stored at 0x350000 in the -flash and have a maximum size of 9.3MiB. The flash starting at 0xCB0000 is +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.
Writing image to flash diff --git a/include/configs/legoev3.h b/include/configs/legoev3.h index 542b8f072c..812fd0c14a 100644 --- a/include/configs/legoev3.h +++ b/include/configs/legoev3.h @@ -164,7 +164,7 @@ "mmcargs=setenv bootargs mem=${memsize} console=${console} root=/dev/mmcblk0p2 rw rootwait lpj=747520\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 0x300000; sf read ${filesysaddr} 0x350000 0x960000; bootm ${loadaddr}\0" \ + "flashboot=sf probe 0; sf read ${loadaddr} 0x50000 0x400000; sf read ${filesysaddr} 0x450000 0xA00000; bootm ${loadaddr}\0" \ "loadimage=fatload mmc 0 ${loadaddr} uImage\0" \ "loadbootscr=fatload mmc 0 ${bootscraddr} boot.scr\0" \ "bootscript=source ${bootscraddr}\0" \

On Sat, May 19, 2018 at 11:25:03PM -0500, David Lechner wrote:
This increases the kernel image to 4M and the rootfs image to 10M.
It is getting hard to get a kernel image to fit in 3M.
Signed-off-by: David Lechner david@lechnology.com
Applied to u-boot/master, thanks!

This moves the UART init for LEGO MINDSTORMS EV3 to board_early_init_f(). Some console messages were not being printed because the UART was not enabled until later in the init process.
Signed-off-by: David Lechner david@lechnology.com --- board/lego/ev3/legoev3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/board/lego/ev3/legoev3.c b/board/lego/ev3/legoev3.c index 5e70363588..69010055d3 100644 --- a/board/lego/ev3/legoev3.c +++ b/board/lego/ev3/legoev3.c @@ -132,6 +132,11 @@ void get_board_serial(struct tag_serialnr *serialnr)
int board_early_init_f(void) { + /* enable the console UART */ + writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | + DAVINCI_UART_PWREMU_MGMT_UTRST), + &davinci_uart1_ctrl_regs->pwremu_mgmt); + /* * Power on required peripherals * ARM does not have access by default to PSC0 and PSC1 @@ -166,10 +171,5 @@ int board_init(void) if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) return 1;
- /* enable the console UART */ - writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | - DAVINCI_UART_PWREMU_MGMT_UTRST), - &davinci_uart1_ctrl_regs->pwremu_mgmt); - return 0; }

On Sat, May 19, 2018 at 11:25:04PM -0500, David Lechner wrote:
This moves the UART init for LEGO MINDSTORMS EV3 to board_early_init_f(). Some console messages were not being printed because the UART was not enabled until later in the init process.
Signed-off-by: David Lechner david@lechnology.com
Applied to u-boot/master, thanks!

This disables networking related items in the config. The EV3 does not have any networking hardware, so this is wasted space.
Signed-off-by: David Lechner david@lechnology.com --- board/lego/ev3/legoev3.c | 4 +--- configs/legoev3_defconfig | 4 +--- include/configs/legoev3.h | 2 -- 3 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/board/lego/ev3/legoev3.c b/board/lego/ev3/legoev3.c index 69010055d3..423c2fa44b 100644 --- a/board/lego/ev3/legoev3.c +++ b/board/lego/ev3/legoev3.c @@ -14,8 +14,6 @@
#include <common.h> #include <i2c.h> -#include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h> @@ -162,7 +160,7 @@ int board_init(void)
/* setup the SUSPSRC for ARM to control emulation suspend */ writel(readl(&davinci_syscfg_regs->suspsrc) & - ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | + ~(DAVINCI_SYSCFG_SUSPSRC_I2C | DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | DAVINCI_SYSCFG_SUSPSRC_UART1), &davinci_syscfg_regs->suspsrc); diff --git a/configs/legoev3_defconfig b/configs/legoev3_defconfig index c5f54a98d3..8ee2d223fd 100644 --- a/configs/legoev3_defconfig +++ b/configs/legoev3_defconfig @@ -18,9 +18,7 @@ CONFIG_CMD_MMC=y CONFIG_CMD_SF=y CONFIG_CMD_SPI=y # CONFIG_CMD_SETEXPR is not set -CONFIG_CMD_DHCP=y -CONFIG_CMD_MII=y -CONFIG_CMD_PING=y +# CONFIG_CMD_NET is not set CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_DIAG=y diff --git a/include/configs/legoev3.h b/include/configs/legoev3.h index 812fd0c14a..6972cedabf 100644 --- a/include/configs/legoev3.h +++ b/include/configs/legoev3.h @@ -43,7 +43,6 @@ DAVINCI_SYSCFG_SUSPSRC_TIMER0 | \ DAVINCI_SYSCFG_SUSPSRC_SPI0 | \ DAVINCI_SYSCFG_SUSPSRC_UART1 | \ - DAVINCI_SYSCFG_SUSPSRC_EMAC | \ DAVINCI_SYSCFG_SUSPSRC_I2C)
/* @@ -152,7 +151,6 @@ "run flashboot; " \ "fi" #define CONFIG_EXTRA_ENV_SETTINGS \ - "hostname=EV3\0" \ "memsize=64M\0" \ "filesyssize=10M\0" \ "verify=n\0" \

On Sat, May 19, 2018 at 11:25:05PM -0500, David Lechner wrote:
This disables networking related items in the config. The EV3 does not have any networking hardware, so this is wasted space.
Signed-off-by: David Lechner david@lechnology.com
Applied to u-boot/master, thanks!

This removes the unused clock and RAM config options that were cargo- culted when this board was copied from the DA850 EVM.
Signed-off-by: David Lechner david@lechnology.com --- include/configs/legoev3.h | 54 --------------------------------------- 1 file changed, 54 deletions(-)
diff --git a/include/configs/legoev3.h b/include/configs/legoev3.h index 6972cedabf..9eb95bc030 100644 --- a/include/configs/legoev3.h +++ b/include/configs/legoev3.h @@ -39,60 +39,6 @@
#define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */
-#define CONFIG_SYS_DA850_SYSCFG_SUSPSRC ( \ - DAVINCI_SYSCFG_SUSPSRC_TIMER0 | \ - DAVINCI_SYSCFG_SUSPSRC_SPI0 | \ - DAVINCI_SYSCFG_SUSPSRC_UART1 | \ - DAVINCI_SYSCFG_SUSPSRC_I2C) - -/* - * PLL configuration - */ - -#define CONFIG_SYS_DA850_PLL0_PLLM 24 -#define CONFIG_SYS_DA850_PLL1_PLLM 21 - -/* - * DDR2 memory configuration - */ -#define CONFIG_SYS_DA850_DDR2_DDRPHYCR (DV_DDR_PHY_PWRDNEN | \ - DV_DDR_PHY_EXT_STRBEN | \ - (0x4 << DV_DDR_PHY_RD_LATENCY_SHIFT)) - -#define CONFIG_SYS_DA850_DDR2_SDBCR ( \ - (1 << DV_DDR_SDCR_MSDRAMEN_SHIFT) | \ - (1 << DV_DDR_SDCR_DDREN_SHIFT) | \ - (1 << DV_DDR_SDCR_SDRAMEN_SHIFT) | \ - (1 << DV_DDR_SDCR_BUS_WIDTH_SHIFT) | \ - (0x3 << DV_DDR_SDCR_CL_SHIFT) | \ - (0x2 << DV_DDR_SDCR_IBANK_SHIFT) | \ - (0x2 << DV_DDR_SDCR_PAGESIZE_SHIFT)) - -/* SDBCR2 is only used if IBANK_POS bit in SDBCR is set */ -#define CONFIG_SYS_DA850_DDR2_SDBCR2 0 - -#define CONFIG_SYS_DA850_DDR2_SDTIMR ( \ - (14 << DV_DDR_SDTMR1_RFC_SHIFT) | \ - (2 << DV_DDR_SDTMR1_RP_SHIFT) | \ - (2 << DV_DDR_SDTMR1_RCD_SHIFT) | \ - (1 << DV_DDR_SDTMR1_WR_SHIFT) | \ - (5 << DV_DDR_SDTMR1_RAS_SHIFT) | \ - (8 << DV_DDR_SDTMR1_RC_SHIFT) | \ - (1 << DV_DDR_SDTMR1_RRD_SHIFT) | \ - (0 << DV_DDR_SDTMR1_WTR_SHIFT)) - -#define CONFIG_SYS_DA850_DDR2_SDTIMR2 ( \ - (7 << DV_DDR_SDTMR2_RASMAX_SHIFT) | \ - (0 << DV_DDR_SDTMR2_XP_SHIFT) | \ - (0 << DV_DDR_SDTMR2_ODT_SHIFT) | \ - (17 << DV_DDR_SDTMR2_XSNR_SHIFT) | \ - (199 << DV_DDR_SDTMR2_XSRD_SHIFT) | \ - (0 << DV_DDR_SDTMR2_RTP_SHIFT) | \ - (0 << DV_DDR_SDTMR2_CKE_SHIFT)) - -#define CONFIG_SYS_DA850_DDR2_SDRCR 0x00000494 -#define CONFIG_SYS_DA850_DDR2_PBBPR 0x30 - /* * Serial Driver info */

On Sat, May 19, 2018 at 11:25:06PM -0500, David Lechner wrote:
This removes the unused clock and RAM config options that were cargo- culted when this board was copied from the DA850 EVM.
Signed-off-by: David Lechner david@lechnology.com
Applied to u-boot/master, thanks!

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

On Sat, May 19, 2018 at 11:25:07PM -0500, David Lechner wrote:
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
Applied to u-boot/master, thanks!
participants (2)
-
David Lechner
-
Tom Rini