Welcome! Log In Create A New Profile

Advanced

Having trouble with an NSA310S, freezing after loading kernel

Posted by gargravarr 
Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 06:54AM
Hey folks,

First, just wanted to say, thanks to everyone who put all this effort into Debian-ising these devices, some fantastic resources here!

I have a ZyXEL NSA310S. I'm fed up with its limitations and want to completely replace the OS with Debian. I'm an experienced Linux user and live behind a bash prompt so I'm not scared :)

I have a USB-TTL adapter hooked up to the serial header and an Ubuntu computer available. I've followed bodhi's instructions in this thread: https://forum.doozan.com/read.php?2,12096 for 5.2.9. I have functioning USB and can load the necessary files into memory. However, when I try to bootm, u-boot freezes after attempting to start the kernel:

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

And I then have to hard-reset the device. It does this with both bodhi's 5.2.9 kernel and my attempt to debootstrap Debian Buster on 4.19. The U-Boot commands I'm using are:

usb start
setenv bootargs console=ttyS0,115200 root=/dev/sda1 usb-storage.delay_use=0 rootdelay=1 rw
ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-nsa310s.dtb
ext2load usb 0:1 0x1100000 /boot/uInitrd
ext2load usb 0:1 0x800000 /boot/uImage
bootm 0x800000 0x1100000 0x1c00000

The NSA was running the latest available firmware (4.75) before I started this. U-Boot version is
U-Boot 1.1.4 (May 28 2013 - 16:07:08) Marvell version: 3.6.0
. I investigated updating the version of U-Boot based on https://forum.doozan.com/read.php?3,12381 where I noticed the step to check for bad blocks:

/ # dmesg | grep -i bad
Scanning device for bad blocks
Bad eraseblock 452 at 0x000003880000
Bad eraseblock 504 at 0x000003f00000

I'm not sure if this is in the first 1M but it seems significant. Other data pertaining to my NAS:

/ # cat /etc/fw_env.config
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundand
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
# NAND example
/dev/mtd1               0x0000          0x20000         0x20000                 4

/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "uboot"
mtd1: 00080000 00020000 "uboot_env"
mtd2: 00080000 00020000 "key_store"
mtd3: 00080000 00020000 "info"
mtd4: 00a00000 00020000 "etc"
mtd5: 00a00000 00020000 "kernel_1"
mtd6: 02fc0000 00020000 "rootfs1"
mtd7: 00a00000 00020000 "kernel_2"
mtd8: 02fc0000 00020000 "rootfs2"

Marvell>> printenv
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=AD03
PRODUCT_NAME=STG-315
FEATURE_BIT=00
CONTRY_TYPE=FF
VENDOR_NAME=MitraStar Technology Corp.
run_diag=yes
ethaddr=28:28:5D:1F:2D:42
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;
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=0x4640000
pcieTune=no
ethact=egiga0

Can anyone point me in the right direction please? Many thanks.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 04:10PM
Either upgrade the uboot or append the dtb to the kernel.

If you have no plan to go back to stock, upgrading the uboot is the better option. Details and downloads here;

uBoot for Kirkwood boxes



Edited 1 time(s). Last edit at 05/05/2020 04:12PM by jdwl101.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 04:13PM
jdwl101 Wrote:
-------------------------------------------------------
> Either upgrade the uboot or append the dtb to the
> kernel.
>
> If you have no plan to go back to stock, upgrading
> the uboot is the better option. Details and
> downloads here;
>
> uBoot
> for Kirkwood boxes



I already appended the DTB to the kernel as in bodhi's instructions. I'm not confident in upgrading u-boot due to the aforementioned bad blocks.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 04:16PM
Ok, if the dtb is appended you don't need to load it in the boot process.

Please post a full boot log up until the point it freezes, with some more details we may be able to identify where it's going wrong.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 04:38PM
gargravarr,


> / # dmesg | grep -i bad
> Scanning device for bad blocks
> Bad eraseblock 452 at 0x000003880000
> Bad eraseblock 504 at 0x000003f00000

These are OK. The first 1M is block 0-7.

Even though you have serial console, it is still much easier to install from stock OS. It is the hard way (to install from serial console).

Can you log in to stock OS?

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



Edited 1 time(s). Last edit at 05/05/2020 04:39PM by bodhi.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 04:42PM
bodhi Wrote:
-------------------------------------------------------
> gargravarr,
>
>
> > / # dmesg | grep -i bad
> > Scanning device for bad blocks
> > Bad eraseblock 452 at 0x000003880000
> > Bad eraseblock 504 at 0x000003f00000
>
> These are OK. The first 1M is block 0-7.
>
> Even though you have serial console, it is still
> much easier to install from stock OS. It is the
> hard way (to install from serial console).
>
> Can you log in to stock OS?


Thanks, that's good to hear. Yes, I have the stock OS still bootable - the snippets from the OS in my original post were made after the ones from u-boot.

The guides I've read don't seem to make much of the stock OS though, there's very few tools available.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 05, 2020 04:50PM
gargravarr,

> Thanks, that's good to hear. Yes, I have the stock
> OS still bootable - the snippets from the OS in my
> original post were made after the ones from
> u-boot.

Then it is easy. Log into stock.

Summary:

1. Create the USB rootfs Debian-5.2.9-kirkwood-tld-1-rootfs-bodhi.tar.bz2 (you did). Don't do step 4 at all, keep the uImage as original. Plug this in the the box (if it was created using another Linux box)

2. Install new u-boot from the tarball uboot.2017.07-tld-1.nsa310s.bodhi.tar

https://forum.doozan.com/read.php?3,12381

And reboot.

So look at the u-boot installation over, and post questions if you are not sure about something.

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



Edited 1 time(s). Last edit at 05/05/2020 04:51PM by bodhi.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 05:01AM
bodhi Wrote:
-------------------------------------------------------
> gargravarr,
>
> > Thanks, that's good to hear. Yes, I have the
> stock
> > OS still bootable - the snippets from the OS in
> my
> > original post were made after the ones from
> > u-boot.
>
> Then it is easy. Log into stock.
>
> Summary:
>
> 1. Create the USB rootfs
> Debian-5.2.9-kirkwood-tld-1-rootfs-bodhi.tar.bz2
> (you did). Don't do step 4 at all, keep the uImage
> as original. Plug this in the the box (if it was
> created using another Linux box)
>
> 2. Install new u-boot from the tarball
> uboot.2017.07-tld-1.nsa310s.bodhi.tar
>
> https://forum.doozan.com/read.php?3,12381
>
> And reboot.
>
> So look at the u-boot installation over, and post
> questions if you are not sure about something.


Okay, so I tried to follow the instructions, but I discovered I don't have `flash_erase`, only `flash_eraseall` - I'm very hesitant to poke at this in case it does exactly what it says it does! There is no `flash_erase` on the filesystem.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 05:24AM
Quote

A. Flashing Instruction:


Installation is the same for each u-Boot image, the instruction below is written to include all boxes. So choose the platform name that you are installing for, and copy/paste the appropriate commands.

If you are running kernel that do not provide mtd-utils and uboot-tools (fw_setenv, fw_printenv, flash_erase, nandwrite), you can download the NAND and U-Boot tools binaries here in this thread.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 05:28AM
bodhi Wrote:
-------------------------------------------------------
>
Quote

A. Flashing Instruction:
>
>
> Installation is the same for each u-Boot image,
> the instruction below is written to include all
> boxes. So choose the platform name that you are
> installing for, and copy/paste the appropriate
> commands.
>
> If you are running kernel that do not provide
> mtd-utils and uboot-tools (fw_setenv, fw_printenv,
> flash_erase, nandwrite), you can download the NAND
> and U-Boot tools binaries here in this
> thread.


Whoops, my bad. Trying that now.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 05:34AM
/ # /e-data/52be4d76-9754-4d4e-bcee-7228b6f8015d/tmp/tools/flash_erase /dev/mtd0
 0 4
Erasing 128 Kibyte @ 60000 -- 100 % complete

nandwrite /dev/mtd0 /e-data/52be4d76-9754-4d4e-bcee-7228b6f8015d/tmp/uboot.2
017.07-tld-1.nsa310s.mtd0.kwb 
Writing data to block 0
Writing data to block 20000
Writing data to block 40000
Writing data to block 60000

Slightly different output from the thread, but it seems to have been successful. Also, the NSA310S seems to store its environment variables in a separate partition, so no messing around with offsets needed. Here goes...
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 06:18AM
It worked!

U-Boot updated successfully and I'm now able to boot 5.2.9! Many thanks for your help bodhi, I'll get to work on writing the OS to flash next.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 03:56PM
gargravarr,

Don't reboot yet.

Quote

Slightly different output from the thread, but it seems to have been successful. Also, the NSA310S seems to store its environment variables in a separate partition, so no messing around with offsets needed. Here goes...

You need to do step 8 and the rest. The stock envs are not relevant in the new u-boot.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 05:06PM
bodhi Wrote:
-------------------------------------------------------
> gargravarr,
>
> Don't reboot yet.
>
>
Quote

Slightly different output from the thread,
> but it seems to have been successful. Also, the
> NSA310S seems to store its environment variables
> in a separate partition, so no messing around with
> offsets needed. Here goes...
>
> You need to do step 8 and the rest. The stock envs
> are not relevant in the new u-boot.

Whoops.

On the plus side, the stock environment variables didn't break anything (although I do see a warning about the CRC failing, so I guess step 8 fixes that). I was also able to flash my plain Debian kernel and ramdisk to the NAND and it boots correctly. Guess I just need to flush out and reset the environment variables and it should be perfect.
Re: Having trouble with an NSA310S, freezing after loading kernel
May 06, 2020 10:37PM
gargravarr Wrote:
-------------------------------------------------------
> bodhi Wrote:
> -------------------------------------------------------
> > gargravarr,
> >
> > Don't reboot yet.
> >
> >
Quote

Slightly different output from the
> thread,
> > but it seems to have been successful. Also, the
> > NSA310S seems to store its environment
> variables
> > in a separate partition, so no messing around
> with
> > offsets needed. Here goes...
> >
> > You need to do step 8 and the rest. The stock
> envs
> > are not relevant in the new u-boot.
>
> Whoops.
>
> On the plus side, the stock environment variables
> didn't break anything (although I do see a warning
> about the CRC failing, so I guess step 8 fixes
> that).

The new u-boot does not use or touch stock envs.


> I was also able to flash my plain Debian
> kernel and ramdisk to the NAND and it boots
> correctly. Guess I just need to flush out and
> reset the environment variables and it should be
> perfect.

Sounds good.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Having trouble with an NSA310S, freezing after loading kernel
May 07, 2020 03:19AM
Hmm, so I read the requirements:

Quote

r1. There must be only one partition among all partitions from all drives that contains the kernel files. The 2 kernel files are /boot/uImage and /boot/uInitrd.
r2. The partition that contains the 2 kernel files must be partition 1 in a disk drive
r3. The partition that contains the rootfs must be labeled rootfs
r4. The rootfs partition is recommended to be type Ext3 (this is not a hard requirement, ext4 should boot OK, but Ext3 will ensure no problem).

The NAND on this NSA310S is split into 9 partitions:

[   18.944010] Creating 9 MTD partitions on "orion_nand":
[   18.965905] 0x000000000000-0x000000100000 : "uboot"
[   18.980137] 0x000000100000-0x000000180000 : "uboot_env"
[   18.997455] 0x000000180000-0x000000200000 : "key_store"
[   19.017520] 0x000000200000-0x000000280000 : "info"
[   19.041946] 0x000000280000-0x000000c80000 : "etc"
[   19.056260] 0x000000c80000-0x000001680000 : "kernel_1"
[   19.075145] 0x000001680000-0x000004640000 : "rootfs1"
[   19.102567] 0x000004640000-0x000005040000 : "kernel_2"
[   19.118613] 0x000005040000-0x000008000000 : "rootfs2

My guess is that the *2 partitions are the previous versions for safe upgrades. As the NAS boots correctly, is it going to break things if I start modifying the default environment?
Re: Having trouble with an NSA310S, freezing after loading kernel
May 07, 2020 04:41AM
gargravarr,

>
Quote

r1. There must be only one partition
> among all partitions from all drives that contains
> the kernel files. The 2 kernel files are
> /boot/uImage and /boot/uInitrd.
> r2. The partition that contains the 2 kernel files
> must be partition 1 in a disk drive
> r3. The partition that contains the rootfs must be
> labeled rootfs
> r4. The rootfs partition is recommended to be type
> Ext3 (this is not a hard requirement, ext4 should
> boot OK, but Ext3 will ensure no problem).

The above describe what the rnew ootfs on USB should looks like. What partitions should be on the USB rootfs.


> The NAND on this NSA310S is split into 9
> partitions:

NAND partitions are where the stock u-boot, stock kernel, and stock rootfs. So ignore what's in NAND. The mtd0 is correct for new u-boot installation.


[   18.965905] 0x000000000000-0x000000100000 : "uboot"

-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: