Welcome! Log In Create A New Profile

Advanced

Understanding my environment

Posted by balanga 
Understanding my environment
February 24, 2019 05:05PM
I've recently tried to get my U-Boot 2017.05-tld-2 working again - the one with bootelf for FreeBSD, and I don't undestand the environment I have or where it comes from....

-Boot 2017.05-tld-2 (Jul 26 2017 - 02:37:42 -0700)
Seagate GoFlex Home

SoC:   Kirkwood 88F6281_A1
DRAM:  128 MiB
WARNING: Caches not enabled
NAND:  256 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
88E1116 Initialized on egiga0
Hit any key to stop autoboot: 10.
GoFlexHome> printenv
api_address=7b12860
arcNumber=3338
baudrate=115200
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; reset
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_add
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=usb
console=console=ttyS0,115200
device=0:1
devices=usb ide
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-goflexhome.dtb
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
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
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_d
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=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: 2920/131068 bytes
GoFlexHome> terminal: Input/output error
[root@archlinux u-boot]# exit
exit

Script done on 2019-02-24 22:40:46+00:00


Not sure where most of this comes from or what it means, but I'd like to change some of it, such as ethaddr, ipaddr, and serverip and maybe a few others.

Can I do that using saveend?

And do I take it that environment variables will be overridden by the contents of /boot/uEnv.txt?
Re: Understanding my environment
February 24, 2019 05:34PM
balanga,

Quote

> *** Warning - bad CRC, using default environment

Note the error above. It means that the envs area on flash is not intialized as this u-boot expected it too. Basically, you've installed u-boot image, but you have not installed the default envs image.

So the envs below are from internal u-boot definition. I've used the same set of envs for both (image, and internal).

> GoFlexHome> printenv
> api_address=7b12860
> arcNumber=3338
> baudrate=115200
> bootcmd=run bootcmd_uenv; run scan_disk; run
> set_bootargs; run bootcmd_exec; reset
> 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_add
> bootcmd_uenv=run uenv_load; if test $uenv_loaded
> -eq 1; then run uenv_import; fi
> bootdelay=10
> bootdev=usb
> console=console=ttyS0,115200
> device=0:1
> devices=usb ide
> disks=0 1 2 3
> dtb_file=/boot/dts/kirkwood-goflexhome.dtb
> 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
> 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
> 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_d
> 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=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


> Can I do that using saveend?

Yes. At this point, without having to flash the envs image, you can also do saveenv. So that the current envs will be saved to flash. And while it saves the envs, a checksum is created in that area. So next time you boot up the box, envs will be read successfully. And then you can change them.

Actually, you can change them right after saveenv. But it sounds like you want to use uEnv.txt to change them on the fly. That's better.

> And do I take it that environment variables will
> be overridden by the contents of /boot/uEnv.txt?

Except the 2 envs: bootcmd and bootcmd_uenv. All others envs can be overridden by /boot/uEnv.txt.

To boot FreeBSD, as your goal has been. You can try to write new bootcmd_exec in /boot/uEnv.txt. So it should look something like this:

cat /boot/uEnv.txt
bootcmd_exec=run boot_freebsd
boot_freebsd=xxxxxxxxxxxxxxx

Replace xxxxxxxxxxxxxxx above with the envs for booting FreeBSD.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Understanding my environment
March 06, 2019 05:27AM
bodhi Wrote:
-------------------------------------------------------
> balanga,

> So the envs below are from internal u-boot
> definition. I've used the same set of envs for
> both (image, and internal).

bodhi,

I'm still not sure of the source of environment variables...

I want to test some procedures I've written and would like to start with a pristine environment, ie no u-boot, no environment, by kwbooting from uboot 2017.07-tld-1. Does this u-boot have it's own internal envs, and if so how would I use them rather than the ones in flash?
Re: Understanding my environment
March 06, 2019 06:07AM
> I want to test some procedures I've written and
> would like to start with a pristine environment,
> ie no u-boot, no environment, by kwbooting from
> uboot 2017.07-tld-1. Does this u-boot have it's
> own internal envs, and if so how would I use them
> rather than the ones in flash?

You can't do that easily.

If the env area has valid envs, that will be used, whether by kwboot uboot or uboot in NAND. Unless you wipe out the NAND envs to make it invalid. Then the internal envs in u-boot will be used.

The alternative is to make a uEnv.txt that has exactly the same content as what in NAND envs. And then modify whichever envs you want to modify. With the caveat that bootcmd and bootcmd_uenv can not be changed.


----

Summarily, the internal envs in uboot will be used if and only if the NAND envs area is corrupted, or empty.

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



Edited 2 time(s). Last edit at 03/06/2019 06:10AM by bodhi.
Re: Understanding my environment
March 06, 2019 06:54AM
My aim is to create a simple guide for installing OpenWrt on a GoFlex Home unit.

If I kwboot from uboot.2017.07-tld-1 and use the envs from uboot.2016.05-tld-1.environment amended for GoFlex Home,

ie.
setenv mtdparts 'mtdparts=orion_nand:0x100000@0x0(u-boot),-@0x100000(ubi)'.
setenv partition 'nand0,0'.
setenv set_bootargs_openwrt 'setenv bootargs console=ttyS0,115200 $mtdparts'
setenv bootcmd_openwrt 'run set_bootargs_openwrt; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000'
setenv bootcmd 'run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run bootcmd_openwrt'
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 guess that should be OK... One of those lines is particularly long, so may well have a typo...

In principle the installation should consist of:-

kwbooting
amending the environment
booting initramfs from an attached USB stick
running sysupgrade

Does that sound right?
Re: Understanding my environment
March 06, 2019 06:34PM
We already have a guide here in the thread that I've asked you to post questions at, and you kept ignoring my request :)

https://forum.doozan.com/read.php?4,78534,79744#msg-79744

I'd understand you might want to create a simpler guide for a beginner audience somewhere else. But I think joerg's writeup is good even for users who only have some basic Linux experience. Perhaps you could post some beginner steps in that thread to help people whom you think need helps filling in the details.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Understanding my environment
March 06, 2019 10:06PM
bodhi,

OK will do.

Didn't mean to ignore your request.
Re: Understanding my environment
March 16, 2019 01:25PM
With a view to straightening out my environment, I've attempted to understand

uboot.2016.05-tld-1.environment.

For my own clarification I have split it into assignments and procedures and want to look at the assignments first.

This is how I see them (excuse any errors...) after reordering them according to certain functions as I see them

arcNumber=2097
machid=0x831

bootdelay=10
bootdev=usb
device=0:1
devices=usb ide mmc
disks=0 1 2 3
usb_ready_retry=15

led_error=orange blinking
led_exit=green off
led_init=green blinking

mainlineLinux=yes

mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)

partition=nand0,2

ethact=egiga0
ethaddr=52:3b:20:9c:11:51
ipaddr=192.168.0.231
serverip=192.168.0.220

stderr=serial
stdin=serial
stdout=serial

dtb_file=/boot/dts/kirkwood-pogo_e02.dtb
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
uenv_addr=0x810000


Of these I would see:-

arcNumber=2097
machid=0x831
ethaddr=52:3b:20:9c:11:51
ipaddr=192.168.0.231
serverip=192.168.0.220
dtb_file=/boot/dts/kirkwood-pogo_e02.dtb

as candidates for tailoring to my situation....

I guess the others should be left as they are although I'm interested in what these are for:-

mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
partition=nand0,2
Re: Understanding my environment
March 16, 2019 03:46PM
> arcNumber=2097
> machid=0x831

These are backward compatible envs (for really old uboot). But for FDT kernel, they are no longer necessary.

BTW, they are default for a Kirkwood reference board. For Go Flex Home, they are different (see u-boot the installation instruction).

> ethaddr=52:3b:20:9c:11:51
> ipaddr=192.168.0.231
> serverip=192.168.0.220

Yes. These are specific to your box.

> dtb_file=/boot/dts/kirkwood-pogo_e02.dtb

Yes. This DTB is adjusted to whichever box it is running.

>
> as candidates for tailoring to my situation....
>
> I guess the others should be left as they are
> although I'm interested in what these are for:-
>
> mainlineLinux=yes

This backward compatible env for older system.


> mtdids=nand0=orion_nand
> mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
> partition=nand0,2

These are NAND definition.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Understanding my environment
March 25, 2019 02:49PM
So, can I safely remove

arcnumber
machid
mainlineLinux
baudrate
console

?

I've seen that arcnumber should be set to 3338 for goflexhome but is it actually necessary?
Re: Understanding my environment
March 25, 2019 04:18PM
> So, can I safely remove
>
> arcnumber
> machid
> mainlineLinux

Don't remove them. They serve useful purpose: backward compatibility with older kernels.

> baudrate
> console

These are important in some edge cases.

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