Thank you very much for the information.
I understand now that it is definitely necessary to make the appropriate changes in the U-Boot environment in order to start OpenWrt 21.x or 22.x on NBG6616. This is also necessary for people who would choose to switch from the original ZyXEL firmware, which is not clear from the chapter "Upgrade from ZyXEL customized OpenWrt" (in https://openwrt.org/toh/zyxel/nbg6616#upgrade_from_zyxel_customized_openwrt).
The problem I see is that there is no tried and tested instruction manual for NBG6616 that clearly states the procedure how to set up the U-Boot environment in OpenWrt 19.x (for example 19.07.10).
What I have done so far:
- Analysis
# cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "env"
mtd2: 00010000 00010000 "RFdata"
mtd3: 00060000 00010000 "zyxel_rfsd"
mtd4: 00060000 00010000 "romd"
mtd5: 00010000 00010000 "header"
mtd6: 00200000 00010000 "kernel"
mtd7: 00ce0000 00010000 "rootfs"
mtd8: 00a10000 00010000 "rootfs_data"
mtd9: 00ee0000 00010000 "firmware"
# dmesg
...
[ 0.929778] m25p80 spi0.0: found mx25l12805d, expected m25p80
[ 0.936218] m25p80 spi0.0: mx25l12805d (16384 Kbytes)
[ 0.941376] 9 cmdlinepart partitions found on MTD device spi0.0
[ 0.947406] Creating 9 MTD partitions on "spi0.0":
[ 0.952274] 0x000000000000-0x000000030000 : "u-boot"
[ 0.958443] 0x000000030000-0x000000040000 : "env"
[ 0.964774] 0x000000040000-0x000000050000 : "RFdata"
[ 0.970923] 0x000000050000-0x0000000b0000 : "zyxel_rfsd"
[ 0.977914] 0x0000000b0000-0x000000110000 : "romd"
[ 0.983825] 0x000000110000-0x000000120000 : "header"
[ 0.990486] 0x000000120000-0x000000320000 : "kernel"
[ 0.996633] 0x000000320000-0x000001000000 : "rootfs"
[ 1.002267] mtd: device 7 (rootfs) set to be root filesystem
[ 1.008112] 1 squashfs-split partitions found on MTD device rootfs
[ 1.014385] 0x0000005f0000-0x000001000000 : "rootfs_data"
[ 1.021914] 0x000000120000-0x000001000000 : "firmware"
...
- Setting
# cat /etc/fw_env.config
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd1 0x30000 0x10000
But I have no idea if this is correct! fw_printenv works even if I specify a different value in the "Device offset".
- Printing test U-boot environment
# fw_printenv
baudrate=115200
ipaddr=192.168.1.1
serverip=192.168.1.33
uboot_env_ver=1.5
img_prefix=nbg6616-
loadaddr=80400000
readonly=ro
setmtdparts=setenv mtdparts mtdparts=spi0.0:${ldr_psize}(u-boot)${readonly},${env_psize}(env)${readonly},${rfdat_psize}(RFdata)${readonly},${rfsdat_psize}(rootfs_data),${romd_psize}(romd),${hdr_psize}(header),${rfs_psize}(rootfs)
flashargs=setenv bootargs board=NBG6616 root=/dev/mtdblock6 rootfstype=jffs2 noinitrd ${bootmode} ${zld_ver}
addtty=setenv bootargs ${bootargs} console=ttyS0,${baudrate}
addmtd=setenv bootargs ${bootargs} ${mtdparts}
boot_flash=run setmtdparts flashargs addtty addmtd;fsload ${loadaddr} /boot/vmlinux.lzma.uImage;bootm ${loadaddr}
bootcmd=run boot_flash
ldr_paddr=0x9f000000
ldr_psize=0x30000
env_paddr=0x9f030000
env_psize=0x10000
rfdat_paddr=0x9f040000
rfdat_psize=0x10000
rfsdat_paddr=0x9f050000
rfsdat_psize=0x60000
romd_paddr=0x9f0b0000
romd_psize=0x60000
hdr_paddr=0x9f110000
hdr_psize=0x10000
rfs_paddr=0x9f120000
rfs_psize=0xee0000
lu=tftp ${loadaddr} ${dir}u-boot.bin;zflash erase ${ldr_paddr} ${ldr_psize};zflash write ${fileaddr} ${ldr_paddr} ${filesize}
lf=tftp ${loadaddr} ${dir}${img_prefix}rootfs.jffs2;nand erase ${rfs_paddr} ${rootfs_psize};nand write ${fileaddr} ${rfs_paddr} ${filesize}
hostname=NBG6616
serialnum=S............
countrycode=E1
ethaddr=.................
Now it should follow:
# fw_setenv boot_openwrt bootm 0x9F120000
# fw_setenv bootcmd run boot_openwrt
And if /dev/mtd1 is writable, it should be configurable. Unfortunately I'm worried - I'm not sure about the /etc/fw_env.config setting and if it goes wrong I won't start again. If a daredevil is found, I'll be glad to know how it went.