u-boot env.txt

The aarch64 (ARM64) u-boot was found from FreeBSD ports in sysutils/u-boot-*. There was some information how to install it. Sometimes the U-Boot is used with uEnv.txt or similar file to configure it. The U-Boot reads the file and sets variables. At least in Armbian Linux. Is there any options to configure the FreeBSD u-boot (from the ports) for example the env.txt ?

Actually the problem occurs when booting NetBSD using the same EFI boot loader. The u-boot is from the FreeBSD. Every second time the device boots, it tries booting from the network using TFTP. Is this the bootloader booting and how can I prevent it to happen?

esc
 
It is possible. It is called boot scripts (*.scr files) which are compiled from pure text file.
In that script (same as in u-boot prompt/shell) you can source environment (which would be your uEnv i guess) from any file.

I am not at the moment at my arm64 machine, so can't share mine, but you can google examples.
Mine boots FreeBSD, Linux and OpenBSD without problems (if we exclude enabling USB keyboard and trying to boot *BSDs :sssh:) and have crude boot-manager (last booted OS will be booted on next boot if not changed in u-boot shell).

What are exact errors? Did you try to manually load NetBSD loader?
I can load .efi files (loader.efi and OpeBSD's equivalent).
Network boot seems like autoboot tried to locally load something to boot from eMMC/SD/USB/NVMe (depends on boot order) and failed so it tries from network.
 
The first problem is how to change the DTB-file. One of the USB-ports does not work and it is difficult to use the keyboard. (FreeBSD did not find the network interface either. Options are either the keyboard and TV-screen or the network interface from USB.) The device should not try a TFTP boot. Are the *.scr files from the uBoot?
 
Changing DTB: find .dts file (device tree source) of your .dtb and compile it to dtb:
Code:
dtc -H epapr -i . -I dts -O dtb -o out.dtb in.dts
Or create device tree overlay (.dtso) and compile it, for example:
Example of enabling BMP180 sensor on i2c bus2:
Code:
/dts-v1/;
/plugin/;

/ {
        compatible = "rockchip,rk3399";

        fragment@0 {
                target =<&i2c2>;
                __overlay__ {
                        status = "okay";

                        bmp: bmp180@77 {
                                compatible = "bosch,bmp180";
                                reg = <0x77>;
                        };
                };
        };
};

dtso file can be loaded from u-boot or from FreeBSD - there are many examples on the Internet how to do it.

You create your own .scr file:
Code:
mkimage -C none -A arm -T script -d /boot/efi/boot.cmd /boot/efi/boot.scr

For your specific problems - how to enable USB for your platform - earch for $PLATFORM USB overlay or look into Linux's overlays (or better: Armbian's) for your specific platform
 
JohnnySorocil Great writeup.
Thanks for the mkimage command settings.
So make a textfile.
SCSI SCAN <<One liner>>
Save as /boot/efi/boot.cmd
run mkimage command

Would it be OK to store boot.scr on EFI partition via /boot/msdos/ link?
 
Last edited:
Nice it worked I have SATA on BPi without intervention
scsi info
scsi scan
scsi info

Code:
U-Boot SPL 2021.07 (Jan 14 2022 - 21:10:47 -0500)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Trying to boot from MMC1


U-Boot 2021.07 (Jan 14 2022 - 21:10:47 -0500) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
Model: LeMaker Banana Pi
I2C:   ready
DRAM:  1 GiB
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... Setting up a 720x576i composite-pal console (overscan 32x20)
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@1c50000
starting USB...
Bus usb@1c14000: USB EHCI 1.00
Bus usb@1c14400: USB OHCI 1.0
Bus usb@1c1c000: USB EHCI 1.00
Bus usb@1c1c400: USB OHCI 1.0
scanning bus usb@1c14000 for devices... 1 USB Device(s) found
scanning bus usb@1c14400 for devices... 1 USB Device(s) found
scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
102 bytes read in 2 ms (49.8 KiB/s)
## Executing script at 43100000
scanning bus for devices...
Target spinup took 0 ms.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst
  Device 0: (0:0) Vendor: ATA Prod.: MICRON_M510DC_MT Rev: 0013
            Type: Hard Disk
            Capacity: 915715.3 MB = 894.2 GB (1875385008 x 512)
Device 0: (0:0) Vendor: ATA Prod.: MICRON_M510DC_MT Rev: 0013
            Type: Hard Disk
            Capacity: 915715.3 MB = 894.2 GB (1875385008 x 512)
SCRIPT FAILED: continuing...
41178 bytes read in 5 ms (7.9 MiB/s)
Scanning disk mmc@1c0f000.blk...
** Unrecognized filesystem type **
Scanning disk ahci_scsi.id0lun0...
** Unrecognized filesystem type **
Found 4 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootarm.efi
1403700 bytes read in 80 ms (16.7 MiB/s)
Booting /efi\boot\bootarm.efi

Wonder what made script fail warning? It seems to work fine.Do I need EOF?
 
EOF in my source document did not stop the warning.
No big deal. It works.
SCRIPT FAILED: continuing...
It is possible I have an old mkimage in /usr/local/bin/ I am using.
The file does not appear part of any package.

mkimage -V
mkimage version 2020.07

That looks like a u-boot version of mkimage.

Here is the ports version. So I am not on the newest.
/usr/ports/sysutils/u-boot-bananapi/work/u-boot-2021.07/tools # ./mkimage -V
mkimage version 2021.07

When I look at my boot.scr in hex code I see the header and plain text commands but no footer.
That seems to be the issue.
 
I noticed when I used mkimage that is was using load address of 000000.
Code:
 mkimage -C none -A arm -T script -d boot.cmd boot.scr
Image Name:
Created:      Tue Jan 25 20:47:25 2022
Image Type:   ARM Linux Script (uncompressed)
Data Size:    18 Bytes = 0.02 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 10 Bytes = 0.01 KiB = 0.00 MiB

That seemed strange but the resulting file works.
 
Would it be OK to store boot.scr on EFI partition via /boot/msdos/ link?
This location works fine.

But for compiled DTBO they must go in /boot/dtb/overlay

There is also an overlay directory on the EFI partition with mmc.dtb in it.
So board level overlays in EFI overlays and OS level overlays in /boot/dtb/overlays ?
 
U-boot (via script or manually from shell) can load dtb or dtbo from partitions which are accessible by u-boot, eg: EFI partition (or any EFI, FAT32, ext2, extfat(?)). There is u-boot ZFS support but I didn't get it to read from FreeBSD ZFS pool.
FreeBSD can load dtb or dtbo from partition accessible by FreeBSD's loader.efi (efi/fat32/zfs, ...)

You can (probably) combine one or both of the mentioned methods from above.
 
So I see this on boot.
Code:
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1...

So is this a file you could use to over-ride the u-boot envirnoment?
 
Honestly, I don't know, I've never used uboot.env, always used uEnv.txt. Also, U-boot checks for both /uEnv.txt and /boot/uEnv.txt.
I just checked the source code:
Code:
% grep -ri 'uenv\.txt' .
....
bootenv=uEnv.txt
....
Most of ./include/configs/*.h files have this assignment.

However:
Code:
% grep -r FAT_ENV_FILE .
./include/configs/sama5d27_som1_ek.h:#define FAT_ENV_FILE        "uboot.env"
./include/configs/am335x_evm.h:#define FAT_ENV_FILE            "uboot.env"
reveals only these two configs headers.
 
This thread helped me get my RockPro64 booting with NVMe automatically.
U-Boot gives a bunch of noisy messages about script failing but it works.
mkimage is included with sysutils/u-boot-tools
Thanks
JohnnySorocil

My choice of /boot/EFI/ directory really works well for this.
So when I backup my boot medium the u-boot script is included.
 
Back
Top