I made this simple script that will run fw_printenv sequentially on all possible flash sectors in the first two mtd partitions, to identify where are stock uboot envs even if you are not using stock firmware anymore.
To be run on different devices it might need some adjustments (it currently checks only 1 MiB of flash sectors per partition, and checks only the first two partitions, which should be enough as uboot partition is 1MiB and the uboot_env partition is 0.5MiB).
I've left in the loop I used to generate the hex values, it's commented out but will work as long as you have installed bc in your system.
To be run on different devices it might need some adjustments (it currently checks only 1 MiB of flash sectors per partition, and checks only the first two partitions, which should be enough as uboot partition is 1MiB and the uboot_env partition is 0.5MiB).
I've left in the loop I used to generate the hex values, it's commented out but will work as long as you have installed bc in your system.
#!/bin/sh # MTD device name Device offset Env. size Flash sector size Number of sectors #/dev/mtd0 0xc0000 0x20000 0x20000 #backing up current config mv /etc/fw_env.config /etc/fw_env.config.backup #list of block addresses #128k = 131072 bytes -> 0x20000 in hexadecimal and we sum 0x20000 to it to get our addresses. # address=180000 # # while [ "$address" != "0" ] ; do # # address=$( echo "obase=16;ibase=16;$address-20000" | bc ) # echo $address # # done # addresses for mtd0 # E0000 # C0000 # A0000 # 80000 # 60000 # 40000 # 20000 # 0 # addresses for mtd1 # same as above, it restarts from 0 in each mtd #zyxel nsa310 new mtdparts, kinda #mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env),0x100000(second_stage_uboot),0x7b80000(ubi) for address in e0000 c0000 a0000 80000 60000 40000 20000 0; do echo "/dev/mtd0 0x$address 0x20000 0x20000" > /etc/fw_env.config cat /etc/fw_env.config echo "stuff found at mtd0 $address" fw_printenv echo ----------------------------- done for address in e0000 c0000 a0000 80000 60000 40000 20000 0; do echo "/dev/mtd1 0x$address 0x20000 0x20000" > /etc/fw_env.config echo "stuff found at mtd1 $address" fw_printenv echo ----------------------------- done #restoring current config mv /etc/fw_env.config.backup /etc/fw_env.config