Save UBOOT environment

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Save UBOOT environment

2,405 Views
parth_shah
Contributor III

U-Boot 2019.07

CPU: Freescale i.MX6SX rev1.4 at 792MHz

Linux version 4.14.200

Yocto: dunfell

 

We want to enable the support for storing the uboot arguments in EMMC.

Please provide the details to enable on IMX6.

 

@igorpadykov : Any suggestion?

0 Kudos
Reply
2 Replies

2,394 Views
igorpadykov
NXP Employee
NXP Employee

Hi Parth

 

>We want to enable the support for storing the uboot arguments in EMMC.

 

one can look at  #define CONFIG_SYS_MMC_ENV_DEV 3 /*USDHC4*/

https://source.codeaurora.org/external/imx/uboot-imx/tree/include/configs/mx6sxsabresd.h?h=lf_v2021....

 

Best regards
igor

0 Kudos
Reply

2,366 Views
parth_shah
Contributor III

We have made changes as you suggested, but still we are facing issue.
#define CONFIG_SYS_MMC_ENV_DEV 3

 


Please find our approach below and let us know any corrections/addtional changes required.

 


Step 1: Cross compiling fw_printenv
-----------------------------------

 

We have cross compiled and copied fw_printenv to /bin/

 

and created symlink as below
ln -s fw_printenv fw_setenv

 


So we have both fw_printenv and fw_setenv are present in /bin

 

/bin/fw_setenv -> fw_printenv
/bin/fw_printenv

 


Step 2: Creating fw_env.config file
-----------------------------------

 

Created fw_env.config file with below mentioned content

 

vi /etc/fw_env.config
/dev/mmcblk3 0x400000 0x20000
/dev/mmcblk3 0x400000 0x20000

 


Step 3: Reading and writing uboot environment variables from Linux command line
-------------------------------------------------------------------------------

 

Now able to read and write the uboot environment variables

 


root@f1 ~# fw_printenv

 

Warning: Bad CRC, using default environment
bootcmd=f1boot
bootdelay=2
baudrate=115200
ethprime=eth0
loadaddr=0x82000000
bootdelay=3
rd_loadaddr=0x83000000
fdt_loadaddr=0x81000000
dtb_file=imx6sx_35som_better_emmc.dtb
m4_loadaddr=0x9FF00000
kernel_image=uImage
rootfs=rootfs_fct.cpio.gz.u-boot
user_bootargs=console=ttymxc0,115200
ummcdev=CONFIG_SYS_MMC_ENV_DEV
bootargs_base=setenv bootargs "${user_bootargs}" ubootver="${ubootver}" root=/dev/mmcblk3p2 rw rootfstype=ext4
bootargs_base_fct=setenv bootargs "${user_bootargs}" ubootver="${ubootver}" root=/dev/ram0 rw ramdisk_size=0x10000000
load_fct_kernel_usb=mw.b ${loadaddr} 0 0x10 ; fatload usb 0 ${loadaddr} ${kernel_image}
load_fct_dtb_usb=mw.b ${fdt_loadaddr} 0 0x10 ; fatload usb 0 ${fdt_loadaddr} ${dtb_file}
load_fct_fs_usb=mw.b ${rd_loadaddr} 0 0x10 ; fatload usb 0 ${rd_loadaddr} ${rootfs}
load_fct_kernel_tftp=mw.b ${loadaddr} 0 0x10 ; tftpboot ${loadaddr} ${kernel_image}
load_fct_dtb_tftp=mw.b ${fdt_loadaddr} 0 0x10 ; tftpboot ${fdt_loadaddr} ${dtb_file}
load_fct_fs_tftp=mw.b ${rd_loadaddr} 0 0x10 ; tftpboot ${rd_loadaddr} ${rootfs}
load_device_tree=mw.b ${fdt_loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${fdt_loadaddr} iotgw.dtb
load_kernel_mmc=mw.b ${loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${loadaddr} kernel.f1img
load_m4_mmc=mw.b ${m4_loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${m4_loadaddr} iotgw_rpmsg.m4
bootcmd_fct_usb=usb start ; run load_fct_kernel_usb ; run load_fct_dtb_usb ; run load_fct_fs_usb ; run bootargs_base_fct;bootm ${loadaddr} ${rd_loadaddr} ${fdt_loadaddr};
bootcmd_fct_tftp=run load_fct_kernel_tftp ; run load_fct_dtb_tftp ; run load_fct_fs_tftp ; run bootargs_base_fct;bootm ${loadaddr} ${rd_loadaddr} ${fdt_loadaddr};
bootcmd_mmc=run load_device_tree ; run load_kernel_mmc ; run load_m4_mmc ; run bootargs_base ;bootaux ${m4_loadaddr} ;bootm ${loadaddr} - ${fdt_loadaddr};

 

 

root@f1 ~# fw_setenv user_bootargs "console=ttymxc0,115200 spi-ksz9897.multi_dev=1 spi-ksz9897.eth1_ports=0xc spi-ksz9897.eth1_vlan=0x7e spi-ksz9897.eth1_proto=hsr"

 

Warning: Bad CRC, using default environment

 


root@f1 ~# fw_printenv

 

bootcmd=f1boot
bootdelay=2
baudrate=115200
ethprime=eth0
loadaddr=0x82000000
bootdelay=3
rd_loadaddr=0x83000000
fdt_loadaddr=0x81000000
dtb_file=imx6sx_35som_better_emmc.dtb
m4_loadaddr=0x9FF00000
kernel_image=uImage
rootfs=rootfs_fct.cpio.gz.u-boot
ummcdev=CONFIG_SYS_MMC_ENV_DEV
bootargs_base=setenv bootargs "${user_bootargs}" ubootver="${ubootver}" root=/dev/mmcblk3p2 rw rootfstype=ext4
bootargs_base_fct=setenv bootargs "${user_bootargs}" ubootver="${ubootver}" root=/dev/ram0 rw ramdisk_size=0x10000000
load_fct_kernel_usb=mw.b ${loadaddr} 0 0x10 ; fatload usb 0 ${loadaddr} ${kernel_image}
load_fct_dtb_usb=mw.b ${fdt_loadaddr} 0 0x10 ; fatload usb 0 ${fdt_loadaddr} ${dtb_file}
load_fct_fs_usb=mw.b ${rd_loadaddr} 0 0x10 ; fatload usb 0 ${rd_loadaddr} ${rootfs}
load_fct_kernel_tftp=mw.b ${loadaddr} 0 0x10 ; tftpboot ${loadaddr} ${kernel_image}
load_fct_dtb_tftp=mw.b ${fdt_loadaddr} 0 0x10 ; tftpboot ${fdt_loadaddr} ${dtb_file}
load_fct_fs_tftp=mw.b ${rd_loadaddr} 0 0x10 ; tftpboot ${rd_loadaddr} ${rootfs}
load_device_tree=mw.b ${fdt_loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${fdt_loadaddr} iotgw.dtb
load_kernel_mmc=mw.b ${loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${loadaddr} kernel.f1img
load_m4_mmc=mw.b ${m4_loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${m4_loadaddr} iotgw_rpmsg.m4
bootcmd_fct_usb=usb start ; run load_fct_kernel_usb ; run load_fct_dtb_usb ; run load_fct_fs_usb ; run bootargs_base_fct;bootm ${loadaddr} ${rd_loadaddr} ${fdt_loadaddr};
bootcmd_fct_tftp=run load_fct_kernel_tftp ; run load_fct_dtb_tftp ; run load_fct_fs_tftp ; run bootargs_base_fct;bootm ${loadaddr} ${rd_loadaddr} ${fdt_loadaddr};
bootcmd_mmc=run load_device_tree ; run load_kernel_mmc ; run load_m4_mmc ; run bootargs_base ;bootaux ${m4_loadaddr} ;bootm ${loadaddr} - ${fdt_loadaddr};
user_bootargs=console=ttymxc0,115200 spi-ksz9897.multi_dev=1 spi-ksz9897.eth1_ports=0xc spi-ksz9897.eth1_vlan=0x7e spi-ksz9897.eth1_proto=hsr

 

 


Step 5: Reading Uboot environment variables from uboot command line
-------------------------------------------------------------------

 

IoT U-Boot >printenv

 

baudrate=115200
bootargs_base=setenv bootargs "${user_bootargs}" ubootver="${ubootver}" root=/dev/mmcblk3p2 rw rootfstype=ext4
bootargs_base_fct=setenv bootargs "${user_bootargs}" ubootver="${ubootver}" root=/dev/ram0 rw ramdisk_size=0x10000000
bootcmd=f1boot
bootcmd_fct_tftp=run load_fct_kernel_tftp ; run load_fct_dtb_tftp ; run load_fct_fs_tftp ; run bootargs_base_fct;bootm ${loadaddr} ${rd_loadaddr} ${fdt_loadaddr};
bootcmd_fct_usb=usb start ; run load_fct_kernel_usb ; run load_fct_dtb_usb ; run load_fct_fs_usb ; run bootargs_base_fct;bootm ${loadaddr} ${rd_loadaddr} ${fdt_loadaddr};
bootcmd_mmc=run load_device_tree ; run load_kernel_mmc ; run load_m4_mmc ; run bootargs_base ;bootaux ${m4_loadaddr} ;bootm ${loadaddr} - ${fdt_loadaddr};
bootdelay=3
booted_from_usb=n
dtb_file=imx6sx_35som_better_emmc.dtb
eth1addr=00:04:9f:01:1b:68
ethact=ethernet@02188000
ethaddr=00:04:9f:01:1b:58
ethprime=eth0
fdt_loadaddr=0x81000000
fdtcontroladdr=9de52d08
kernel_image=uImage
load_device_tree=mw.b ${fdt_loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${fdt_loadaddr} iotgw.dtb
load_fct_dtb_tftp=mw.b ${fdt_loadaddr} 0 0x10 ; tftpboot ${fdt_loadaddr} ${dtb_file}
load_fct_dtb_usb=mw.b ${fdt_loadaddr} 0 0x10 ; fatload usb 0 ${fdt_loadaddr} ${dtb_file}
load_fct_fs_tftp=mw.b ${rd_loadaddr} 0 0x10 ; tftpboot ${rd_loadaddr} ${rootfs}
load_fct_fs_usb=mw.b ${rd_loadaddr} 0 0x10 ; fatload usb 0 ${rd_loadaddr} ${rootfs}
load_fct_kernel_tftp=mw.b ${loadaddr} 0 0x10 ; tftpboot ${loadaddr} ${kernel_image}
load_fct_kernel_usb=mw.b ${loadaddr} 0 0x10 ; fatload usb 0 ${loadaddr} ${kernel_image}
load_kernel_mmc=mw.b ${loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${loadaddr} kernel.f1img
load_m4_mmc=mw.b ${m4_loadaddr} 0 0x10 ; mmc dev ${ummcdev} && fatload mmc ${ummcdev}:7 ${m4_loadaddr} iotgw_rpmsg.m4
loadaddr=0x82000000
m4_loadaddr=0x9FF00000
rd_loadaddr=0x83000000
rootfs=rootfs_fct.cpio.gz.u-boot
stderr=serial
stdin=serial
stdout=serial
ubootver=2019.07-g0ee95423-g0ee95423
ummcdev=CONFIG_SYS_MMC_ENV_DEV
user_bootargs=console=ttymxc0,115200

 


From the above steps we can observe that, we are able to set uboot environment variables from linux command line.
But getting below CRC error and uboot is booting with default environment variables only.

 


Warning: Bad CRC, using default environment

 


And saveenv is not available in Uboot shell

 

our uboot configs have below chnages:

 

# CONFIG_ENV_IS_NOWHERE is not set
CONFIG_ENV_IS_IN_MMC=y
CONFIG_CMD_SAVEENV=y

0 Kudos
Reply