Can't flash u-boot on NSA 325 from arch - permission denied

Discussion about U-Boot and the kernel.

Can't flash u-boot on NSA 325 from arch - permission denied

Postby dtralara » Tue Jul 14, 2020 3:17 pm

After trying (and failing) to install arch on my NSA325 version 2 with a new 4T HDD, I wanted to upgrade u-boot from the default one.

Code: Select all
Marvell>> version
U-Boot 1.1.4 (Jul 18 2013 - 10:47:29) Marvell version: 3.5.9


I try to follow these instruction https://forum.doozan.com/read.php?3,12381 but I have permission problems for /dev/mtd devices even logged as root.

Code: Select all
# flash_erase /dev/mtd0 0 4
flash_erase: error!: /dev/mtd0
             error 13 (Permission denied)
# nandwrite /dev/mtd0 uboot.2017.07-tld-1.nsa325.mtd0.kwb
nandwrite: error!: /dev/mtd0
           error 13 (Permission denied)

Is there's a way to change permission for these device files on my current linux system?

Is there another way to flash the uboot, that doesn't rely on a usb (since uboot doesn't seem to detect usb - at least during my numerous failed attempts to install arch)?

PS: Printing the "firmware environment variables" in the u-boot return this. Is there anything wrong here.

Code: Select all
Marvell>> printenv
bootdelay=2
baudrate=115200
loads_echo=0
ipaddr=10.4.52.165
serverip=10.4.52.7
rootpath=/srv/ubuntu
netmask=255.255.255.0
nandEcc=1bit
MODEL_ID=AE03
PRODUCT_NAME=NSA-325v2
FEATURE_BIT=00
CONTRY_TYPE=FF
VENDOR_NAME=MitraStar Technology Corp.
run_diag=yes
ethaddr=10:7B:EF:88:07:6B
console=console=ttyS0,115200 mtdparts=nand_mtd:0xc0000@0(uboot)ro,0x7f00000@0x100000(root)
ethprime=egiga0
bootargs_root=root=/dev/nfs rw
bootargs_end=:::orion:eth0:none
image_name=uImage
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
lcd0_enable=0
lcd0_params=640x480-16@60
ethmtu=1500
mvPhoneConfig=mv_phone_config=dev[0]:fxs,dev[1]:fxo
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
usb0Mode=host
yuk_ethaddr=00:00:00:EE:51:81
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
image_multi=yes
ethact=egiga0
arcNumber=4495
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
bootargs_linux=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
bootcmd_linux=setenv bootargs $(bootargs_linux); ide reset; ext2load ide 0:1 $(loadaddr) /uImage; bootm $(loadaddr)
bootcmd_stock=setenv bootargs $(bootargs_stock); nand read.e $(loadaddr) $(kernel_addr) 0xA00000; bootm $(loadadr)
to_stock=setenv mainlineLinux no; setenv bootcmd \'run bootcmd_stock\'; saveenv; reset
to_linux=setenv mainlineLinux yes; setenv bootcmd \'run bootcmd_linux\'; saveenv; reset
bootcmd='run bootcmd_linux'
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=yes
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
netbsd_en=no
vxworks_en=no
disaMvPnp=no
enaAutoRecovery=yes
kernel_addr=0xc80000
pcieTune=no
pcieTune1=no
bootargs=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

Environment size: 2439/131068 bytes

dtralara
 
Posts: 11
Joined: Wed Apr 15, 2020 2:27 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby summers » Tue Jul 14, 2020 4:07 pm

IIRC thats becuase when passed the mtd partitions to the linux command line, you passed the wrong name. This changed several years ago, IIRC you need something like orion_nand ... I dig some more when I get home, and see what I have on my NSA325 ...

Ah yes - try this old post: https://archlinuxarm.org/forum/viewtopic.php?f=9&t=14424&p=63494
summers
 
Posts: 833
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby dtralara » Tue Jul 14, 2020 6:09 pm

Thank you.

I fail to modify the kernel arguments

From linux, I can't seem to find relevant options for fw_setenv
Code: Select all
# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=run distro_bootcmd
bootdelay=2
baudrate=115200
arch=sandbox
cpu=sandbox
board=sandbox
board_name=sandbox
stdin=serial,cros-ec-keyb,usbkbd
stdout=serial,vidconsole
stderr=serial,vidconsole
ethaddr=00:00:11:22:33:44
eth1addr=00:00:11:22:33:45
eth3addr=00:00:11:22:33:46
eth5addr=00:00:11:22:33:47
ipaddr=1.2.3.4
bootm_size=0x10000000
kernel_addr_r=0x1000000
fdt_addr_r=0xc00000
ramdisk_addr_r=0x2000000
scriptaddr=0x1000
pxefile_addr_r=0x2000


I found something from the u-boot prompt, I tried to modify this
Code: Select all
setenv bootargs=console=ttyS0,115200 mtdparts=orion_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


But it doesn't seem to have an effect:
Code: Select all
mtdinfo /dev/mtd0
libmtd: error!: cannot open "/dev/mtd0"
        error 13 (Permission denied)
libmtd: error!: cannot open "/dev/mtd0"
        error 13 (Permission denied)
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


What I'm missing?
dtralara
 
Posts: 11
Joined: Wed Apr 15, 2020 2:27 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby summers » Tue Jul 14, 2020 7:06 pm

need to use
Code: Select all
mtdparts=mtdparts=orion_nand:


Rather than
Code: Select all
mtdparts=orion_mtd:
summers
 
Posts: 833
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby dtralara » Tue Jul 14, 2020 8:24 pm

I'm still confused, I can't make it work for some reason.

I interrupt boot and get the Marvell u-boot prompt, sett all the variables mentioning mtd, and then run the boot sequence.

Code: Select all
Marvell>> setenv bootargs=console=ttyS0,115200 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) root=/dev/sda2 rw rootwait loglevel=8                                                                                             

Marvell>> setenv bootargs_stock=console=ttyS0,115200 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) root=/dev/nfs rw init=/init

Marvell>> setenv bootargs_linux=console=ttyS0,115200 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) root=/dev/sda2 rw rootwait loglevel=8

Marvell>> setenv console=console=ttyS0,115200 mtdparts=mtdparts=orion_nand:0xc0000@0(uboot)ro,0x7f00000@0x100000(root)

Marvell>> boot




Although the kernel seems to pass

Code: Select all
dmesg | grep "Kernel command line"
[    0.000000] Kernel command line: console=ttyS0,115200=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) root=/dev/sda2 rw rootwait loglevel=8



I still have the permission problem...
Code: Select all
mtdinfo /dev/mtd0                                                                                    ⏎
libmtd: error!: cannot open "/dev/mtd0"
        error 13 (Permission denied)
libmtd: error!: cannot open "/dev/mtd0"
        error 13 (Permission denied)
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
dtralara
 
Posts: 11
Joined: Wed Apr 15, 2020 2:27 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby summers » Wed Jul 15, 2020 5:18 am

Ah you are setting it in bootargs, trick is in the line passed to the kernel you just need the mtdparts=orion_nand bit. In the usual set up that is expanded from the env variable mtdparts. So what's usual is that the variable mtdparts is set to mtdparts=orion_nand...

Let me read your environment variables more carefully. You can always check what has been passed in dmesg ...

As you are writing direct into bootargs, then I think you want.

Code: Select all
setenv bootargs_linux=console=ttyS0,115200 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) root=/dev/sda2 rw rootwait loglevel=8


The the bootcmd will copy that into bootargs.
summers
 
Posts: 833
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby dtralara » Wed Jul 15, 2020 11:34 am

Frustrating.
The kernel option seems to be passed correctly.

Code: Select all
dmesg | grep boot
[    0.000000] Kernel command line: console=ttyS0,115200=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) root=/dev/sda2 rw rootwait loglevel=8
[    7.267100] 0x000000000000-0x000000100000 : "uboot"
[    7.272401] 0x000000100000-0x000000180000 : "uboot_env"


Isn't it the case?

But I still have the same privilege problem

Code: Select all
Device is writable:             false


Is this supposed to happen with this linux kernel?

Code: Select all
Linux alarm 4.4.227-1-ARCH #1 PREEMPT Sat Jun 13 04:13:48 UTC 2020 armv5tel GNU/Linux


Sorry and thanks for your patience.
dtralara
 
Posts: 11
Joined: Wed Apr 15, 2020 2:27 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby summers » Wed Jul 15, 2020 11:56 am

problem is you have
Code: Select all
console=ttyS0,115200=mtdparts=orion_nand:
when what you need is
Code: Select all
console=ttyS0,115200 mtdparts=orion_nand:
- so need to remove the extra "=" ...
summers
 
Posts: 833
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can't flash u-boot on NSA 325 from arch - permission den

Postby dtralara » Wed Jul 15, 2020 2:16 pm

Thanks.
The correct setenv call was this one

Code: Select all
setenv bootargs_linux console=ttyS0,115200  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) root=/dev/sda2 rw rootwait loglevel=8


And then it worked
Code: Select all
#flash_erase /dev/mtd0 0 4
Erasing 128 Kibyte @ 60000 -- 100 % complete
# nandwrite /dev/mtd0 uboot.2017.07-tld-1.nsa325.mtd0.kwb
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


Code: Select all
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
*** Warning - bad CRC, using default environment


Thanks again.
dtralara
 
Posts: 11
Joined: Wed Apr 15, 2020 2:27 pm


Return to U-Boot/Kernel

Who is online

Users browsing this forum: No registered users and 2 guests

cron