On Tue, Jun 14, 2022 at 9:18 AM Tom Rini <tr...@konsulko.com> wrote: > > On Tue, Jun 14, 2022 at 09:14:03AM -0700, Tim Harvey wrote: > > On Mon, Jun 13, 2022 at 7:57 PM Tom Rini <tr...@konsulko.com> wrote: > > > > > > Move the environment text over from being set via > > > CONFIG_EXTRA_ENV_SETTINGS in include/configs/gw_ventana.h and over > > > to plain text in board/gateworks/gw_ventana/gw_ventana.env. This lets > > > us drop CONFIG_EXTRA_ENV_SETTINGS_COMMON as everything resides in a > > > single environment file now. > > > > > > Cc: Tim Harvey <thar...@gateworks.com> > > > Signed-off-by: Tom Rini <tr...@konsulko.com> > > > --- > > > board/gateworks/gw_ventana/gw_ventana.env | 145 +++++++++++++++++++++ > > > include/configs/gw_ventana.h | 148 ---------------------- > > > 2 files changed, 145 insertions(+), 148 deletions(-) > > > create mode 100644 board/gateworks/gw_ventana/gw_ventana.env > > > > > > diff --git a/board/gateworks/gw_ventana/gw_ventana.env > > > b/board/gateworks/gw_ventana/gw_ventana.env > > > new file mode 100644 > > > index 000000000000..9a316c74f215 > > > --- /dev/null > > > +++ b/board/gateworks/gw_ventana/gw_ventana.env > > > @@ -0,0 +1,145 @@ > > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > > +/* > > > + * Copyright (C) 2013 Gateworks Corporation > > > + */ > > > + > > > +splashpos=m,m > > > +splashimage=CONFIG_SYS_LOAD_ADDR > > > +usb_pgood_delay=2000 > > > +console=ttymxc1 > > > +bootdevs=usb mmc sata flash > > > +hwconfig=_UNKNOWN_ > > > + > > > +disk=0 > > > +part=1 > > > + > > > +fdt_high=0xffffffff > > > +fdt_addr=0x18000000 > > > +initrd_high=0xffffffff > > > +fixfdt=fdt addr ${fdt_addr} > > > +bootdir=boot > > > +loadfdt= > > > + if ${fsload} ${fdt_addr} ${bootdir}/${fdt_file}; then > > > + echo Loaded DTB from ${bootdir}/${fdt_file}; > > > + run fixfdt; > > > + elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file1}; then > > > + echo Loaded DTB from ${bootdir}/${fdt_file1}; > > > + run fixfdt; > > > + elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file2}; then > > > + echo Loaded DTB from ${bootdir}/${fdt_file2}; > > > + run fixfdt; > > > + fi > > > + > > > +fs=ext4 > > > +script=6x_bootscript-ventana > > > +loadscript= > > > + if ${fsload} ${loadaddr} ${bootdir}/${script}; then > > > + source ${loadaddr}; > > > + fi > > > + > > > +uimage=uImage > > > +mmc_root=mmcblk0p1 > > > +mmc_boot= > > > + setenv fsload "${fs}load mmc ${disk}:${part}"; > > > + mmc dev ${disk} && mmc rescan && > > > + setenv dtype mmc; run loadscript; > > > + if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then > > > + setenv bootargs console=${console},${baudrate} > > > + root=/dev/${mmc_root} rootfstype=${fs} > > > + rootwait rw ${video} ${extra}; > > > + if run loadfdt; then > > > + bootm ${loadaddr} - ${fdt_addr}; > > > + else > > > + bootm; > > > + fi; > > > + fi > > > + > > > +sata_boot= > > > + setenv fsload "${fs}load sata ${disk}:${part}"; > > > + sata init && > > > + setenv dtype sata; run loadscript; > > > + if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then > > > + setenv bootargs console=${console},${baudrate} > > > + root=/dev/sda1 rootfstype=${fs} > > > + rootwait rw ${video} ${extra}; > > > + if run loadfdt; then > > > + bootm ${loadaddr} - ${fdt_addr}; > > > + else > > > + bootm; > > > + fi; > > > + fi > > > + > > > +usb_boot= > > > + setenv fsload "${fs}load usb ${disk}:${part}"; > > > + usb start && usb dev ${disk} && > > > + setenv dtype usb; run loadscript; > > > + if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then > > > + setenv bootargs console=${console},${baudrate} > > > + root=/dev/sda1 rootfstype=${fs} > > > + rootwait rw ${video} ${extra}; > > > + if run loadfdt; then > > > + bootm ${loadaddr} - ${fdt_addr}; > > > + else > > > + bootm; > > > + fi; > > > + fi > > > + > > > +#ifdef CONFIG_SPI_FLASH > > > +image_os=ventana/openwrt-imx6-imx6q-gw5400-a-squashfs.bin > > > +image_uboot=ventana/u-boot_spi.imx > > > + > > > +spi_koffset=0x90000 > > > +spi_klen=0x200000 > > > + > > > +spi_updateuboot=echo Updating uboot from > > > + ${serverip}:${image_uboot}...; > > > + tftpboot ${loadaddr} ${image_uboot} && > > > + sf probe && sf erase 0 80000 && > > > + sf write ${loadaddr} 400 ${filesize} > > > +spi_update=echo Updating OS from ${serverip}:${image_os} > > > + to ${spi_koffset} ...; > > > + tftp ${loadaddr} ${image_os} && > > > + sf probe && > > > + sf update ${loadaddr} ${spi_koffset} ${filesize} > > > + > > > +flash_boot= > > > + if sf probe && > > > + sf read ${loadaddr} ${spi_koffset} ${spi_klen}; then > > > + setenv bootargs console=${console},${baudrate} > > > + root=/dev/mtdblock3 > > > + rootfstype=squashfs,jffs2 > > > + ${video} ${extra}; > > > + bootm; > > > + fi > > > +#else > > > +image_rootfs=openwrt-imx6-ventana-rootfs.ubi > > > +nand_update=echo Updating NAND from ${serverip}:${image_rootfs}...; > > > + tftp ${loadaddr} ${image_rootfs} && > > > + nand erase.part rootfs && > > > + nand write ${loadaddr} rootfs ${filesize} > > > + > > > +flash_boot= > > > + setenv fsload 'ubifsload'; > > > + ubi part rootfs; > > > + if ubi check boot; then > > > + ubifsmount ubi0:boot; > > > + setenv root ubi0:rootfs ubi.mtd=2 > > > + rootfstype=squashfs,ubifs; > > > + setenv bootdir; > > > + elif ubi check rootfs; then > > > + ubifsmount ubi0:rootfs; > > > + setenv root ubi0:rootfs ubi.mtd=2 > > > + rootfstype=ubifs; > > > + fi; > > > + setenv dtype nand; run loadscript; > > > + if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then > > > + setenv bootargs console=${console},${baudrate} > > > + root=${root} ${video} ${extra}; > > > + if run loadfdt; then > > > + ubifsumount; > > > + bootm ${loadaddr} - ${fdt_addr}; > > > + else > > > + ubifsumount; bootm; > > > + fi; > > > + fi > > > +#endif > > > diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h > > > index 77f41502220a..47a72fc8fce5 100644 > > > --- a/include/configs/gw_ventana.h > > > +++ b/include/configs/gw_ventana.h > > > @@ -76,152 +76,4 @@ > > > #define CONFIG_IPADDR 192.168.1.1 > > > #define CONFIG_SERVERIP 192.168.1.146 > > > > > > -#define CONFIG_EXTRA_ENV_SETTINGS_COMMON \ > > > - "splashpos=m,m\0" \ > > > - "splashimage=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ > > > - "usb_pgood_delay=2000\0" \ > > > - "console=ttymxc1\0" \ > > > - "bootdevs=usb mmc sata flash\0" \ > > > - "hwconfig=_UNKNOWN_\0" \ > > > - "video=\0" \ > > > - \ > > > - "disk=0\0" \ > > > - "part=1\0" \ > > > - \ > > > - "fdt_high=0xffffffff\0" \ > > > - "fdt_addr=0x18000000\0" \ > > > - "initrd_high=0xffffffff\0" \ > > > - "fixfdt=" \ > > > - "fdt addr ${fdt_addr}\0" \ > > > - "bootdir=boot\0" \ > > > - "loadfdt=" \ > > > - "if ${fsload} ${fdt_addr} ${bootdir}/${fdt_file}; then " \ > > > - "echo Loaded DTB from ${bootdir}/${fdt_file}; " \ > > > - "run fixfdt; " \ > > > - "elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file1}; then > > > " \ > > > - "echo Loaded DTB from ${bootdir}/${fdt_file1}; " \ > > > - "run fixfdt; " \ > > > - "elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file2}; then > > > " \ > > > - "echo Loaded DTB from ${bootdir}/${fdt_file2}; " \ > > > - "run fixfdt; " \ > > > - "fi\0" \ > > > - \ > > > - "fs=ext4\0" \ > > > - "script=6x_bootscript-ventana\0" \ > > > - "loadscript=" \ > > > - "if ${fsload} ${loadaddr} ${bootdir}/${script}; then " \ > > > - "source ${loadaddr}; " \ > > > - "fi\0" \ > > > - \ > > > - "uimage=uImage\0" \ > > > - "mmc_root=mmcblk0p1\0" \ > > > - "mmc_boot=" \ > > > - "setenv fsload \"${fs}load mmc ${disk}:${part}\"; " \ > > > - "mmc dev ${disk} && mmc rescan && " \ > > > - "setenv dtype mmc; run loadscript; " \ > > > - "if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then " \ > > > - "setenv bootargs console=${console},${baudrate} " > > > \ > > > - "root=/dev/${mmc_root} rootfstype=${fs} " > > > \ > > > - "rootwait rw ${video} ${extra}; " \ > > > - "if run loadfdt; then " \ > > > - "bootm ${loadaddr} - ${fdt_addr}; " \ > > > - "else " \ > > > - "bootm; " \ > > > - "fi; " \ > > > - "fi\0" \ > > > - \ > > > - "sata_boot=" \ > > > - "setenv fsload \"${fs}load sata ${disk}:${part}\"; " \ > > > - "sata init && " \ > > > - "setenv dtype sata; run loadscript; " \ > > > - "if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then " \ > > > - "setenv bootargs console=${console},${baudrate} " > > > \ > > > - "root=/dev/sda1 rootfstype=${fs} " \ > > > - "rootwait rw ${video} ${extra}; " \ > > > - "if run loadfdt; then " \ > > > - "bootm ${loadaddr} - ${fdt_addr}; " \ > > > - "else " \ > > > - "bootm; " \ > > > - "fi; " \ > > > - "fi\0" \ > > > - "usb_boot=" \ > > > - "setenv fsload \"${fs}load usb ${disk}:${part}\"; " \ > > > - "usb start && usb dev ${disk} && " \ > > > - "setenv dtype usb; run loadscript; " \ > > > - "if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then " \ > > > - "setenv bootargs console=${console},${baudrate} " > > > \ > > > - "root=/dev/sda1 rootfstype=${fs} " \ > > > - "rootwait rw ${video} ${extra}; " \ > > > - "if run loadfdt; then " \ > > > - "bootm ${loadaddr} - ${fdt_addr}; " \ > > > - "else " \ > > > - "bootm; " \ > > > - "fi; " \ > > > - "fi\0" > > > - > > > -#ifdef CONFIG_SPI_FLASH > > > - #define CONFIG_EXTRA_ENV_SETTINGS \ > > > - CONFIG_EXTRA_ENV_SETTINGS_COMMON \ > > > - "image_os=ventana/openwrt-imx6-imx6q-gw5400-a-squashfs.bin\0" \ > > > - "image_uboot=ventana/u-boot_spi.imx\0" \ > > > - \ > > > - "spi_koffset=0x90000\0" \ > > > - "spi_klen=0x200000\0" \ > > > - \ > > > - "spi_updateuboot=echo Updating uboot from " \ > > > - "${serverip}:${image_uboot}...; " \ > > > - "tftpboot ${loadaddr} ${image_uboot} && " \ > > > - "sf probe && sf erase 0 80000 && " \ > > > - "sf write ${loadaddr} 400 ${filesize}\0" \ > > > - "spi_update=echo Updating OS from ${serverip}:${image_os} " \ > > > - "to ${spi_koffset} ...; " \ > > > - "tftp ${loadaddr} ${image_os} && " \ > > > - "sf probe && " \ > > > - "sf update ${loadaddr} ${spi_koffset} ${filesize}\0" \ > > > - \ > > > - "flash_boot=" \ > > > - "if sf probe && " \ > > > - "sf read ${loadaddr} ${spi_koffset} ${spi_klen}; then " \ > > > - "setenv bootargs console=${console},${baudrate} " > > > \ > > > - "root=/dev/mtdblock3 " \ > > > - "rootfstype=squashfs,jffs2 " \ > > > - "${video} ${extra}; " \ > > > - "bootm; " \ > > > - "fi\0" > > > -#else > > > - #define CONFIG_EXTRA_ENV_SETTINGS \ > > > - CONFIG_EXTRA_ENV_SETTINGS_COMMON \ > > > - \ > > > - "image_rootfs=openwrt-imx6-ventana-rootfs.ubi\0" \ > > > - "nand_update=echo Updating NAND from > > > ${serverip}:${image_rootfs}...; " \ > > > - "tftp ${loadaddr} ${image_rootfs} && " \ > > > - "nand erase.part rootfs && " \ > > > - "nand write ${loadaddr} rootfs ${filesize}\0" \ > > > - \ > > > - "flash_boot=" \ > > > - "setenv fsload 'ubifsload'; " \ > > > - "ubi part rootfs; " \ > > > - "if ubi check boot; then " \ > > > - "ubifsmount ubi0:boot; " \ > > > - "setenv root ubi0:rootfs ubi.mtd=2 " \ > > > - "rootfstype=squashfs,ubifs; " \ > > > - "setenv bootdir; " \ > > > - "elif ubi check rootfs; then " \ > > > - "ubifsmount ubi0:rootfs; " \ > > > - "setenv root ubi0:rootfs ubi.mtd=2 " \ > > > - "rootfstype=ubifs; " \ > > > - "fi; " \ > > > - "setenv dtype nand; run loadscript; " \ > > > - "if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then " \ > > > - "setenv bootargs console=${console},${baudrate} " > > > \ > > > - "root=${root} ${video} ${extra}; " \ > > > - "if run loadfdt; then " \ > > > - "ubifsumount; " \ > > > - "bootm ${loadaddr} - ${fdt_addr}; " \ > > > - "else " \ > > > - "ubifsumount; bootm; " \ > > > - "fi; " \ > > > - "fi\0" > > > -#endif > > > - > > > #endif /* __CONFIG_H */ > > > -- > > > 2.25.1 > > > > > > > Tom, > > > > Thanks, I've been looking forward to seeing how env is going to get > > migrated out of headers. Can you explain the process used to create > > this patch? It seems you may have something automated. > > > > Acked-by: Tim Harvey <thar...@gateworks.com> > > So, I do not have anything automated, unfortunately. In cases like this > where we don't use distro_bootcmd and also don't use defined blocks of > commands, it's a matter of applying a few regexs to remove quotes, > spaces and trailing \, then giving it a quick read to make sure it's > still right. This last part is some of why it can't be automated as we > have cases of: > "some_bootargs=a=1 b=2" \ > "c=3\0" > and since there's no indent on c=3, it would become "c=3" in the > environment rather than "some_bootargs" being set to "a=1 b=2 c=3". >
Tom, I see - Its good to see this as an example and thanks for the cleanup! Tim