WRT3200ACM 21.02 rc1 /usr/sbin/fw_printenv -n boot_part not working

On my WRT3200ACM running on OpenWrt 21.02.0-rc1 r16046-59980f7aaf

luci-app-advanced-reboot 1.0.0-1 is not displaying the partitions right.
Both partitions displaying "Alternative" instead off "Active" for one of them.

The following command is also not working and probably the reason it's not functioning;

root@OpenWrt:/sbin# /usr/sbin/fw_printenv -n boot_part
Cannot parse config file '/etc/fw_env.config': No such file or directory
root@OpenWrt:/sbin#

Is this a 21.02 bug, or am I missing something?

fw_printenv comes from the uboot-envtools package.

Hi @frollic

uboot-envtools 2021.01-5 are installed.

Ah,

my bad, it's the conf that's missing.

Yes, you need to (re)create the fw_env.config file - Wrt3200acm: sysupgrade falling back - #7 by anomeome

Verify the sanity of the value by reading the dmesg output, it lists all the partitions.

I can't find the file in the build_dir of my imagebuild. Can I find the file somewhere else?

it's a plain text file, create it yourself.

But what needs to be in the file?

yup,

that's what's in WRT3200ACM 21.02 rc1 /usr/sbin/fw_printenv -n boot_part not working - #4 by frollic

I did read the threat, but I think I missing brain capacity :wink:

dmesg is a lot of info, and I have no idea what part I need.

something like this, but I don't know what:

 # MTD device   env offset  env size    sector size
       /dev/mtd1      0x00000     0x10000     0x10000

:slight_smile:

start by running dmesg/reading the system log in webUI.

It'll list all mtds during boot.

Can only find one, maybe that's the problem?

Tue May 18 06:32:36 2021 kern.notice kernel: [   37.720265] ubi2: detaching mtd6
Tue May 18 06:32:36 2021 kern.notice kernel: [   37.724012] ubi2: mtd6 is detached
Tue May 18 07:15:28 2021 kern.notice kernel: [  603.320704] ubi2: attaching mtd6
Tue May 18 07:15:29 2021 kern.notice kernel: [  603.706836] ubi2: scanning is finished
Tue May 18 07:15:29 2021 kern.notice kernel: [  603.718477] ubi2: attached mtd6 (name "rootfs1", size 74 MiB)

that's it ?

there should be more mtds ...

I know, so maybe that's the problem. In /dev there are 9 of them.

in that case, do over ssh

cat /proc/mtd

root@OpenWrt:/dev# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 00020000 00020000 "u_env"
mtd2: 00040000 00020000 "s_env"
mtd3: 00040000 00020000 "devinfo"
mtd4: 001e0000 00020000 "sysdiag"
mtd5: 05000000 00020000 "kernel1"
mtd6: 04a00000 00020000 "rootfs1"
mtd7: 05000000 00020000 "kernel2"
mtd8: 04a00000 00020000 "ubi"
mtd9: 05600000 00020000 "syscfg"
mtd10: 005c0000 00020000 "unused_area"
root@OpenWrt:/dev#

11 mtds

And found this.

Tue May 18 06:32:35 2021 user.notice advanced-reboot: attempting to unmount alternative partition (mtd6)
Tue May 18 06:32:36 2021 kern.info kernel: [   37.702277] block ubiblock2_0: released
Tue May 18 06:32:36 2021 kern.notice kernel: [   37.720265] ubi2: detaching mtd6
Tue May 18 06:32:36 2021 kern.notice kernel: [   37.724012] ubi2: mtd6 is detached

can always do dmesg |grep "mtd"

but since /proc/mtd worked, /dev/mtd1 0x0 0x20000 0x20000 seems to be correct.

put it in the conf, then try fw_printenv by itself, to see if it can read the partition.

/etc/fw_env.config
In the file

/dev/mtd1 0x0 0x20000 0x20000
root@OpenWrt:/etc# fw_printenv
Cannot open dev/mtd1: No such file or directory
root@OpenWrt:/etc#
root@OpenWrt:/etc# dmesg |grep "mtd"
[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mtdblock8 ro rootdelay=1 rootfstype=jffs2 earlyprintk mtdparts=armada-nand:2048K(uboot)ro,128K(u_env),256K(s_env),256K@8064K(devinfo),1920K@8320K(sysdiag),80m@10m(kernel),74m@16m(rootfs),80m@90m(alt_kernel),74m@96m(alt_rootfs),160m@10m(ubifs),-@170m(syscfg)
[    0.000000] Bootloader command line (ignored): console=ttyS0,115200 root=/dev/mtdblock8 ro rootdelay=1 rootfstype=jffs2 earlyprintk mtdparts=armada-nand:2048K(uboot)ro,128K(u_env),256K(s_env),256K@8064K(devinfo),1920K@8320K(sysdiag),80m@10m(kernel),74m@16m(rootfs),80m@90m(alt_kernel),74m@96m(alt_rootfs),160m@10m(ubifs),-@170m(syscfg)
[    2.230295] UBI: auto-attach mtd8
[    2.233633] ubi0: attaching mtd8
[    2.638777] ubi0: attached mtd8 (name "ubi", size 74 MiB)
[    9.346349] ubi1: attaching mtd9
[    9.800675] ubi1: attached mtd9 (name "syscfg", size 86 MiB)
[   36.871928] ubi2: attaching mtd6
[   37.386492] ubi2: attached mtd6 (name "rootfs1", size 74 MiB)
[   37.720265] ubi2: detaching mtd6
[   37.724012] ubi2: mtd6 is detached
[  603.320704] ubi2: attaching mtd6
[  603.718477] ubi2: attached mtd6 (name "rootfs1", size 74 MiB)
[  603.884142] ubi2: detaching mtd6
[  603.887643] ubi2: mtd6 is detached
[  910.071432] ubi2: attaching mtd6
[  910.469011] ubi2: attached mtd6 (name "rootfs1", size 74 MiB)
[  910.636236] ubi2: detaching mtd6
[  910.639817] ubi2: mtd6 is detached
root@OpenWrt:/etc#

My mistake, mtd1 reads:

root@OpenWrt:/etc# fw_printenv
CASset=max
MALLOC_len=5
MPmode=SMP
SMT-2D=NIFNH42014CBX01
altFwSize=0x5000000
altKernAddr=0x5a00000
altKernSize=0x0600000
altnandboot=setenv bootargs console=ttyS0,115200 root=/dev/mtdblock8 ro rootdelay=1 rootfstype=jffs2 earlyprintk $mtdparts;nand read $defaultLoadAddr $altKernAddr $altKernSize; bootm $defaultLoadAddr
auto_recovery=yes
autoload=no
baudrate=115200
boot_order=hd_scr usb_scr mmc_scr hd_img usb_img mmc_img pxe net_img net_scr
bootargs_dflt=$console $nandEcc $mtdparts_lgcy $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel
bootargs_end=:10.4.50.254:255.255.255.0:Armada38x:eth0:none
bootargs_root=root=/dev/nfs rw
bootcmd_auto=stage_boot $boot_order
bootcmd_fdt=tftpboot 0x2000000 $image_name;tftpboot $fdtaddr $fdtfile;setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_boot=tftpboot 0x2000000 $image_name; setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_edit=tftpboot $fdtaddr $fdtfile; fdt addr $fdtaddr; setenv bootcmd $bootcmd_fdt_boot
bootcmd_lgcy=tftpboot 0x2000000 $image_name;setenv bootargs $console $nandEcc $mtdparts_lgcy $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end  video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel;  bootm $loadaddr;
bootdelay=3
cacheShare=no
console=console=ttyS0,115200
defaultLoadAddr=0x2000000
device_partition=0:1
disaMvPnp=no
eeeEnable=no
enaClockGating=no
enaCpuStream=no
enaFPU=yes
enaMonExt=no
enaWrAllo=no
eth1addr=00:50:43:73:45:33
eth1mtu=1500
eth2addr=00:50:43:73:73:33
eth2mtu=1500
eth3addr=00:50:43:45:73:73
eth3mtu=1500
ethact=egiga0
ethaddr=60:38:E0:C7:73:00
ethmtu=1500
ethprime=egiga0
fdt_addr=2040000
fdt_skip_update=no
fdtaddr=0x1000000
fdtfile=armada-38x-modular.dtb
fileaddr=1000000
filesize=21E0000
firmwareName=rango.img
flash_alt_image=tftpboot $defaultLoadAddr $firmwareName && nand erase $altKernAddr $altFwSize && nand write $defaultLoadAddr $altKernAddr $filesize
flash_pri_image=tftpboot $defaultLoadAddr $firmwareName && nand erase $priKernAddr $priFwSize && nand write $defaultLoadAddr $priKernAddr $filesize
ide_path=/
image_name=uImage
initrd_name=uInitrd
ipaddr=192.168.1.1
kernel_addr_r=2080000
lcd0_enable=0
lcd0_params=640x480-16@60
lcd_panel=0
limit_dram_size=yes
loadaddr=0x02000000
loads_echo=0
mtddevname=uboot
mtddevnum=0
mtdids=nand0=armada-nand
mtdparts=mtdparts=armada-nand:2048K(uboot)ro,128K(u_env),256K(s_env),256K@8064K(devinfo),1920K@8320K(sysdiag),80m@10m(kernel),74m@16m(rootfs),80m@90m(alt_kernel),74m@96m(alt_rootfs),160m@10m(ubifs),-@170m(syscfg)
mvNetConfig=mv_net_config=4,(00:50:43:11:11:11,0:1:2:3),mtu=1500
mv_pon_addr=00:50:43:33:73:73
nandEcc=nfcConfig=4bitecc
nandboot=setenv bootargs console=ttyS0,115200 root=/dev/mtdblock6 ro rootdelay=1 rootfstype=jffs2 earlyprintk $mtdparts;nand read $defaultLoadAddr $priKernAddr $priKernSize; bootm $defaultLoadAddr
netbsd_en=no
netmask=255.255.255.0
netretry=no
partition=nand0,0
pcieTune=no
pexMode=RC
priFwSize=0x5000000
priKernAddr=0x0a00000
priKernSize=0x0600000
pxe_files_load=:default.arm-armadaxp-db:default.arm-armadaxp:default.arm
pxefile_addr_r=3100000
ramdisk_addr_r=2880000
rootpath=/srv/nfs/
run_script=no
sata_delay_reset=0
sata_dma_mode=yes
script_addr_r=3000000
script_name=boot.scr
sd_detection_dat3=no
serverip=192.168.1.254
standalone=fsload 0x2000000 $image_name;setenv bootargs $console $nandEcc $mtdparts_lgcy root=/dev/mtdblock0 rw ip=$ipaddr:$serverip$bootargs_end; bootm 0x2000000;
stderr=serial
stdin=serial
stdout=serial
update_both_images=tftpboot $defaultLoadAddr $firmwareName && nand erase $priKernAddr $priFwSize && nand erase $altKernAddr $altFwSize && nand write $defaultLoadAddr $priKernAddr $filesize && nand write $defaultLoadAddr $altKernAddr $filesize
usb0Mode=host
usbActive=0
usbType=2
vxworks_en=no
yuk_ethaddr=00:00:00:EE:51:81
boot_part_ready=3
boot_part=2
bootcmd="run altnandboot"
root@OpenWrt:/etc#