Welcome! Log In Create A New Profile

Advanced

Debian on Zyxel NSA325v2 with U-boot from openwrt

Posted by alazarski 
Debian on Zyxel NSA325v2 with U-boot from openwrt
December 29, 2023 02:28PM
Good day,

I'm writing due to lost of hope that I'm able to restore system on my device Zyxel NSA325v2. Till now I used stock u-boot and firmware but it was not enough for me so I decided to change to other OS. According to instruction on https://openwrt.org/toh/zyxel/nsa325 I change stock u-boot for https://archive.openwrt.org/releases/18.06.0/targets/kirkwood/generic/u-boot-nsa325/ this and flash nand with their firmware (OpenWrt)
But during start Openwrt stop working while loading kernel with information
[    1.174598] Run /sbin/init as init process
[    1.197688] SQUASHFS error: xz decompression failed, data probably corrupt
[    1.204621] SQUASHFS error: Failed to read block 0x1138ce: -5
[    1.210397] SQUASHFS error: Unable to read fragment cache entry [1138ce]
[    1.217127] SQUASHFS error: Unable to read page, block 1138ce, size 13d5c
[    1.223950] SQUASHFS error: Unable to read fragment cache entry [1138ce]
[    1.230685] SQUASHFS error: Unable to read page, block 1138ce, size 13d5c
[    1.237500] SQUASHFS error: Unable to read fragment cache entry [1138ce]
[    1.244236] SQUASHFS error: Unable to read page, block 1138ce, size 13d5c
[    1.251057] SQUASHFS error: Unable to read fragment cache entry [1138ce]
[    1.257780] SQUASHFS error: Unable to read page, block 1138ce, size 13d5c
[    1.264603] SQUASHFS error: Unable to read fragment cache entry [1138ce]
[    1.271342] SQUASHFS error: Unable to read page, block 1138ce, size 13d5c
[    1.278223] Starting init: /sbin/init exists but couldn't execute it (error -5)
[    1.285562] Run /etc/init as init process
[    1.289754] Run /bin/init as init process
[    1.295574] Run /bin/sh as init process


BusyBox v1.35.0 (2023-04-27 20:28:15 UTC) built-in shell (ash)

/bin/sh: can't access tty; job control turned off
/ #

However I finally I decided to install Debian except OpenWrt. This u-boot has ext4ls and ext4load command and has an USB support. It is from 2018y so relatively new and according to doozan forum should work.
my env variabel is as listed :


NSA325> printenv
baudrate=115200
bootcmd=usb reset; run usb_bootcmd; usb stop; reset
bootdelay=3
console=console=ttyS0,115200
ethact=egiga0
ethaddr=5C:F4:AB:50:13:2C
load_uimage=ext4load usb 0:1 0x800000 /boot/uImage
load_uinitrd=ext4load usb 0:1 0x2100000 /boot/uInitrd
mtddevname=uboot
mtddevnum=0
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x00c0000(uboot),0x80000(uboot_env),0x7ec0000(ubi)
partition=nand0,0
stderr=serial
stdin=serial
stdout=serial
usb_boot=mw 0x800000 0 1; run load_uimage; run load_uinitrd; bootm 0x800000 0x2100000
usb_bootcmd=run usb_set_bootargs; run usb_boot
usb_set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 earlyprintk=serial

Environment size: 722/131068 bytes

I've done everything acording to instruction https://forum.doozan.com/read.php?2,12096. I prepared 32 GB USB stick and formating it on ext4 format usign Terminal and
mkfs.ext4 -E lazy_itable_init=0
as mentioned. Then I unpacking Debian-6.5.7-kirkwood-tld-1-rootfs-bodhi.tar.bz2 and changing /etc/fstab to ext4. Of course every step in terminal not in GUI

USB is seen and recognized by U-Boot but it cannot read directory /boot


NSA325> usb reset
resetting 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
NSA325> ext4ls usb 0:1 /boot
Failed to iterate over directory boot
** Can not find directory. **

Where could be a problem. Now I cannot change to Kirkwood 2023.04 U-Boot Kirkwood - ZyXEL NSA325 becous of lack of OS. However I don't think it is a matter in my case. What can I do to obtain a debian on my device? Thank you for any help



Edited 2 time(s). Last edit at 12/29/2023 02:42PM by alazarski.
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 29, 2023 03:44PM
alazarski,

> NSA325> ext4ls usb 0:1 /boot
> Failed to iterate over directory boot
> ** Can not find directory. **
>
> Where could be a problem. Now I cannot change to
> Kirkwood 2023.04 U-Boot Kirkwood - ZyXEL NSA325
> becous of lack of OS. However I don't think it is
> a matter in my case. What can I do to obtain a
> debian on my device? Thank you for any help

1. Easy way: just make Ext3 rootfs and boot with it now. Worry about installing new u-boot and switch to Ext4 after you've logged in to Debian.

2. A bit more work: kwboot with my u-boot image for Kirkwood 2023.04 U-Boot Kirkwood - ZyXEL NSA325. See example here:

https://forum.doozan.com/read.php?3,51739,51919#msg-51919

When you kwboot with this new u-boot, the envs are probably not at the same location as OpenWrt so might give you error. But it's OK, the default envs will be good enough. And the rootfs uImage should be the original, so reverse Step 4 that you might have done to use OpenWrt u-boot.

Quote

4. (Stock u-boot only) Create uImage with embedded DTB for booting with older u-boots (2012 or earlier). Skip this step if you have installed the latest U-Boot for Kirkwood (or are installing this u-boot at the same time, or running kwboot with latest u-boot image).

Please replace kirkwood-goflexnet.dtb below with the correct DTB name for your box (see the folder /media/sdb1/boot/dts for the exact spelling of your Kirkwood box name).

Generate the uImage with DTB embedded inside:
cd /media/sdb1/boot
cp -a zImage-6.5.7-kirkwood-tld-1 zImage.fdt
cat dts/kirkwood-goflexnet.dtb >> zImage.fdt
mv uImage uImage.orig
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-6.5.7-kirkwood-tld-1 -d zImage.fdt uImage
sync


Restore the original to boot with Kirkwood 2023.04 U-Boot Kirkwood - ZyXEL NSA325:
cp -a uImage.orig uImage

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



Edited 1 time(s). Last edit at 12/29/2023 03:44PM by bodhi.
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 29, 2023 04:21PM
My u-boot has ext2load, ext2ls and ext4load, ext4fs that’s why I used ext4. It is no problem when partition on roots will be ext3 ?
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 29, 2023 05:22PM
> My u-boot has ext2load, ext2ls and ext4load,
> ext4fs that’s why I used ext4.

Ext4 might not work properly in this u-boot.

> It is no problem
> when partition on roots will be ext3 ?

I prefer Ext3 while testing the installation. In fact, most of my rootfs are Ext3. For rootfs, there is not much gain using Ext4. For data partition, use Ext4 to get improvement in speed.

In u-boot, use ext2load, ext2ls for Ext2 or Ext3.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 29, 2023 07:22PM
I checked all configuration for this u-Boot (from OpenWrt) it looks as following :
1. When rootfs is in ext4 format the command ext4ls can read all directory from USB (etc. /bin /etc ) with no problme except /boot (I don't know why - folder is empty). For that reason as I understand it cannot load uImage and uInitrd

2. When rootfs is in ext3 format command ext2ls and ext4ls cannot read anything and suspend an U-Boot.

NSA325> usb info 0
config for device 0
*** No device available ***
NSA325> ext2ls usb 0:1 /etc
** Can not find directory. **

as I see the only option is to use kwboot?
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 29, 2023 08:22PM
> as I see the only option is to use kwboot?

Yes, always good to do kwboot successfully before a big change. And you'd need to do this before installing my u-boot version anyway! (You can boot back to OpenWrt on NAND as a rescue system with some further set up).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 30, 2023 01:50PM
Hi bodhi I relized that the problem was in USB formatting. During extracting file I lost a folders from Debian that's why u-boot cannot read a proper data. But when I make a USB in right way and try to load debian I get a message. I still has an old U-Boot because I decided first fix a problem with USB stick.

NSA325> boot
resetting 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
6223944 bytes read in 665 ms (8.9 MiB/s)
5791271 bytes read in 602 ms (9.2 MiB/s)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux-6.5.7-kirkwood-tld-1
   Created:      2023-10-31  22:53:22 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    6223880 Bytes = 5.9 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 02100000 ...
   Image Name:   initramfs-6.5.7-kirkwood-tld-1
   Created:      2023-10-31  22:53:55 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    5791207 Bytes = 5.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
   Loading Ramdisk to 1f597000, end 1fb1cde7 ... OK

Starting kernel ...


Error: invalid dtb and unrecognized/unsupported machine ID
  r1=0x00000000, r2=0x00000100
  r2[]=05 00 00 00 01 00 41 54 00 00 00 00 00 00 00 00
Available machine support:

ID (hex)        NAME
ffffffff        Generic DT based system
ffffffff        Marvell Kirkwood (Flattened Device Tree)

Please check your kernel config and/or bootloader.


Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 30, 2023 02:39PM
alazarski,

> Hi bodhi I relized that the problem was in USB
> formatting. During extracting file I lost a
> folders from Debian that's why u-boot cannot read
> a proper data. But when I make a USB in right way
> and try to load debian I get a message.

Cool! I thougt it is strange that OpenWrt u-boot would have USB problem.

> I still
> has an old U-Boot because I decided first fix a
> problem with USB stick.
>
> machine ID
> r1=0x00000000, r2=0x00000100
> r2[]=05 00 00 00 01 00 41 54 00 00 00 00 00 00
> 00 00
> Available machine support:
>
> ID (hex) NAME
> ffffffff Generic DT based system
> ffffffff Marvell Kirkwood (Flattened Device
> Tree)
>
> Please check your kernel config and/or
> bootloader.

With this old u-boot, you need to append the DTB to uImage. Basically, you need to treat it as stock u-boot. So do Step 4, and use the nsa325 DTB file in this step.


Quote
https://forum.doozan.com/read.php?2,12096

4. (Stock u-boot only) Create uImage with embedded DTB for booting with older u-boots (2012 or earlier). Skip this step if you have installed the latest U-Boot for Kirkwood (or are installing this u-boot at the same time, or running kwboot with latest u-boot image).

Please replace kirkwood-goflexnet.dtb below with the correct DTB name for your box (see the folder /media/sdb1/boot/dts for the exact spelling of your Kirkwood box name).

Generate the uImage with DTB embedded inside:
cd /media/sdb1/boot
cp -a zImage-6.5.7-kirkwood-tld-1 zImage.fdt
cat dts/kirkwood-goflexnet.dtb >> zImage.fdt
mv uImage uImage.orig
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-6.5.7-kirkwood-tld-1 -d zImage.fdt uImage
sync

If your Linux box does not have mkimage, then install it
apt-get install u-boot-tools

After you've booted into Debian, then you can consider installing new u-boot. And remember to restore uImage to uImage.orig when you boot with new u-boot.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 30, 2023 04:55PM
Everything looks almost good. I cannot belive. It's alive!
Running local boot scripts (/etc/rc.local)
ssh-keygen: generating new host keys: RSA
ECDSA
ED25519

Starting OpenBSD Secure Shell server: sshd
.
.

Debian GNU/Linux 12 debian ttyS0

debian login: Starting OpenBSD Secure Shell server: sshd
Debian GNU/Linux 12 debian ttyS0

debian login:


Thank you!



Edited 2 time(s). Last edit at 12/30/2023 05:14PM by alazarski.
Re: Debian on Zyxel NSA325v2 with U-boot from openwrt
December 30, 2023 05:17PM
Congrats!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
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: