Welcome! Log In Create A New Profile

Advanced

Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt

Posted by LeggoMyEggo 
Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 14, 2015 03:40PM
******!!!!CURRENTLY BETA AND FOR SINGLE DEVICE ATTACHED BOOTING ONLY!!!!!********

With the release of the latest bodhi u-boot for Oxnas (uboot.2013.10-tld-4 u-Boot), those of us with Oxnas powered Pogoplugs now have the opportunity to use an alternative boot environment that is called from the new default uboot environment through the uenv_import function. With this new uenv import function, all you need to do is put a file in /boot named uEnv.txt. If you put a file name uEnv.txt in /boot, and provided the boot env's set in that file are valid, that will become your boot environment. This allows you to modify the boot environment without changing the firmware env's so that if you want to leave the stock firmware as is you can boot that by renaming uEnv.txt to something else or if you want to change the device you boot from you simply just modify uEnv.txt to say change boot from IDE as opposed to USB.

I have devised a set of boot env's that I want to post as a file as a sample for anyone else to use. You'll notice the boot env's are set in this file slightly differently than from the fw_setenv command in that you use an equals sign and you don't need to have single quote characters in front and in back of the environment variable you are trying to set. My suggested boot env's are below and I would ask my fellow forum members to review them and comment before I attach it as a file. I just want to make sure I don't have any syntax errors or have left anything out so thanks for your eyes in advance:

Suggested uEnv.txt content:

autoload=no
baudrate=115200
bootdelay=3
rootdelay=10
rootfstype=ext3
console=console=ttyS0,115200n8
usb_root=/dev/sda1 
ide_root=/dev/sda1
ethact=mii0
ethaddr=>>>>>>>>>>>>>>>NOTHING HERE YET<<<<<<<<<<<<<<<<<<
serverip=>>>>>>>>>>>>>>>NOTHING HERE YET<<<<<<<<<<<<<<<<<<
ipaddr=>>>>>>>>>>>>>>>NOTHING HERE YET<<<<<<<<<<<<<<<<<<<
mtdids=nand0=41000000.nand
mtdparts=mtdparts=41000000.nand:14m(boot),-(data)
preboot_nc=run if_netconsole start_netconsole
if_netconsole=ping $serverip
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version
stdin=serial
stdout=serial
stderr=serial
uimage_addr=0x60500000
uinitrd_addr=0x60e00000
dtb_addr=0x62c00000
boot_device=0:1
bootcmd=run dt_bootcmd_usb
dt_bootm=bootm $uimage_addr $uinitrd_addr $dtb_addr
dt_bootcmd_ide=ide reset; run dt_ide_bootcmd; ide reset
dt_ide_bootcmd=run ide_set_bootargs; run dt_ide_boot
ide_set_bootargs=setenv bootargs console=ttyS0,115200 root=/dev/sda1 rootdelay=10
dt_ide_boot=run dt_ide_load_uimage; run dt_ide_load_initrd; run dt_ide_load_dtb; run dt_bootm
dt_ide_load_uimage=ext2load ide $boot_device $uimage_addr /boot/uImage
dt_ide_load_initrd=ext2load ide $boot_device $uinitrd_addr /boot/uInitrd
dt_ide_load_dtb=ext2load ide $boot_device $dtb_addr /boot/dts/ox820-pogoplug-pro.dtb
dt_bootcmd_usb=usb start; run dt_usb_bootcmd; usb stop; reset
dt_usb_bootcmd=run usb_set_bootargs; run dt_usb_boot
usb_set_bootargs=setenv bootargs console=ttyS0,115200 root=/dev/sda1 rootdelay=10
dt_usb_boot=run dt_usb_load_uimage; run dt_usb_load_initrd; run dt_usb_load_dtb; run dt_bootm
dt_usb_load_uimage=ext2load usb $boot_device $uimage_addr /boot/uImage
dt_usb_load_initrd=ext2load usb $boot_device $uinitrd_addr /boot/uInitrd
dt_usb_load_dtb=ext2load usb $boot_device $dtb_addr /boot/dts/ox820-pogoplug-pro.dtb

Edit: Attached sample file for the lazy. Not that lazy, you need to change the file name to uEnv.txt and finish filling out the information.



Edited 8 time(s). Last edit at 05/08/2015 03:16PM by LeggoMyEggo.
Attachments:
open | download - uEnv.txt-sample (1.8 KB)
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 14, 2015 04:21PM
@ LeggoMyEggo,

Two comments:

1. The below variable is a leftover default value from the original GitHub u-boot. We should take it out to avoid confusion:
preboot=run safeboot

Furthermore, in uboot.2013.10-tld-4 u-boot version, if loaded from uEnv.txt, the variable preboot does not serve its purpose anyway. Because the uEnv.txt is loaded by the bootcmd, and preboot happened before bootcmd is executed.

2. This is a nice set of u-boot envs defaults for uEnv.txt, but great for single drive booting only. Perhaps you should note that fact in the 1st post. When multiple drives are attached, the following variables are mutually exclusive, so it would cause some problem (ide will take device 0).

usb_device=0:1
ide_device=0:1

PS.

Btw, I have a scan disk env script ready (similar to Jeff's usb_scan_disk, but will scan al drive types) for public consumption, but not uploaded yet.

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



Edited 1 time(s). Last edit at 03/14/2015 04:24PM by bodhi.
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 14, 2015 04:34PM
bodhi,

OK, I removed the preboot=run safeboot and I changed the usb_device and ide_device variables to be simply just boot_device. As you have noted, this only accounts for a single device being attached at boot time. I take it then that the scan disk routine you mention would be able to handle a multi-disk scenario and properly assign the device number based on the results of the scan. I'll go ahead and note this in my first post and await the introduction of the scan disk function for incorporation in my suggested env's.

Edit: Just as an FYI, my overall goal with this is to be able to simply modify the bootcmd variable to be either bootcmd= run dt_bootcmd_usb or bootcmd=run dt_bootcmd_ide depending on preference with all the other variables remaining untouched.

I also changed dt_load_uimage, dt_load_unitrd and dt_load_dtb (for usb) to be dt_usb_load_uimage, dt_usb_load_initrd and dt_usb_load_dtb respectively to maintain consistency with the nomenclature of the corresponding ide variables.



Edited 2 time(s). Last edit at 03/14/2015 05:10PM by LeggoMyEggo.
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 16, 2015 06:05PM
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 16, 2015 10:18PM
bodhi Wrote:
-------------------------------------------------------
> Scan disk:
> http://forum.doozan.com/read.php?3,19093,20399#msg
> -20399

I'm trying to figure it out. The diskscan can't be called for out of uEnv.txt because u-boot has to know which disk is the rootfs before it will search for the uEnv.txt file in that rootfs' /boot folder. Is there a variable set in the "pre-boot" part of u-boot (where the disk scan is performed) which could be read by uEnv.txt which I could use in the uEnv.txt file to direct bootcmd accourdingly? I'm thinking something like 'if diskscan variable = x, boot from usb else if diskscan variable =y boot from ide'. Or something like that. My situation, I followed Jeff's guide on poking a hole in my Pro so that I have an esata port externally available. So now I can boot from ide or usb depending on preference. I was hoping that all I would have to do is plug in a bootable drive into one interface or the other and that u-boot would automatically detect what interface contained the rootfs and then boot from that drive automatically. I'm thinking even with diskscan, unless I change bootcmd via fw_setenv, it's gonna default to the usb interface and not check ide. Is this assumption wrong?



Edited 2 time(s). Last edit at 03/16/2015 10:30PM by LeggoMyEggo.
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 16, 2015 10:58PM
@LeggoMyEggo,

> The diskscan can't
> be called for out of uEnv.txt because u-boot has
> to know which disk is the rootfs before it will
> search for the uEnv.txt file in that rootfs' /boot
> folder.

Not really. The scan disk has nothing to do with rootfs yet. If you reread my post:
http://forum.doozan.com/read.php?3,19093,19093#msg-19093
we are still in Section A. This is still where u-boot tries to find uImage. How u-boot finds the rootfs can be defined in uEnv.txt.

I think I can see where your problem is. Because the post above deals with the normal case where the bootcmd env can be defined and save normally.

In your case, because you rely solely on the default bootcmd in u-boot code to piggy back the entire set of envs in uEnv.txt. So let's look at the default bootcmd
bootcmd=run bootcmd_uenv; run dt_bootcmd_usb; reset

So what you need to do in the case where the NAND block is bad: you can not redefine bootcmd, so you must piggy back on the " run dt_bootcmd_usb" part. So whatever you need to do in a real bootcmd, you must include it in there.

For example, to boot with USB and then SATA in order of preference, this must be defined inside uEnv.txt:

dt_usb_bootcmd=run usb_set_bootargs; run dt_usb_boot; run dt_ide_boot

I hope I've clarified it :) I know it's a little weird looking, but because your NAND block is bad, you can't change the name dt_usb_bootcmd. And the default bootcmd was defined with a normal booting where the USB is the only drive (it's a fallback mechanism, after all).

Please ask questions if you have them, you're helping me to test this abnormal case. I might still be missing something.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 17, 2015 06:33AM
Actually I wasn't thinking about my special case board with the bad nand blocks. It developed other problems - I can get it to boot with the specially prepared disk but for some reason it can't fully boot the kernel with known good rootfs' both on usb and ide disks. I've given up on it kind of.

What I was thinking about is a normal healthy system where I can properly change the board nand boot env's with fw_setenv. But even with a normal healthy system, what I was looking for was the ability to boot off of an ide disk at will without having previously changed anything in the nand boot env's. So you are saying this scan disk function which is part of the default boot environment would scan all the connected devices, whether usb or ide, and search for the one which has the /boot directory and then boot off of that one automaitcally?. If so that is what I wanted.
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 17, 2015 03:23PM
LeggoMyEggo,

> So you are saying this scan disk
> function which is part of the default boot
> environment would scan all the connected devices,
> whether usb or ide, and search for the one which
> has the /boot directory and then boot off of that
> one automaitcally?. If so that is what I
> wanted.

Yes. That's exactly the purpose. But it is not inside u-boot (i.e. default). You must set it with setenv in console, or fw_setenv in Linux.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 17, 2015 04:04PM
bodhi Wrote:
-------------------------------------------------------
> Yes. That's exactly the purpose. But it is not
> inside u-boot (i.e. default). You must set it with
> setenv in console, or fw_setenv in Linux.

So confirming, the scandisk check is performed before the uenv import call/function?
Re: Pogoplug V3 (Pro and Classic) - Sample u-boot Env's for uEnv.txt
March 17, 2015 04:18PM
LeggoMyEggo,

>
> So confirming, the scandisk check is performed
> before the uenv import call/function?

It could be before or after, depending on your need.

This will scan the disks that were specified in devices to find uImage, regardless of what will be redefined in bootcmd_uenv.
fw_setenv bootcmd 'run scan_disk; run bootcmd_uenv; run set_bootargs_xxx; run bootcmd_xxx, reset'

This will redefine the envs according to what in uEnv.txt, and then scan the disk to find uImage. Scan disk run this way will be affected by what were defined in uEnv.txt.
fw_setenv bootcmd 'run bootcmd_uenv; run scan_disk; run set_bootargs_xxx; run bootcmd_xxx, reset'

Normally, the second option is what we want. For example, if we want to only consider USB and not SATA, then setting devices=usb in uEnv.txt will tell scan_disk to ignore ide devices.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
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: