Fw_printenv not working

Hello

I have 2 turris omnia with the latest version of uboot -(2022) after updating it via nor-update.

But now fw_printenv and fw_setenv doesnt work (i want in the next boot, set & save the U-Boot default environment, and reboot again to repair CRC checksum)

in turris 1 when i execute fw_printenv says this error

Read error on /dev/mtd0: Attempted to read 65536 bytes but got 0

in turris 2 work printenv but setenv doesnt work throwing this error

Read error on /dev/mtd0: Attempted to read 262144 bytes but got 196608
Error: can’t write fw_env to flash

Flash layout in both turris are the same

root@turris:~# cat /proc/mtd
dev: size erasesize name
mtd0: 000f0000 00010000 “U-Boot”
mtd1: 00700000 00010000 “Rescue system”
mtd2: 00010000 00010000 “u-boot-env”

What is the content of /etc/fw_env.config?
Can you try to update this file with

/dev/mtd0 0xf0000 0x10000 0x10000

and try it again?

yes i have tested with that file modified and now reads the fw_printenv but fw_setenv doesnt work…

after research i set in env_config this settings and show ok. My uboot version from turris is
U-Boot SPL 2022.10-rc4-OpenWrt-r16653+119-44ce70f0e2 (Sep 15 2022 - 18:21:35 +0000)

/dev/mtd0 0xc0000 0x10000 0x40000

finally i setted all default settings via UART but still shows bad CRC and doesnt show all parameters

1 Like

I found this:

I tried to read mtd2, still getting CRC error, I didn’t try to set.

root@turris:~# cat /proc/mtd
dev: size erasesize name
mtd0: 000f0000 00010000 “U-Boot”
mtd1: 00700000 00010000 “Rescue system”
mtd2: 00010000 00010000 “u-boot-env”
root@turris:~# cat /etc/fw_env.config
/dev/mtd2 0x0 0x10000 0x10000
root@turris:~# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath}
ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200
root@turris:~#

I will try your settings too. I assumed they were for old U-boot versions.

1 Like

Finally is WORKING thanks setting as /dev/mtd2 works well

so after set the file

echo ‘/dev/mtd2 0x00000 0x10000 0x10000’ > /etc/fw_env.config

its working well and show all config without issues in the latest uboot 2022

2 Likes

Same here, /dev/mtd2 0x0 0x10000 0x10000 works for me with:

  • U-Boot 2022.10-rc4-OpenWrt-r16653+119-44ce70f0e2 (Sep 15 2022 - 18:21:35 +0000)
  • uboot-envtools - 2021.01-5
  • root@turris:~# cat /proc/mtd
    dev:    size   erasesize  name
    mtd0: 000f0000 00010000 "U-Boot"
    mtd1: 00700000 00010000 "Rescue system"
    mtd2: 00010000 00010000 "u-boot-env"
    root@turris:~#
    

Both fw_printenv and fw_setenv work as intended. \o/

Are you getting “Warning: Bad CRC, using default environment”?

No. But I did issue env default -a followed by saveenv in the U-Boot console (through a serial connection) in the past. Maybe this rewrote the environment including the correct CRC?

now its working well without crc error. in my other turris after set via fw_setenv works well without access it via serial

fw_setenv bootcmd “env default -a; saveenv; reset”

What is the output of fw_printenv?
I need to get a UART cable, before I start messing with uboot.

this is myu fw_printenv

**root@Turris_Omnia:~# fw_printenv
arch=arm
baudrate=115200
board=turris_omnia
board_name=turris_omnia
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr -q ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr -q ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_pci_enum=pci enum
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 nvme0 scsi0 usb0 pxe dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=devtype=dhcp; run boot_net_usb_start; run boot_pci_enum; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; if test -z “${fdtfile}” -a -n “${soc}”; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00010:UNDI:003000;setenv bootp_arch 0xa;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr -q ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_nvme0=devnum=0; run nvme_boot
bootcmd_pxe=run boot_net_usb_start; run boot_pci_enum; dhcp; if pxe get; then pxe boot; fi
bootcmd_rescue=i2c dev 2; i2c mw 0x2a.1 0x3 0x1c 1; i2c mw 0x2a.1 0x4 0x1c 1; mw.l 0x01000000 0x00ff000c; i2c write 0x01000000 0x2a.1 0x5 4 -s; setenv bootargs “earlyprintk console=ttyS0,115200 omniarescue=$omnia_reset rescue_mode=$omnia_reset”; sf probe; sf read 0x1000000 0x100000 0x700000; lzmadec 0x1000000 0x1700000; if gpio input gpio@71_4; then bootm 0x1700000#sfp; else bootm 0x1700000; fi; bootz 0x1000000
bootcmd_scsi0=devnum=0; run scsi_boot
bootcmd_usb0=devnum=0; run usb_boot
bootdelay=3
console=ttyS0,115200
cpu=armv7
distro_bootcmd=scsi_need_init=; setenv nvme_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethprime=eth2
fdt_addr_r=0x2000000
fdt_high=0x10000000
fdtfile=armada-385-turris-omnia.dtb
initrd_high=0x10000000
kernel_addr_r=0x1000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x800000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
nvme_boot=run boot_pci_enum; run nvme_init; if nvme dev ${devnum}; then devtype=nvme; run scan_dev_for_boot_part; fi
nvme_init=if ${nvme_need_init}; then setenv nvme_need_init false; nvme scan; fi
pxefile_addr_r=0x1900000
ramdisk_addr_r=0x2200000
sata_boot=if sata dev ${devnum}; then devtype=sata; run scan_dev_for_boot_part; fi
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}…; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z “${fdtfile}” -a -n “${soc}”; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing…; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing…; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing…; fi; done
scriptaddr=0x1800000
scsi_boot=run boot_pci_enum; run scsi_init; if scsi dev ${devnum}; then devtype=scsi; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then scsi_need_init=false; scsi scan; fi
soc=mvebu
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=CZ.NIC
**

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.