2023.04 U-Boot Kirkwood - ZyXEL NSA325
May 26, 2023 09:22PM
In addition to the capabilties provided by u-boot 2017.07-tld-1 for NSA325 , this 2023.04-tld-1 NSA325 u-boot has the following new capabilties:

- Supports for USB 3.0. You can now boot with the rootfs attached to the USB 3.0 port in front.
- Netconsole enhancement. (See Note C.1.2).
- Distro boot (see Note C.2 after the Installation Steps for usage).

=============================================

Update 01 July 2023: Fixed netconsole
Update 26 May 2023

Download at Dropbox

uboot.2023.04-tld-1.nsa325.bodhi.tar
md5sum
15ef315acc142d4704fd4b8eec18b6be
sha256sum
f0eebe427f509179a6fd7c0a5a017180b0c2cdec13f5d71fb27fcf95246cca2b

As always, please verify the hash of what you've downloaded!

This tarball includes 4 files
uboot.2023.04-tld-1.nsa325.kwb
uboot.2023.04-tld-1.nsa325.environment.img
uboot.2023.04-tld-1.nsa325.environment
uboot.2023.04-tld-1.nsa325.boot.scr

A. Preparation

A.1. UART booting

It is strongly recommmended that you try to run kwboot to test this boot image with UART booting before flashing to NAND. This is the rescue path when and if the flashing goes wrong for some reason. See example here. And to download latest ARM kwboot binary for UART booting see here.

A.2. Flashing tools

If you are running an OS (eg. stock FW) that does 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.


B. Flashing Instruction:

1. Setup fw_env.config

U-Boot 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 you don't have /etc/fw_env.config file in your system then go ahead and create this file:

echo "/dev/mtd0 0xc0000 0x20000 0x20000" > /etc/fw_env.config

- And your mtd partitions should be:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "uboot"
mtd1: 00080000 00020000 "stock_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"

2. Backup mtd0 and envs

Save your current uBoot image and envs image in mtd0, and save your current u-boot envs with fw_printenv.

2.1 Dumping NAND mtd0:
nanddump --noecc --omitoob -l 0x80000 -f mtd0.nsa325 /dev/mtd0
nanddump --noecc --omitoob -f mtd0.nsa325.envs -s 786432 -l 131072 /dev/mtd0
If installing from stock u-boot, also save stock envs
nanddump --noecc --omitoob -f mtd0.nsa325.envs.stock /dev/mtd1

2.2. Save envs:
fw_printenv > current_envs.txt
For most stock OS, there is no fw_printenv. So it's OK if this step fails.

Copy these files to a persistent storage.

3. Check for bad blocks

Be sure there is no bad block in the first 1M of your NAND. This is very important, if there is bad block in the first 1M (blocks 0 to 7), don't flash u-boot, because you will almost certainly soft-brick your box.

Example of bad block in mtd0:
dmesg | grep -i 'bad'

[    2.413231] Scanning device for bad blocks
[    2.417731] Bad eraseblock 3 at 0x000000060000

This bad eraseblock 3 is the 4th block which resides within mtd0 first 1M (block 0 to block 7). Please stop at this step and post question in this thread for a workaround.

4. Extract the archive to /tmp

cd /tmp
tar xf uboot.2023.04-tld-1.nsa325.bodhi.tar

5. Flash u-boot image to NAND

Be extra careful with the next 2 commands, you should see output that look like below in those steps. If there is error, then do not reboot, post your problem here so we can help.

Erase 4 blocks
flash_erase /dev/mtd0 0 4
Expected output:
Erase Total 4 Units 
Performing Flash Erase of length 131072 at offset 0x60000 done

Write the image
nandwrite /dev/mtd0 /tmp/uboot.2023.04-tld-1.nsa325.kwb
Expected output:
Writing data to block 0 at offset 0x0 
Writing data to block 1 at offset 0x20000 
Writing data to block 2 at offset 0x40000 
Writing data to block 3 at offset 0x60000

6. Flash default u-boot envs image

If you are upgrading from 2017.07-tld-1 u-boot, you can skip this step. But some envs will need to be updated before reboot. See Note section below after the installation steps. Especially if your rootfs is SATA, then you must adjust the env described in Note section "C.1.1 SATA boot envs". Or if you are using netconsole then you must adjust the env described in Note section "C.1.2 Netconsole envs".

Be extra careful with the next 2 commands, you should see output that look like below. If there is error, then do not reboot, post your problem here so we can help.

Erase 1 block
flash_erase /dev/mtd0 0xc0000 1
Expected output:
Erase Total 1 Units
Performing Flash Erase of length 131072 at offset 0xc0000 done

Write the image
nandwrite -s 786432 /dev/mtd0 /tmp/uboot.2023.04-tld-1.nsa325.environment.img
Expected output:
Writing data to block 6 at offset 0xc0000

7. Restore MAC address

Modify the following u-boot variable using fw_setenv:

Restore the MAC address using the saved envs in current_envs.txt. Or find the MAC address on the sticker outside the case. Replace xx:xx:xx:xx:xx:xx with the real values.

fw_setenv ethaddr 'xx:xx:xx:xx:xx:xx'
For sanity check, list you envs again
fw_printenv

Don't reboot if there is error while listing U-Boot envs.

8. (Optional) Activate netconsole

Skip this step if you already have serial console connected. Netconsole can be set up anytime later.

Adjust 192.168.0.xxx and 192.168.0.yyy below to the real numbers in your network configuration. 192.168.0.xxx is this pogoplug static IP address, and 192.168.0.yyy is the IP address of the netconsole server where it will monitor the output from this pogoplug. The ipaddr can be any unique address that you want to use. serverip is IP address of the netconsole server, so usually a Linux box in your network.

fw_setenv preboot  'run preboot_nc'
fw_setenv ipaddr   '192.168.0.xxx'
fw_setenv serverip '192.168.0.yyy'

9. Reboot

Upon reboot, in either serial console or netconsole, U-Boot banner should show:

U-Boot 2023.04-tld-1 (Jun 24 .......)
ZyXEL NSA325 2-Bay Power Media Server

DONE installation.


C. Note

C.1. Envs changes from 2017.07-tld-1 u-to 2023.04-tld-1 u-boot.

As mentioned in Step 6, if you are upgrading from 2017.07-tld-1 u-boot then this is a u-boot drop in replacement (no need to flash new default envs image). However there are changes in envs for 2023.04-tld-1 that need to be retrofitted if you have chosen not flashing the default envs in Step 6.

C.1.1 SATA boot envs

In this new u-boot, the SATA device was changed from "ide" to "sata", and also the command to start it. So if SATA is the boot drive, you must adjust these envs.

fw_setenv devices 'sata usb'
fw_setenv init_sata 'sata init'
fw_setenv scan_disk 'echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_sata "sata init";  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'
fw_setenv uenv_init_devices 'echo Initializing devices...; setenv init_usb "usb start";  setenv init_sata "sata init";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done'

C.1.2 Netconsole envs

Both serial console and netconsole input and output are now muxed to one console.

So in this new u-boot, the stdin/stdout/stderr netconsole was change from "serial" to "serial,nc". Therefore, if netconsole is used, you must adjust the start_netconsole env.
fw_setenv start_netconsole 'setenv ncip $serverip; setenv bootdelay 10; setenv stdin serial,nc; setenv stdout serial,nc; setenv stderr serial,nc; version'


C.2. Distro Boot

C.2.1 (Optional) Booting all distros

In this new u-boot, I've implemented the Distro Boot capability. So any distro (such as Ubuntu, Alpine, Fedora, etc.) can be booted as long as they conform to the Distro Boot standard. However, for the purpose of booting our Debian Kirkwood kernel released here for this box, it is not relevant and should be ignored.

C.2.2 Using boot.scr to recover from damaged or corrupted envs NAND block

Included in the tarball uboot.2023.04-tld-1.nsa325.bodhi.tar is the script file uboot.2023.04-tld-1.nsa325.boot.scr. This is a Distro-Boot-compliant boot script. It can be used to recover from a damaged/corrupted envs NAND block, or if the envs NAND block has never been flashed (same as corrupted).

So for whatever reason, if in serial console, U-Boot reported the CRC error while loading the envs, using the boot.scr will provide a minimalist booting envs and enable booting into Debian. And then the default envs image can be flashed.

- Mount the USB rootfs on another Linux box. Assuming it is mounted at /media/sdb1.

cd /media/sdb1/boot
cp -a uboot.2023.04-tld-1.nsa325.boot.scr boot.scr
sync

- Unmount and then bring it back to the NSA325. Power up and let it boot automatically. The boot.scr should come into play, and allow booting to Debian.


C.3. uEnv.txt

This capabilty is the same as in previously released u-boot-2017.07-tld-1.

Description TBD.

END of NOTE.

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



Edited 4 time(s). Last edit at 07/08/2023 12:06AM by bodhi.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
June 09, 2023 11:30PM
1st post updated:

Quote

8. (Optional) Activate netconsole

Please do not activate netconsole! I'm troubleshooting a problem, stay tune... .

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
July 01, 2023 03:34PM
I've uploaded a new version:

Quote

Update 01 July 2023: Fixed netconsole

If you've already installed May 26 version, then you only need to flash the new u-boot image as described in step 5:

Quote

5. Flash u-boot image to NAND

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
September 03, 2023 04:09AM
Hi bodhi,

Thank you for your hard work and keeping those devices alive. Where could I find the source code for this updated u-boot? I would like to adapt my u-boot (for Freecom Silverstore HNCN2) so it could boot from the USB 3.0.

Thank you

---------------------------------


Regards,
garagoyun
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
September 03, 2023 02:34PM
garagoyun,

I've sent in the patch to mainline this NSA325 u-boot. It went through review and will be in the mainline tree soon. I also did the same for the Pogo V4 (sometime last year).

The difference between the mainline version of Kirkwood u-boots and my downstream versions here are minor. Some minor changes are not suitable for mainline so I carry the patches here.

And I have not got around to push the Kirkwood 2023.04-tld-1 branch to GitHub yet. But I will upload the rest of the binaries to Dropbox (one by one after I done some tests for each).

So for the Freecom Silverstore HNCN2, you could wait for the u-boot release candidate 2023.10-rc4 and use that version to clone the NSA325 and start from there.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
September 03, 2023 03:40PM
bodhi,

Great! Thank you very much!

---------------------------------


Regards,
garagoyun
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
September 04, 2023 01:19PM
> So for the Freecom Silverstore HNCN2, you could
> wait for the u-boot release candidate 2023.10-rc4
> and use that version to clone the NSA325 and start
> from there.

Actually, I think Oct 2nd (when u-boot 2023.10 wil be released) is a better time to look for the board.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
September 04, 2023 01:46PM
Quote

Actually, I think Oct 2nd (when u-boot 2023.10 wil be released) is a better time to look for the board.

No problems. I am overloaded with work at the moment anyway. I usually have free time towards the end of the year.

Thanks!

---------------------------------


Regards,
garagoyun
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 01:58PM
hi,
1. got only 4 partitions:
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000
root@debian:/boot# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00400000 00020000 "uImage"
mtd2: 02000000 00020000 "rootfs"
mtd3: 05b00000 00020000 "data"

2. Bad blocks are:
root@debian:/boot/nand_backup# dmesg | grep -i 'bad'
[ 8.632478] Scanning device for bad blocks
[ 8.642563] Bad eraseblock 100 at 0x000000c80000
[ 8.653102] Bad eraseblock 200 at 0x000001900000
[ 281.253499] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[ 281.278377] sd 0:0:0:0: [sda] Start/Stop Unit failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK

May i proceeed from your rootfs USB as boot/target system with ssd and hdd still does noe treplay on SSH, installed ACPI and get orange flasing led...
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 02:28PM
zebe,

Quote

1. got only 4 partitions:
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000
root@debian:/boot# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00400000 00020000 "uImage"
mtd2: 02000000 00020000 "rootfs"
mtd3: 05b00000 00020000 "data"

That was because during installation for the u-boot 2017.07-tld-1, you did not adjust your mtdparts as instructed:

Quote
https://forum.doozan.com/read.php?3,12381
e.2 Box specific envs:

Then for all boxes, restore these 2 envs using the saved envs text in step c (replace xxx with the real saved values)
fw_setenv mtdparts 'xxxxxxxxx'
fw_setenv ethaddr 'xx:xx:xx:xx:xx:xx'

But it is OK. After you install this u-boot 2023.04-tld-1, it will be corrected automatically in the envs.

Quote

2. Bad blocks are:
root@debian:/boot/nand_backup# dmesg | grep -i 'bad'
[    8.632478] Scanning device for bad blocks
[    8.642563] Bad eraseblock 100 at 0x000000c80000
[    8.653102] Bad eraseblock 200 at 0x000001900000
[  281.253499] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[  281.278377] sd 0:0:0:0: [sda] Start/Stop Unit failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK

The above bad blocks are OK. They are far from mtd0, which is the 1st MB (blocks 0 to 7).

Quote
Instruction
3. Check for bad blocks

Be sure there is no bad block in the first 1M of your NAND. This is very important, if there is bad block in the first 1M (blocks 0 to 7), don't flash u-boot, because you will almost certainly soft-brick your box.

And yes you can flash the new u-boot image and its envs image. Your mtd0 is 1MB as shown below:

Quote

root@debian:/boot# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00400000 00020000 "uImage"
mtd2: 02000000 00020000 "rootfs"
mtd3: 05b00000 00020000 "data"

====

With all that said, it is always a good idea to connect serial console so you can see the booting progress. And rescue your box (if you had made some mistake during installation, or there is a power outage during the flashing operations).

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



Edited 1 time(s). Last edit at 10/29/2023 02:31PM by bodhi.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 02:54PM
... And i did it, so far w/out Uart and.. got into bootloop.
So Uart eventually inavoidable (
Suspect syntax errors because i used bash syntax: Export Variable = no-paretheses-value instead of that
Tcsh/no setenv, printenv command available/. May it be so?



Edited 3 time(s). Last edit at 10/29/2023 02:59PM by zebe.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 04:06PM
> So Uart eventually inavoidable (
> Suspect syntax errors because i used bash syntax:
> Export Variable = no-paretheses-value instead of
> that
> Tcsh/no setenv, printenv command available/. May
> it be so?

Yes. The envs must be set exactly as stated in the instruction.

Now before hooking up serial console, you can try using the USB rescue rootfs to boot again

But to ensure it will boot, set the envs to exactly as default values. Do this:

Mount the USB rootfs on another Linux box. Assuming it is mounted at /media/sdb1. And you still have the uEnv.txt there in /boot.

cd /media/sdb1/boot
mv uEnv.txt uEnv.txt.rescue

Copy the default envs file from the u-boot tarball to this USB rootfs, and make a new uEnv.txt.

cp -a uboot.2023.04-tld-1.nsa325.environment uEnv.txt

And then edit the uEnv.txt files to replace what's currently there with
device=0:1
device_type=usb
devices=usb
disk_number=0
disks=0 1 2 3

And then sync, umount, remove the USB rootfs, bring it back to the NSA325, cold start. Basically follow the same steps in the How-To you have done once before.

After you have booted into the USB rootfs, you can proceed to fix the envs in NAND so it will boot properly without uEnv.txt.

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



Edited 1 time(s). Last edit at 10/29/2023 04:08PM by bodhi.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 04:58PM
Ok, this means i should switch from bash to tcsh first because there is no setenv, printenvcommand otherwise...?
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 05:06PM
The setenv and printenv commands are u-boot shell commands, not Linux shell commands. Therefore the shell you are using from Linux have no bearing. From Linux you would use the fw_printenv and fw_setenv commands after first setting the appropriate values in /etc/fw_env.config.

Ray
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 29, 2023 05:11PM
zebe,

> Ok, this means i should switch from bash to tcsh
> first because there is no setenv, printenvcommand
> otherwise...?

No. As I said, you need to basically copy/paste the fw_setenvs commands as instructed in the Installation Steps. If you have problem doing that, then it's a hint that you are not doing the installation correctly. And a standard Debian default shell should be used.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
October 30, 2023 08:38AM
OK but unfortunately still cant ping my box, UART to be done eventually..
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
November 06, 2023 12:05PM
OK,hi again.
\Booting w.random eth addres...



Edited 6 time(s). Last edit at 11/06/2023 02:05PM by zebe.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
November 06, 2023 01:34PM
zebe,

With serial console connected, power up, and let it boot automatically, all the way into Debian. Log in, and

cat /proc/mtd
cat /etc/fw_env.config
fw_printenv
mount

And post the entire serial console log here (post everything on your terminal).

And btw, don't do fsck -A. When you want to check file system, it should be per partition. Like:
e2fsck /dev/sda1
e2fsck /dev/sdb1

..... so on

This box mtd5 is prone for that ecc error. It can be ignored, we are not booting stock OS on NAND.

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



Edited 1 time(s). Last edit at 11/06/2023 07:55PM by bodhi.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
November 07, 2023 06:03AM
Cant get consistent eth0 w/DHCP in my LAN.
Unless i command reboot via UART link...



Edited 4 time(s). Last edit at 11/07/2023 12:44PM by zebe.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
November 07, 2023 01:46PM
https://forum.doozan.com/read.php?3,135222,136102#msg-136102

> With serial console connected, power up, and let
> it boot automatically, all the way into Debian.
> Log in, and
>
>
> cat /proc/mtd
> cat /etc/fw_env.config
> fw_printenv
> mount
>
>
> And post the entire serial console log here (post
> everything on your terminal).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 29, 2023 03:06AM
I have tried this new U-Boot with the UART serial kwboot.
The result is this:
SoC:   Kirkwood 88F6282_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive

After this it remains stuck with no booting.
My rootsfs is on SATA.
Is this becasue I stll have the old Env as stated in C.1.1 of first post ?

The same is happening also with the previous U-Boot but than, after some time, the boot starts.

host 192.168.1.19 is my Rasperry and I anyhow would like avoid that the boot look for this. How can I avoid that my Pi is detected as egiga0 device ?

This is my env:
root@debian:~# fw_printenv
arcNumber=2097
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
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; sleep 3
bootdelay=10
bootdev=usb
device=0:1
devices=usb ide mmc
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-nsa325.dtb
ethact=egiga0
ethaddr=EC:43:F6:40:84:91
if_netconsole=ping $serverip
ipaddr=192.168.1.200
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
machid=0x831
mainlineLinux=yes
mtdids=nand0=orion_nand
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=run preboot_nc
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
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.1.19
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=echo Initializing 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 $disks; do if test $uenv_loaded -eq 0; then setenv device_type $devtype; setenv disk_number $disknum; run uenv_read; fi; done; done;
uenv_read=echo Loading envs from $device_type $disk_number...; if load $device_type  $disk_number:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; echo ... envs loaded; fi
usb_ready_retry=15

root@debian:~# cat /boot/uEnv.txt
devices=ide usb
disks=0 1 2 3 4 5 6 7
ethaddr=EC:43:F6:40:84:91
custom_params=init=/bin/systemd
load_dtb_addr=0x2c00000



Edited 1 time(s). Last edit at 12/29/2023 03:27AM by miazza.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 29, 2023 01:37PM
miazza,

> Using egiga0 device
> host 192.168.1.19 is alive
>
> After this it remains stuck with no booting.

> My rootsfs is on SATA.
> Is this becasue I stll have the old Env as stated
> in C.1.1 of first post ?

Yes.

> host 192.168.1.19 is my Rasperry and I anyhow
> would like avoid that the boot look for this. How
> can I avoid that my Pi is detected as egiga0
> device ?

> preboot=run preboot_nc

Since you activated netconsole as above, and your netconsole server is also your serial console server, you'll see output stops on serial console after
> Using egiga0 device
> host 192.168.1.19 is alive
Output is now going to netconsole.

What you can do is open 2 terminals on the rPi, one for serial console, and one for netconsole. On the netconsole server run

nc.traditional -lup 6666 192.168.1.200 6666
And you will see netconsole starts, and you can interrupt the count down. After that, adjust the sata boot cmd

setenv devices 'sata usb'
setenv init_sata 'sata init'
setenv scan_disk 'echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_sata "sata init";  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'
setenv uenv_init_devices 'echo Initializing devices...; setenv init_usb "usb start";  setenv init_sata "sata init";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done'

And then
boot

======

The above is just show to yourself that it can boot the rootfs. When you flash the new u-boot for real, you would want to adjust these evnvs at that time (if you don't want to flash the new default envs and restore your box specific envs such as ipaddr, ethaddr, serverip,....)

======

To completely turn off netconsole you can do either 1 or 2 below.

1. Set the serverip to something other than 192.168.1.19. Assuming 192.168.1.25 is not on your network.
fw_setenv serverip 192.168.1.25

Or

2. adjust the env preboot
fw_setenv preboot  "echo netconsole not running"
or remove it completely
fw_setenv preboot

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 29, 2023 03:43PM
The netconsole at 192.168.1.19 is on a different pi from the one where I have the serial consol (192.168.1.254).

I have started the netconsole as you said but I cannot see any countdown:
pi@Raspberrypy-4:~ $ nc.traditional -lup 6666 192.168.1.200 6666
    U-Boot 2023.04-tld-1 (Jun 24 2023 - 17:50:21 -0700)
ZyXEL NSA325 2-Bay Power Media Server
It remains stuck at this point and I cannot do anything.

On the serial console:

pi@raspberrypi:~/ftp/files $ kwboot  -t -B 115200 /dev/ttyUSB0 -b uboot.2023.04-Sending boot message. Please reboot the target...|
Sending boot image...
  0 % [......................................................................]
  1 % [......................................................................]
  3 % [......................................................................]
  5 % [......................................................................]
  6 % [......................................................................]
  8 % [......................................................................]
 10 % [......................................................................]
 11 % [......................................................................]
 13 % [......................................................................]
 15 % [......................................................................]
 17 % [......................................................................]
 18 % [......................................................................]
 20 % [......................................................................]
 22 % [......................................................................]
 23 % [......................................................................]
 25 % [......................................................................]
 27 % [......................................................................]
 29 % [......................................................................]
 30 % [......................................................................]
 32 % [......................................................................]
 34 % [......................................................................]
 35 % [......................................................................]
 37 % [......................................................................]
 39 % [......................................................................]
 41 % [......................................................................]
 42 % [......................................................................]
 44 % [......................................................................]
 46 % [......................................................................]
 47 % [......................................................................]
 49 % [......................................................................]
 51 % [......................................................................]
 53 % [......................................................................]
 54 % [......................................................................]
 56 % [......................................................................]
 58 % [......................................................................]
 59 % [......................................................................]
 61 % [......................................................................]
 63 % [......................................................................]
 64 % [......................................................................]
 66 % [......................................................................]
 68 % [......................................................................]
 70 % [......................................................................]
 71 % [......................................................................]
 73 % [......................................................................]
 75 % [......................................................................]
 76 % [......................................................................]
 78 % [......................................................................]
 80 % [......................................................................]
 82 % [......................................................................]
 83 % [......................................................................]
 85 % [......................................................................]
 87 % [......................................................................]
 88 % [......................................................................]
 90 % [......................................................................]
 92 % [......................................................................]
 94 % [......................................................................]
 95 % [......................................................................]
 97 % [......................................................................]
 99 % [....................................]
[Type Ctrl-\ + c to quit]


U-Boot 2023.04-tld-1 (Jun 24 2023 - 17:50:21 -0700)
ZyXEL NSA325 2-Bay Power Media Server

SoC:   Kirkwood 88F6282_A1
Model: ZyXEL NSA325
DRAM:  512 MiB
Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  128 MiB
Loading Environment from NAND... OK
Resetting console stdin/stdout/stderr to serial...
In:    serial
Out:   serial
Err:   serial
pcie0.0: Link up
Net:   eth0: ethernet-controller@72000
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device
host 192.168.1.19 is alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device
host 192.168.1.19 is alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device
host 192.168.1.19 is alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device
host 192.168.1.19 is alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device
host 192.168.1.19 is alive
At the last try the net console starts as above but everything remain stuck with an orage led flashing on the 325.

With the previous u-boot I have the following in serial console:
pi@raspberrypi:~ $ minicom

Welcome to minicom 2.7.1

OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyUSB0, 21:49:38

Press CTRL-A Z for help on special keys



U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:42:03 -0700)
ZyXEL NSA325 2-Bay Power Media Server

SoC:   Kirkwood 88F6282_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
Using egiga0 device
host 192.168.1.19 is alive
[    0.000000][    T0] Booting Linux on physical CPU 0x0
[    0.000000][    T0] Linux version 6.6.3-kirkwood-tld-1 (root@tldDebian) (gcc3
[    0.000000][    T0] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cf
[    0.000000][    T0] CPU: VIVT data cache, VIVT instruction cache
[    0.000000][    T0] OF: fdt: Machine model: ZyXEL NSA325
[    0.000000][    T0] Memory policy: Data cache writeback
[    0.000000][    T0] Zone ranges:
[    0.000000][    T0]   Normal   [mem 0x0000000000000000-0x000000001fffffff]
[    0.000000][    T0] Movable zone start for each node
[    0.000000][    T0] Early memory node ranges

Also I cannot see any countdown.



Edited 1 time(s). Last edit at 12/29/2023 04:02PM by miazza.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 29, 2023 03:48PM
> host 192.168.1.19 is alive

> At the last try the net console starts as above
> but everything remain stuck with an orage led
> flashing on the 325.

Then try shutdown the 192.168.1.19 rPi, or change it's IP address.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 29, 2023 04:16PM
Ok. I powerd off 192.168.1.19 and now:
U-Boot 2023.04-tld-1 (Jun 24 2023 - 17:50:21 -0700)
ZyXEL NSA325 2-Bay Power Media Server

SoC:   Kirkwood 88F6282_A1
Model: ZyXEL NSA325
DRAM:  512 MiB
Core:  19 devices, 15 uclasses, devicetree: separate
NAND:  128 MiB
Loading Environment from NAND... OK
Resetting console stdin/stdout/stderr to serial...
In:    serial
Out:   serial
Err:   serial
pcie0.0: Link up
Net:   eth0: ethernet-controller@72000
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.1.19 is not alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.1.19 is not alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.1.19 is not alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.1.19 is not alive
ethernet-controller@72000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-controller@72000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.1.19 is not alive
Hit any key to stop autoboot:  0
NSA325> setenv devices 'sata usb'
NSA325> setenv init_sata 'sata init'
NSA325> setenv scan_disk 'echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_sata "sata init";  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'
NSA325> setenv uenv_init_devices 'echo Initializing devices...; setenv init_usb "usb start";  setenv init_sata "sata init";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done'
NSA325> boot
Initializing devices...
starting USB...
Bus ehci@50000: USB EHCI 1.00
Bus xhci_pci: Register 4000820 NbrPorts 4
Starting the controller
USB XHCI 0.96
scanning bus ehci@50000 for devices... 2 USB Device(s) found
scanning bus xhci_pci for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Loading envs from sata 0...
Failed to load '/boot/uEnv.txt'
Loading envs from sata 1...
121 bytes read in 46 ms (2 KiB/s)
... envs loaded
importing envs ...
running scan_disk ...
Scan device ide
## Error: "scan_ide" not defined
device ide 0:1
** Bad device specification ide 0 **
Couldn't find partition ide 0:1
Can't set block device
device ide 1:1
** Bad device specification ide 1 **
Couldn't find partition ide 1:1
Can't set block device
device ide 2:1
** Bad device specification ide 2 **
Couldn't find partition ide 2:1
Can't set block device
device ide 3:1
** Bad device specification ide 3 **
Couldn't find partition ide 3:1
Can't set block device
device ide 4:1
** Bad device specification ide 4 **
Couldn't find partition ide 4:1
Can't set block device
device ide 5:1
** Bad device specification ide 5 **
Couldn't find partition ide 5:1
Can't set block device
device ide 6:1
** Bad device specification ide 6 **
Couldn't find partition ide 6:1
Can't set block device
device ide 7:1
** Bad device specification ide 7 **
Couldn't find partition ide 7:1
Can't set block device
Scan device usb
device usb 0:1
** Bad device specification usb 0 **
Couldn't find partition usb 0:1
Can't set block device
device usb 1:1
** Bad device specification usb 1 **
Couldn't find partition usb 1:1
Can't set block device
device usb 2:1
** Bad device specification usb 2 **
Couldn't find partition usb 2:1
Can't set block device
device usb 3:1
** Bad device specification usb 3 **
Couldn't find partition usb 3:1
Can't set block device
device usb 4:1
** Bad device specification usb 4 **
Couldn't find partition usb 4:1
Can't set block device
device usb 5:1
** Bad device specification usb 5 **
Couldn't find partition usb 5:1
Can't set block device
device usb 6:1
** Bad device specification usb 6 **
Couldn't find partition usb 6:1
Can't set block device
device usb 7:1
** Bad device specification usb 7 **
Couldn't find partition usb 7:1
Can't set block device
loading uImage ...
** Bad device specification usb 0 **
Couldn't find partition usb 0:1
Can't set block device
loading uInitrd ...
** Bad device specification usb 0 **
Couldn't find partition usb 0:1
Can't set block device
loading DTB /boot/dts/kirkwood-nsa325.dtb ...
** Bad device specification usb 0 **
Couldn't find partition usb 0:1
Can't set block device
Wrong Image Format for bootm command
Error occured, error code = 112
ERROR: can't get kernel image!
NSA325>

Can't boot from SATA. It loads /boot/uEnv.txt from SATA 1 but no boot.

uEnv.txr is:
devices=mmc usb ide
disks=0 1 2 3 4 5 6 7
ethaddr=EC:43:F6:40:84:91
custom_params=init=/bin/systemd
load_dtb_addr=0x2c00000



Edited 1 time(s). Last edit at 12/29/2023 04:30PM by miazza.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 29, 2023 05:15PM
> Can't boot from SATA. It loads /boot/uEnv.txt from
> SATA 1 but no boot.
>
> uEnv.txr is:
>
> devices=mmc usb ide
> disks=0 1 2 3 4 5 6 7
> ethaddr=EC:43:F6:40:84:91
> custom_params=init=/bin/systemd
> load_dtb_addr=0x2c00000
>

You can see that the uEnv.txt has reversed the change you made

NSA325> setenv devices 'sata usb'


So either change the uEnv.txt on SATA 1 to

devices=sata usb
disks=0 1 2 3 4 5 6 7
ethaddr=EC:43:F6:40:84:91
custom_params=init=/bin/systemd
load_dtb_addr=0x2c00000

Or remove this line

devices=mmc usb ide

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 30, 2023 01:24AM
OK. Now it boots correctly:
NSA325> boot
Initializing devices...
starting USB...
Bus ehci@50000: USB EHCI 1.00
Bus xhci_pci: Register 4000820 NbrPorts 4
Starting the controller
USB XHCI 0.96
scanning bus ehci@50000 for devices... 2 USB Device(s) found
scanning bus xhci_pci for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Loading envs from sata 0...
Failed to load '/boot/uEnv.txt'
Loading envs from sata 1...
122 bytes read in 43 ms (2 KiB/s)
... envs loaded
importing envs ...
running scan_disk ...
Scan device sata
device sata 0:1
Failed to load '/boot/uImage'
device sata 1:1
1 bytes read in 34 ms (0 Bytes/s)
Found bootable drive on sata 1
loading uImage ...
6337856 bytes read in 116 ms (52.1 MiB/s)
loading uInitrd ...
14063684 bytes read in 166 ms (80.8 MiB/s)
loading DTB /boot/dts/kirkwood-nsa325.dtb ...

Is there any way to reduce the number of tries to find the netconsole other than disable it ? the boot takes some time with this to complete the 6 cycles.

So now I can flash the new version. I guess these bad blocks are compatible:
root@debian:~# dmesg | grep -i 'bad'
[    5.300864] Scanning device for bad blocks
[    5.327370] Bad eraseblock 226 at 0x000001c40000
[    5.355035] Bad eraseblock 460 at 0x000003980000
[    5.391212] Bad eraseblock 783 at 0x0000061e0000
[    5.401279] Bad eraseblock 833 at 0x000006820000

Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 30, 2023 02:51PM
> Is there any way to reduce the number of tries to
> find the netconsole other than disable it ? the
> boot takes some time with this to complete the 6
> cycles.

This env is where the pings are.
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
You'll need at least 2 pings to make sure the fist one is not false positive, which happens quite frequently. For certain networks you might need more than 2 pings, so that's why I chose 5.

So you can change the number of pings like this:
fw_setenv preboot_nc "setenv nc_ready 0; for pingstat in 1 2; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi"

I would not bother changing it, if you have serial console then you should not use netconsole. We use netconsole only when it is not convenient to connect serial console (i.e. location hard to reach).

> So now I can flash the new version. I guess these
> bad blocks are compatible:
>
> root@debian:~# dmesg | grep -i 'bad'
> [    5.300864] Scanning device for bad blocks
> [    5.327370] Bad eraseblock 226 at
> 0x000001c40000
> [    5.355035] Bad eraseblock 460 at
> 0x000003980000
> [    5.391212] Bad eraseblock 783 at
> 0x0000061e0000
> [    5.401279] Bad eraseblock 833 at
> 0x000006820000
> 
>

Those bad blocks are OK.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
December 31, 2023 03:26AM
Thank you bodhi.
New u-boot now flashed and working.

I have now a dedicated PI close to the NAS that I can switch on only when I need the Serial Console (quite expensive serial console :)).

netconsole is easier and cheaper :)



Edited 1 time(s). Last edit at 12/31/2023 03:40AM by miazza.
Re: 2023.04 U-Boot Kirkwood - ZyXEL NSA325
May 20, 2024 04:47PM
Quick question: is this only for NSA325 or also the NSA325v2?
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: