Welcome! Log In Create A New Profile

Advanced

Zyxel NSA325 questions (uboot)

Posted by Alatun 
Zyxel NSA325 questions (uboot)
April 25, 2020 12:52PM
Hi there!

I've been testing the debian install like documented here in the forums on my NSA325. I've got a serial connection and was successful in running

./kwboot -t -B 115200 /dev/ttyUSB0 -b uboot.2017.07-tld-1.nsa325.mtd0.kwb -p

with an attached USB stick prepared with the Debian kirkwood rootfs. So I could test the whole thing, without modifying the original setup.

What I noticed: without an USB stick the new U-Boot does not boot the original stock firmware, but does a reset. I have quite some experience with Linux on Intel systems, but this the first time dealing with the ARM and embedded world. The hardware configuration of these systems seems not being done via hardware scanning, but by using a "device tree" and U-Boot seems responsible initializing the hardware and then starting the linux kernel.

My first question: if I update to a new U-Boot, how can I start the stock firmware? And maybe switch between booting from the internal flash and from USB / disk.

Second question: I've seen several "fw_setenv" commands in the guides here, which set env variables for U-Boot, but I'd like to get more knowledge what's going on. Probably some values are being passed to the Linux kernel, but some also must control the behavior of U-Boot. Maybe someone can point me in the right direction.

Thanks in advance.
Re: Zyxel NSA325 questions (uboot)
April 25, 2020 04:56PM
Alatun,

> My first question: if I update to a new U-Boot,
> how can I start the stock firmware? And maybe
> switch between booting from the internal flash and
> from USB / disk.

No, currently it is not possible to boot back to stock FW after you've installed the new u-boot. It might be possible in the future, if I run out of things to do on my list, and have time to play with it a bit. But this has a very low priority.

> Second question: I've seen several "fw_setenv"
> commands in the guides here, which set env
> variables for U-Boot, but I'd like to get more
> knowledge what's going on. Probably some values
> are being passed to the Linux kernel, but some
> also must control the behavior of U-Boot. Maybe
> someone can point me in the right direction.
>

In u-boot, the command is setenv. In Linux, the command is fw_setenv. They do the same thing. But setenv will not save the envs permanently, until you do saveenv. fw_setenv will change the env and save it at the same time.

So to test various settings, setenv should be used in u-boot prompt. Since it is transient, if you reset the box (with u-boot reset command), or cycle power, then every thing will be back to the way it was. And then when you are sure to want to keep the envs change, you would do saveenv.

In my u-boot installation instruction, only fw_setenv was used. This has a purpose: no serial console needed, and it is only possible to use fw_setenv if your current system configuration is already what need to be.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Zyxel NSA325 questions (uboot)
April 26, 2020 02:38AM
Thx bodhi,

I'm looking for a way to reset the box the original firmware state, if anything goes wrong. Later yesterday evening I found the command printenv which dumps all the env settings which are currently set.

I've recorded both the stock env settings and the settings of the 2017.07 U-Boot (see below). If I understood things correctly, it should be possible to switch back to the stock firmware by applying the stock U-Boot env settings. Right? Or are the different versions of U-Boot no longer compatible regarding the commands involved?

So, if I create two scripts: one for setting the stock U-Boot env setting and one for booting from USB / disk this could solve the above problem.

The only problem could be, that each setup has slightly different keys. But does this matter?

Stock U-Boot env settings:
bootargs=console=ttyS0,115200 mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2) root=/dev/nfs rw init=/init
bootcmd=nand read.e 0x2000000 $(kernel_addr) 0xA00000; bootm 0x2000000
bootdelay=2
baudrate=115200
loads_echo=0
ipaddr=10.4.52.165
serverip=10.4.52.7
rootpath=/srv/ubuntu
netmask=255.255.255.0
nandEcc=1bit
MODEL_ID=AE03
PRODUCT_NAME=NSA-325v2
FEATURE_BIT=00
CONTRY_TYPE=FF
VENDOR_NAME=MitraStar Technology Corp.
run_diag=yes
ethaddr=4C:9E:FF:BF:55:FC
stdin=serial
stdout=serial
stderr=serial
console=console=ttyS0,115200 mtdparts=nand_mtd:0xc0000@0(uboot)ro,0x7f00000@0x100000(root)
mainlineLinux=no
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
ethprime=egiga0
netbsd_en=no
vxworks_en=no
bootargs_root=root=/dev/nfs rw
bootargs_end=:::DB88FXX81:eth0:none
image_name=uImage
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
lcd0_enable=0
lcd0_params=640x480-16@60
disaMvPnp=no
ethmtu=1500
mvPhoneConfig=mv_phone_config=dev[0]:fxs,dev[1]:fxo
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
usb0Mode=host
yuk_ethaddr=00:00:00:EE:51:81
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
image_multi=yes
enaAutoRecovery=yes
kernel_addr=0xc80000
pcieTune=no
pcieTune1=no
ethact=egiga0

New U-Boot env:
arcNumber=4495
baudrate=115200
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; reset
bootcmd_exec=run load_uimage; if run load_initrd; then if run load_dtb; then bootm $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootm $load_uimage_addr $load_initrd_addr; fi; else if run load_dtb; then bootm $load_uimage_addr - $load_dtb_addr; else bootm$load_uimage_addr; fi; fi
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=usb
console=console=ttyS0,115200
device=0:1
devices=usb ide
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-nsa325.dtb
ethact=egiga0
ethaddr=52:3b:20:9c:11:51
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_dtb_addr=0x1c00000
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_initrd_addr=0x1100000
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
load_uimage_addr=0x800000
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)
partition=nand0,2
preboot_nc=run if_netconsole start_netconsole
scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_ide "ide reset";  setenv scan_mmc "mmc rescan"; for dev in $devices; do if test $scan_done -eq 0; then echo Scan device $dev; run scan_$dev; for disknum in $disks; do if test $scan_done -eq 0; then echo device $dev $disknum:1; if load $dev $disknum:1 $load_uimage_addr /boot/uImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; done
serverip=192.168.0.220
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
stderr=serial
stdin=serial
stdout=serial
uenv_addr=0x810000
uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize
uenv_init_devices=setenv init_usb "usb start";  setenv init_ide "ide reset";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done;
uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices;  do for disknum in 0; do run uenv_read_disk; done; done;
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
uenv_read_disk=if test $devtype -eq mmc; then if $devtype part; then run uenv_read;  fi; else if $devtype part $disknum; then run uenv_read; fi;  fi
usb_ready_retry=15
Re: Zyxel NSA325 questions (uboot)
April 26, 2020 03:39AM
Alatun,

> I've recorded both the stock env settings and the
> settings of the 2017.07 U-Boot (see below). If I
> understood things correctly, it should be possible
> to switch back to the stock firmware by applying
> the stock U-Boot env settings. Right?

No, it will not work.

> Or are the
> different versions of U-Boot no longer compatible
> regarding the commands involved?

The difference is not in the command set or the envs. The difference betweek stock u-boot and new u-boot is structural.

The new u-boot set up its registers, memory,... etc to run a mainline kernel. Stock u-boot is set up to run this NSA325 stock kernel, a customed kernel 2.6.xx running on busybox.

-bodhi
===========================
Forum Wiki
bodhi's corner
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: