Welcome! Log In Create A New Profile

Advanced

Zyxel NSA325v2 - bumpy road to Debian

Posted by shiva 
Zyxel NSA325v2 - bumpy road to Debian
August 03, 2017 03:27PM
Hi all,

After much thought and some tests on the default NSA325v2 firmware I decided to flash bodhi's latest U-Boot and debian version on it. The end result should be an ownCloud instance on a Debian USB stick, having all files stored on RAID 1 SATA drives. Nothing more.

I did flash the new U-Boot but missed to flash the U-Boot env. Luckily I am not the only one screwing the U-boot env params up.

So I created an ext-3 rootfs on a 32Gb USB stick and placed the latest debian 4.12.1 on it, including uImage with the proper dbt embedded. I also added an uEnv.txt file in /boot inspired from the one in uboot.2016.05.tld-1.environment.bodhi.tar (see attached)

During boot the kernel panics:
[    6.017072] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    6.024628] Please append a correct "root=" boot option; here are the available partitions:
6.033061] 1f00            1024 mtdblock0 
[    6.033065]  (driver?)
[    6.039660] 1f01             512 mtdblock1 
[    6.039664]  (driver?)
[    6.046229] 1f02             512 mtdblock2 
[    6.046232]  (driver?)
[    6.052814] 1f03             512 mtdblock3 
[    6.052817]  (driver?)
[    6.059406] usb 1-1: new high-speed USB device number 2 using orion-ehci
[    6.066230] 1f04           10240 mtdblock4 
[    6.066234]  (driver?)
[    6.072818] 1f05           10240 mtdblock5 
[    6.072822]  (driver?)
[    6.079416] 1f06           48896 mtdblock6 
[    6.079420]  (driver?)
[    6.085984] 1f07           10240 mtdblock7 
[    6.085987]  (driver?)
[    6.092568] 1f08           48896 mtdblock8 
[    6.092571]  (driver?)
[    6.099156] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    6.107453] CPU: 0 PID: 1 Comm: swapper Not tainted 4.12.1-kirkwood-tld-1 #1

I've been changing some of the env settings but to no avail (attached is the full log of the last 3 trials). Last one was:
NSA325> run bootcmd_uenv
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found

Partition Map for USB device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            61169728        00056e13-01     83 Boot
loading envs from usb 0 ...
2781 bytes read in 301 ms (8.8 KiB/s)
importing envs ...
## Warning: Input data exceeds 1048576 bytes - truncated
## Info: input data size = 1048578 = 0x100002
NSA325> setenv arcNumber 4495
NSA325> setenv machid
NSA325> setenv rootfstype
NSA325> setenv usb_root "LABEL=rootfs"
NSA325> setenv mtdparts "mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)"
NSA325> setenv partition "nand0,2"
NSA325> setenv 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"
NSA325> setenv set_bootargs "setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params"
NSA325> boot
I must mention that I have no SATA drive connected. I removed them (2 1Tb Seagates) until I will have a working debian on the device.

Now the most weirdness part: yesterday, printenv command in U-Boot displayed:
printenv
arcNumber=4495
baudrate=115200
bootcmd=run bootcmd_uenv; run bootcmd_usb; usb stop; run bootcmd_sata; reset
bootcmd_sata=run sata_init; run set_bootargs_sata; run sata_boot
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootcmd_usb=run usb_init; run set_bootargs_usb; run usb_boot
bootdelay=10
console=ttyS0,115200
device=0:1
ethact=egiga0
ethaddr=b6:d0:5e:0f:a1:17
led_error=orange blinking
led_exit=green off
led_init=green blinking
machid=118f
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
rootdelay=10
rootfstype=ext2
sata_boot=mw 0x800000 0 1; run sata_load_uimage; if run sata_load_uinitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
sata_init=ide reset
sata_load_uimage=ext2load ide $device 0x800000 /boot/uImage
sata_load_uinitrd=ext2load ide $device 0x1100000 /boot/uInitrd
sata_root=/dev/sda1
set_bootargs_sata=setenv bootargs console=$console root=$sata_root rootdelay=$rootdelay rootfstype=$rootfstype $mtdparts
set_bootargs_usb=setenv bootargs console=$console root=$usb_root rootdelay=$rootdelay rootfstype=$rootfstype $mtdparts
stderr=serial
stdin=serial
stdout=serial
uenv_import=echo importing envs ...; env import -t 0x810000
uenv_load=usb start; setenv uenv_loaded 0; for devtype in usb; 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 0x810000 /boot/uEnv.txt; then setenv uenv_loaded 1; fi
uenv_read_disk=if $devtype part $disknum; then run uenv_read; fi
usb_boot=mw 0x800000 0 1; run usb_load_uimage; if run usb_load_uinitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
usb_init=usb start
usb_load_uimage=ext2load usb $device 0x800000 /boot/uImage
usb_load_uinitrd=ext2load usb $device 0x1100000 /boot/uInitrd
usb_root=/dev/sda1

but today it just prints the attached image and never stops. I have to cut power down to the NAS.

Which is another thing that rubs me the wrong way: is there any other way of forcing the device to reboot/reset when using the serial connection except for this hard power-off? Yesterday the kernel failed to boot but it also did not return to U-Boot console and I had no way of reseting it except for plugging out the cord.
Attachments:
open | download - uEnv.txt (2.7 KB)
open | download - console_log_2017.08.03.txt (55.1 KB)
open | download - Screenshot_20170804_001115.png (5.4 KB)
Re: Zyxel NSA325v2 - bumpy road to Debian
August 03, 2017 04:15PM
shiva,

There is a couple of setup problems in your system right now.

1. The rootfs has DTB embbeded inside uImage. It should not.

Quote

So I created an ext-3 rootfs on a 32Gb USB stick and placed the latest debian 4.12.1 on it, including uImage with the proper dbt embedded. I also added an uEnv.txt file in /boot inspired from the one in uboot.2016.05.tld-1.environment.bodhi.tar (see attached)

2. The envs are not quite OK.

Quote

but today it just prints the attached image and never stops. I have to cut power down to the NAS.


Solution:

1. Your rootfs should not have the DTB embbeded in uImage. So reverse that. Moun the drive on other Linux box and resore original uImage. Assuming it is mounted at /media/sdb1:

cd /media/sdb1/boot
mv uImage uImage.nsa325.with.fdt
cp -a uImage.orig uImage
sync

Now the rootfs is ready for step 2.

2. To restore the env to a good state, do this extra step.

http://forum.doozan.com/read.php?3,29362,29390#msg-29390

Afer you have run the script uboot.2016.05-tld-1.environment.scr in that post. Your envs will be reversed to the pristine default state.

And then you can run your own settings adjustment in doing this.
run bootcmd_uenv

And then you can boot.

-bodhi
===========================
Wiki
latest Kirkwood kernel builds and rootfs
latest u-boot-kirkwood builds
latest Oxnas kernel builds and rootfs
latest u-boot-oxnas builds
latest MVEBU Armada kernel builds and rootfs
U-Boot & Kernel Booting process
bodhi's u-boot GitHub
bodhi's corner
Re: Zyxel NSA325v2 - bumpy road to Debian
August 27, 2017 11:53AM
Hi Bodhi,

So I did steps #1 and #2 and I was able to log into Debian. Such relief!!!

To persist the env settings I did the following steps:
  1. rebooted the device
  2. loaded again the settings from uboot.2016.05-tld-1.environment.scr
  3. I've set the devices, ethaddr, dtb_file, arcNumber, machid (removed), ipaddr, serverip
  4.   NSA325> saveenv  Saving Environment to NAND...  Erasing NAND...  Erasing at 0xc0000 -- 100% complete.  Writing to NAND... OK  NSA325> reset  

After this, debian booted just fine.

I do have a couple of questions for the next stage of my project:
  • 'disks' u-boot env. setting - I've read that it specifies the number of partitions - partitions from USB stick, USB stick + all SATA disks?
  • sata drives in RAID1 with luks encryption - is it possible? does it affect performance badly?
  • does NSA325v2 have hardware RAID (the SATA connectors are on an extension board plugged into the main board)
  • will the sata drives always spin? Do I need to configure anything in Debian for them to spin down when not used?
  • Does the 'copy to USB3' still work? Or it must be configured? Can I use the copy and shutdown instructions from 'NSA 325 v2 Debian Is Possible' thread
  • I see ssh service is started so I could access the device through ssh. Is netconsole also available? Can it be disabled or secured?
  • Are there any things to watch out for when securing the ARM-based Debian?

Thank you.



Edited 2 time(s). Last edit at 08/27/2017 12:29PM by shiva.
Re: Zyxel NSA325v2 - bumpy road to Debian
August 27, 2017 04:44PM
shiva,

> [*] 'disks' u-boot env. setting - I've read that i
> t specifies the number of partitions - partitions
> from USB stick, USB stick + all SATA disks?

Set disks to the total number of disks that you expect to be in your system. Not number of partitions. The convention is: your kernel files in /boot/* must be in the /boot of the 1st partition of a disk. That 1st partition usually is the rootfs. However, you could put the rootfs on any partition (in case you need to have 2 partitions such as for f2fs, btrfs). The label rootfs tell the kernel where the rootfs is.


> [*] will the sata drives always spin? Do I need to
> configure anything in Debian for them to spin down
> when not used?

The only way for a SATA disk to sleep is if it is not the system drive (i.e. the rootfs in on USB). So if you want the SATA disk to sleep, then your system should be on USB.

> [*] Does the 'copy to USB3' still work?

You need to use the key daemon to use the buttons:
http://forum.doozan.com/read.php?2,32460,32467#msg-32467

> [*] I see ssh service is started so I could access
> the device through ssh. Is netconsole also availab
> le? Can it be disabled or secured?

Netconsole is not runing until you explicitly set it up. So if you have not done that then it was disabled.

-bodhi
===========================
Wiki
latest Kirkwood kernel builds and rootfs
latest u-boot-kirkwood builds
latest Oxnas kernel builds and rootfs
latest u-boot-oxnas builds
latest MVEBU Armada kernel builds and rootfs
U-Boot & Kernel Booting process
bodhi's u-boot GitHub
bodhi's corner



Edited 1 time(s). Last edit at 08/27/2017 11:49PM by bodhi.
Re: Zyxel NSA325v2 - bumpy road to Debian
August 28, 2017 08:37AM
Hi bodhi,

So disks env. param for me would be 3 - the usb stick + 2 SATA hdds

rootfs is on the USB stick however I want to setup nextCloud on it which requires a sql database and website pages (adn data). If I place the db and the nextcloud data files on the SATA drives - will they spin down when no request is made to the website?

I think netconsole is activated in u-boot params.
Re: Zyxel NSA325v2 - bumpy road to Debian
August 28, 2017 04:06PM
shiva Wrote:
-------------------------------------------------------
> Hi bodhi,
>
> So disks env. param for me would be 3 - the usb st
> ick + 2 SATA hdds
>

You could use a larger number such as 8, it does not hurt or slow down the booting. As soon as scandisk found the system drive, the scanning will stop.

> rootfs is on the USB stick however I want to setup
> nextCloud on it which requires a sql database and
> website pages (adn data). If I place the db and th
> e nextcloud data files on the SATA drives - will t
> hey spin down when no request is made to the websi
> te?

If nextCloud does not perform any background disk access, then yes.

See here for spindown instruction:

http://forum.doozan.com/read.php?2,24943,24944#msg-24944

>
> I think netconsole is activated in u-boot params.

Please post the latest serial console bootlog and the u-boot envs here and I will verify if it is active or not, also make adjustment to turn it off.

-bodhi
===========================
Wiki
latest Kirkwood kernel builds and rootfs
latest u-boot-kirkwood builds
latest Oxnas kernel builds and rootfs
latest u-boot-oxnas builds
latest MVEBU Armada kernel builds and rootfs
U-Boot & Kernel Booting process
bodhi's u-boot GitHub
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: