August 14, 2018

U-Boot environment variables and commands

This is sort of my own cheat sheet for using U-boot.

First of all, the set an enviroment variable, you don't use an equal sign, you do this:

setenv var value
If you want to delete a variable, so this:
setenv var
In my case, deleting "bootcmd" ensures that U-Boot just drops into its command cli rather than trying to boot in some way, which is good for debugging. The command "bdinfo" shows me (among other things) the following.
eth0name    = dwmac.c0060000
ethaddr     = d2:a5:61:c9:2e:e4
current eth = dwmac.c0060000
ip_addr     = 
Network commands such as "bootp" give me:
dwmac.c0060000: No link.

Compile with debug enabled

If you study the source you will notice various "debug" macros spread throughout the code. Look at include/common.h to see that these are activated if the DEBUG macro is defined. I defined this in the Makefile by adding a line like this:
KBUILD_CFLAGS += -DDEBUG
I put this line shortly after the following line. This line could just be modified, but I prefered to add a line of my own that could be commented out.
KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
                   -Wno-format-security \
                   -fno-builtin -ffreestanding

This yields a lot of output, which I have not yet found terribly useful.
Some of it, for my as yet not working board, is as follows:

Net:
now=4565770, last=4565770, timestamp=4565770
+udelay=1000
now=4603433, last=4603433, timestamp=4603433
A. tmo=1000, tmp=4603433
B. tmo=4604433, tmp=4603433
dwmac.c0060000 connected to Generic PHY
dwmac.c0060000
initcall: 0000000043c06cac (relocated to 000000007da34cac)
fdtdec_get_config_int: bootdelay
### main_loop entered: bootdelay=1

fdtdec_get_config_int: kernel-offset
fdtdec_get_config_int: rootdisk-offset
fdtdec_get_config_string: bootcmd
fdtdec_get_config_int: bootsecure
### main_loop: bootcmd=""

nanopi3# ping 1.1.1.1
Trying dwmac.c0060000
dwmac.c0060000: No link.
FAIL
ping failed; host 1.1.1.1 is not alive
Command failed, result=1


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org