Welcome! Log In Create A New Profile

Advanced

NSA325v2 uBoot messed up after upgrade

Posted by udp 
udp
NSA325v2 uBoot messed up after upgrade
March 27, 2018 03:36PM
Hi guys,
at first: Thank you, especially Bodhi, for all the work you set into this project.

I have a NSA325v2 with UART-access. I' ve been using Debian 4.4 since february 2016. Last weekend my USB flash key is broken - no partitions, no block-device-access, no recognition via fdisk.

So I bought a new one and downloaded the debian-4.12.1-rootfs. There is only one partition and I formatted it to ext3 and labeled it "rootfs". Then I got root an expanded the tarball in this partition. I've checked /etc/fstab for the fs-type of the root-partition.

I could not boot into the new OS, therefore I tried to upgrade uBoot from stock to 2017.07.

I followed the instructions in this thread https://forum.doozan.com/read.php?3,12381, but I am not sure, if I missed some point.

  • I backed up the env and mtd0, but in an overhasty act I destroyed the backup on the flash key.
  • I checked for bad blocks, but there were none.
  • I erased /mtd0 and wrote the uboot.2017.07-tld-1-nsa325.mtd0.kwb to /mtd0. The output was as expected.
  • I think, I might have skipped flashing the default u-boot envs.

I've put the uEnv.txt-file in the /boot-folder and when I start the NAS and can get to the "NSA325>" prompt.

When I try to autoboot to Debian I get stuck either at
"Uncompressing Linux... done, booting the kernel."
when I build the uImage with
cp -a zImage-4.12.1-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-4.12.1-kirkwood-tld-1 -d zImage.fdt  uImage

or at
Error: unrecognized/unsupported machine ID (r1 = 0x0000118f).

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.
when I use the original image file without embedded dtb file.

I've double checked, but "machid" is neither set in uEnv.txt nor in "setenv".


Screen of my NAS with skipped autoboot:
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
Hit any key to stop autoboot:  0 
NSA325>

This is the environment:
arcNumber=4495
baudrate=115200
bootargs=$(bootargs_linux)
bootargs_0000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)=root=LABEL=rootfs loglevel=8
bootargs_inux=consol=ttyS0,115200 mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0A00000(kernel_2),0x2FC0000(rootfs2) root=LABEL=rootfs loglevel=8
bootargs_linux=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2) earlyprintk=serial
bootargs_stock=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=echo Booting Linux... ; run bootcmd_linux; echo booting from NAND... ; run bootcmd_stock; reset
bootcmd_largs=)
bootcmd_linux=setenv mainlineLinux yes; setenv bootargs $(bootargs_linux); mw.l f1010100 0020c000; usb reset; ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-nsa325.dtb; ext2load usb 0:1 0x800000  /boot/uImage; ext2load usb 0:1 0x02100000 /boot/uInitrd; bootm 0x800000 0x02100000
bootcmd_lnv=bootargs $(bootargs_linux)
bootcmd_ls=$(bootargs_linux)
bootcmd_stock=setenv mainlineLinux no; setenv bootargs $(bootargs_stock); nand read.e 0x2000000 $(kernel_addr) 0xA00000; bootm 0x2000000
bootdelay=3
devices=usb ide
disks=0 1 2 3 4 5 6 7
ethact=egiga0
ethaddr=00:50:43:00:02:02
fileaddr=1100000
filesize=6e8f80
ipaddr=192.168.1.5
load_dtb=ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-nsa325.dtb
load_init=ext2load usb 0:1 0x1100000 /boot/uInitrd
load_initrd=ext2load usb 0:1 0x1100000 /boot/uInitrd
load_uimage=ext2load usb 0:1 0x800000 /boot/uImage
loadaddr=0x02000000
mainlineLinux=yes
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)
serverip=192.168.152.24
stderr=serial
stdin=serial
stdout=serial
to_linux=setenv mainlineLinux yes; setenv bootcmd \\'run bootcmd_linux\\'; saveenv; reset
to_stock=setenv mainlineLinux no; setenv bootcmd \\'run bootcmd_stock\\'; saveenv; reset
usb_boot=run load_dtb; run load_uimage; if run load_initrd; then bootm 0x800000 0x1100000 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
usb_set_bootargs=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts init=/bin/systemd


My OS on the PC is openSUSE, so at the moment I can't use kwboot to rebuild the uBoot-Environment at the moment. (Yes, I've already tried that...).

Can anybody tell me, what I've missed or what I can do to get this box up and running again?


-andy-
Re: NSA325v2 uBoot messed up after upgrade
March 27, 2018 04:32PM
andy,

The fix is quite simple, you don't need kwboot at all. Your u-boot was flashed successful and you can boot without problem.

Since you missed flashing the default envs, current it has problem booting into Debian. You can set it to the right defaults at the u-boot prompt using the default script Iv've created.

Let me find the link and come back to edit this post.

---------

OK. Here is how to set the default envs at u-boot-prompt:

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


Note that your box is NSA325 so the envs need some adjustement after you loaded and ran the script. And replace xx:xx:xx:xx:xx:xx with the real number for your box.

Quote

Adjust the other specific envs and then boot the rootfs:
setenv devices 'usb ide'
setenv ethaddr xx:xx:xx:xx:xx:xx
setenv dtb_file '/boot/dts/kirkwood-nsa325.dtb'
boot

Once you've booted successful into Debian, you can repeat this and save the envs at serial console to make it permanent. Or you can flash the default envs at the Linux prompt using the u-boot installation instruction.

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



Edited 1 time(s). Last edit at 03/27/2018 04:42PM by bodhi.
udp
Re: NSA325v2 uBoot messed up after upgrade
March 28, 2018 10:35AM
Hey bodhi,
thank you for the fast reply. I did the following:
NSA325> usb start
NSA325> ext2load usb 0:1 0x800000 /boot/uboot.2016.05-tld-1.environment.scr
3232 bytes read in 892 ms (2.9 KiB/s)
NSA325> source 0x800000
NSA325> setenv devices 'usb ide'
NSA325> setenv ethaddr 00:50:43:00:02:02
NSA325> setenv dtb_file '/boot/dts/kirkwood-nsa325.dtb'
NSA325> setenv machid 
NSA325> setenv arcNumber 4495
NSA325> boot

Then this happened:

Reset IDE: Bus 0: OK Bus 1: OK 
  Device 0: Model: WDC WD2000FYYZ-01UL1B1 Firm: 01.01K02 Ser#:  WD-WMC1P0DESU38
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
  Device 1: Model: WDC WD2000FYYZ-01UL1B1 Firm: 01.01K02 Ser#:  WD-WMC1P0D84JLM
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)

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

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            30027776        000e4c31-01     83

## 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 ...
2743 bytes read in 799 ms (2.9 KiB/s)

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

Part    Start Sector    Num Sectors     UUID            Type
  1     63              1028097         07195f1b-01     08
  2     1028160         3905995905      07195f1b-02     20


Partition Map for IDE device 1  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     63              1028097         0c5ab5a3-01     83
  2     1028160         3905995905      0c5ab5a3-02     20
importing envs ...
running scan_disk ...
Scan device usb
device usb 0:1
1 bytes read in 722 ms (0 Bytes/s)
Found bootable drive on usb 0
## Error: "lad_uimage" not defined
loading uInitrd ...
7245696 bytes read in 943 ms (7.3 MiB/s)
loading DTB /boot/dts/kirkwood-nsa325.dtb ...
14548 bytes read in 1569 ms (8.8 KiB/s)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   uboot.2016.05-tld-1.environment.
   Created:      2016-08-07  22:21:47 UTC
   Image Type:   ARM Linux Script (uncompressed)
   Data Size:    3168 Bytes = 3.1 KiB
   Load Address: 00000000
   Entry Point:  00000000
   Contents:
      Image 0: 3160 Bytes = 3.1 KiB
   Verifying Checksum ... OK
Wrong Image Type for bootm command
Error occured, error code = 5
ERROR: can't get kernel image!

As you can see, there is an error. I think there was a typo in the "bootcmd_exec":
bootcmd_exec=run lad_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

Because this error returned after adjusting "bootcmd_exec" I tried to circumvent this by
NSA325> printenv load_uimage
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
NSA325> setenv lad_uimage 'echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage'

so the full command list looks like this:
NSA325> usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
NSA325> ext2load usb 0:1 0x800000 /boot/uboot.2016.05-tld-1.environment.scr
3232 bytes read in 892 ms (2.9 KiB/s)
NSA325> source 0x800000
## Executing script at 00800000

Warning: egiga0 MAC addresses don't match:
Address in SROM is         52:3b:20:9c:11:51
Address in environment is  00:50:43:00:02:02

NSA325> setenv devices 'usb ide'
NSA325> setenv ethaddr 00:50:43:00:02:02

Warning: egiga0 MAC addresses don't match:
Address in SROM is         00:50:43:00:02:02
Address in environment is  52:3b:20:9c:11:51
NSA325> setenv machid 
NSA325> setenv arcNumber 4495
NSA325> setenv dtb_file '/boot/dts/kirkwood-nsa325.dtb'
NSA325> printenv load_uimage
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
NSA325> setenv lad_uimage 'echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage'
NSA325> boot
The output is

Reset IDE: Bus 0: OK Bus 1: OK 
  Device 0: Model: WDC WD2000FYYZ-01UL1B1 Firm: 01.01K02 Ser#:  WD-WMC1P0DESU38
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
  Device 1: Model: WDC WD2000FYYZ-01UL1B1 Firm: 01.01K02 Ser#:  WD-WMC1P0D84JLM
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)

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

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            30027776        000e4c31-01     83

## 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 ...
2743 bytes read in 799 ms (2.9 KiB/s)

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

Part    Start Sector    Num Sectors     UUID            Type
  1     63              1028097         07195f1b-01     08
  2     1028160         3905995905      07195f1b-02     20


Partition Map for IDE device 1  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     63              1028097         0c5ab5a3-01     83
  2     1028160         3905995905      0c5ab5a3-02     20
importing envs ...
running scan_disk ...
Scan device usb
device usb 0:1
1 bytes read in 722 ms (0 Bytes/s)
Found bootable drive on usb 0
loading uImage ...
3821592 bytes read in 922 ms (4 MiB/s)
loading uInitrd ...
7245696 bytes read in 944 ms (7.3 MiB/s)
loading DTB /boot/dts/kirkwood-nsa325.dtb ...
14548 bytes read in 1568 ms (8.8 KiB/s)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux-4.12.1-kirkwood-tld-1
   Created:      2018-03-27  19:16:42 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3821528 Bytes = 3.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 01100000 ...
   Image Name:   initramfs-4.12.1-kirkwood-tld-1
   Created:      2018-03-27  19:18:02 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    7245632 Bytes = 6.9 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01c00000
   Booting using the fdt blob at 0x1c00000
   Loading Kernel Image ... OK
   Loading Ramdisk to 1f424000, end 1fb0cf40 ... OK
   Loading Device Tree to 1f41d000, end 1f4238d3 ... OK
Error occured, error code = 9
resetting ...

So I got one step further, but still stuck in another place...

This is the output of printenv between "setenv lad_uimage" and "boot"
NSA325> printenv 
arcNumber=4495
baudrate=115200
bootargs=$(bootargs_linux)
bootargs_0000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)=root=LABEL=rootfs loglevel=8
bootargs_inux=consol=ttyS0,115200 mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0A00000(kernel_2),0x2FC0000(rootfs2) root=LABEL=rootfs loglevel=8
bootargs_linux=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2) earlyprintk=serial
bootargs_stock=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=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_largs=)
bootcmd_linux=setenv mainlineLinux yes; setenv bootargs $(bootargs_linux); mw.l f1010100 0020c000; usb reset; ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-nsa325.dtb; ext2load usb 0:1 0x800000  /boot/uImage; ext2load usb 0:1 0x02100000 /boot/uInitrd; bootm 0x800000 0x02100000
bootcmd_lnv=bootargs $(bootargs_linux)
bootcmd_ls=$(bootargs_linux)
bootcmd_stock=setenv mainlineLinux no; setenv bootargs $(bootargs_stock); nand read.e 0x2000000 $(kernel_addr) 0xA00000; bootm 0x2000000
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=usb
device=0:1
devices=usb ide
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-nsa325.dtb
ethact=egiga0
ethaddr=00:50:43:00:02:02
fileaddr=800000
filesize=ca0
if_netconsole=ping $serverip
ipaddr=192.168.0.231
lad_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
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_init=ext2load usb 0:1 0x1100000 /boot/uInitrd
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
loadaddr=0x02000000
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
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
to_linux=setenv mainlineLinux yes; setenv bootcmd \\'run bootcmd_linux\\'; saveenv; reset
to_stock=setenv mainlineLinux no; setenv bootcmd \\'run bootcmd_stock\\'; saveenv; reset
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_boot=run load_dtb; run load_uimage; if run load_initrd; then bootm 0x800000 0x1100000 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
usb_ready_retry=15
usb_set_bootargs=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts init=/bin/systemd

Environment size: 4971/131068 bytes
NSA325>

greets
-andy-

=============================================================================================
edit1: typo

edit2:
I wrote the Debian-4.12.1 tarball on the USB key again...I remembered that I have changed the uImage file yesterday in the evening...
Now the box is up and running again.

Thank you, bodhi for your help.

greets
-andy-



Edited 2 time(s). Last edit at 03/28/2018 11:54AM by udp.
Re: NSA325v2 uBoot messed up after upgrade
March 28, 2018 03:50PM
> I wrote the Debian-4.12.1 tarball on the USB key
> again...I remembered that I have changed the
> uImage file yesterday in the evening...
> Now the box is up and running again.
>
> Thank you, bodhi for your help.
>
> greets
> -andy-

Cool! you're welcome.

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

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: