Can I use linux-kirkwood-dt on NSA320 ?

This forum is for topics dealing with problems with software specifically in the ARMv5 repo.

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby boteium » Sat Feb 06, 2016 12:24 pm

Tried that. still no luck
boteium
 
Posts: 13
Joined: Sun Jan 31, 2016 3:57 am

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby summers » Sat Feb 06, 2016 1:53 pm

Was thinking about it some more on the way back from choir.

Assuming that flashing the uboot and the uboot env variables went OK (e.g. no error), then the scripting in the new uboot env variables, does a scan of disks looking for what its after. I'll grab a copy and print here. Anyway if this is the case, you should be able to write a full file system to a USB disk - and the uboot, should boot that. That makes it far easier than popping the HDD every time.

$this->bbcode_second_pass_code('', 'startboot=usb start; ide reset; for devtype in usb ide; do setenv devnum 0; while ${devtype} dev ${devnum}; do echo ${devtype} found on device ${devnum}; setenv bootpart ${devnum}:1; echo Checking for: ${bootdir}/uEnv.txt ...; if test -e ${devtype} ${bootpart} ${bootdir}/uEnv.txt; then load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/uEnv.txt; env import -t ${loadaddr} ${filesize}; echo Loaded environment from ${bootdir}/uEnv.txt; echo Checking if uenvcmd is set ...; if test -n ${uenvcmd}; then echo Running uenvcmd ...; run uenvcmd; fi; fi; if run loadimage; then if env exists root; then echo root has been defined by user; else part uuid ${devtype} ${bootpart} uuid; setenv root PARTUUID=${uuid}; fi; run mainargs; if run loadfdt; then if run loadrd; then bootz ${loadaddr} ${rdaddr}:${filesize} ${fdtaddr}; else bootz ${loadaddr} - ${fdtaddr}; fi; else if run loadrd; then echo Booting uImage with initrd; bootm ${loadaddr} ${rdaddr}:${filesize}; else bootm ${loadaddr}; fi; fi; else echo No kernel found; fi; setexpr devnum ${devnum} + 1; done; done;')

So lets unwrap that:

$this->bbcode_second_pass_code('', '
usb start;
ide reset;
for devtype in usb ide; do
setenv devnum 0;
while ${devtype} dev ${devnum}; do
echo ${devtype} found on device ${devnum};
setenv bootpart ${devnum}:1;
echo Checking for: ${bootdir}/uEnv.txt ...;
if test -e ${devtype} ${bootpart} ${bootdir}/uEnv.txt; then
load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/uEnv.txt;
env import -t ${loadaddr} ${filesize};
echo Loaded environment from ${bootdir}/uEnv.txt;
echo Checking if uenvcmd is set ...;
if test -n ${uenvcmd}; then
echo Running uenvcmd ...;
run uenvcmd;
fi;
fi;
if run loadimage; then
if env exists root; then
echo root has been defined by user;
else
part uuid ${devtype} ${bootpart} uuid;
setenv root PARTUUID=${uuid};
fi;
run mainargs;
if run loadfdt; then
if run loadrd; then
bootz ${loadaddr} ${rdaddr}:${filesize} ${fdtaddr};
else
bootz ${loadaddr} - ${fdtaddr};
fi;
else
if run loadrd; then
echo Booting uImage with initrd;
bootm ${loadaddr} ${rdaddr}:${filesize};
else
bootm ${loadaddr};
fi;
fi;
else
echo No kernel found;
fi;
setexpr devnum ${devnum} + 1;
done;
done;
')

So you can see it scanning through the disks, looking for /boot/uEnv.txt - and when it finds that updates the env variables. So that gives a way in - but should work on a usb stick. You'll need to know some of the other commands called:

$this->bbcode_second_pass_code('', 'loadfdt=echo loading ${fdtdir}/${fdtfile} ...; load ${devtype} ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}')
$this->bbcode_second_pass_code('', 'loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfilez} || load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfilem}')
$this->bbcode_second_pass_code('', 'loadrd=load ${devtype} ${bootpart} ${rdaddr} ${bootdir}/${rdfile}')
$this->bbcode_second_pass_code('', 'mainargs=setenv bootargs console=${console} ${mtdparts} root=${root} rw rootwait ${optargs} ${ncargs}')

So you can see it loading the image also from ${devtype} - so again that can be on the USB stick.

Whats relevent is:

$this->bbcode_second_pass_code('', 'bootdir=/boot')

So everything boot related must be in a the /boot directory on the relevent partition.

Does this give you enough to try? Let me know if you need more, and I can grab the settings off my NSA325.

Hope this helps,

David.

P.S. Oh yes - reason I know all this - is becuase I did exactly what you did, though I'd bricked my machine - but did manage to get it back to life (and without using a uart). So there is hope.
P.P.S. Does make me feel a bit bad though, that I never completed the code in the script to get the boot partuuid set correctly. I'll work on that now.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby summers » Sat Feb 06, 2016 3:17 pm

And as I've written the code now. Think this is the robust version of setting the uEnv.txt file.

$this->bbcode_second_pass_code('', '
rootfs=`mount | sed -n 's/^\([^ ]*\).* \/ .*/\1/p'`
rootuuid=`blkid $rootfs | sed -n 's/^.*\(PARTUUID=\)\"\(.*\)\"$/\1\2/p'`
echo root=${rootuuid} > /boot/uEnv.txt
')

It removes the quotes from the PARTUUID, and I'm not 100% if that is correct.

I'm also a tad concerned, that although this command works on ARM-ARCH, it isn't working on my desktop ARCH. Seems that the blkid command works differently. On desktop to need to access $this->bbcode_second_pass_code('', 'ls -l /dev/disk/by-uuid'). Now the blkid should work on all machines, so I need to understand the command a bit more.

moonman/WarheadsSE: can we think a bit more about posting a script like this? Its just far to common people bricking kirkwood devices when upgrading uboot.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby hamal » Sat Feb 06, 2016 4:04 pm

I didn't execute the script directly.
I read it and excuted each command manually.
So, I made 2 changes.
A. nsa325 was changed to nsa320.
B. I didn't remove the /boot partition and fstab.
instead, I edit uEnv.txt and rsync to /.
So, Both sda1 and sda2 have /boot with the correct uEnv.txt, uboot, and dt kernel.

I also remove the second hard drive and usb key.
The only hard drive plugged in (left slot) with arch system on it is a 3tb drive with hybrid mbr.
I guess uboot was properly installed. Because the blue and green leds light up when booting.
the fan spin up crazy (noisy) and become quiter after a while, just like before.
but since the only fw_env I changed after flash the uboot was mac addr and forget to set netconsole up.
I guess I would need to get a usb serial cable.

edit:
I am with my family now. there was a big earthquake in the neighborhood. We are all okay. I would try usb boot tomorrow when get home.
hamal
 
Posts: 15
Joined: Wed Jun 06, 2012 2:35 pm

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby summers » Sat Feb 06, 2016 10:56 pm

Ah - assuming that you created /boot in both sda1 and sda2 - that may be your problem (usually if one of sda1/2 was your boot partition, the files in that one would be in /). From what I recall where it finds /boot does that become the root partition if root env variable isn't set properly? Hmm doesn't make total sense.

[edit - just checked root isn't set in the default env varables, but is read when the image is parsed - as set in bootargs. So yes looks like you need a valid root set in a uEnv.txt file]
[reedit - what hogwash I posted - if root isn't set, then the script sets it to the same directory as it run loadimage; worked in ...]

Anyway I may be tempted to clear out the sda1/2 that isn't the root partition. On my set up, I ended up totally removing the old boot partition, and reformating the hdd - so that / had all the avaiable file space. Useful for me as my original / was only 1G ... reformatting like this can only be done if you pull, the hdd - so I killed two birds with one stone.

Anyway at least you can try the usb stick, with a full root partition on it. e.g. format as ext4 covering the whole usb, and just extract a arm arch root on it ....

Oh yes did you include /boot/dtbs/kirkwood-nsa320.dt in the boot directory? Need the device tree ...

Oh yes - hope you are all OK after the earthquake.
Last edited by summers on Tue Feb 09, 2016 6:50 pm, edited 2 times in total.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby boteium » Sun Feb 07, 2016 4:56 pm

Okay, it boots now !!

Re-creating usb with correct partuuid in uEnv doesn't just work.
I finally got it work by using /dev/sda1 in uEnv and commenting out EVERYTHING in fstab.
I'm sure I have the correct uuid in fstab. Don't know why it stuck.

Anyway, Thanks everyone of you.
Arch community is the best. <3

Edit:
Maybe the key is GPT ? Can uboot read Hybrid MBR ?

Edit2:
The PARTUUID of my 3T drive is way longer than usual.
boteium
 
Posts: 13
Joined: Sun Jan 31, 2016 3:57 am

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby boteium » Sun Feb 07, 2016 6:00 pm

I can now use PARTUUID in uEnv.txt after usb drive converted to GPT.
Not gonna format the hard drive though.
But I guess uboot doesn't like Hybrid MBR.
boteium
 
Posts: 13
Joined: Sun Jan 31, 2016 3:57 am

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby summers » Mon Feb 08, 2016 9:53 am

Glad you managed to get it to come up.

Think the issue that often comes up with PARTUUID, is this is the UUID of the partition. So its a way of point to the partition through the partition table. Usually UUID is the id of the actualy filesystem in the partition (be that ext4,vfat etc). So the PARTUUID is independent of whats in the parition (ext4,vfat etc).

[s]Think this constraint comes from the linux kernel (IIRC), it recognises PARTUUID, but not the other UUIDs or something.[/s]
Just checked, linux kernel seems to cope with almost any root= definition. So not sure where the PARTUUID constraint comes from. Maybe uboot ...

*only* way I know of getting it is via the blkid program, or the /dev/disks-by-uuid (or somin) filesystem.

Anyway with the hybrid partition table - do let the comunity know what you discover. As far as I know, you are threading new land now - so learning what the issues are.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby hamal » Mon Feb 08, 2016 10:53 am

Summary :

doesn't work:
MBR and PARTUUID (usb drive)
Hybrid MBR and PARTUUID (hard drive)
Hybrid MBR and /dev/sdX (hard drive)

works:
MBR with /dev/sda (usb drive)
GPT with PARTUUID (uab drive)
hamal
 
Posts: 15
Joined: Wed Jun 06, 2012 2:35 pm

Re: Can I use linux-kirkwood-dt on NSA320 ?

Postby summers » Mon Feb 08, 2016 1:39 pm

Whats strange is on my NSA325 I'm HDD MBR (dos) + PARTUID, and that boots fine.

PARTUUID = disk UUID + "-" + two digit part number.

So fidks shows the Disk identifier as :

Disk identifier: 0x94a2dc27

Root is /dev/sda1 and has id:

PARTUUID="94a2dc27-01"

And this boots fine. So still something odd going on.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

PreviousNext

Return to ARMv5

Who is online

Users browsing this forum: No registered users and 7 guests