Welcome! Log In Create A New Profile

Advanced

Rescue System for Pogo V4/Mobile using OpenWrt (Install with NetConsole)

Posted by iSKUNK! 
Rescue System for Pogo V4/Mobile using OpenWrt (Install with NetConsole)
April 27, 2020 05:52PM
This post is the final installation instruction:

https://forum.doozan.com/read.php?4,100764,101409#msg-101409



=======

Hello,

I have a Pogoplug Mobile device (POGO-V4-A1-01) with SSH and telnet access enabled.

I would like to get rid of the original Pogoplug OS completely, and reflash the on-board memory with OpenWRT. However, I'd also like to have netconsole, and the ability to boot off a root filesystem on a USB drive. It is unclear that the U-Boot builds that OpenWRT provides have these capabilities, and in any event not only is their installation process not as well-documented as the ones here, their process assumes serial console access, which I do not have (not least since this would require soldering).

Would it be feasible to use bodhi's U-Boot together with an on-board OpenWRT image?


====
bodhi edit: I've changed the thread title to make it easier to search for. And point to the installation instruction inside this thread.



Edited 1 time(s). Last edit at 05/05/2020 11:36PM by bodhi.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 27, 2020 06:00PM
iSKUNK,

> Would it be feasible to use bodhi's U-Boot
> together with an on-board OpenWRT image?

Yes. See the Wiki thread

https://forum.doozan.com/read.php?2,23630

Quote

Rescue Systems
...
Rescue System for Pogo E02 using LEDE/OpenWrt

The mtd partitions are different between Pogo E02 and Pogo Mobile. So the instruction needs to be adjusted a bit. But in general, they are almost identical.

If you can find the OpenWrt images for Pogo V4/Mobile in their trunk, then it will work.

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



Edited 1 time(s). Last edit at 04/27/2020 06:04PM by bodhi.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 27, 2020 06:05PM
I see that you don't have serial console! that will make it more difficult.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 27, 2020 06:18PM
Ah, I see that Lede on Pogo E02 HowTo page. (The name is out-of-date; Lede was merged into OpenWRT a while ago and no longer exists as a distinct project.)

Can't the entire process be done from the running Linux system? I don't believe the flashing tools are present in the original OS, but I can pull them down.

Otherwise, it seems like the first step is to follow the standard install procedure for your U-Boot build and environment? I'm assuming repartitioning the flash memory is not necessary?

Addendum: I have copied the files/tools onto the device, and read through the U-Boot instructions, poking at the system without modifying it yet. It appears that the default fw_env.config file does not suit the device, because fw_printenv returns "Warning: Bad CRC, using default environment." I don't think that the nandwrite command for the environment block is going to be the same for this device as for others.

Is there an fw_env.config file tailored for this device? Or should I just use blparam for the flashing?



Edited 1 time(s). Last edit at 04/27/2020 07:43PM by iSKUNK!.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 27, 2020 10:18PM
> Can't the entire process be done from the running
> Linux system?

Possibly.

>
> Otherwise, it seems like the first step is to
> follow the standard install procedure for your
> U-Boot build and environment? I'm assuming
> repartitioning the flash memory is not necessary?
>

MTDs must be repartitioned first if you are going to flash OpenWrt images in Debian, or in stock OS.

> Addendum: I have copied the files/tools onto the
> device, and read through the U-Boot instructions,
> poking at the system without modifying it yet. It
> appears that the default fw_env.config file does
> not suit the device, because fw_printenv returns
> "Warning: Bad CRC, using default environment."

It is understanble. Stock does not provide the necessary configuration to do this.

> Or should I just use blparam for the
> flashing?

No, nand write is the correct tool. You can ignore that Bad CRC error, and not using fw_printenv until after flashing new u-boot and new u-boot env images.

The fw_printenv is just to back up the current envs to a text file, so you can reference it later to find the MAC address and other info. It does not prevent you from installing new u-boot.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 27, 2020 10:49PM
Okay, so I take it that writing the environment to 0xC0000 on this device is still the correct action (that this is the appropriate location for the new U-Boot, even if it isn't so for the old one). I have used blparam to read the current environment, and saved a copy of that information.

I recently found the thread HowTo: OpenWrt on Kirkwood boxes, which seems to come pretty close to what I want to do. (Isn't that a good thread to link in the wiki?) If I follow that procedure, where OpenWRT is flashed to the on-board NAND from a USB drive using U-Boot via netconsole, would that not require repartitioning MTD?

(Just for my understanding, what is it that leads to the requirement of repartitioning? It seemed like OpenWRT's installation process does this to increase the size of the usable root filesystem, and I did see a couple references here to newer versions of OpenWRT being too big to download to the device directly. Is it just about making the OS partition bigger?)

Once the new U-Boot is installed, but before I start messing around with the OS, should I expect the device to continue booting into the Pogoplug OS?
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 27, 2020 11:17PM
iSKUNK!,

> Okay, so I take it that writing the environment to
> 0xC0000 on this device is still the correct action
> (that this is the appropriate location for the new
> U-Boot, even if it isn't so for the old one).

Correct.

> I recently found the thread
> HowTo:
> OpenWrt on Kirkwood boxes
, which seems to
> come pretty close to what I want to do

> If I
> follow that procedure, where OpenWRT is flashed to
> the on-board NAND from a USB drive using U-Boot
> via netconsole, would that not require
> repartitioning MTD?

You will actually repartition the MTDs in u-boot prompt, whether you do it in serial console or netconsole. Or you would do repartition whether in stock OS or Debian.

>. (Isn't that a good thread to link in the wiki?)

It has potential to be a really good instruction with some adjustments. But I cannot vouch for the current instruction, since the OP was not willing to modify some of the wrong steps and/or description with the corrections that I've suggested.

Nobody is perfect, including yours truly :) And I need to have confidence in the instruction before promoting it to the Wiki.

> (Just for my understanding, what is it that leads
> to the requirement of repartitioning? It seemed
> like OpenWRT's installation process does this to
> increase the size of the usable root filesystem,
> and I did see a couple references here to newer
> versions of OpenWRT being too big to download to
> the device directly. Is it just about making the
> OS partition bigger?)

The current MTDs partitioning is not large enough. And OpenWrt image must be flashed after the parition was reformatted in UBIFS.

> Once the new U-Boot is installed, but before I
> start messing around with the OS, should I expect
> the device to continue booting into the Pogoplug
> OS?

Not possible to boot stock OS without further tweaks, once you've installed new u-boot. You can boot into the Debian rootfs on USB. And then go from there.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 28, 2020 12:02AM
I agree that having correct information posted on matters like these is quite important!

Is setting the "mtdparts" variable equivalent to repartitioning, then? (As in, is this variable basically a partition table?)

The U-Boot install procedure mentions setting mtdparts and ethaddr after flashing (to restore their old values), but blparam did not give me anything for mtdparts. Will that be a problem?

Okay, so I won't be able to boot the stock OS anymore, but I assume netconsole will work.

Now, I don't actually have a USB drive immediately handy. Borrowing a bit from the OpenWRT installation process, could I load the initial uImage through TFTP, instead of doing "usb reset; fatload usb ..."? Here is what I'm thinking:
uboot> setenv ipaddr 192.168.1.2
uboot> setenv serverip 192.168.1.4
uboot> tftpboot openwrt-19.07.2-kirkwood-cloudengines_pogoe02-initramfs-uImage
uboot> bootm 0x800000
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 28, 2020 01:32AM
iSKUNK!,

> Is setting the "mtdparts" variable equivalent to
> repartitioning, then? (As in, is this variable
> basically a partition table?)

That and the env mtdid determine the partition layout.

>
> The U-Boot install procedure mentions setting
> mtdparts and ethaddr after flashing (to restore
> their old values), but blparam did not give me
> anything for mtdparts. Will that be a problem?

mtdparts should be 2MB for u-boot and the rest for ubi (to make it compatible with the new u-boot installation instruction).

> Okay, so I won't be able to boot the stock OS
> anymore, but I assume netconsole will work.
>

Right! that's the rescue mechanism.


> Now, I don't actually have a USB drive immediately
> handy. Borrowing a bit from the OpenWRT
> installation process, could I load the initial
> uImage through TFTP, instead of doing "usb reset;
> fatload usb ..."? Here is what I'm thinking:
>
> uboot> setenv ipaddr 192.168.1.2
> uboot> setenv serverip 192.168.1.4
> uboot> tftpboot
> openwrt-19.07.2-kirkwood-cloudengines_pogoe02-initramfs-uImage
> uboot> bootm 0x800000
>

openwrt-19.07.2-kirkwood-cloudengines_pogoe02-initramfs-uImage is the OpenWrt image for Pogo E02. You probably can boot with it, but it will crash eventually. You need to find this image for Pogo V4/Mobile.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 28, 2020 02:13AM
So, if I'm eyeballing these other threads correctly, the command/value I should use is
fw_setenv mtdparts 'mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)'
?

(I don't see anything on "mtdid"; is that something I need to set, or just an internal thing?)

Quote

openwrt-19.07.2-kirkwood-cloudengines_pogoe02-initramfs-uImage is the OpenWrt image for Pogo E02. You probably can boot with it, but it will crash eventually. You need to find this image for Pogo V4/Mobile.

The OpenWRT page I linked earlier appears to indicate that the Pogoplug Mobile (POGO-V4-A1-01, blue logo) should actually use the E02 firmware, that only the Pogoplug Series 4 (POGO-V4-A3-01, red logo) should use V4 proper. However, it is not clear whether this is intended as a requirement, or is simply an accident of reading through an associated forum thread (search for mentions of "E02").

Just to be sure, then: This blue-logo device should in fact use uboot.2017.07-tld-1.pogo_v4.bodhi.tar and openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage, and not the pogoe02 equivalents?

(All this time, I'd been preparing with E02 builds, given what I saw on the OpenWRT page...)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 28, 2020 03:40AM
> The OpenWRT page I linked earlier appears to
> indicate that the Pogoplug Mobile (POGO-V4-A1-01,
> blue logo) should actually use the E02 firmware,
> that only the Pogoplug Series 4 (POGO-V4-A3-01,
> red logo) should use V4 proper.

That's terrible info. It could not be more wrong.

The Pogo V4 and Pogo Mobile are identical. The only difference is that the V4 has more ports exposed, such as a real SATA port slot where you can plug in a 2.5" HDD. So in the Mobile, you will always see that the SATA port is down (but in reality, it is supporting SATA).

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



Edited 1 time(s). Last edit at 04/28/2020 06:22AM by bodhi.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 28, 2020 06:05PM
Thanks for confirming. Yes, it struck me as odd that the V4-A1-01 supposedly didn't use the same software as the V4-A3-01, given the similarity of the two devices.

Below is what I'm starting with, and the commands that I plan to run to install U-Boot (taken from the install thread and also the OpenWRT on Kirkwood boxes thread). Could you give them a final once-over, in case I got anything wrong?

1. I'm starting with the stock Pogoplug OS, with SSH/telnet enabled, and have logged in as "root" (password "ceadmin").

2. I've copied the fw_env.config file into place under /etc:
~ # cat /etc/fw_env.config 
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0               0xc0000         0x20000         0x20000
Noted that fw_printenv does not work yet...
~ # fw_printenv
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200
...but it will once the new U-Boot and its environment have been flashed.

3. I've also copied in the "pogo_v4" build of U-Boot, the U-Boot environment file (both linked here), and the U-Boot flashing utilities, all unpacked into a temporary location.

4. The commands to run:
# Check that the first eight NAND blocks (1 MB) are good
dmesg | grep -i bad

# Install U-Boot
flash_erase /dev/mtd0 0 4
nandwrite /dev/mtd0 uboot.2017.07-tld-1.pogo_v4.mtd0.kwb

# Install U-Boot environment
flash_erase /dev/mtd0 0xc0000 1
nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img

# Check that the environment looks sane
fw_printenv

# Set variables for Pogoplug Mobile/V4
fw_setenv arcNumber 3960
fw_setenv machid f78

# Set 2MB U-Boot partition, and give everything else to ubifs
fw_setenv mtdparts 'mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)'

# Restore original MAC address
# (actual value redacted)
fw_setenv ethaddr '00:25:XX:XX:XX:XX'

# (Skipped the uEnv.txt-loading bit, by request)

# No SATA on this device, so no adjustment to bootcmd_uenv

# No dtb_file in the OpenWRT filesystem

# Set up netconsole
fw_setenv preboot_nc 'setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi'
fw_setenv preboot 'run preboot_nc'
fw_setenv ipaddr   '192.168.100.15'
fw_setenv serverip '192.168.100.10'

# Modification to boot Debian on USB, but fall back to OpenWRT on NAND
fw_setenv bootcmd_exec 'if run load_uimage; then; 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; fi'

# Reboot!



Edited 2 time(s). Last edit at 04/29/2020 06:52PM by iSKUNK!.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 28, 2020 10:40PM
iSKUNK,

State what is the starting point, is it stock OS?

> # Note: /etc/fw_env.config is already in place

Don't say that. Just

cat /etc/fw_env.config

>
> # Install U-Boot
> flash_erase /dev/mtd0 0 4
> nandwrite /dev/mtd0
> uboot.2017.07-tld-1.pogo_v4.mtd0.kwb
>
> # Install U-Boot environment
> flash_erase /dev/mtd0 0xc0000 1
> nandwrite -s 786432 /dev/mtd0
> uboot.2016.05-tld-1.environment.img


Do a fw_printenv at this point to see if the envs are OK.


> # Apply correction to uEnv.txt loading

No need to do anything with uEnv.txt at this point.

> # Set up netconsole
> fw_setenv preboot_nc 'setenv nc_ready 0; for
> pingstat in 1 2 3 4 5; do; sleep 1; if run
> if_netconsole; then setenv nc_ready 1; fi; done;
> if test $nc_ready -eq 1; then run
> start_netconsole; fi'
> fw_setenv preboot 'run preboot_nc'
> fw_setenv ipaddr '192.168.100.15'
> fw_setenv serverip '192.168.100.10'
>

Looks OK.

> # Modification to boot Debian on USB, but fall
> back to OpenWRT on NAND

> fw_setenv bootcmd_exec 'if run load_uimage; then;
> 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; fi'
>

OK.

> # Reboot!

Yes, you can reboot and hope netconsole works. So you can continue to install OpenWrt in netconsole.

If netconsole does not work, then create a Debian USB rootfs to boot with it.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 29, 2020 03:54AM
Okay, I have revised (and clarified) my previous post as requested. Yes, I am starting with the stock Pogoplug OS, modified only as far as enabling SSH/telnet.

Side note: I'm actually using telnet, because the Pogoplug's SSH server is only offering an insecure key-exchange algorithm that my client refuses:
$ ssh root@192.168.100.15
Unable to negotiate with 192.168.100.15 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

I will perform the U-Boot (and hopefully OpenWRT) installation soon, when I have a more open block of time, and will report the results!
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 29, 2020 04:14AM
Check bad blocks first:
dmesg | grep -i bad

# Install U-Boot
flash_erase /dev/mtd0 0 4
nandwrite /dev/mtd0 uboot.2017.07-tld-1.pogo_v4.mtd0.kwb

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 29, 2020 07:00PM
I added the bad-block check to my command list above.

Here are the results of my session. I'll use color-coding, so that all this text doesn't run together. Comments are in light grey, commands I type in are in red, and command output is green.
# Check that the first eight NAND blocks (1 MB) are good

/tmp # dmesg | grep -i bad
<6>[    1.010000] Scanning device for bad blocks
<4>[    1.030000] Bad eraseblock 360 at 0x000002d00000
<5>[    1.370000] UBI: number of bad PEBs:         1
<5>[    1.410000] UBI: number of PEBs reserved for bad PEB handling: 8

# (360 is a long way after 8, so we're good for flashing U-Boot)


# Install U-Boot

/tmp # ./flash_erase /dev/mtd0 0 4
Erasing 128 Kibyte @ 60000 -- 100 % complete

/tmp # ./nandwrite /dev/mtd0 uboot.2017.07-tld-1.pogo_v4.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


# Install U-Boot environment

/tmp # ./flash_erase /dev/mtd0 0xc0000 1
Erasing 128 Kibyte @ c0000 -- 100 % complete

/tmp # ./nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img
Writing data to block 6 at offset 0xc0000


# Check that the environment looks sane

/tmp # ./fw_printenv
arcNumber=2097
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=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
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 mmc
disks=0 1 2 3
ethact=egiga0
ethaddr=52:3b:20:9c:11:51
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
dtb_file=/boot/dts/kirkwood-pogo_e02.dtb
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
machid=0x831
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
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_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
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
usb_ready_retry=15

# (No errors reading the variables, so we're good)


# Note that fw_setenv normally does not have any output,
# so this next section is a little boring

# Set variables for Pogoplug Mobile/V4
/tmp # ./fw_setenv arcNumber 3960
/tmp # ./fw_setenv machid f78

# Set 2MB U-Boot partition, and give everything else to ubifs
/tmp # ./fw_setenv mtdparts 'mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)'

# Restore original MAC address
# (actual value redacted)
/tmp # ./fw_setenv ethaddr '00:25:XX:XX:XX:XX'

# Set up netconsole
/tmp # ./fw_setenv preboot_nc 'setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi'
/tmp # ./fw_setenv preboot 'run preboot_nc'
/tmp # ./fw_setenv ipaddr   '192.168.100.15'
/tmp # ./fw_setenv serverip '192.168.100.10'

# Modification to boot Debian on USB, but fall back to OpenWRT on NAND
/tmp # ./fw_setenv bootcmd_exec 'if run load_uimage; then; 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; fi'

# I noticed that dtb_file was set to a file that is incorrect for this device,
# and that I don't have anyway, so I cleared its value

/tmp # ./fw_setenv dtb_file

# And last, but not least...

/tmp # rebootConnection closed by foreign host.

With that, I started up nc to get the netconsole, and crossed my fingers...
$ nc -l -u -p 6666

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4
gcc (Debian 6.3.0-18) 6.3.0 20170516
GNU ld (GNU Binutils for Debian) 2.28
Hit any key to stop autoboot:  5

It worked! And curiously enough, I didn't have to run two nc commands to be able to communicate with U-Boot---the above command was enough. I hit Enter, and that got me to the U-Boot prompt.
Hit any key to stop autoboot:  5 
 0 
Pogov4> 

Pogov4> 

Pogov4> printenv
printenv
arcNumber=3960
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
[...]

Now, I have a couple of questions:

1. I noticed that in the U-Boot variables that involve script commands, there are temporary variables, like "nc_ready", that are used to control the script flow. However, these variables are assigned values using e.g. "setenv nc_ready 1", which records their value persistently in the NAND. Wouldn't it work to assign them temporary (RAM-only) values using shell-variable syntax, like "nc_ready=1"? This appears to work at the prompt, which makes sense given that U-Boot's syntax takes after the Bourne shell.

2. I have a bad eraseblock at the 45 MB mark. While this isn't an issue for U-Boot, it may cause trouble for an OpenWRT install on the NAND. Is there a way to work around the bad block? (Or does the NAND route around it automatically?)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 29, 2020 09:33PM
iSKUNK,

It looks really good so far!


> Here are the results of my session. I'll use
> color-coding, so that all this text doesn't run
> together. Comments are in light grey, commands I
> type in are in red, and command output is green.
>
> # Check that the first eight NAND
> blocks (1 MB) are good
> 
> /tmp # dmesg | grep -i bad
> <6>[    1.010000] Scanning device
> for bad blocks
> <4>[    1.030000] Bad eraseblock 360 at
> 0x000002d00000
> <5>[    1.370000] UBI: number of bad PEBs:        
> 1
> <5>[    1.410000] UBI: number of PEBs reserved for
> bad PEB handling: 8
> 
> # (360 is a long way after 8, so
> we're good for flashing U-Boot)
> 
> 
> # Install U-Boot
> 
> /tmp # ./flash_erase /dev/mtd0 0
> 4
> Erasing 128 Kibyte @ 60000 -- 100 %
> complete
> 
> /tmp # ./nandwrite /dev/mtd0
> uboot.2017.07-tld-1.pogo_v4.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
> 
> 
> # Install U-Boot
> environment
> 
> /tmp # ./flash_erase /dev/mtd0
> 0xc0000 1
> Erasing 128 Kibyte @ c0000 -- 100 %
> complete
> 
> /tmp # ./nandwrite -s 786432
> /dev/mtd0
> uboot.2016.05-tld-1.environment.img
> Writing data to block 6 at offset
> 0xc0000
> 
> 
> # Check that the environment looks
> sane
> 
> /tmp # ./fw_printenv
> arcNumber=2097
> 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=run bootcmd_uenv; run scan_disk; run
> set_bootargs; run bootcmd_exec
> 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 mmc
> disks=0 1 2 3
> ethact=egiga0
> ethaddr=52:3b:20:9c:11:51
> if_netconsole=ping $serverip
> ipaddr=192.168.0.231
> led_error=orange blinking
> led_exit=green off
> led_init=green blinking
> dtb_file=/boot/dts/kirkwood-pogo_e02.dtb
> load_dtb_addr=0x1c00000
> load_initrd_addr=0x1100000
> load_uimage_addr=0x800000
> load_dtb=echo loading DTB $dtb_file ...; load
> $bootdev $device $load_dtb_addr $dtb_file
> load_initrd=echo loading uInitrd ...; load
> $bootdev $device $load_initrd_addr /boot/uInitrd
> load_uimage=echo loading uImage ...; load $bootdev
> $device $load_uimage_addr /boot/uImage
> machid=0x831
> 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
> 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_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
> uenv_read=echo loading envs from $devtype $disknum
> ...; if load $devtype $disknum:1 $uenv_addr
> /boot/uEnv.txt; then setenv uenv_loaded 1; fi
> usb_ready_retry=15
> 
> # (No errors reading the variables,
> so we're good)
> 
> 
> # Note that fw_setenv normally does
> not have any output,
> # so this next section is a little boring
> 
> # Set variables for Pogoplug
> Mobile/V4
> /tmp # ./fw_setenv arcNumber
> 3960
> /tmp # ./fw_setenv machid
> f78
> 
> # Set 2MB U-Boot partition, and
> give everything else to ubifs
> /tmp # ./fw_setenv mtdparts
> 'mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)'
> 
> # Restore original MAC address
> # (actual value redacted)
> /tmp # ./fw_setenv ethaddr
> '00:25:XX:XX:XX:XX'
> 
> # Set up netconsole
> /tmp # ./fw_setenv preboot_nc
> 'setenv nc_ready 0; for pingstat in 1 2 3 4 5; do;
> sleep 1; if run if_netconsole; then setenv
> nc_ready 1; fi; done; if test $nc_ready -eq 1;
> then run start_netconsole; fi'
> /tmp # ./fw_setenv preboot 'run
> preboot_nc'
> /tmp # ./fw_setenv ipaddr  
> '192.168.100.15'
> /tmp # ./fw_setenv serverip
> '192.168.100.10'
> 
> # Modification to boot Debian on
> USB, but fall back to OpenWRT on NAND
> /tmp # ./fw_setenv bootcmd_exec 'if
> run load_uimage; then; 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; fi'
> 
> # I noticed that dtb_file was set
> to a file that is incorrect for this device,
> # and that I don't have anyway, so I cleared its
> value
> 
> /tmp # ./fw_setenv
> dtb_file
> 
> # And last, but not
> least...
> 
> /tmp #
> rebootConnection
> closed by foreign host.
>
>
> With that, I started up nc to get the
> netconsole, and crossed my fingers...
>
> $ nc -l -u -p 6666
> 
> U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01
> -0700)
> Pogoplug V4
> gcc (Debian 6.3.0-18) 6.3.0 20170516
> GNU ld (GNU Binutils for Debian) 2.28
> Hit any key to stop autoboot:  5
>
>
> It worked!

Awesome!


> And curiously enough, I didn't have to
> run two nc commands to be able to
> communicate with U-Boot---the above command was
> enough.

That's true. Only one command is enough. And to cover all bases that command should be

nc -lup 6666 192.168.100.15 6666


> I hit Enter, and that got me to the U-Boot
> prompt.
>
> Hit any key to stop autoboot:  5 
>  0 
> Pogov4> 
> 
> Pogov4> 
> 
> Pogov4> printenv
> printenv
> arcNumber=3960
> bootcmd=run bootcmd_uenv; run scan_disk; run
> set_bootargs; run bootcmd_exec
> [...]
>
>
> Now, I have a couple of questions:
>

> 1. I noticed that in the U-Boot variables that
> involve script commands, there are temporary
> variables, like "nc_ready", that are used to
> control the script flow. However, these variables
> are assigned values using e.g. "setenv nc_ready
> 1", which records their value persistently in the
> NAND. Wouldn't it work to assign them temporary
> (RAM-only) values using shell-variable syntax,
> like "nc_ready=1"? This appears to work at the
> prompt, which makes sense given that U-Boot's
> syntax takes after the Bourne shell.

The syntax looks like Bourn shell, but there are quite a bit of limitation that it is not the same as Bourne shell. Usually the envs need to be set globally (with setenv) to make the script logic foolproof. And in this case, nc_ready is really transient because without a saveenv, nothing got written to NAND during the next boot.

>
> 2. I have a bad eraseblock at the 45 MB mark.
> While this isn't an issue for U-Boot, it may cause
> trouble for an OpenWRT install on the NAND. Is
> there a way to work around the bad block? (Or does
> the NAND route around it automatically?)

That's where UBIFS comes in. The bad blocks are gathered by this file system and will be marked, so it is not in the ubi volume. Note that joerg erased the ubi partition at u-boot prompt in his instruction. It is prudent to do this to avoid problem once you log into OpenWrt and format the rest.
nand erase.part ubi

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 29, 2020 09:51PM
Quote
bodhi
And in this case, nc_ready is really transient because without a saveenv, nothing got written to NAND during the next boot.

Ohh, okay. So "setenv" only changes a variable temporarily (in RAM) on its own; "saveenv" is needed to actually commit the new value(s) to NAND. So it's different from fw_setenv in that way.

(After seeing the "printenv" listing, I was concerned that the use of "setenv" might have caused needless wear on the NAND memory, so it is good to hear that this is not the case.)

Quote
bodhi
That's where UBIFS comes in. The bad blocks are gathered by this file system and will be marked, so it is not in the ubi volume. Note that joerg erased the ubi partition at u-boot prompt in his instruction. It is prudent to do this to avoid problem once you log into OpenWrt and format the rest.

Ah, understood. I will proceed with the OpenWRT installation process, then!
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 30, 2020 05:31PM
I'm happy to report that the OpenWRT installation was a success. Since this is all past the "one wrong move and you've got a brick" stage, I was able to work through it on my own, while eyeballing the two other relevant threads closely.

Below is the transcript of what I did, also color-coded for clarity. Starting in netconsole:
Pogov4> nand erase.part ubi
NAND erase.part: invalid partition number 2 for device nand0 (orion_nand)
no such partition
device 0 offset 0x200000, size 0x7e00000
Skipping bad block at  0x02d00000                                          
Erasing at 0x7fe0000 -- 100% complete.
OK

# (I later figured out that the above error is due to the "partition"
# variable referencing a NAND partition that doesn't exist.
# In any event, the error appears to be harmless.) 


# Because I don't have a USB drive handy, I've set up a TFTP server
# at the IP address in the "serverip" variable, with an appropriate
# copy of an OpenWRT uImage file

# (You can also load this file off an attached FAT32-formatted USB drive
# if that's easier; search for "fatload" in this thread)

# This downloads the uImage file into memory via TFTP

Pogov4> tftpboot openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage
Using egiga0 device
TFTP from server 192.168.100.10; our IP address is 192.168.100.15
Filename 'openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage'.
Load address: 0x800000
Loading: #################################################################
	 #################################################################
	 #################################################################
	 ###################################################
	 8.7 MiB/s
done
Bytes transferred = 3605263 (37030f hex)

# And this boots it

Pogov4> bootm 0x800000
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.171
   Created:      2020-02-27  21:05:12 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3605199 Bytes = 3.4 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK


Starting kernel ...

At this point, the netconsole became unresponsive, so I disconnected. The device soon connected to my network normally, receiving an IP address via DHCP. I connected to that address via SSH:

$ ssh root@192.168.100.25
The authenticity of host '192.168.100.25 (192.168.100.25)' can't be established.
RSA key fingerprint is SHA256:ZW5fg5lnzTuCQrmCpygs4SxcvWrNq/fRfF7COTLvswk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.25' (RSA) to the list of known hosts.


BusyBox v1.30.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.2, r10947-65030d81f3
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~#

# Note that this OpenWRT environment is only running in RAM!
# It has not been installed to the device's NAND yet

# The stock fw_env.config is not correct for this device...

root@OpenWrt:~# cat /etc/fw_env.config
/dev/mtd1 0x0 0x20000 0x20000

# ...so fw_printenv doesn't work

root@OpenWrt:~# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200

# So we set the correct values...

root@OpenWrt:~# echo /dev/mtd0 0xc0000 0x20000 0x20000 >/etc/fw_env.config

# ...and now fw_printenv works

root@OpenWrt:/tmp# fw_printenv
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
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 mmc
disks=0 1 2 3
ethact=egiga0
if_netconsole=ping $serverip
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
mainlineLinux=yes
mtdids=nand0=orion_nand
partition=nand0,2
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
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
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_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
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
usb_ready_retry=15
arcNumber=3960
machid=f78
mtdparts=mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)
ethaddr=00:25:XX:XX:XX:XX
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
preboot=run preboot_nc
ipaddr=192.168.100.15
serverip=192.168.100.10
bootcmd_exec=if run load_uimage; then; 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; fi


# Now, set some variables to address booting OpenWRT from NAND

root@OpenWrt:~# fw_setenv partition 'nand0,0'
root@OpenWrt:~# fw_setenv set_bootargs_owrt 'setenv bootargs console=ttyS0,115200 $mtdparts'
root@OpenWrt:~# fw_setenv bootcmd_owrt 'run set_bootargs_owrt; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000'

# This next variable, we're actually appending to the end of it
# (you might have a value different from this)

root@OpenWrt:~# fw_printenv bootcmd
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec

# Add "; run bootcmd_owrt" to the end 

root@OpenWrt:~# fw_setenv bootcmd 'run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run bootcmd_owrt'


# Copy an OpenWRT sysupgrade image file to the /tmp dir on the device
# (probably the same OpenWRT version as the uImage used previously)
# and double-check for the correct MD5/SHA256 hash

root@OpenWrt:/tmp# md5sum openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin
b297f8ed76cc9b2d9e4ad0ac57523a75  openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin

# Run sysupgrade (which will promptly kick you out)

root@OpenWrt:/tmp# sysupgrade -v openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin
Cannot save config while running from ramdisk.
Commencing upgrade. Closing all shell sessions.
Connection to 192.168.100.25 closed by remote host.
Connection to 192.168.100.25 closed.

Now, back to netconsole, to see what happens:

$ nc -l -u -p 6666

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4
gcc (Debian 6.3.0-18) 6.3.0 20170516
GNU ld (GNU Binutils for Debian) 2.28
Hit any key to stop autoboot:  0 
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

Reset IDE: ide_preinit failed
Card did not respond to voltage select!
mmc_init: -95, time 11
## 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

## Unknown partition table type 0
loading envs from usb 0 ...
** Bad device usb 0 **

no IDE devices available
Card did not respond to voltage select!
mmc_init: -95, time 10
running scan_disk ...
Scan device usb
device usb 0:1
** Bad device usb 0 **
device usb 1:1
** Bad device usb 1 **
device usb 2:1
** Bad device usb 2 **
device usb 3:1
** Bad device usb 3 **
Scan device ide

Reset IDE: ide_preinit failed
device ide 0:1
** Bad device ide 0 **
device ide 1:1
** Bad device ide 1 **
device ide 2:1
** Bad device ide 2 **
device ide 3:1
** Bad device ide 3 **
Scan device mmc
Card did not respond to voltage select!
mmc_init: -95, time 10
device mmc 0:1
Card did not respond to voltage select!
mmc_init: -95, time 11
Card did not respond to voltage select!
mmc_init: -95, time 10
** Bad device mmc 0 **
device mmc 1:1
MMC Device 1 not found
MMC Device 1 not found
** Bad device mmc 1 **
device mmc 2:1
MMC Device 2 not found
MMC Device 2 not found
** Bad device mmc 2 **
device mmc 3:1
MMC Device 3 not found
MMC Device 3 not found
** Bad device mmc 3 **
loading uImage ...
** Bad device usb 0 **
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: attached mtd1 (name "mtd=1", size 126 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 1007, bad PEBs: 1, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 2773805143
ubi0: available PEBs: 0, total reserved PEBs: 1007, PEBs reserved for bad PEB handling: 19
Read 0 bytes from volume kernel to 800000
No size specified -> Using max size (2193408)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.171
   Created:      2020-02-27  21:05:12 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2079191 Bytes = 2 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK


Starting kernel ...

You can see it poking around, trying to find a system to boot on an IDE (SATA) drive, USB drive, MMC (SD card). None of those are present, so it falls back to what's in NAND. And it looks like it booted something successfully. Back to SSH...

# Make sure to delete the old entry for the device from your
# ~/.ssh/known_hosts file, or else you will get a big scary warning
# about the host key having changed

$ ssh root@192.168.100.25
The authenticity of host '192.168.100.25 (192.168.100.25)' can't be established.
RSA key fingerprint is SHA256:yAqh277tA08JMFh5GSbZkka/gcfpIMcoIsP3HMK8Gmg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.25' (RSA) to the list of known hosts.


BusyBox v1.30.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.2, r10947-65030d81f3
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~#

# *Now* this system is installed!

root@OpenWrt:~# cat /etc/fw_env.config
/dev/mtd1 0x0 0x20000 0x20000

# We need to set up fw_env.config again, because
# the first time around it was just a file in RAM

root@OpenWrt:~# echo /dev/mtd0 0xc0000 0x20000 0x20000 >/etc/fw_env.config

# Here's what the MTD partitions look like, just for reference

root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 07e00000 00020000 "ubi"

# A 126 MB partition for OpenWRT, not bad


# Now, connect to port 80 in a browser and start OpenWRT'ing!

And there it is!

OpenWRT is a fine little system to have installed on a device's on-board flash memory, given that it is small in size, and has been thoroughly adapted to that environment (so you don't have to worry about log files and such being written to NAND). It is especially relevant in the case of Pogoplug devices, given that the associated cloud service has been dead and gone for years now, so there's no point in keeping the stock Pogoplug OS.

While my immediate needs will be served with just OpenWRT running on the device, it is good to know that the option of running a full-featured Linux distro on attached storage will always be there.

bodhi, thank you so much for your help and hand-holding :-) Please let me know if there are any revisions you would like, to any of my posts above, so that this thread may be considered "wiki-worthy."



Edited 1 time(s). Last edit at 05/01/2020 01:29AM by iSKUNK!.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
April 30, 2020 08:27PM
iSKUNK,

Excellent :)

Could you make one new post that shows the whole thing. You can call it Part I and Part II, if you like.

The color coding is quite good, it made the working example very easy to read and follow.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 07:20AM
iSKUNK, congratulation on the success and bon voyage with OpenWRT!
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 08:44PM
Quote
bodhi
Could you make one new post that shows the whole thing. You can call it Part I and Part II, if you like.

Happy to oblige! (And thank you for the kind words too, habibie!)

However, there is a problem:

I actually have a second identical Pogoplug device that I wish to upgrade in the same way. I've been putting together a new post that documents the whole process from start to finish, using this device. Unfortunately, I've run into a point where the same steps I followed the first time successfully have yielded an error:
# Now, set some variables to address booting OpenWRT from NAND

root@OpenWrt:~# fw_setenv partition 'nand0,0'
Can't open /dev/mtd0: Permission denied
Error: can't write fw_env to flash

There are only two minor things I did differently from the first time, neither of which I'd imagine is the cause:

1. "setenv partition nand0,0" before the "nand erase.part ubi", to avoid the error message

2. Fixed an apparent typo in the "setenv bootcmd_exec" command: "then;" -> "then"

I've seen that others have encountered this error, generally due to an incorrect value of "mtdparts". But mine appears correct:
root@OpenWrt:~# fw_printenv | grep mtd
mtdids=nand0=orion_nand
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
mtdparts=mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)

Bad blocks are not an issue:
root@OpenWrt:~# dmesg | grep -i bad
[    0.805751] Scanning device for bad blocks
[    0.826173] Bad eraseblock 146 at 0x000001240000
[    0.919265] Bad eraseblock 941 at 0x0000075a0000

The only thing I noticed that seemed odd was the MTD partition table, which is different from the stock one, and different from the one I thought I'd defined when "mtdparts" was set:
root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 001c0000 00020000 "uboot"
mtd1: 00040000 00020000 "uboot_env"
mtd2: 07e00000 00020000 "ubi"

Here's the bit from dmesg about that:
[    0.933031] 3 fixed-partitions partitions found on MTD device orion_nand
[    0.939722] Creating 3 MTD partitions on "orion_nand":
[    0.944860] 0x000000000000-0x0000001c0000 : "uboot"
[    0.950503] 0x0000001c0000-0x000000200000 : "uboot_env"
[    0.956429] 0x000000200000-0x000008000000 : "ubi"

Any idea what's going on? (Or additional info you'd like to see?) This has left me scratching my head.
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 09:48PM
iSKUNK,

> Here's the bit from dmesg about that:
>
> [    0.933031] 3 fixed-partitions partitions found
> on MTD device orion_nand
> [    0.939722] Creating 3 MTD partitions on
> "orion_nand":
> [    0.944860] 0x000000000000-0x0000001c0000 :
> "uboot"
> [    0.950503] 0x0000001c0000-0x000000200000 :
> "uboot_env"
> [    0.956429] 0x000000200000-0x000008000000 :
> "ubi"
>
>
> Any idea what's going on? (Or additional info
> you'd like to see?) This has left me scratching my
> head.


It indicated that the bootcmd or bootargs is not correct. Please post

In serial console,
printenv
And in OpenWrt, post the full dmesg, or at least:
uname -a
cat /proc/cmdline

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 10:40PM
Note that the OpenWRT environment in question is the TFTP-loaded one, not the final one.

Here is the U-Boot environment:
Pogov4> printenv
arcNumber=3960
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_exec=if run load_uimage; then 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; fi
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 mmc
disks=0 1 2 3
ethact=egiga0
ethaddr=00:25:XX:XX:XX:XX
if_netconsole=ping $serverip
ipaddr=192.168.100.15
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_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
machid=f78
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)
nc_ready=1
ncip=192.168.100.10
partition=nand0,2
preboot=run preboot_nc
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
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.100.10
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=nc
stdin=nc
stdout=nc
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_ready_retry=15

Environment size: 3004/131068 bytes

And, before I rebooted to record that...

root@OpenWrt:~# uname -a
Linux OpenWrt 4.14.171 #0 Thu Feb 27 21:05:12 2020 armv5tel GNU/Linux

root@OpenWrt:~# cat /proc/cmdline 
console=ttyS0,115200

root@OpenWrt:~# dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.171 (builder@buildhost) (gcc version 7.5.0 (OpenWrt GCC 7.5.0 r10947-65030d81f3)) #0 Thu Feb 27 21:05:12 2020
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: Cloud Engines PogoPlug Series 4
[    0.000000] Memory policy: Data cache writeback
[    0.000000] On node 0 totalpages: 32768
[    0.000000] free_area_init_node: node 0, pgdat c0d28538, node_mem_map c7efa000
[    0.000000]   Normal zone: 256 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] random: get_random_bytes called from 0xc0700980 with crng_init=0
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line: console=ttyS0,115200
[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Memory: 117148K/131072K available (4804K kernel code, 162K rwdata, 728K rodata, 6144K init, 208K bss, 13924K reserved, 0K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xc8800000 - 0xff800000   ( 880 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc05b1250   (5797 kB)
[    0.000000]       .init : 0xc0700000 - 0xc0d00000   (6144 kB)
[    0.000000]       .data : 0xc0d00000 - 0xc0d28ba0   ( 163 kB)
[    0.000000]        .bss : 0xc0d28ba0 - 0xc0d5cf84   ( 209 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] clocksource: orion_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 11467562657 ns
[    0.000013] sched_clock: 32 bits at 166MHz, resolution 6ns, wraps every 12884901885ns
[    0.000060] Switching to timer-based delay loop, resolution 6ns
[    0.000173] Calibrating delay loop (skipped), value calculated using timer frequency.. 333.33 BogoMIPS (lpj=1666666)
[    0.000206] pid_max: default: 32768 minimum: 301
[    0.000410] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000444] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001270] CPU: Testing write buffer coherency: ok
[    0.002433] Setting up static identity map for 0x100000 - 0x10003c
[    0.002823] mvebu-soc-id: MVEBU SoC ID=0x6281, Rev=0x3
[    0.007678] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.007718] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.007850] pinctrl core: initialized pinctrl subsystem
[    0.009441] NET: Registered protocol family 16
[    0.010042] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.011547] cpuidle: using governor ladder
[    0.012065] Feroceon L2: Enabling L2
[    0.012126] Feroceon L2: Cache support initialised.
[    0.012517] [Firmware Info]: /ocp@f1000000/ethernet-controller@72000/ethernet0-port@0: local-mac-address is not set
[    0.017638] No ATAGs?
[    0.040396] SCSI subsystem initialized
[    0.041035] libata version 3.00 loaded.
[    0.041347] usbcore: registered new interface driver usbfs
[    0.041436] usbcore: registered new interface driver hub
[    0.041513] usbcore: registered new device driver usb
[    0.044185] clocksource: Switched to clocksource orion_clocksource
[    0.045310] NET: Registered protocol family 2
[    0.046151] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.046184] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.046212] TCP: Hash tables configured (established 1024 bind 1024)
[    0.046328] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.046363] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.046552] NET: Registered protocol family 1
[    0.046592] PCI: CLS 0 bytes, default 32
[    0.185067] Crashlog allocated RAM at address 0x3f00000
[    0.186197] workingset: timestamp_bits=30 max_order=15 bucket_order=0
[    0.192392] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.192411] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.290651] io scheduler noop registered
[    0.290673] io scheduler deadline registered (default)
[    0.292192] kirkwood-pinctrl f1010000.pin-controller: registered pinctrl driver
[    0.294289] mvebu-pcie mbus@f1000000:pcie@82000000: PCI host bridge to bus 0000:00
[    0.294316] pci_bus 0000:00: root bus resource [io  0x1000-0xfffff]
[    0.294332] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff]
[    0.294350] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.294399] pci 0000:00:01.0: [11ab:6281] type 01 class 0x060400
[    0.294685] PCI: bus0: Fast back to back transfers disabled
[    0.294706] pci 0000:00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    0.294836] PCI: bus1: Fast back to back transfers enabled
[    0.294859] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    0.294891] pci 0000:00:01.0: PCI bridge to [bus 01]
[    0.295506] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.298080] console [ttyS0] disabled
[    0.298177] f1012000.serial: ttyS0 at MMIO 0xf1012000 (irq = 25, base_baud = 10416666) is a 16550A
[    0.766761] console [ttyS0] enabled
[    0.771452] sata_mv f1080000.sata: version 1.28
[    0.771701] sata_mv f1080000.sata: slots 32 ports 1
[    0.779735] scsi host0: sata_mv
[    0.783085] ata1: SATA max UDMA/133 irq 32
[    0.787991] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xf1
[    0.794357] nand: Hynix H27U1G8F2BTR-BC
[    0.798182] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    0.805751] Scanning device for bad blocks
[    0.826173] Bad eraseblock 146 at 0x000001240000
[    0.919265] Bad eraseblock 941 at 0x0000075a0000
[    0.933031] 3 fixed-partitions partitions found on MTD device orion_nand
[    0.939722] Creating 3 MTD partitions on "orion_nand":
[    0.944860] 0x000000000000-0x0000001c0000 : "uboot"
[    0.950503] 0x0000001c0000-0x000000200000 : "uboot_env"
[    0.956429] 0x000000200000-0x000008000000 : "ubi"
[    0.963148] libphy: Fixed MDIO Bus: probed
[    0.967605] libphy: orion_mdio_bus: probed
[    0.983894] mv643xx_eth: MV-643xx 10/100/1000 ethernet driver version 1.4
[    0.993199] mv643xx_eth_port mv643xx_eth_port.0 eth0: port 0 with MAC address 00:25:31:03:fb:72
[    1.002004] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.008526] ehci-pci: EHCI PCI platform driver
[    1.013022] ehci-orion: EHCI orion driver
[    1.017281] orion-ehci f1050000.ehci: EHCI Host Controller
[    1.022795] orion-ehci f1050000.ehci: new USB bus registered, assigned bus number 1
[    1.030626] orion-ehci f1050000.ehci: irq 29, io mem 0xf1050000
[    1.064205] orion-ehci f1050000.ehci: USB 2.0 started, EHCI 1.00
[    1.070944] hub 1-0:1.0: USB hub found
[    1.074996] hub 1-0:1.0: 1 port detected
[    1.079510] usbcore: registered new interface driver usb-storage
[    1.295609] ata1: SATA link down (SStatus 0 SControl F300)
[    2.164197] rtc-mv f1010300.rtc: internal RTC not ticking
[    2.169712] i2c /dev entries driver
[    2.174053] orion_wdt: Initial timeout 25 sec
[    2.179252] mvsdio f1090000.mvsdio: Got CD GPIO
[    2.183795] mvsdio f1090000.mvsdio: Got WP GPIO
[    2.250152] random: fast init done
[    2.340159] marvell-cesa f1030000.crypto: CESA device successfully registered
[    2.348601] NET: Registered protocol family 10
[    2.355602] Segment Routing with IPv6
[    2.359342] NET: Registered protocol family 17
[    2.363807] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    2.376742] 8021q: 802.1Q VLAN Support v1.8
[    2.384598] UBI error: no valid UBI magic found inside mtd2
[    2.390423] hctosys: unable to open rtc device (rtc0)
[    2.421775] Freeing unused kernel memory: 6144K
[    2.442881] init: Console is alive
[    2.446608] init: - watchdog -
[    2.458331] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.465453] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    2.475561] init: - preinit -
[    2.611760] random: jshn: uninitialized urandom read (4 bytes read)
[    2.658997] random: jshn: uninitialized urandom read (4 bytes read)
[    2.692930] random: jshn: uninitialized urandom read (4 bytes read)
[    2.787977] mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 1000 Mb/s, full duplex, flow control disabled
[    2.797831] mv643xx_eth_port mv643xx_eth_port.0 eth0: link down
[    2.805566] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[    5.922010] mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 1000 Mb/s, full duplex, flow control disabled
[    5.931930] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    5.983180] procd: - early -
[    5.986825] procd: - watchdog -
[    6.544019] procd: - watchdog -
[    6.547470] procd: - ubus -
[    6.555403] urandom_read: 3 callbacks suppressed
[    6.555412] random: ubusd: uninitialized urandom read (4 bytes read)
[    6.600790] random: ubusd: uninitialized urandom read (4 bytes read)
[    6.607560] random: ubusd: uninitialized urandom read (4 bytes read)
[    6.615193] procd: - init -
[    6.994656] kmodloader: loading kernel modules from /etc/modules.d/*
[    7.016494] ip6_tables: (C) 2000-2006 Netfilter Core Team
[    7.037479] ip_tables: (C) 2000-2006 Netfilter Core Team
[    7.060612] nf_conntrack version 0.5.0 (2048 buckets, 8192 max)
[    7.135886] xt_time: kernel timezone is -0000
[    7.156637] PPP generic driver version 2.4.2
[    7.175137] NET: Registered protocol family 24
[    7.182791] kmodloader: done loading kernel modules from /etc/modules.d/*
[    7.193800] urngd: v1.0.2 started.
[    7.301847] random: crng init done
[    7.305274] random: 1 urandom warning(s) missed due to ratelimiting
[   17.323269] br-lan: port 1(eth0) entered blocking state
[   17.328541] br-lan: port 1(eth0) entered disabled state
[   17.334052] device eth0 entered promiscuous mode
[   17.423694] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   19.931141] mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 1000 Mb/s, full duplex, flow control disabled
[   19.941021] br-lan: port 1(eth0) entered blocking state
[   19.946264] br-lan: port 1(eth0) entered forwarding state
[   19.953831] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 11:12PM
iSKUNK,

> Here is the U-Boot environment:

No, those were the Pogo V4 default u-boot envs to boot Debian, not the final ones you are going to boot with into OpenWrt system. I need to see the envs just right before you execute

boot


What we see here in the log is: the bootarg for mtd partitions in the command line was not used (probably because the env was wrong).

So at OpenWrt shell, you wil not be able to do any flashing further.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 11:48PM
The point where I got the error was right as I was about to set the U-Boot variables for booting normally into OpenWRT (set_bootargs_owrt, bootcmd_owrt, bootcmd). Before that first-time boot of OpenWRT, this is what I did in the U-Boot session (first time the new U-Boot came up):
setenv partition nand0,0

nand erase.part ubi

tftpboot openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage

bootm 0x800000

The last U-Boot variable I'd (fw_)setenv'ed was "dtb_file", while still in Pogoplug OS. Do I need to set some other variable, or give some arguments to "bootm"?
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 01, 2020 11:56PM
iSKUNK! Wrote:
-------------------------------------------------------
> The point where I got the error was right as I was
> about to set the U-Boot variables for booting
> normally into OpenWRT (set_bootargs_owrt,
> bootcmd_owrt, bootcmd). Before that first-time
> boot of OpenWRT, this is what I did in the U-Boot
> session (first time the new U-Boot came up):
>
> setenv partition nand0,0
> 
> nand erase.part ubi
> 
> tftpboot
> openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage
> 
> bootm 0x800000
>
>
> The last U-Boot variable I'd (fw_)setenv'ed was
> "dtb_file", while still in Pogoplug OS. Do I need
> to set some other variable, or give some arguments
> to "bootm"?

The bootargs env is implicit iduring bootm. So you need to run

run set_bootargs


to get it set to a correct string (Or whatever variable that finalizes the bootargs before bootm).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 02, 2020 12:43AM
Okay, now I understand what's going on: OpenWRT has to be booted with the "mtdparts=..." option on the kernel command line in order to partition and write to the NAND correctly.

I don't understand why the whole process worked the first time, when I didn't do this. But oh well, better this is caught now, rather than months/years later when some poor soul gets the error while following my directions to the letter :-]

So I've added this step, right before the "bootm":
# Set bootargs so that OpenWRT will start up correctly
Pogov4> setenv bootargs console=ttyS0,115200 $mtdparts
(since "set_bootargs_owrt" has not yet been written to the environment)

Immediately after running that, printenv shows a value of
bootargs=console=ttyS0,115200 mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)

Once OpenWRT is booted, the MTD partitioning looks right:
root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 07e00000 00020000 "ubi"

And after setting up /etc/fw_env.config, fw_setenv finally works :-)

Thank you for the rescue! I'll continue with the install, and post the completed (and colorful!) transcript soon...
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 02, 2020 01:44AM
Cool!

> Thank you for the rescue! I'll continue with the
> install, and post the completed (and colorful!)
> transcript soon...

It's very well done so far, toolproofing the procedure like you are doing! I do this whenever I build a new u-boot version.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug Mobile with bodhi's U-Boot and OpenWRT?
May 02, 2020 10:37PM
All right, here is my "director's cut" of the process of installing a new U-Boot and current (19.07.2) OpenWRT on a Pogoplug Mobile, complete with deleted scenes not present in the original release (seen above). I've confirmed these steps by running through them on a second Pogoplug device, so I'm pretty darn sure that this process will work for anyone who follows it to the letter.

And so, without further ado...

* * *

Installation of a Modern U-Boot and OpenWRT on a Pogoplug Mobile: A Tale in Four Parts

Part I: Ye Olde Pogoplug OS

We start with a Pogoplug Mobile (POGO-V4-A1-01, blue logo) with its stock OS, and SSH/telnet access enabled. (If neither of those are working for you, then you'll probably need to crack open the case and get serial-terminal access in order to enable them.)

This process should be identical for a Pogoplug Series 4 (POGO-V4-A3-01, red logo), if that's what you have.

The below transcript is color-coded for your convenience. Red is text that you type in; green is output from commands you've entered; grey is commentary to help guide the way.

# Username is "root", default password is "ceadmin"

# You can SSH in, but newer clients will refuse to connect due
# to an old security algorithm

$ ssh root@192.168.100.25
Unable to negotiate with 192.168.100.25 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

# You can do this...

$ ssh -o KexAlgorithms=diffie-hellman-group1-sha1 root@192.168.100.25
The authenticity of host '192.168.100.25 (192.168.100.25)' can't be established.
RSA key fingerprint is SHA256:2mfYb77dWKJAYgFmUwy3rqSNMINATCJpZj+5aE/FNf0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.25' (RSA) to the list of known hosts.
root@192.168.100.25's password:
~ #

# ...or this (if telnet is enabled)

$ telnet 192.168.100.25
Trying 192.168.100.25...
Connected to 192.168.100.25.
Escape character is '^]'.

PogoplugMobile login: root
Password:
~ # 


# First things first: Grab the stock U-Boot environment

~ # /usr/local/cloudengines/bin/blparam
bootdelay=1
baudrate=115200
loads_echo=0
rootpath=/mnt/ARM_FS/
netmask=255.255.0.0
run_diag=yes
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=no
CASset=min
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
MALLOC_len=1
ethprime=egiga0
netbsd_en=no
vxworks_en=no
load_nand=nboot 0x800000 0 0x200000
load_nand2=nboot 0x800000 0 0x500000
boot=bootm 0x800000
boot_nand=run load_nand boot || run load_nand2 boot
disaMvPnp=no
ethmtu=1500
usb0Mode=host
nandEcc=1bit
hddPowerCtrl=no
pcieTune=no
ethact=egiga0
ethaddr=00:25:XX:XX:XX:XX
cesvcid=XXXXXXXXXXXXXXXXXXXXXXXXXX
ceboardver=PPV4A1
ipaddr=192.168.58.233
serverip=192.168.58.188
bootargs=console=ttyS0,115200 root=ubi0:rootfs ubi.mtd=4,2048 rootfstype=ubifs
bootcmd=run boot_nand

# Copy-and-paste all that information somewhere safe
# (you'll be needing the value of "ethaddr", at least)


# Just for reference, the stock MTD partition table

~ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 00300000 00020000 "uImage"
mtd2: 00300000 00020000 "uImage2"
mtd3: 00800000 00020000 "failsafe"
mtd4: 07000000 00020000 "root"

Now, copy the following files into /tmp:

1. U-Boot image for pogo_v4 (e.g. uboot.2017.07-tld-1.pogo_v4.bodhi.tar), available here

2. U-Boot environment file (e.g. uboot.2016.05-tld-1.environment.bodhi.tar), same place as #1

3. U-Boot flashing utilities (linux-tools-installation-bodhi.tar.gz)

How you get these files in is up to you. You can use scp, wget (no support for https:// URLs), nc, or perhaps even a USB drive.

# md5sum is available on the system, so check those hashes!
# Any corruption in these files could lead to bricking!

/tmp # md5sum linux* uboot*
e58f442411eb35e641d40ea0577e00ff  linux-tools-installation-bodhi.tar.gz
3823eef10011b864859d31a76470e0e3  uboot.2016.05-tld-1.environment.bodhi.tar
e2c2b4927dcd8189f0c97dd81b72ad7e  uboot.2017.07-tld-1.pogo_v4.bodhi.tar

# Unpack all three files, keeping everything in /tmp


# The system has no /etc/fw_env.config file, which we need in order
# to use fw_printenv / fw_saveenv (to view/set U-Boot variables)

/tmp # ./tools/fw_printenv
Cannot parse config file: No such file or directory

# We can set one up with the correct values easily...

/tmp # echo /dev/mtd0 0xc0000 0x20000 0x20000 >/etc/fw_env.config
-sh: can't create /etc/fw_env.config: Read-only file system

# ...if we briefly remount root as read-write

/tmp # mount -o remount,rw,noatime /
/tmp # echo /dev/mtd0 0xc0000 0x20000 0x20000 >/etc/fw_env.config
/tmp # mount -o remount,ro /

# fw_printenv still won't work, but it will soon

/tmp # ./tools/fw_printenv
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200


# Very important thing to do before we flash:
# Check that the first eight NAND blocks (1 MB) are good

/tmp # dmesg | grep -i bad
<6>[    1.010000] Scanning device for bad blocks
<4>[    1.030000] Bad eraseblock 360 at 0x000002d00000
<5>[    1.370000] UBI: number of bad PEBs:         1
<5>[    1.410000] UBI: number of PEBs reserved for bad PEB handling: 8

# Block 360 is bad, but fortunately, this isn't one of the first 8,
# so we're good for flashing U-Boot. If a block in 0-7 is bad, then
# DO NOT PROCEED FURTHER! BRICKING WILL ENSUE! Ask bodhi for help


# Install U-Boot

/tmp # ./tools/flash_erase /dev/mtd0 0 4
Erasing 128 Kibyte @ 60000 -- 100 % complete

/tmp # ./tools/nandwrite /dev/mtd0 uboot.2017.07-tld-1.pogo_v4.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


# Install U-Boot environment

/tmp # ./tools/flash_erase /dev/mtd0 0xc0000 1
Erasing 128 Kibyte @ c0000 -- 100 % complete

/tmp # ./tools/nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img
Writing data to block 6 at offset 0xc0000


# fw_printenv should work now; check that the environment looks sane

/tmp # ./tools/fw_printenv
arcNumber=2097
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=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
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 mmc
disks=0 1 2 3
ethact=egiga0
ethaddr=52:3b:20:9c:11:51
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
dtb_file=/boot/dts/kirkwood-pogo_e02.dtb
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
machid=0x831
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
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_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
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
usb_ready_retry=15

# (No errors reading the variables, so we're good)


# bodhi's U-Boot flashing utilities package does not include fw_setenv
# because it's the same as fw_printenv, it just needs to be run under
# a different name

/tmp # ./tools/fw_setenv
-sh: ./tools/fw_setenv: not found

# We can use a symlink, or just copy the file to fw_setenv

/tmp # ln -s fw_printenv tools/fw_setenv
/tmp # ./tools/fw_setenv


# Note that fw_setenv normally does not have any output,
# so this next section is a little boring

# Set variables for Pogoplug Mobile/V4
/tmp # ./tools/fw_setenv arcNumber 3960
/tmp # ./tools/fw_setenv machid f78

# Set 2MB U-Boot partition, and give everything else to ubifs
/tmp # ./tools/fw_setenv mtdparts 'mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)'

# Restore original MAC address from the stock U-Boot environment
# (actual value redacted)
/tmp # ./tools/fw_setenv ethaddr '00:25:XX:XX:XX:XX'

# Set up netconsole
/tmp # ./tools/fw_setenv preboot_nc 'setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi'
/tmp # ./tools/fw_setenv preboot 'run preboot_nc'

# Note that "ipaddr" is the IP address that the device will use
# (only when U-Boot is active), and "serverip" is the IP address of the
# system that will be viewing the console
/tmp # ./tools/fw_setenv ipaddr   '192.168.100.15'
/tmp # ./tools/fw_setenv serverip '192.168.100.10'

# Modification to boot Debian on USB, but fall back to OpenWRT on NAND
/tmp # ./tools/fw_setenv bootcmd_exec 'if run load_uimage; then 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; fi'

# OpenWRT neither provides nor needs a DTB file, so unset that variable
/tmp # ./tools/fw_setenv dtb_file


# And with that, we're ready to reboot

# Note: The stock Pogoplug OS can't be booted by the new U-Boot,
# so if you need anything from there, then grab it now, because this is
# the last time you'll have the chance!

# See you on the other side...

/tmp # rebootConnection closed by foreign host.

Part II: You Boot into U-Boot

Back on the system that has the "serverip" IP address, start up nc to get the netconsole, and cross your fingers...
# Use the IP address that you set in the "ipaddr" variable
# (this ensures that you only get output from the Pogoplug)
#
# Note: If the command exits immediately, then use "nc -lup 6666" instead.
# You'll be needing this command again later, so be sure to remember it

$ nc -lup 6666 192.168.100.25 6666

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4
gcc (Debian 6.3.0-18) 6.3.0 20170516
GNU ld (GNU Binutils for Debian) 2.28
Hit any key to stop autoboot:  5

Success! (If you don't see this within a minute of rebooting, then you're in trouble)

Hit Enter to stop the autoboot (it's not actually "any key," sorry), and get to the U-Boot prompt.

Hit any key to stop autoboot:  5 
 0 
Pogov4> 
Pogov4> 

# Double-check the environment

Pogov4> printenv
arcNumber=3960
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_exec=if run load_uimage; then 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; fi
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 mmc
disks=0 1 2 3
ethact=egiga0
ethaddr=00:25:XX:XX:XX:XX
if_netconsole=ping $serverip
ipaddr=192.168.100.15
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_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
machid=f78
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)
nc_ready=1
ncip=192.168.100.10
partition=nand0,2
preboot=run preboot_nc
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
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.80.10
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=nc
stdin=nc
stdout=nc
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_ready_retry=15

Environment size: 3004/131068 bytes

U-Boot installation is complete, and verified!

Part III: OpenWRT Enters the Scene

Now, we'll prepare to boot OpenWRT from the device's RAM.

This installation uses OpenWRT 19.07.2, which at the time of this writing, is the current stable release. You'll need to download two files:

1. openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage (sha256=edce2ce63a9707ea1e854a9fc8df07ab449ce6279d0acbbe6ce02a59385ebd87)

2. openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin (sha256=b2d97fe30f163ed757a2992e9c92fa90d945d917bccac9c40cd3521b354d8913)

(Be sure to check the official download site, however, as there may be a newer version out by the time you read this. And again, check those hashes!)

# This will prevent the next command from giving an error
Pogov4> setenv partition nand0,0

# Erase the MTD partition table so that OpenWRT can set it up later

Pogov4> nand erase.part ubi
NAND erase.part: device 0 offset 0x200000, size 0x7e00000
Skipping bad block at  0x02d00000                                          
Erasing at 0x7fe0000 -- 100% complete.
OK


# Because I didn't have a USB drive handy, I set up a TFTP server
# at the IP address in the "serverip" variable, with the OpenWRT uImage file

# You can also load this file off an attached FAT32-formatted USB drive
# if that's easier for you; search for "fatload" in this thread

# Download the uImage file into memory via TFTP

Pogov4> tftpboot openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage
Using egiga0 device
TFTP from server 192.168.100.10; our IP address is 192.168.100.15
Filename 'openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-initramfs-uImage'.
Load address: 0x800000
Loading: #################################################################
	 #################################################################
	 #################################################################
	 ###################################################
	 8.7 MiB/s
done
Bytes transferred = 3605263 (37030f hex)

# Set bootargs so that OpenWRT partitions the NAND correctly

Pogov4> setenv bootargs console=ttyS0,115200 $mtdparts

# And finally, boot up OpenWRT

Pogov4> bootm 0x800000
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.171
   Created:      2020-02-27  21:05:12 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3605199 Bytes = 3.4 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK


Starting kernel ...

At this point, the netconsole will became unresponsive, so you can disconnect (Ctrl-C will do it). The device will soon connect to the network normally, receiving an IP address via DHCP. Connect to that address via SSH:

# You might have to remove the previous host key from ~/.ssh/known_hosts
# if you had used SSH earlier to log into the old Pogoplug OS

$ ssh root@192.168.100.25
The authenticity of host '192.168.100.25 (192.168.100.25)' can't be established.
RSA key fingerprint is SHA256:ZW5fg5lnzTuCQrmCpygs4SxcvWrNq/fRfF7COTLvswk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.25' (RSA) to the list of known hosts.


BusyBox v1.30.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.2, r10947-65030d81f3
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~#

# Note that this OpenWRT environment is only running in RAM!
# It has not been installed to the device's NAND yet


# The stock fw_env.config is not correct for our setup...

root@OpenWrt:~# cat /etc/fw_env.config
/dev/mtd1 0x0 0x20000 0x20000

# ...so fw_printenv doesn't work

root@OpenWrt:~# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200

# So we set the correct values...

root@OpenWrt:~# echo /dev/mtd0 0xc0000 0x20000 0x20000 >/etc/fw_env.config

# ...and now fw_printenv works

root@OpenWrt:/tmp# fw_printenv
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
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 mmc
disks=0 1 2 3
ethact=egiga0
if_netconsole=ping $serverip
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
mainlineLinux=yes
mtdids=nand0=orion_nand
partition=nand0,2
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
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
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_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
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
usb_ready_retry=15
arcNumber=3960
machid=f78
mtdparts=mtdparts=orion_nand:0x200000@0x0(u-boot),-@0x200000(ubi)
ethaddr=00:25:XX:XX:XX:XX
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
preboot=run preboot_nc
ipaddr=192.168.100.15
serverip=192.168.100.10
bootcmd_exec=if run load_uimage; then; 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; fi

# The MTD partition table should look like this

root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 07e00000 00020000 "ubi"


# Now, set some variables to address booting OpenWRT from NAND

root@OpenWrt:~# fw_setenv partition 'nand0,0'
root@OpenWrt:~# fw_setenv set_bootargs_owrt 'setenv bootargs console=ttyS0,115200 $mtdparts'
root@OpenWrt:~# fw_setenv bootcmd_owrt 'run set_bootargs_owrt; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000'

# This next variable, we're actually appending to the end of it
# (you might have a value different from this)

root@OpenWrt:~# fw_printenv bootcmd
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec

# Just add "; run bootcmd_owrt" to the end 

root@OpenWrt:~# fw_setenv bootcmd 'run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run bootcmd_owrt'


# Copy the OpenWRT sysupgrade image file to the /tmp dir on the device
# and double-check for the correct hash

root@OpenWrt:/tmp# $ sha256sum openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin
b2d97fe30f163ed757a2992e9c92fa90d945d917bccac9c40cd3521b354d8913  openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin

# Run sysupgrade (which will promptly kick you out)

root@OpenWrt:/tmp# sysupgrade openwrt-19.07.2-kirkwood-cloudengines_pogoplugv4-squashfs-sysupgrade.bin
Cannot save config while running from ramdisk.
Commencing upgrade. Closing all shell sessions.
Connection to 192.168.100.25 closed by remote host.
Connection to 192.168.100.25 closed.

Part IV: OpenWRT Makes Itself at Home

Back to netconsole, to see what happens! (Don't press any key; just let it do its thing)

# Use the same command you used before

$ nc -lup 6666 192.168.100.25 6666

U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:34:01 -0700)
Pogoplug V4
gcc (Debian 6.3.0-18) 6.3.0 20170516
GNU ld (GNU Binutils for Debian) 2.28
Hit any key to stop autoboot:  0 
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

Reset IDE: ide_preinit failed
Card did not respond to voltage select!
mmc_init: -95, time 11
## 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

## Unknown partition table type 0
loading envs from usb 0 ...
** Bad device usb 0 **

no IDE devices available
Card did not respond to voltage select!
mmc_init: -95, time 10
running scan_disk ...
Scan device usb
device usb 0:1
** Bad device usb 0 **
device usb 1:1
** Bad device usb 1 **
device usb 2:1
** Bad device usb 2 **
device usb 3:1
** Bad device usb 3 **
Scan device ide

Reset IDE: ide_preinit failed
device ide 0:1
** Bad device ide 0 **
device ide 1:1
** Bad device ide 1 **
device ide 2:1
** Bad device ide 2 **
device ide 3:1
** Bad device ide 3 **
Scan device mmc
Card did not respond to voltage select!
mmc_init: -95, time 10
device mmc 0:1
Card did not respond to voltage select!
mmc_init: -95, time 11
Card did not respond to voltage select!
mmc_init: -95, time 10
** Bad device mmc 0 **
device mmc 1:1
MMC Device 1 not found
MMC Device 1 not found
** Bad device mmc 1 **
device mmc 2:1
MMC Device 2 not found
MMC Device 2 not found
** Bad device mmc 2 **
device mmc 3:1
MMC Device 3 not found
MMC Device 3 not found
** Bad device mmc 3 **
loading uImage ...
** Bad device usb 0 **
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: attached mtd1 (name "mtd=1", size 126 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 1007, bad PEBs: 1, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 2773805143
ubi0: available PEBs: 0, total reserved PEBs: 1007, PEBs reserved for bad PEB handling: 19
Read 0 bytes from volume kernel to 800000
No size specified -> Using max size (2193408)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.171
   Created:      2020-02-27  21:05:12 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2079191 Bytes = 2 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK


Starting kernel ...

You can see U-Boot poking around, trying to find a system to boot on an IDE (SATA) drive, USB drive, MMC (SD card). None of those are present, so it falls back to what's in NAND. And it looks like it booted something successfully. Back to SSH...

# Make sure to delete the old entry for the device from your
# ~/.ssh/known_hosts file, or else you will get a big scary warning
# about the host key having changed

$ ssh root@192.168.100.25
The authenticity of host '192.168.100.25 (192.168.100.25)' can't be established.
RSA key fingerprint is SHA256:yAqh277tA08JMFh5GSbZkka/gcfpIMcoIsP3HMK8Gmg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.25' (RSA) to the list of known hosts.


BusyBox v1.30.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.2, r10947-65030d81f3
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~#

# *Now* this system is installed!

root@OpenWrt:~# cat /etc/fw_env.config
/dev/mtd1 0x0 0x20000 0x20000

# We need to set up fw_env.config again, because
# the first time around it was just a file in RAM

root@OpenWrt:~# echo /dev/mtd0 0xc0000 0x20000 0x20000 >/etc/fw_env.config

# Check the MTD partitions again

root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 07e00000 00020000 "ubi"

# (That's a 126 MB partition for OpenWRT, by the way)


# Now, point your Web browser to port 80 and start configuring!

The End

One last thing you may want to do is set U-Boot's "ipaddr" and "serverip" variables to LAN addresses that are unlikely to occur on your network. When the Pogoplug powers up, if the system at "serverip" responds to a ping, it will get netconsole access---which (from a security perspective) is equivalent to getting root. You can always connect the device directly to something like a laptop, and set the laptop to whatever strange address you use.

If you'd like to run Debian on this device from external storage (e.g. a USB drive), see this thread. OpenWRT can remain installed on the NAND as a fallback for when no storage is attached.

Please give bodhi your virtual cookies for supporting these fine little devices :-)

* * *

bodhi, thank you again for all your help! Please let me know if any corrections/clarifications are needed in the above.



Edited 2 time(s). Last edit at 05/05/2020 02:17AM by iSKUNK!.
Author:

Your Email:


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: