NSA320: how to manually flash UBoot 2016.09?

Ask questions about Arch Linux ARM. Please search before making a new topic.

NSA320: how to manually flash UBoot 2016.09?

Postby psychokiller » Wed Apr 22, 2020 2:44 pm

While trying to flash UBoot 2016.09 on a NSA320 (and having already experienced the package install problems on a NSA325) I tried following the instructions here https://archlinuxarm.org/forum/viewtopic.php?f=53&t=8857&start=50#p48437.

So i booted a freshly installed ALARM from first sata hdd, installed uboot-tools, mtdutils and wget to download the uboot-nsa320 package. I unxz'd and untar'd the package and tried to issue a flash_erase command, but I got precisely the same error as with the installation using pacman -S uboot-nsa320:
$this->bbcode_second_pass_code('', '
flash_erase: error!: /dev/mtd0
error 13 (Permission denied)
')
So I tried removing the sata drive and boot to stock, just to realize that in stock flash_erase is missing...

What point am I missing? How can I manually flash the UBoot 2016.09 from stock linux or ALARM? Or do I have to flash it from UBoot using fatload and nand.write.e?

Thanx for any help.
psychokiller
 
Posts: 40
Joined: Tue Sep 15, 2015 5:39 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby summers » Wed Apr 22, 2020 4:53 pm

what does $this->bbcode_second_pass_code('', 'mtdinfo /dev/mtd0') say? If its that the device isn't writable, its usually becuase the wrong chip name has been given to the kernel for mtd devices. Newer kernels need to start: $this->bbcode_second_pass_code('', 'mtdparts=mtdparts=orion_nand:'), so the orion bit. This was the case on NSA325, so probably also on NSA320. You can try the change, safely I think, and see if it makes it writable ....

You can use $this->bbcode_second_pass_code('', 'dmesg | grep "Kernel command line"') to check
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby psychokiller » Wed Apr 22, 2020 6:40 pm

The commands you suggested shows this:
$this->bbcode_second_pass_code('', '
[root@alarm ~]# mtdinfo /dev/mtd0
mtd0
Name: uboot
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 8 (1048576 bytes, 1024.0 KiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 512 bytes
OOB size: 64 bytes
Character device major/minor: 90:0
Bad blocks are allowed: true
Device is writable: false
')

$this->bbcode_second_pass_code('', '
[root@alarm ~]# dmesg | grep "Kernel command line"
[ 0.000000] Kernel command line: 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/sda2 rw rootwait loglevel=8
')

So it seems it says mtdparts=nans_mtd instead of orion_nand: do I have to change the kernel command line in UBoot env or /boot/cmdline.txt in ALARM?
psychokiller
 
Posts: 40
Joined: Tue Sep 15, 2015 5:39 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby summers » Wed Apr 22, 2020 7:28 pm

So if your /boot has uEnv.txt (and uboot understands):

$this->bbcode_second_pass_code('', 'mtdparts=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)')

If your uboot doesn't yet do uEnv.txt then you have to change it via fw_setenv; so check fw_printenv for the mtdparts bits, and change nand_mdt to orion_nand

If that doesn't work, the machine I think should still boot - so you can change it back.

Orion is the name of the marvel nand driver btw, which is why the name change came about ....

I don't recall /boot/cmdline.txt - so don't recall if uboot reads that, but yes its the kernel command line you need to change ...

Oh yes, if you have access to the uart - you can just interrupt the boot, and just make the change for that single boot.
Last edited by summers on Sat Apr 25, 2020 1:04 am, edited 2 times in total.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby psychokiller » Thu Apr 23, 2020 8:59 am

Thanx to summers!

I changed all the referencesto nand_mtd in the UBoot environment to orion_nand and I was finally able to do a flash_erase from ALARM.
I now have both NSA325 and NSA320 flashed with this UBoot version:
$this->bbcode_second_pass_code('', '
U-Boot 2016.09.01-1 (Oct 10 2016 - 23:15:39 -0600) Arch Linux ARM
Zyxel NSA320
gcc (GCC) 6.2.1 20160830
GNU ld (GNU Binutils) 2.27
')
And both are able to boot from a USB key with a single partition formatted with ext2 and http://os.archlinuxarm.org/os/ArchLinuxARM-kirkwood-latest.tar.gz unpacked on it.

If I format the fs with ext4 instead, UBoot does not load anything from it... Will open a new thread for that.

Paolo
psychokiller
 
Posts: 40
Joined: Tue Sep 15, 2015 5:39 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby summers » Thu Apr 23, 2020 9:27 am

No problem. Things like this should be updated in the install script - the orion_nand has been the way its been in the kernel for many years, so the install script is just a hang over from days long past. This is a problem that has popped up quite a bit ...

So why do you have both a NSA320 and NSA325 box? Thats alot of NAS ....

Oh yes, also 2016 uboot can boot from ext4, so if you want to format the root file system as ext4 it will still work. 2016 uboot though doesn't do btrfs and the like (mine you come to that, neither does the default kernel - its needs a module for btrfs ...)

Oh you say ext4 doesn't work - odd its what I have:
$this->bbcode_second_pass_code('', 'cat /proc/mounts
...
/dev/sda1 / ext4 rw,noatime 0 0
...
')
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby psychokiller » Thu Apr 23, 2020 10:04 am

$this->bbcode_second_pass_quote('', 's')ummers wrote:
So why do you have both a NSA320 and NSA325 box? Thats alot of NAS ....

I found them on Ebay in 2019 for a few quids (around 40/50 euro each except shipping), both in great shape. I wished to upgrade a couple of Dockstars I use for few things at home and wish to have a backup so that if any device fails I have another to swap in quickly. I am actually after another NSA325 if anyone happen to have it laying around unused he/she can DM me, since NSA325 and 320 are not exactly the same and cannot be a true drop in replacement.
The final goal is to have them boot from USB and have the two drives in the sata slots to be in RAID1.
And well, I do not plan to actually use them as true NAS, but for home automation and the like...

$this->bbcode_second_pass_quote('', 's')ummers wrote:
Oh you say ext4 doesn't work - odd its what I have:


Yes, unfortunately ext4 does not work for me. I had:
- an 8gb USB key
- partitioned with parted with an msdos partition table
- created a primary partition 0%-100% to use up all the USB key space
- created an ext4 fs with mkfs.ext4 on the partition
- mounted it
- untar'ed http://os.archlinuxarm.org/os/ArchLinuxARM-kirkwood-latest.tar.gz on the mounted ext4 fs
- sync'ed all
- inserted the USB key into a rear port on the NSA320 and booted

Here follows the output from UBoot, it seems it only looks for ext2 on the USB device... I actually tried the above procedure with n ext2 fs and NSA320 boots fine. The reason I would like to use ext4 is that ext2 is far more sensititive to power outages and would corrupt far more easily needing a manual fsck upon restart (otherwise it would panic).
$this->bbcode_second_pass_code('', '
U-Boot 2016.09.01-1 (Oct 10 2016 - 23:15:39 -0600) Arch Linux ARM
Zyxel NSA320

SoC: Kirkwood 88F6281_A1
DRAM: 512 MiB
WARNING: Caches not enabled
NAND: 128 MiB
In: serial
Out: serial
Err: serial
Net: egiga0
MV88E1318 PHY initialized on egiga0
IDE: Bus 0: OK Bus 1: not available
Device 0: Model: ST2000VN000-1HJ164 Firm: SC60 Ser#: W524R1VT
Type: Hard Disk
Supports 48-bit addressing
Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
Using egiga0 device

ARP Retry count exceeded; starting again
ping failed; host 10.10.10.5 is not alive
Hit any key to stop autoboot: 0
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

Reset IDE: Bus 0: OK Bus 1: not available
Device 0: Model: ST2000VN000-1HJ164 Firm: SC60 Ser#: W524R1VT
Type: Hard Disk
Supports 48-bit addressing
Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)

USB device 0:
Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0
Type: Removable Hard Disk
Capacity: 7502.1 MB = 7.3 GB (15364416 x 512)
... is now current device
usb found on device 0
Checking for: /boot/uEnv.txt ...
Unsupported feature found (64bit, possibly metadata_csum), not mounting
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Unsupported feature found (64bit, possibly metadata_csum), not mounting
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Unsupported feature found (64bit, possibly metadata_csum), not mounting
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
No kernel found

USB device 1: unknown device

Device 0: Model: ST2000VN000-1HJ164 Firm: SC60 Ser#: W524R1VT
Type: Hard Disk
Supports 48-bit addressing
Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
... is now current device
ide found on device 0
Checking for: /boot/uEnv.txt ...
** File not found /boot/zImage **
** File not found /boot/uImage **
No kernel found

Device 1: not available
Trying to boot from NAND ...
ubi0: attaching mtd1
ubi0: scanning is finished
UBI init error 22
Error reading superblock on volume 'ubi0:rootfs' errno=-19!
ubifsmount - mount UBIFS volume

Usage:
ubifsmount <volume-name>
- mount 'volume-name' volume
NSA320>
')
psychokiller
 
Posts: 40
Joined: Tue Sep 15, 2015 5:39 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby summers » Thu Apr 23, 2020 10:16 am

Sounds vaguely familiar. You could try making the file system with
$this->bbcode_second_pass_code('', 'mkfs.ext4 -O ^metadata_csum,^64bit /dev/sdb1')
Where you change sdb into whatever your usb stick is. And in the partition table make sure its id is 83 (Linux).
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby psychokiller » Thu Apr 23, 2020 10:27 am

I googled the error message regarding the unsupported feature related to 64 bit something in ext4 and found this thread https://archlinuxarm.org/forum/viewtopic.php?f=53&t=12572.

Will try to prepare the USB key again by disabling the 64 bit feature of ext4 in the mkfs.ext4 invocation and will keep this thread updated.

Hold on for now...

Paolo
psychokiller
 
Posts: 40
Joined: Tue Sep 15, 2015 5:39 pm

Re: NSA320: how to manually flash UBoot 2016.09?

Postby psychokiller » Thu Apr 23, 2020 12:50 pm

I recreated the ext4 file system with the ^metadata_csum,^64bit options and now UBoot 2016.09-1 loves it and boot it regularly.

$this->bbcode_second_pass_quote('', 's')ummers wrote:
..odd its what I have:
$this->bbcode_second_pass_code('', 'cat /proc/mounts
...
/dev/sda1 / ext4 rw,noatime 0 0
...')

may I ask you how did you manage to set noatime option: through fstab or systemd.mount?

I actually have an empty fstab and root partition is mounted, I think, using systemd.

Would like to set noatime and nodiratime to reduce wear on USB key, but have little idea where to set it.

Thanx, Paolo.
psychokiller
 
Posts: 40
Joined: Tue Sep 15, 2015 5:39 pm
Top

Next

Return to User Questions

Who is online

Users browsing this forum: No registered users and 15 guests