Welcome! Log In Create A New Profile

Advanced

Kirkwood U-Boot and Debian Installer Script (WORK-IN-PROGRESS)

Posted by bodhi 
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
July 31, 2016 01:15PM
Good. This will avoid the step of switching to SSH everytime.
̶d̶̶o̶̶ ̶̶y̶̶o̶̶u̶̶ ̶̶k̶̶n̶̶o̶̶w̶̶ ̶̶h̶̶o̶̶w̶̶ ̶̶i̶̶ ̶̶c̶̶o̶̶u̶̶l̶̶d̶̶ ̶̶m̶̶a̶̶k̶̶e̶̶ ̶̶s̶̶e̶̶r̶̶i̶̶a̶̶l̶̶ ̶̶a̶̶c̶̶c̶̶e̶̶s̶̶s̶̶ ̶̶w̶̶o̶̶r̶̶k̶̶ ̶̶w̶̶i̶̶t̶̶h̶̶o̶̶u̶̶t̶̶ ̶̶s̶̶u̶̶p̶̶e̶̶r̶̶ ̶̶u̶̶s̶̶e̶̶r̶̶?̶̶ ̶̶i̶̶ ̶̶a̶̶l̶̶r̶̶e̶̶a̶̶d̶̶y̶̶ ̶̶a̶̶d̶̶d̶̶e̶̶d̶̶ ̶̶m̶̶y̶̶ ̶̶u̶̶s̶̶e̶̶r̶̶n̶̶a̶̶m̶̶e̶̶ ̶̶t̶̶o̶̶ ̶̶d̶̶i̶̶a̶̶l̶̶o̶̶u̶̶t̶̶ ̶̶g̶̶r̶̶o̶̶u̶̶p̶̶,̶̶ ̶̶b̶̶u̶̶t̶̶ ̶̶t̶̶h̶̶i̶̶s̶̶ ̶̶d̶̶i̶̶d̶̶n̶'̶t̶̶ ̶̶h̶̶e̶̶l̶̶p̶̶.̶ Nevermind. I just had to change owner of /dev/ttyUSB0.



Edited 2 time(s). Last edit at 07/31/2016 01:20PM by ElMariachi.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 02:01AM
ElMariachi Wrote:
-------------------------------------------------------
>
> Failing with:
>
> Full log is attached.

Thanks for the testing, we should be nearly done. One last thing that can fail is left.

That command is trying to change a tool's config file in the firmware but I disabled all "switch firmware to read-write" functions because I don't want my script to make any changes in stock firmware.

Will have to make a chroot (disguise the tools folder as the root folder) to have our tool find our config so it can work, for now I move that file in a folder we can write into.

Can you test again the one attached here?
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 02:05AM
bodhi Wrote:
-------------------------------------------------------
> Don't use screen. Install picocom and use that.
> Screen is the worst to use with serial
> console.

Konsole (KDE's terminal) allows me to scrollback "infinite" lines from "screen" as it makes a temporary file. It's the only terminal application I know that offers this.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 02:44AM
Here we go: (actually I would have expected this script to take way longer for being done.)

100%[======================================>] 46          --.-K/s   in 0s      

2000-01-01 00:01:08 (5.53 MB/s) - `/tmp/tools/fw_printenv.md5' saved [46/46]

--2000-01-01 00:01:08--  https://dl.dropboxusercontent.com/u/47541136/linux/tools_for_Kirkwood_installer/fw_printenv
Resolving dl.dropboxusercontent.com... 45.58.69.69
Connecting to dl.dropboxusercontent.com|45.58.69.69|:443... connected.
WARNING: cannot verify dl.dropboxusercontent.com's certificate, issued by `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certs.godaddy.com/repository//CN=Go Daddy Secure Certificate Authority - G2':
  Self-signed certificate encountered.
HTTP request sent, awaiting response... 200 OK
Length: 668497 (653K) [text/plain]
Saving to: `/tmp/tools/fw_printenv'

100%[======================================>] 668,497      633K/s   in 1.0s    

2000-01-01 00:01:10 (633 KB/s) - `/tmp/tools/fw_printenv' saved [668497/668497]

verify file /tmp/tools/fw_printenv with md5 /tmp/tools/fw_printenv.md5
7d28314b0d2737094e57632a6fe43bbe
7d28314b0d2737094e57632a6fe43bbe
passed
# Successfully installed /tmp/tools/fw_printenv.
# checking for /tmp/tools/etc/fw_env.config...

# Installing /tmp/tools/etc/fw_env.config...
/tmp/tools/etc/fw_env.config
https://dl.dropboxusercontent.com/u/47541136/linux/tools_for_Kirkwood_installer/fw_env.config
https://dl.dropboxusercontent.com/u/47541136/linux/tools_for_Kirkwood_installer/fw_env.config.md5
/tmp/tools/etc/fw_env.config.md5
/tmp/tools/etc/fw_env.config.md5: No such file or directory
/tmp/tools/etc/fw_env.config.md5: No such file or directory
## Could not install /tmp/tools/etc/fw_env.config from https://dl.dropboxusercontent.com/u/47541136/linux/tools_for_Kirkwood_installer/fw_env.config, exiting.
-sh-3.2# ~

Btw:
Could you please point me to the easiest way for making a full backup of stock bootloader + firmware + env (everything) and restoring this data to another GoFlexNet device before converting it? So I could revert if needed. Could I actually flash the same backup data of the GFN I'm currently using on another GoFlexNet either? Because I got to give away the one I am currently fiddling on, but I have an older one for myself, but that one already an old version modified bootloader and rescue system on it.
Thanks :)



Edited 3 time(s). Last edit at 08/01/2016 02:50AM by ElMariachi.
Attachments:
open | download - 01.txt (46.1 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 03:04AM
> Could you please point me to the easiest way for
> making a full backup of stock bootloader +
> firmware + env (everything) and restoring this
> data to another GoFlexNet device before converting
> it?

Wiki - Debian on ARM Topics and Tutorials

Quote

Booting Debian on Pogoplug

How to set up U-Boot for booting in multiple drives configuration
Backup and Restore NAND mtds
UART Booting HowTo for Selected Kirkwood Devices
Migrating from Arch to Debian?
How to boot new Debian rootfs using stock u-boot tftp

BTW, the only NAND area that's going to be written over is mtd0 where u-boot is. So stock FW rootfs will not be touched.

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 08/01/2016 03:06AM by bodhi.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 03:12AM
bobafetthotmail,

> Will have to make a chroot

I'm not sure I understand why would we need to chroot? the tools are static, and the only thing need to be written to / is /etc/fw_env.config?

One more thing I forgot to mention: we need to check if the user is root and bail out if s/he is not root.

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 08/01/2016 03:16AM by bodhi.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 03:29AM
ElMariachi Wrote:
-------------------------------------------------------
> Here we go: (actually I would have expected this
> script to take way longer for being done.)

Argh, I should not cowboy-code when I'm at work (forgot to add the code to make the new folder). Can you try again with this?



Edited 1 time(s). Last edit at 08/01/2016 03:30AM by bobafetthotmail.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 03:46AM
bodhi Wrote:
-------------------------------------------------------
> bobafetthotmail,
>
> > Will have to make a chroot
>
> I'm not sure I understand why would we need to
> chroot? the tools are static, and the only thing
> need to be written to / is /etc/fw_env.config?

Yes, that config must be written to /etc/fw_env.config but I don't want have to deal with the firmware.
I don't want to have to care about specific firmware configurations in a multi-device installer system like this as I'd likely have to add hacks for many devices and any firmware update may make this a failure point.

Besides, we don't really need to change it at all as the stock firmware cannot be booted from new uboot anyway.

With a tiny chroot the tool will think that $TOOLS/etc/fw_env.config is /etc/fw_env.config, and everything will be fine regardless of how the firmware actually is. Theoretically.

The current busybox has chroot command already, I'll make some tests this evening.

It's not complicating my work nor annoying as asking people to do it by hand in a tutorial.
The script is executed by a machine after all, let's leverage this.

It's more annoying when a firmware change/difference breaks my script out of the blue and I have to troubleshoot stuff over a forum in inappropriate moments.

Btw, also the original script from jeff also had a large amount of code dealing with making a chroot to install debian from scratch, that I have removed. (for now at least)

> One more thing I forgot to mention: we need to
> check if the user is root and bail out if s/he is
> not root.

A good point. I've not seen devices that give you non-root shells but that's a possibility.



Edited 3 time(s). Last edit at 08/01/2016 04:53AM by bobafetthotmail.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 05:50AM
2000-01-01 00:01:18 (34.1 MB/s) - `/tmp/tools/etc/fw_env.config' saved [329/329]

verify file /tmp/tools/etc/fw_env.config with m[   78.990000] end_request: I/O error, dev mtdblock0, sector 0
[   78.990000] Buffer I/O error on device mtdblock0, logical block 0
d5 /tmp/tools/et[   79.000000] end_request: I/O error, dev mtdblock0, sector 8
[   79.000000] Buffer I/O error on device mtdblock0, logical block 1
c/fw_env.config.[   79.010000] end_request: I/O error, dev mtdblock0, sector 16
[   79.010000] Buffer I/O error on device mtdblock0, logical block 2
md5
2794ab37f51[   79.020000] end_request: I/O error, dev mtdblock0, sector 24
[   79.020000] Buffer I/O error on device mtdblock0, logical block 3
ef51ca840b4f6cab1a08d
2794ab37f51ef51ca840b4f6c[   79.030000] end_request: I/O error, dev mtdblock0, sector 0
[   79.030000] Buffer I/O error on device mtdblock0, logical block 0
ab1a08d
passed
# Successfully installed /tmp/tools/etc/fw_env.config.
no disks detected, exiting now
-sh-3.2#

Looking fine, without an HDD attached. I know the script doesn't change nvram, yet, but does it already write to the HDD? I'd have to cleanup a drive then.

And would you prefer USB oder SATA storage?

Edit1:
I decided to kill my already existing Debian installation, plugged the Transcend SSD and rebooted.
The script doesn't recognize the SATA drive, yet:
100%[======================================>] 329         --.-K/s   in 0s      

2000-01-01 00:01:59 (32.5 MB/s) - `/tmp/tools/etc/fw_env.config' saved [329/329]

verify file /tmp/tools/etc/fw_env.config with md5 /tmp/tools/etc/fw_env.config.md5
2794ab37f51ef51ca840b4f6cab1a08d
2794ab37f51ef51ca840b4f6cab1a08d
passed
# Successfully installed /tmp/tools/etc/fw_env.config.
[  120.520000] end_request: I/O error, dev mtdblock0, sector 0
[  120.520000] Buffer I/O error on device mtdblock0, logical block 0
[  120.530000] end_request: I/O error, dev mtdblock0, sector 8
[  120.530000] Buffer I/O error on device mtdblock0, logical block 1
[  120.540000] end_request: I/O error, dev mtdblock0, sector 16
[  120.540000] Buffer I/O error on device mtdblock0, logical block 2
[  120.550000] end_request: I/O error, dev mtdblock0, sector 24
[  120.550000] Buffer I/O error on device mtdblock0, logical block 3
[  120.560000] end_request: I/O error, dev mtdblock0, sector 0
[  120.560000] Buffer I/O error on device mtdblock0, logical block 0
no disks detected, exiting now
-sh-3.2#

Edit2:
Attached a log using an unpartitioned USB storage (actually just an microSD card in an USB-SD-card reader as I got no USB flash drive left).

Using this USB drive, the script cancels with:
40% [==============>                        ] 58,604,763  1022K/s   in 57s     


Cannot write to `/tmp/rootfs/Debian-4.4.0-kirkwood-tld-1-rootfs-bodhi.tar.bz2' (No such file or directory).
verify file /tmp/rootfs/Debian-4.4.0-kirkwood-tld-1-rootfs-bodhi.tar.bz2 with md5 /tmp/rootfs/Debian-4.4.0-kirkwood-tld-1-rootfs-bodhi.tar.bz2.md5
9f957e1dc5a36f90a285ab4615cb02fd
d504625466587ff351f8722af3753914
failed
---extracting debian rootfs to install Debian
bunzip2: short write
tar: can't open 'Debian-4.4.0-kirkwood-tld-1-rootfs-bodhi.tar': No such file or directory
rm: can't remove 'Debian-4.4.0-kirkwood-tld-1-rootfs-bodhi.tar': No such file or directory
root files not extracted correctly! Aborting!
-sh-3.2#
I first thought the sd card couldn't take this punishment, but I tried it multiple times. The rootfs download always breaks at 40%. I checked and saw that /tmp is full:
-sh-3.2# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/mtdblock2           32.0M     15.3M     16.7M  48% /
none                     61.6M     61.5M      4.0k 100% /tmp
-sh-3.2#

Notes:
-The "what drive you want to install Debian in" selection is kind of messed up.
-the script paused at
 partition to mount is /dev/sda1 
, waiting for a keypress, without telling me so



Edited 12 time(s). Last edit at 08/01/2016 06:54AM by ElMariachi.
Attachments:
open | download - 01.txt (49 KB)
open | download - usb.txt (62.2 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 07:03AM
I'd like to note that all that

[  120.520000] end_request: I/O error, dev mtdblock0, sector 0
[  120.520000] Buffer I/O error on device mtdblock0, logical block 0

is not caused by my script trying to write anything, it's probably caused by the fdisk -l command I use to scan for disks.

ElMariachi Wrote:
-------------------------------------------------------
> The script doesn't recognize the drive, yet:

The new script attached should print the attached drive info (that is used by the script to figure out what is a disk) before quitting.
If you give me the full log of another run with that SSD I'll try to figure out why it is not detected.

It should have detected all drives that were connected at boot, hotplugging Sata isn't working well on Kirkwoods.

>I got to mention that at one time the installation pauses at
Yes, it was there for my own debugging mostly. It's now a 5 second wait.

> So do you think the sd card can't take this
> punishment?

no, my mistake again.
It's unbelievable, I have tested this on my devices and there it worked fine even with this mistake in it. :/

Yet another script. Sorry for the inconvenience.
Please run one on USB and one on Sata, if possible.



Edited 2 time(s). Last edit at 08/01/2016 07:05AM by bobafetthotmail.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 07:14AM
It's no problem. :)

I started the GFN with both drives plugged in this time.

Seems like a little regression:
100%[======================================>] 329         --.-K/s   in 0s      

2000-01-01 00:01:34 (32.6 MB/s) - `/tmp/tools/etc/fw_env.config' saved [329/329]

verify file /tmp/tools/etc/fw_env.config with md5 /tmp/tools/etc/fw_env.config.md5
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 119: cat: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 119: cut: command not found

./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 123: md5sum: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 123: cut: command not found

passed
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 192: rm: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 242: chmod: command not found
# Successfully installed /tmp/tools/etc/fw_env.config.
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 782: fdisk: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 786: fdisk: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 786: grep: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 786: grep: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 786: awk: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 786: awk: command not found
./file.php?3,file=953,filename=kirkwood-installer-fix5.sh: line 786: sed: command not found
no disks detected, exiting now
-sh-3.2#

Btw:
I first didn't read the title exactly and thought that the script would also install a rescue system(That's why I though of backin up all mtds). But of course that's not of priority now and an option for later. Also I would like to remind you, to maybe 'individualize' the system in the end. Honestly I don't exactly remember what this was about, but I read it here in forum and it must have been something like creating an own system certificate, SSH key or such.. :)



Edited 3 time(s). Last edit at 08/01/2016 07:19AM by ElMariachi.
Attachments:
open | download - bothdrives.txt (54.7 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 11:07AM
bobafetthotmail,

> It's more annoying when a firmware
> change/difference breaks my script out of the blue
> and I have to troubleshoot stuff over a forum in
> inappropriate moments.

We are not in any hurry for a deadline :)

> Btw, also the original script from jeff also had a
> large amount of code dealing with making a chroot
> to install debian from scratch, that I have
> removed. (for now at least)

One thing I hate to do is design-by-committee. So I will wait until you think it is ready, and review it.

There is one point I feel should make: the script should stay as simple as what Jeff's orginal version, as much as possible. I know we try to improve things, but I can't imagine that will be much more complicate than that script.

Stock OS does not use fw_env.config so it is OK to write it to the root. But I see your point of not touching FW. Just a reminder not to add many more moving parts that could break.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 11:15AM
Got home and did some testing on my side too, I screwed up the setup of the toolbox and the script was using system's tools, so the behaviour was erratic.
:/

Now it properly uses the toolbox (as it can no more fallback on system tools as you see in the errors above), and I found and fixed other things too, probably also the sata issue.

I also wrote a chroot function and here works fine, it's the "02" option.
It will first do a fw_printenv using the system's tool (so will print your envs)
Then it will do a fw_printenv from inside the chroot so it will use our config file, and in your case this should error out as you don't have uboot envs in that place.

can you please test 01 with both Sata and USB and 02 (once)?

>I first didn't read the title exactly and thought that the script would also install a rescue system
The current goal is just installing Debian and uboot without fuss on the longish list of supported kirkwood boxes, as the tutorial is a bit long and scares off people.
Bodhi's modern uboot is fire-and-forget, as long as you plug a storage device with first partition labeled "rootfs" and all files inside in the right place it will boot Debian from it automatically (also works with a RAID, if you follow my tutorial from the forum's "wiki" in bodhi's signature).
As long as you have access to a Linux PC you can prepare another rootfs device with it.

To install a proper rescue system we need a rescue system for all (most) boxes first. The current one based on emdebian is relatively limited, pretty large for the embedded storage size, and works for some devices only (pogoplugs I think).

The very long-term goal (mine) is to have the script also install pre-made OpenWRT/LEDE firmware as a fallback. OpenWRT/LEDE is a third party opensource linux distro targeting embedded devices, it is mostly known for routers, it currently supports some of the kirkwood boxes, but far from all.
Being targeted at devices with 8-16 MB of storage, it's very light and allows me to fit more or less everything you ever need (also webinterface and all) in the 256MB or so that most Kirkwood boxes have.
From my limited testing with my Zyxel NSA310, it's just a matter of adding to their project the settings for making the firmware images for each box in the right way with stuff they have already, and that's what I'd like to do next.
But I'm not a hardcore developer so it's not going to be fast.

>Also I would like to remind you, to maybe 'individualize' the system in the end. Honestly I don't exactly remember what this was about, but I read it here in forum and it must have been something like creating an own system certificate, SSH key or such.. :)

Yeah I know, it's at the end of bodhi's tutorial I think. This has to be done by something else I think, even if I can chroot into the rootfs, the kernel in the stock firmware is too old to run the new programs in it.

That's a task for another simpler post-install script, also for setting buttons and lights and so on.



Edited 4 time(s). Last edit at 08/01/2016 03:50PM by bobafetthotmail.
Attachments:
open | download - kirkwood-installer-6.sh (39 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 11:49AM
bodhi Wrote:
-------------------------------------------------------
> One thing I hate to do is design-by-committee. So
> I will wait until you think it is ready, and
> review it.

Well, I agree on it but I'll also say that I don't like to work on things in my free time then being told you don't want it made like that or that you use things you don't like just to not offend me or something.
So yeah, maybe not very in depth, but having some feedback from you would be nice.
It is already structured as it would be in its final form, more or less.

> There is one point I feel should make: the script
> should stay as simple as what Jeff's orginal
> version, as much as possible. I know we try to
> improve things, but I can't imagine that will be
> much more complicate than that script.

Main difference is that I'm enclosing more stuff in functions as it makes the whole thing more tidy and easier to read.
It may be a habit or personal style.

> Stock OS does not use fw_env.config so it is OK to
> write it to the root. But I see your point of not
> touching FW.

Zyxel firmwares do use that afaik, others may too.

> Just a reminder not to add many more
> moving parts that could break.

The point of using our own static toolbox was that I could take advantage of decent tools so I could do relatively advanced things without fear of issues.
That chroot trick is one of them, but I'm fine with dropping it if there are better options.
If you have a better idea to avoid writing to / while still using fw_printenv/setenv (recompile a hacked fw_printenv hardcoded to look where we need it to look without having a config anywhere?), I'm all ears.



Edited 1 time(s). Last edit at 08/01/2016 04:15PM by bobafetthotmail.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 01, 2016 10:51PM
bobafetthotmail,

> Well, I agree on it but I'll also say that I don't
> like to work on things in my free time then being
> told you don't want it made like that or that you
> use things you don't like just to not offend me or
> something.
> So yeah, maybe not very in depth, but having some
> feedback from you would be nice.
> It is already structured as it would be in its
> final form, more or less.

Understood :) I've been a little bit too busy so willl try to review it and and test on a couple of my spare boxes (GFNet/Home) before the weekend is over.

> Main difference is that I'm enclosing more stuff
> in functions as it makes the whole thing more tidy
> and easier to read.
> It may be a habit or personal style.

It's great.

> That chroot trick is one of them, but I'm fine
> with dropping it if there are better options.
> If you have a better idea to avoid writing to /
> while still using fw_printenv/setenv (recompile a
> hacked fw_printenv hardcoded to look where we need
> it to look without having a config anywhere?), I'm
> all ears.

I think that's the only way. If we don't chroot, we have to write to / to use fw_printenv/setenv after flashing envs image at 0xc00000. So I think chroot is cool to avoid messing with stock /.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 12:51AM
There still is the same problem with 01:
Saving to: `/tmp/tools/etc/fw_env.config'

100%[======================================>] 329         --.-K/s   in 0s      

2000-01-01 00:02:10 (34.7 MB/s) - `/tmp/tools/etc/fw_env.config' saved [329/329]

verify file /tmp/tools/etc/fw_env.config with md5 /tmp/tools/etc/fw_env.config.md5
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 122: cat: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 122: cut: command not found

./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 126: md5sum: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 126: cut: command not found

passed
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 195: rm: command not found
 chmodding 644  --  /tmp/tools/etc/fw_env.config
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 246: chmod: command not found
# Successfully installed /tmp/tools/etc/fw_env.config.
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 789: fdisk: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 793: fdisk: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 793: grep: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 793: grep: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 793: sed: command not found
no disks detected, exiting now
-sh-3.2# ls /dev/sd*
/dev/sda    /dev/sda5   /dev/sdb14  /dev/sdc1   /dev/sdc6   /dev/sdd15
/dev/sda1   /dev/sda6   /dev/sdb15  /dev/sdc10  /dev/sdc7   /dev/sdd2
/dev/sda10  /dev/sda7   /dev/sdb2   /dev/sdc11  /dev/sdc8   /dev/sdd3
/dev/sda11  /dev/sda8   /dev/sdb3   /dev/sdc12  /dev/sdc9   /dev/sdd4
/dev/sda12  /dev/sda9   /dev/sdb4   /dev/sdc13  /dev/sdd    /dev/sdd5
/dev/sda13  /dev/sdb    /dev/sdb5   /dev/sdc14  /dev/sdd1   /dev/sdd6
/dev/sda14  /dev/sdb1   /dev/sdb6   /dev/sdc15  /dev/sdd10  /dev/sdd7
/dev/sda15  /dev/sdb10  /dev/sdb7   /dev/sdc2   /dev/sdd11  /dev/sdd8
/dev/sda2   /dev/sdb11  /dev/sdb8   /dev/sdc3   /dev/sdd12  /dev/sdd9
/dev/sda3   /dev/sdb12  /dev/sdb9   /dev/sdc4   /dev/sdd13
/dev/sda4   /dev/sdb13  /dev/sdc    /dev/sdc5   /dev/sdd14
-sh-3.2# fdisk /dev/sda -l

Disk /dev/sda: 32.0 GB, 32017047552 bytes
255 heads, 63 sectors/track, 3892 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1         487     3911796  83 Linux
/dev/sda2             488        3893    27352064   7 HPFS/NTFS
-sh-3.2# fdisk /dev/sdb -l   

Disk /dev/sdb: 8018 MB, 8018460672 bytes
247 heads, 62 sectors/track, 1022 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1        1022     7825423  83 Linux
-sh-3.2# which cat
/bin/cat
-sh-3.2#
I had both drives plugged, but couldn't get to the point for choosing one.

And for 02:
verify file /tmp/tools/etc/fw_env.config with md5 /tmp/tools/etc/fw_env.config.md5
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 122: cat: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 122: cut: command not found

./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 126: cut: command not found

passed
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 195: rm: command not found
 chmodding 644  --  /tmp/tools/etc/fw_env.config
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 246: chmod: command not found
# Successfully installed /tmp/tools/etc/fw_env.config.
######this is the output of normal fw_printenv
######this is the output of normal fw_printenv
######this is the output of normal fw_printenv
######this is the output of normal fw_printenv
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 1354: fw_printenv: command not found
######this is the output of chrooted fw_printenv
######this is the output of chrooted fw_printenv
######this is the output of chrooted fw_printenv
######this is the output of chrooted fw_printenv
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 529: mkdir: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 530: mount: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 532: mkdir: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 533: mount: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 535: mkdir: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 536: mount: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 540: chroot: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 543: umount: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 544: umount: command not found
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 545: umount: command not found




Installation complete

You can now reboot your device into Debian.
If your device does not start Debian after rebooting,
you may need to restart the device by disconnecting the power.

The new root password is 'root'  Please change it immediately after
logging in.

Reboot now? [Y/n] 
./file.php?3,file=960,filename=kirkwood-installer-6.sh: line 126: md5sum: command not found

(The reboot after this is working)



Edited 2 time(s). Last edit at 08/02/2016 01:14AM by ElMariachi.
Attachments:
open | download - 01(usb+sata).txt (54.3 KB)
open | download - 02.txt (54.3 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 01:32AM
Sigh, reordered an element that was getting called too soon.
Attachments:
open | download - kirkwood-installer-7.sh (39 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 02:33AM
I'm sorry, it's still same.
Attachments:
open | download - 01-sata.txt (52.9 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 03:11AM
I don't get why it does not error on my system as to not error here it should be calling things it should not have access to, anyway, try with this.
Attachments:
open | download - kirkwood-installer-8.sh (39 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 06:41AM
Did you notice that it doesn't even download busybox at all?
downloading tools and making a rootfs
Connecting to pogoplug.s3.amazonaws.com (54.231.168.150:80)
wget                 100% |*******************************|  2135k 00:00:00 ETA
wget: not an http or ftp url: https://dl.dropboxusercontent.com/u/47541136/linux/tools_for_Kirkwood_installer/busybox
chmod: /tmp/tools/busybox: No such file or directory
new PATH is now /tmp/tools
./file.php?3,file=965,filename=kirkwood-installer-8.sh: line 288: /tmp/tools/busybox: No such file or directory
./file.php?3,file=965,filename=kirkwood-installer-8.sh: line 290: ln: command not found
You can also see this result in 01.txt
We are still using stock wget at this point and you are trying to download through https.

Edit:

For saving us one post-cycle, I placed busybox onto my pc and changed the script to download busybox from there.
Results for both options (sata and usb) are in attachments.



Edited 4 time(s). Last edit at 08/02/2016 07:33AM by ElMariachi.
Attachments:
open | download - 01.txt (52.9 KB)
open | download - sata.txt (42 KB)
open | download - usb.txt (45.3 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 12:48PM
ElMariachi Wrote:
-------------------------------------------------------
> Results for both options (sata and usb) are in
> attachments.

Thanks for taking the time to do the hack to test further.

It seems the device does not have the drivers to mount ext4 partitions, not even as ext2, which was the "last thing that could have gone wrong" I was talking about (I was underestimating my own ability to cause trouble).

"mount: mounting /dev/sdb1 on /tmp/rootfs failed: Invalid argument" for both, and on a system that has ext4 driver it works fine.

This means I have to switch to plan B: using dd to write a small ext4 partition image with the rootfs inside, counting on e2fsck (file system checker) to expand that into a larger partition. I'm half sure it should work.

Or Plan C and use ext3 or XFS or even ext2 depending on what drivers the device has. ext filesystems are bootable for uboot, XFS is not so I would have to make a separate /boot partition.

Or Plan D and scrap the part of the script dealing with rootfs creation and simply make a dd image of the rootfs the users can write on a drive with Rufus (windows program to make bootable usb drives and similar) or whatever other tool from their PC and distribute it in a 7z archive so it is compressed and not as large as the partition it will create.

Any ideas? What would you prefer of the proposed solutions?



Edited 2 time(s). Last edit at 08/02/2016 01:17PM by bobafetthotmail.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 01:42PM
bobafetthotmail,

> Any ideas?

One foolproof solution would be reversing the installation. And we only need a small toolbox. Let's try creating the basic rootfs first using ext3, and then chroot into that and do u-boot installation.

The things to watch for if we doing this: we need to gather the mtds info, ethaddr, ... things that in the rootfs chroot we can't see.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 03:20PM
What about first creating mini os, that after creation installs uboot, then reboots and self destructs for making place for the final installation?

Edit:

I have just seen, that there's a fuse module. So couldn't you load fuse-ext2? I read that it had experimental ext4 support.

-sh-3.2# lsmod                               
Module                  Size  Used by    Tainted: P  
xce                    21872  0 
tun                     9152  1 
ufsd                  599656  0 
fuse                   43156  0 
hfsplus                81188  0 
hfs                    50980  0 
vfat                   10784  0 
fat                    48828  1 vfat
-sh-3.2#



Edited 4 time(s). Last edit at 08/02/2016 04:10PM by ElMariachi.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 04:29PM
bodhi Wrote:
-------------------------------------------------------

> One foolproof solution would be reversing the
> installation. And we only need a small toolbox.
> Let's try creating the basic rootfs first using
> ext3, and then chroot into that and do u-boot
> installation.

Hmm, the current toolbox is smaller than a rootfs and should be able to install uboot fine already.
Here the issue is that it would be nice to have a ext4 rootfs even if stock firmware does not have that driver.

I don't know if the Debian Jessie (or later) applications in the chroot will run at all with the kernel 2.6 of stock firmware.

We can simply try to use ext3 for the rootfs without making changes to the script, but I'm not very happy with that compromise (and I'm sure there will be devices that lack a ext3 driver too).

ElMariachi Wrote:
-------------------------------------------------------
> What about first creating mini os, that after
> creation installs uboot, then reboots and self
> destructs for making place for the final
> installation?

Yeah, this would have been the plan A if we had a recovery to flash in the internal flash. Flash uboot and recovery while into stock firmware, reboot in recovery, install Debian from recovery, reboot to Debian.

In our case we can make it anyway with a usb drive. we format a ex2 partition as rootfs, install a tweaked rootfs in it, on reboot it calls automatically a script that finishes the installation then erases that usb drive.


---
I'll have to test if Plan B (as said above) works at all. If it works it would be faster than using a recovery drive as above.

In the meantime I've attached the script, hoping it does not break again, it should now try to make a ext3 rootfs instead of a ext4 rootfs. See if it works now
Attachments:
open | download - kirkwood-installer-9.sh (39.1 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 04:49PM
bobafetthotmail,

> We can simply try to use ext3 for the rootfs
> without making changes to the script, but I'm not
> very happy with that compromise (and I'm sure
> there will be devices that lack a ext3 driver
> too).

On the contrary, ext3 rootfs should be used, IMO. This has ramification: backward compatibility (see my instruction for installing rootfs). Ext4 is better no doubt, but it would prevent the user to ever boot with stock u-boot again. So I always leave it to the users to upgrade it later.

Upgrading from ext3 to ext4 is quite simple to do after the installation. I think it is best to leave the rootfs as ext3. Stock uboot/OS can use ext3, if there is no ext3 driver, it wil just simply use ext2 without the journal.

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 2 time(s). Last edit at 08/02/2016 04:52PM by bodhi.
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 05:19PM
Good, now we need to know what device we are working on
here is a list, please write the number of the device
00. download and unpack toolbox
01. make a Debian rootfs in a drive
02. test chroot with a printenv
1.Zyxel nsa310
2.Zyxel nsa325v1 or nsa325v2
3.Pogoplug
01
downloading tools and making a rootfs
Connecting to pogoplug.s3.amazonaws.com (54.231.168.202:80)
wget                 100% |*******************************|  2135k 00:00:00 ETA
--2000-01-01 00:01:10--  https://dl.dropboxusercontent.com/u/47541136/linux/tools_for_Kirkwood_installer/busybox
Resolving dl.dropboxusercontent.com... 108.160.173.165
Connecting to dl.dropboxusercontent.com|108.160.173.165|:443... connected.
ERROR: cannot verify dl.dropboxusercontent.com's certificate, issued by `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certs.godaddy.com/repository//CN=Go Daddy Secure Certificate Authority - G2':
  Self-signed certificate encountered.
To connect to dl.dropboxusercontent.com insecurely, use `--no-check-certificate'.
new PATH is now /tmp/tools
./file.php?3,file=969,filename=kirkwood-installer-9.sh: line 290: ln: command not found
./file.php?3,file=969,filename=kirkwood-installer-9.sh: line 291: ln: command not found
./file.php?3,file=969,filename=kirkwood-installer-9.sh: line 292: ln: command not found

(Regarding the ext4 problem: Did you see that there's a fuse module? I edited it in, but I think this was after you had posted on already.)



Edited 2 time(s). Last edit at 08/02/2016 05:20PM by ElMariachi.
Attachments:
open | download - 01.txt (54.6 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 06:02PM
bodhi Wrote:
-------------------------------------------------------

> On the contrary, ext3 rootfs should be used, IMO.
> This has ramification: backward compatibility (see
> my instruction for installing rootfs). Ext4 is
> better no doubt, but it would prevent the user to
> ever boot with stock u-boot again. So I always
> leave it to the users to upgrade it later.
>
> Upgrading from ext3 to ext4 is quite simple to do
> after the installation. I think it is best to
> leave the rootfs as ext3. Stock uboot/OS can use
> ext3, if there is no ext3 driver, it wil just
> simply use ext2 without the journal.

Hm, looked up the upgrade path to ext4 https://ext4.wiki.kernel.org/index.php/UpgradeToExt4
I have some doubts that this can be performed on a live rootfs, but iit's easy enough for me to do the switch from my linux PC.
To use the older uboot again we need to have also stock uboots somewhere, or we should hope that the place the script dumps the images to does not get erased (I'd rather like to send them to a ftp server so we can offer stock uboots + envs for various devices too).

So fine for me, ext3 rootfs will be then.

ElMariachi
>(Regarding the ext4 problem: Did you see that there's a fuse module? I edited it in, but I think this was after you had posted on already.)

It's easier and less likely to blow up to just steal a ext4 kernel module from some ARM kernel 2.6 and modprobe it in with the script, but I'd rather avoid it as it is not guaranteed to work on all boxes.

---
also, added that --no-check-certificate to the script, now it should really work, hopefully.
Attachments:
open | download - kirkwood-installer-10.sh (39.1 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 02, 2016 09:44PM
bobafetthotmail,

> To use the older uboot again we need to have also
> stock uboots somewhere,
>

Jeff copied the original u-boot to stock rootfs. But we are strict about messing with stock. So I would dump it to /tmp only (1MB or less). And then at the end, copy the image to the new Debian rootfs /boot.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 03, 2016 04:03AM
And we got a winner! (for sata and usb)
---everything fine




Installation complete

You can now reboot your device into Debian.
If your device does not start Debian after rebooting,
you may need to restart the device by disconnecting the power.

The new root password is 'root'  Please change it immediately after
logging in.

Reboot now? [Y/n]

PS:
Again for the backup question that I had:
I would like to clone the GFN I am currently working on to another one, for making the other one stock again. The other one is completely modded including rescue system. So that's why I need to backup more than mtd0. I could use the older GFN then for more testing with stock formware and such, but I have to mod and to give away the current one.

I also tested booting with the USB drive on one of the modded GFNs, it's working fine (besides that I cannot login Debian, because of 'Permission denied (publickey,password).').

I can't test booting the SATA drive, because of that latest problem there.



Edited 2 time(s). Last edit at 08/03/2016 04:22AM by ElMariachi.
Attachments:
open | download - sata.txt (681.1 KB)
open | download - usb.txt (679.1 KB)
open | download - modded-boot.txt (1.4 KB)
Re: Kirkwood U-Boot and Debian Installer Script (WIP)
August 03, 2016 11:49AM
ElMariachi,

> Again for the backup question that I had:
> I would like to clone the GFN I am currently
> working on to another one, for making the other
> one stock again. The other one is completely
> modded including rescue system. So that's why I
> need to backup more than mtd0. I could use the
> older GFN then for more testing with stock
> formware and such, but I have to mod and to give
> away the current one.

Please post this as a different topic in u-boot forum (how to backup/restore your NAND patitions).

-bodhi
===========================
Forum Wiki
bodhi's corner
Sorry, you can't reply to this topic. It has been closed.