How can uboot-environment change from rootfs with fw_setenv?
0
votes
0
answers
197
views
my Linux operating system sometimes gives kernel panic while booting.
For this, I defined a variable in uboot called mybootcount. It will count every time it boots, if it reaches 3, it will go to the second partition, but after a successful boot, when it goes to rootfs, I need to access my env in Linux and set the mybootcount value to 0. I created a /etc/fw_env.config file for this. I made vi /dev/mmcblk1p1 0x140000 0x20000 and saved it, then when I do fw_printenv, I get the error warning: bad crc using default environment. But I don't get any warning during uboot loading.
my uboot config file
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_FAT_DEVICE_AND_PART="1"
CONFIG_ENV_SIZE=0X20000
CONFIG_ENV_OFFSET=0X140000
my uboot loading
U-Boot 2019.04-linux4sam_6.2 (Oct 03 2024 - 10:35:02 +0300) MMC: sdio-host@a0000000: 0, sdio-host@b0000000: 1 Loading Environment from FAT... OK
> printenv
bootargs=console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p2 rw rootwait rootfstype=ext4 panic=3 atmel.pm_modes=standby,ulp1
bootargs2=console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p3 rw rootwait rootfstype=ext4 panic=3 atmel.pm_modes=standby,ulp1
bootcmd=echo bootcounter: ${mybootcount}; run choose_bootargs; setexpr mybootcount ${mybootcount} + 1; saveenv; fatload mmc 1:1 0x21000000 at91-sama5d27_srcgb_mdm.dtb; fatload mmc 1:1 0x22000000 zImage; bootz 0x22000000 - 0x21000000 ;
bootcount=1
bootdelay=3
bootlimit=3
choose_bootargs=if test ${mybootcount} -ge ${bootlimit}; then echo "ROOTFS BACKUP"; setenv bootargs ${bootargs2}; setexpr mybootcount 0; else echo "MAIN ROOTFS"; fi; saveenv;
after kernel
fw_env.config:/dev/mmcblk1p1 0x140000 0x20000
fw_printenv
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200
mybootcount=0
Asked by Ertugrul Sahin
(1 rep)
Oct 7, 2024, 05:37 AM