Welcome! Log In Create A New Profile

Advanced

Clone u-boot and environment settings

Posted by woody 
Clone u-boot and environment settings
August 18, 2019 04:30PM
I have several Pogoplug E02 devices. I recently updated u-boot on one of them to the 2017-07 U-Boot using the instructions posted by Bodhi. I managed to bork up some of the environment settings, so I had to crack open the Pogo and use a serial console to get it working again. I want to upgrade my other devices, but I don't want to have to set the environment settings for each one.

I have a nanddump of mtd0 from the 1st device that I've successfully upgraded. If I restore that nanddump to another unit, will it also update the environment settings? If not, is there a straightforward way to copy the environment settings from one Pogo to another without having to do it manually?
Re: Clone u-boot and environment settings
August 18, 2019 05:02PM
woody,

> I have several Pogoplug E02 devices. I recently
> updated u-boot on one of them to the 2017-07
> U-Boot using the instructions posted by Bodhi. I
> managed to bork up some of the environment
> settings, so I had to crack open the Pogo and use
> a serial console to get it working again. I want
> to upgrade my other devices, but I don't want to
> have to set the environment settings for each
> one.
>
> I have a nanddump of mtd0 from the 1st device that
> I've successfully upgraded. If I restore that
> nanddump to another unit, will it also update the
> environment settings?

Yes, it will update everything. But since this is the Pogo E02, there is safer way to populate the envs (see below). Pogo E02 does not have UART booting with kwboot to rescue the box.

> If not, is there a
> straightforward way to copy the environment
> settings from one Pogo to another without having
> to do it manually?

If you want to skip the u-boot image installation too, then use nanddump and nandwrite to replace the entire mtd0 (1 MB). The envs are embedded inside this 1MB. So you will replace both u-boot and envs.

After you nandwrite the mtd0 backup to the target Pogo E02, you can change them using fw_setenv right away, no need to reboot.


The safe way to transfer the envs easily is to use uEnv.txt (but it is slower than replacing mtd0)

Since you have 2017.07-tld-1 u-boot, you can use this capability.

On the referenced Pogo E02, save the envs in uEnv.txt
fw_printenv > uEnv.txt

And then edit it to have appropriate values for the target Pogo E02 (ethaddr, ipaddr, serverip are unique for each box).

Boot the target Pogo E02. Assuming the target Pogo E02 already has 2017.07-tld-1 u-boot installed.

Copy the uEnv.txt to /boot.

Reboot, interrupt serial console or netconsole, and

run bootcmd_uenv
After this the envs in uEnv.txt will replace the existing ones. Modify them as you need or want to for this target box.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 18, 2019 05:13PM
Thanks for the quick reply! That helps a lot.
Re: Clone u-boot and environment settings
August 18, 2019 06:32PM
Quote
bodhi
After you nandwrite the mtd0 backup to the target Pogo E02, you can change them using fw_setenv right away, no need to reboot.

I forgot! this might not be true if you are inside stock OS. So reboot might be needed in this case.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 18, 2019 10:07PM
In my case, the ones I'm updating still have an old u-boot, so I have to reflash mtd0 anyway. This way, I should be able to flash the nanddump from the one I already converted and fix the environment variables at the same time.

One issue I had with the first one is that it would not boot into my root partition using the partition label. The first partition is labeled ROOTFS in all caps. I changed the boot_args environment variable to 'root=LABEL=ROOTFS', but it didn't work. I got it to boot by changing it to 'root=/dev/sda1'. Any idea why booting by label wouldn't work?
Re: Clone u-boot and environment settings
August 19, 2019 12:42AM
woody,

> One issue I had with the first one is that it
> would not boot into my root partition using the
> partition label. The first partition is labeled
> ROOTFS in all caps. I changed the boot_args
> environment variable to 'root=LABEL=ROOTFS', but
> it didn't work. I got it to boot by changing it to
> 'root=/dev/sda1'. Any idea why booting by label
> wouldn't work?

The rootfs label is quite important and this approach has a few moving parts. Thus I would recommend using rootfs as the label always, to ensure no change is needed.

For whatever reason sometime you need to change the rootfs label, so you might also need to change the /etc/fstab (my basic rootfs has this label to conform with the bootarg). This also depends on which Debian version is the rootfs currently updated to. In the past Debian versions, root device in fstab is not important. But in a few recent Debian versions, the root device specification is more important during rootfs mounting,

LABEL=rootfs    /               ext4    noatime,errors=remount-ro 0 1
Try changing it (of course use ext3 if your current rootf is Ext3):
LABEL=ROOTFS    /               ext4    noatime,errors=remount-ro 0 1

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 19, 2019 12:36PM
Ok, I'm going to relabel my rootfs and try it again

Another question:
I previously had Jeff's rescue system installed, but it's not working with the new environment variables. I think I need to add these back:

force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000  rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd; fi
rescue_bootcmd=if test $rescue_installed -eq 1; then run rescue_set_bootargs; nand read.e 0x800000 0x100000 0x400000; bootm 0x800000; else run pogo_bootcmd; fi
rescue_set_bootargs=setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs ro rootfstype=ubifs $mtdparts $rescue_custom_params
rescue_installed=1

Currently, I'm using this from the default variables:

bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
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_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi

What should I change to enable the rescue system when a regular boot fails?
Re: Clone u-boot and environment settings
August 19, 2019 01:28PM
Quote

I previously had Jeff's rescue system installed, but it's not working with the new environment variables. I think I need to add these back:

force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000 rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd; fi
rescue_bootcmd=if test $rescue_installed -eq 1; then run rescue_set_bootargs; nand read.e 0x800000 0x100000 0x400000; bootm 0x800000; else run pogo_bootcmd; fi
rescue_set_bootargs=setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs ro rootfstype=ubifs $mtdparts $rescue_custom_params
rescue_installed=1

Yes.

And these 2 envs should be modified as:

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'
setenv bootcmd 'run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run rescue_bootcmd'

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 19, 2019 03:51PM
Ok, seems like things are generally working ok, except I still can't boot when I have set_bootargs pointing to 'root=LABEL=rootfs'. I'm running Arch Linux. My root drive is on /dev/sda1 and is labeled 'rootfs'. I changed the partition label to 'rootfs'. The /boot folder is also on that partition. It appears that it should boot that way, but it's not working.

It does work with 'root=/dev/sda1'.
Re: Clone u-boot and environment settings
August 19, 2019 05:24PM
woody,

> Ok, seems like things are generally working ok,
> except I still can't boot when I have set_bootargs
> pointing to 'root=LABEL=rootfs'. I'm running Arch
> Linux
.

Duh :) it would be more helpful if you stated that up front. Remember this is Debian forum.

> My root drive is on /dev/sda1 and is
> labeled 'rootfs'. I changed the partition label to
> 'rootfs'. The /boot folder is also on that
> partition. It appears that it should boot that
> way, but it's not working.
>
> It does work with 'root=/dev/sda1'.

Of course it does not work if you boot Arch Linux with the rootfs label. You need an extra step.

Did I understand correctly that your rootfs is Arch Linux ARM?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 19, 2019 05:31PM
Sorry, I didn't see any indication that this is a Debian forum. The heading I saw was for U-Boot. I thought people were probably using various OS's.

Yes, it's Arch Linux Arm. What's the extra step I need?
Re: Clone u-boot and environment settings
August 19, 2019 06:38PM
woody,

> Sorry, I didn't see any indication that this is a
> Debian forum. The heading I saw was for U-Boot. I
> thought people were probably using various OS's.
>
> Yes, it's Arch Linux Arm. What's the extra step I
> need?

You need to boot with uInitrd to use rootfs label. On Arch rootfs, I think it has an initrd image, I forgot what it's called.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 19, 2019 07:03PM
I'll check it out. Do you think it's ok to use this u-boot with Arch Linux?



Edited 1 time(s). Last edit at 08/19/2019 07:20PM by woody.
Re: Clone u-boot and environment settings
August 19, 2019 08:28PM
woody,

> I'll check it out. Do you think it's ok to use
> this u-boot with Arch Linux?

Sure. Lots of people have used my released u-boot with Arch Linux.

See the Wiki thread

Quote

Booting Other Linux Distros on Pogoplug

How to boot Arch Linux ARM with bodhi's released u-boot
How to boot Void Linux with bodhi's released u-boot

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Clone u-boot and environment settings
August 21, 2019 02:09PM
Ok, I created a test installation of Arch Arm and got it booting up with your U-boot. I then upgraded to the mainline kernel. Now I have a zimage file and a dtb file, but no uimage file. I think that I should be able to boot with the dtb file, but I can't get it to work.

I'm using these env settings:
set_bootargs=setenv bootargs console=ttyS0,115200 root=$usb_root rootdelay=10 $mtdparts $custom_params
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run rescue_bootcmd
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
dtb_file=/boot/dtbs/kirkwood-pogo_e02.dtb

This is what I get in netconsole:
U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:13:18 -0700)
Pogo E02
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... 3 USB Device(s) found
       scanning usb for storage devices...
Use USB retry period from the environment: 15 second(s)
1 Storage Device(s) found
Unknown command 'ide' - try 'help'
Unknown command 'mmc' - try 'help'

Partition Map for USB device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            30863360        af0e515c-01     83

## 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 ...
** File not found /boot/uEnv.txt **
Unknown command 'ide' - try 'help'
Unknown command 'mmc' - try 'help'
running scan_disk ...
Scan device usb
device usb 0:1
** File not found /boot/uImage **
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
Unknown command 'ide' - try 'help'
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
Unknown command 'mmc' - try 'help'
device mmc 0:1
** Bad device mmc 0 **
device mmc 1:1
** Bad device mmc 1 **
device mmc 2:1
** Bad device mmc 2 **
device mmc 3:1
** Bad device mmc 3 **
loading uImage ...
** File not found /boot/uImage **

NAND read: device 0 offset 0x100000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux-3.3.2-kirkwide
   Created:      2012-10-29  22:52:12 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3627768 Bytes = 3.5 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK


Starting kernel ...

Any suggestions on what I need to do to get booted? Do I need an environment setting to load the zimage, or am I doing something else wrong?
Re: Clone u-boot and environment settings
August 21, 2019 11:40PM
Try this uEnv.txt

load_image=echo loading zImage ...; load $bootdev $device $load_uimage_addr /boot/zImage
set_bootargs=setenv bootargs console=ttyS0,115200 root=$usb_root rootdelay=10 $mtdparts $custom_params
bootcmd_exec=if run load_image; then; if run load_initrd; then if run load_dtb; then bootz $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootz $load_uimage_addr $load_initrd_addr; fi; else if run load_dtb; then bootz $load_uimage_addr - $load_dtb_addr; else bootz $load_uimage_addr; fi; fi; fi
dtb_file=/boot/dtbs/kirkwood-pogo_e02.dtb

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



Edited 2 time(s). Last edit at 08/21/2019 11:58PM by bodhi.
Re: Clone u-boot and environment settings
August 22, 2019 04:10PM
Well, that got me into the boot process, but during the boot, several systemd processes fail, including network name resolution and login service. I'm trying to use the 5.2.9-1 kernel. Using TTY, I get a login prompt, but authentication fails. I think that this is an Arch problem, not a U-boot problem. I will see if I can find any discussion on how to fix this.
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: