Welcome! Log In Create A New Profile

Advanced

fw_printenv and fw_setenv

Posted by balanga 
fw_printenv and fw_setenv
October 31, 2017 09:52AM
According to http://projects.doozan.com/uboot/ two new command line tools for configuring the environment: fw_printenv and fw_setenv, which work exactly like their internal printenv and setenv commands.

How do I get them into my uboot if I am booting from a USB stick?
Re: fw_printenv and fw_setenv
October 31, 2017 12:17PM
Re: fw_printenv and fw_setenv
October 31, 2017 04:24PM
feas Wrote:
-------------------------------------------------------
> https://forum.doozan.com/read.php?3,27280

The post start with

Quote

While in stock OS...
and I'm not so I don't know if it applies...
Re: fw_printenv and fw_setenv
October 31, 2017 06:19PM
balanga Wrote:
-------------------------------------------------------
> feas Wrote:
> -------------------------------------------------------
> >
> https://forum.doozan.com/read.php?3,27280
>
> The post start with
>
>
Quote

While in stock OS...
and I'm not so
> I don't know if it applies...

The binaries work in both stock OS and any other modern OS such as Debian or Arch.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: fw_printenv and fw_setenv
November 11, 2017 05:04PM
Further to my original post regarding http://projects.doozan.com/uboot/ which mentions running the folowing:
cd /tmp
wget http://projects.doozan.com/uboot/install_uboot_mtd0.sh
chmod +x install_uboot_mtd0.sh
./install_uboot_mtd0.sh

How can I tell what version of U-Boot this loads? Maybe it is already installed...

After running fw_printenv at the debian command line I get:-
baudrate=115200
bootcmd=ide reset; usb start; setenv letter 9;for type in ide usb; do for disk in 0; do if ${type} part ${disk};then setexpr letter $letter + 1;run load;fi;done;done;
bootdelay=3
bootm=echo Booting from ${disk} ...; run setargs; bootm ${loadaddr};
bootz=echo Booting from ${disk} ...; run setargs; bootz ${loadaddr} - ${fdt_addr};
console=ttyS0
ethact=egiga0
fdt_addr=0x800000
fdt_file=/boot/dtbs/kirkwood-goflexnet.dtb
importbootenv=echo Importing environment (uEnv.txt)...; env import -t $loadaddr $filesize
load=echo Attempting to boot from ${type} ${disk}:1...;if run loadbootenv; then run importbootenv;fi;echo Checking if uenvcmd is set ...;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;echo Running default loadzimage ...;if run loadzimage; then run loadfdt;run bootz;fi;echo Running default loaduimage ...;if run loaduimage; then run bootm;fi;
loadaddr=0x810000
loadbootenv=load ${type} ${disk}:1 ${loadaddr} /boot/uEnv.txt
loadfdt=load ${type} ${disk}:1 ${fdt_addr} ${fdt_file}
loaduimage=load ${type} ${disk}:1 ${loadaddr} ${uimage}
loadzimage=load ${type} ${disk}:1 ${loadaddr} ${zimage}
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),-(rootfs)
setargs=setenv bootargs console=${console},${baudrate} ${optargs} root=/dev/sd${letter}1 rw rootwait ${mtdparts}
uimage=/boot/uImage
zimage=/boot/zImage
ethaddr=00:10:75:2E:AE:0F

I'm still trying to figure out what all this means and where it is set... If I run something like

fw_setenv abc xyz

should I expect abc=xyz to show up when I reboot? And can I reset it subsequently?

Sorry for all these nooby questions, but I seem to have a mental block when it comes to U-Boot.
Re: fw_printenv and fw_setenv
November 11, 2017 07:01PM
balanga,

> Sorry for all these nooby questions, but I seem to
> have a mental block when it comes to U-Boot.

This is why it has been very difficult to help you.

When you have mental block like that, abadon all you have read about u-boot. Pretend you know nothing, and follow instruction to install the latest u-boot for your box:

https://forum.doozan.com/read.php?3,12381

Do each step exactly as instructed (no need to understand what they mean). At each step, if you have problem, stop and post the log of what you've done from beginning. And I or feas will help you get through that step.

Once you have successfully installed u-boot and run Debian. Then at that time, for your own experience, ask questions about what the commands in the steps mean.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: fw_printenv and fw_setenv
November 12, 2017 03:22AM
bodhi,

I really appreciate the hard work you do and the patience you have with people like myself. Thanks to your advice I managed to bring my GoFlexHome back from the dead.

At the moment I'm unable to use my serial cable to access my unit and can't be sure about which U-Boot I'm using. I do have two USB sticks which boot up OK. One is Debian and the one I'm using currently is Linux alarm 4.4.88-1-ARCH #1 PREEMPT armv5tel. I've just discovered that fw_printenv is not included in the rootfs and has to be installed seperately, but have found out how. One thing it shows is

fdt_file=/boot/dtbs/kirkwood-goflexnet.dtb

What does this refer to, since it does not exist on my USB stick and where is it set?


What I'd like to do is show what is installed in NAND and am not sure how to do that. Also is it possible to enter U-Boot commands from a Linux command prompt as I am unable to stop the U-Boot process without a working serial connection.
Re: fw_printenv and fw_setenv
November 12, 2017 04:36AM
balanga,

> At the moment I'm unable to use my serial cable to
> access my unit and can't be sure about which
> U-Boot I'm using.

If you have serial console then you would execute
ver

Without serial console, you can grep the mtd0 inside Linux shell to find the version string:

grep -a --null-data U-Boot /dev/mtd0ro

Note: when you run this grep command, it will show the u-boot version string, and also spit out a whole bunch of NAND errors in sys log (run dmesg to see them). There is no errors, those messages are normal (it is because mtd block devices cannot be read this way without extra setup, which we don't need to do).


> I do have two USB sticks which
> boot up OK. One is Debian and the one I'm using
> currently is Linux alarm 4.4.88-1-ARCH #1 PREEMPT
> armv5tel. I've just discovered that fw_printenv is
> not included in the rootfs and has to be installed
> seperately,

True. Install mtd-utils to get fw_setenv (fw_printenv is the same binary).

> One thing it shows is
fdt_file=/boot/dtbs/kirkwood-goflexnet.dtb

> What does this refer to, since it does not exist
> on my USB stick and where is it set?

This fdt_file variable is a u-boot env variable, it is Arch u-boot way to refer to the location of the device tree blob.

On my Debian rootfs, it is slightly different, it is at
dtb_file=/boot/dts/kirkwood-goflexnet.dtb

If that dtb file is not in Arch rootfs then your Arch rootfs version is not FDT-enable. They released 2 different versions. If you want to run Arch properly, you need to download the FDT-enbale version rootfs, which should have the folder /boot/dtbs.

The DTB is the binary blob resulted from compiling the DTS (Device Tree Specification) with the same name. This is Linux way to specify the box hardware characteristics, and how to initialize the box during kernel booting.


> What I'd like to do is show what is installed in
> NAND and am not sure how to do that.

We already shows how to identify u-boot version in mtd0. Don't worry about the rest of the mtds 1,2,3,4,.... they are not relevant (these contains the stock kernel and stock rootfs of this box). We are booting with USB rootfs, so all those mtds are ignored. But if you want to know exactly what in your box then run

cat /proc/mtd
The output will show the self explanatory names of all mtds.


> Also is it
> possible to enter U-Boot commands from a Linux
> command prompt as I am unable to stop the U-Boot
> process without a working serial connection.

You cannot control u-boot in Linux. The fw_setenv and fw_printenv are Linux commands to manipulate the u-boot envs area. This is so that you can set up the envs for booting,

Once Linux starts, u-boot ceases to exist. The last thing u-boot does is loading the kernel files, and then give control to the bootm command (or bootz if it is setup taht way), and then terminate istself.

So you do need to have working serial console to have full control of u-boot, and also to see what;s going on during Linux kernel booting. Without a working serial console, you can only manipulate the u-boot envs.

BTW, If you have netconsole, then you can control u-boot just like with serial console. But you will not see the entire boolog with netconsole.

----
EDIT: typo.

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



Edited 5 time(s). Last edit at 11/12/2017 05:13AM by bodhi.
Re: fw_printenv and fw_setenv
November 12, 2017 10:41AM
bodhi Wrote:
-------------------------------------------------------
> If you have serial console then you would execute
>
> ver
>
>
> Without serial console, you can grep the mtd0
> inside Linux shell to find the version string:
>
>
> grep -a --null-data U-Boot /dev/mtd0ro
>

[root@alarm ~]# grep -a --null-data U-Boot /dev/mtd0ro
Warning: U-Boot configured device %s at address %11x.
but the device tree has it address %11x.
U-Boot** Invaild partition type "%.32s" (expect "U-Boot")
U-Boot BUG at %s:%d!
U-Boot 2014.04.R2-1 (May 15 2014 - 14:36:05) Arch Linux ARM
Seagate GoFlex Home

Is this what I should expect?
Re: fw_printenv and fw_setenv
November 12, 2017 04:42PM
balanga Wrote:
-------------------------------------------------------
> bodhi Wrote:
> -------------------------------------------------------
> > If you have serial console then you would
> execute
> >
> > ver
> >
> >
> > Without serial console, you can grep the mtd0
> > inside Linux shell to find the version string:
> >
> >
> > grep -a --null-data U-Boot /dev/mtd0ro
> >
>
> [root@alarm ~]# grep -a --null-data U-Boot
> /dev/mtd0ro
> Warning: U-Boot configured device %s at address
> %11x.
> but the device tree has it address %11x.
> U-Boot** Invaild partition type "%.32s" (expect
> "U-Boot")
> U-Boot BUG at %s:%d!
> U-Boot 2014.04.R2-1 (May 15 2014 - 14:36:05) Arch
> Linux ARM
> Seagate GoFlex Home
>
> Is this what I should expect?

Yes, that's Arch U-boot on your mtd0.

-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: