Welcome! Log In Create A New Profile

Advanced

NSA320 Broken uboot

Posted by Sudakan 
NSA320 Broken uboot
August 24, 2019 10:47AM
Hi all, my name is Leo, I'm a software engineer from Argentina.
First of all thank you for all the information provided here.

I'm here as another fellow who screwed up, all by him self, his NSA320 uboot.

First of all, my setup:
  • NSA320 without HDDs (don't wanna screw up my data, I do have an spare HDD to test tho) (had 4.70 firmware)
  • Manjaro on my laptop
  • RPI3B+ HypriotOS

I've followed the provided steps, and did not spot any errors whatsoever during the procedure. The output of the commands did match the provided outputs in the guide.

But, I think I've screwed up during the first steps, I realize that now that I'm reading the guide again after a good night sleep.

Quote

1. uBoot envs config should be defined as followed in your /etc/fw_env.config

cat /etc/fw_env.config

# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000

If I'm not mistaken, I think I life /dev/mtd1 as it was and just added /dev/mtd0, and seeing the partition table below that's probably my mistake.

After reboot, my NSA320 in a boot loop. When turning on, all LEDs are turned on for 1 second, then they stop, fan spins and then it starts again, LEDs turn on for a seconds and so on.
If I try to hold the power button, nothing happens. Only way to power it off is unplugging power.


I have hacked myself a serial cable from the NSA320 to an RPI3B+, and I've tried to use kwboot as stated (https://forum.doozan.com/read.php?3,51739,51919#msg-51919).
Although, I have never used a serial cable connection before so I'm not sure what to expect or how to debug the connection.

Quote
sudo ./kwboot -t -B 115200 /dev/ttyAMA0 -b ./uboot.2017.07.tld-1.nsa320.bodhi.tar -p -d
Segmentation Fault

I don't think my serial connection is working.
Quote
dmesg | grep ttyAMA0
[1.0837481] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 81, base_baud = 0) is a PL011 rev2

Do you guys have any documentation on how to connect the NSA320 through an RPI with serial cable? I couldn't find much info to be honest, but I'm not an expert on the subject so I'm probably using the wrong keywords.

If I'm not mistaken, now what I should do is run kwboot through serial to flash the u-boot image directly.

Thank you!!
Re: NSA320 Broken uboot
August 24, 2019 12:59PM
Ok, so I decided to install Raspbian on the RPI and try kwboot again

I have only connected RX and TX. Following this https://forum.doozan.com/read.php?3,51739,51919#msg-51919


pi@raspberrypi:~ $ sudo ./kwboot  -t -B 115200 /dev/ttyAMA0 -b ./uboot.2017.07-tld-1.nsa320.bodhi.tar
Sending boot message. Please reboot the target...

My device continues to just "restart" by itself. Is my serial connection not working? I'm not sure how to test if the hardware connection is working.

pi@raspberrypi:~ $ sudo screen /dev/ttyAMA0 115200,cs8,istrip   
# no output, nothing happens.


# adding -p throws segmentation fault
pi@raspberrypi:~ $ sudo ./kwboot  -t -B 115200 /dev/ttyAMA0 -b ./uboot.2017.07-tld-1.nsa320.bodhi.tar -p
Segmentation fault

Tried debug options
pi@raspberrypi:~ $ sudo ./kwboot  -t -B 115200 /dev/ttyAMA0 -b ./uboot.2017.07-tld-1.nsa320.bodhi.tar -d
Sending debug message. Please reboot the target...



Edited 2 time(s). Last edit at 08/24/2019 01:03PM by Sudakan.
Re: NSA320 Broken uboot
August 24, 2019 02:18PM
I think I've manged to get the serial connection to work.
Although, there's something wrong with the characters. It's like they overwrite each other.

pi@raspberrypi:~ $ sudo picocom --b 115200 --f n --p n --d 8 /dev/ttyS0
picocom v1.7

port is        : /dev/ttyS0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Terminal ready
4:   USB EHCI0sgsevu
*adc * vs3*neinndSc cubdibacub 
R EiA2rdv
H y key  tntialize on egiga0
          #ntnly0
nntap            Untby
     # i
 rt
dur. e 0lg t/oad.* b*nc8'*dvi lnm.*e

pi@raspberrypi:~ $ sudo picocom --b 115200 /dev/ttyS0
picocom v1.7

port is        : /dev/ttyS0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Terminal ready
 w 8_R 2MBR CotdNd:e1d
                      :itecs
                            N C,si u enmt
iniie e0                                 Isear:rieteg
        it anyeto stoputoic.2 B eic(dena
                                        nprn a0
                                               ##UnNAD  128 MiB
n:ur e eiaoe


Ok, so I got serial working.
For anyone troubling with RPI + Serial. You need to disable Bluetooth on the RPI, since the pins seems to be shared, or something. After doing this, I finally could get output from the NSA320 serial (https://openenergymonitor.org/forum-archive/node/12311.html)

-Boot 2017.07-tld-1 (Sep 05 2017 - 00:46:11 -0700)
ZyXEL NSA320 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
  0 any key to stop autoboot:  5 
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage dide_preinit failed
## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0
loading envs from usb 0 ...
** Bad device usb 0 **

no IDE devices available
running scan_disk ...
Scan device usb
device usb 0:1
** Bad device usb 0 **
device usb 1:1
** Bad device usb 1 **
device usb 2:1
** Bad device usb 2 **
device uide_preinit failed
device ide 0:1
** Bad device ide 0 **
device ide 1:1
** Bad device ide 1 **
device ide 2:1
** Bad device ide 2 **
device ide 3:1
** Bad device ide 3 **
loading uImage ...
** Bad device usb 0 **
loading uInitrd ...
** Bad device usb 0 **
loading DTB /boot/dts/kirkwood-nsa320.dtb ...
** Bad device usb 0 **
Unknown command 'bootm0x800000' - try 'help'
resetting ...



Edited 1 time(s). Last edit at 08/24/2019 02:25PM by Sudakan.
Re: NSA320 Broken uboot
August 24, 2019 02:27PM
Looks like u-boot is good. Make an USB root file system and try to boot it.



Edited 1 time(s). Last edit at 08/24/2019 02:33PM by daviddyer.
Re: NSA320 Broken uboot
August 24, 2019 02:37PM
Hi Leo,

For reference, here is my command I use daily on Debian:
alias myserial='picocom --b 115200 --f n --p n --d 8 /dev/ttyUSB0'


Quote

I have only connected RX and TX. Following this https://forum.doozan.com/read.php?3,51739,51919#msg-51919

You should connect GND too.

About the device, you command is suspected.
picocom --b 115200 --f n --p n --d 8 /dev/ttyS0

On rPi, people have used this (I don't have one at the moment to look at it):
picocom --b 115200 --f n --p n --d 8 /dev/ttyAMA0

But you need to look at dmesg to see which device is used. Try connect the 3 wires to the NSA320 first. And then connect the 3 wires to rPi.

UPDATE: NVM :)

Quote

Ok, so I got serial working.
For anyone troubling with RPI + Serial. You need to disable Bluetooth on the RPI, since the pins seems to be shared, or something. After doing this, I finally could get output from the NSA320 serial (https://openenergymonitor.org/forum-archive/node/12311.html)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 08/24/2019 02:38PM by bodhi.
Re: NSA320 Broken uboot
August 24, 2019 02:40PM
Hi Guys!

I did connect GND too, but my original tests did not have it connected.
So I think the serial connection is working good now.

I'm not sure how to proceed tho.

pi@raspberrypi:~ $ sudo picocom --b 115200 --f n --p n --d 8 /dev/ttyAMA0
picocom v1.7

port is        : /dev/ttyAMA0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Terminal ready


U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:46:11 -0700)
ZyXEL NSA320 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
2 USB Device(s) ide_preinit failed
## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0
loading envs from usb 0 ...
** Bad device usb 0 **

no IDE devices available
running scan_disk ...
E: ide_preinit failed
device ide 0:1
** Bad device ide 0 **
device ide 1:1
** Bad device ide 1 **
device ide 2:1
** Bad device ide 2 **
device ide 3:1
** Bad device ide 3 **
loading uImage ...
** Bad device usb 0 **
loading uInitrd ...
** Bad device usb 0 **
loading DTB /boot/dts/kirkwood-nsa320.dtb ...
** Bad device usb 0 **
Unknown command 'bootm0x800000' - try 'help'
resetting ...

Edit: I actually update the uboot or is this the stock one? sorry for the silly question, not sure how to check versions.



Edited 1 time(s). Last edit at 08/24/2019 02:43PM by Sudakan.
Re: NSA320 Broken uboot
August 24, 2019 02:43PM
Leo,

> scanning bus 0 for devices... 2 USB Device(s)
> found
>        scanning usb for storage dide_preinit

> ** Bad device usb 0 **


See the release thread. Create rootfs on USB using Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2. And you can boot it like this:

Interrupt serial console at count down,

setenv dtb_file '/boot/dts/kirkwood-nsa320.dtb'
boot

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: NSA320 Broken uboot
August 24, 2019 02:44PM
Quote

Edit: I actually update the uboot or is this the stock one? sorry for the silly question, not sure how to check versions.

You did update u-boot successfully. Try verify the envs to see if they are good.

ver
printenv

*** Warning - bad CRC, using default environment

And you did not flash the env image. So your envs need adjustment to boot the USB rootfs!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 3 time(s). Last edit at 08/24/2019 02:47PM by bodhi.
Re: NSA320 Broken uboot
August 24, 2019 02:48PM
bodhi Wrote:
-------------------------------------------------------
>
Quote

Edit: I actually update the uboot or is
> this the stock one? sorry for the silly question,
> not sure how to check versions.
>
> You did updated u-boot successfully. Try verify
> the envs to see if they are good.
>
>
> ver
> printenv
>

Cool!! will try that.
I'm having trouble typing into the serial connection not sure why yet, will investigate.

 sudo picocom --b 115200 --f n --p n --d 8 /dev/ttyAMA0
picocom v1.7

port is        : /dev/ttyAMA0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Terminal ready


U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:46:11 -0700)
ZyXEL NSA320 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot: 1 7   4 3  0 
p�����n��jfjf���

sounds like wrong charset or something to do with character encoding maybe.

I'm not sure if this is possible with my current setup, but is it possible to always boot Debian from a USB on the back, and fallback to original distro if the usb is not plugged in?

Just curious.

Thank you guys!

Quote

And you did not flash the env image. So your envs need adjustment to boot the USB rootfs!

Ok, will try to get the enviroment variables so we can see what's wrong.
Re: NSA320 Broken uboot
August 24, 2019 03:11PM
> Ok, will try to get the enviroment variables so we
> can see what's wrong.

The internal envs from u-boot has some typo that I've not got around to fix.

And since you did not flash the envs image (step 8 in u-boot installation). You will need to do something like this to populate the correct envs:

https://forum.doozan.com/read.php?3,38889,40094#msg-40094

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: NSA320 Broken uboot
August 24, 2019 03:15PM
Yep, I'm pretty sure I didn't do step 8.
Will try the scripts in the link, but I still cannot type into the serial port for whatever reason.

Do you guys see something wrong below that would prevent me from typing correctly into the serial connection?

pi@raspberrypi:~ $ sudo stty -F /dev/ttyAMA0 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

Or do you know how could I debug the connection further?
Thank you!

I've got it!

sudo picocom --b 115200 --f n --p n --d 8 /dev/ttyAMA0 --imap lfcrlf



Edited 2 time(s). Last edit at 08/24/2019 03:18PM by Sudakan.
Re: NSA320 Broken uboot
August 24, 2019 03:20PM
bodhi, thank you. Check this below:

NSA320> ver

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:46:11 -0700)
ZyXEL NSA320 2-Bay Power Media Server
gcc (Debian 6.3.0-18) 6.3.0 20170516
GNU ld (GNU Binutils for Debian) 2.28


NSA320> printenv
arcNumber=3956
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-nsa320.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

Environment size: 3016/131068 bytes

I'll wait for your confirmation before starting with the link you've provided (https://forum.doozan.com/read.php?3,38889,40094#msg-40094)
Re: NSA320 Broken uboot
August 24, 2019 05:10PM
Leo,

> I'll wait for your confirmation before starting
> with the link you've provided
> (https://forum.doozan.com/read.php?3,38889,40094#msg-40094)

It looks good enough to boot with the Debian USB or HDD rootfs. So go ahead create the rootfs Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2.

(As I've mentioned, I had some typos in the internal envs. But that does not affect booting Debian)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: NSA320 Broken uboot
August 24, 2019 05:11PM
It's booting Debian after following the steps you mentioned bodhi, thank you very much, I think I've got it!
Re: NSA320 Broken uboot
August 24, 2019 05:34PM
Sudakan Wrote:
-------------------------------------------------------
> It's booting Debian after following the steps you
> mentioned bodhi, thank you very much, I think I've
> got it!

Awesome!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: NSA320 Broken uboot
August 24, 2019 05:52PM
For my records, and anyone else's

To use the serial with Raspbian Buster Lite

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

Disable bluetooth https://openenergymonitor.org/forum-archive/node/12311.html

sudo stty -F /dev/ttyAMA0 onlcr
sudo stty -F /dev/ttyAMA0 115200 cs8
sudo picocom --b 115200 --f n --p n --d 8 /dev/ttyAMA0 --imap lfcrlf


Thank you very much!
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: