Sunday, October 22, 2023

Orange PI Zero 3 - How to Default U-Boot Environmental Variables + Help Output

Intro:

U-Boot shenanigans. While playing around with VxWorks images I figured I better have a copy of this in case something goes wrong. Little did I know at the time that the OS image would reset all the variables back to normal after the first boot. I kept the post in case someone wants the default output or help command output as a reference.

*The serial connection on the Orange PI Zero 3 (MicroSD port at top) from left to right is GND, RX, TX.

*If you default the boot variables or you screw something up, insert a MicroSD card with "Orangepizero3_1.0.2_debian_bookworm_server_linux6.1.31" burned to it and boot it. This should set the env variables again.

Here's the output of the "env" command:

=> env
env - environment handling commands

Usage:
env default [-f] -a - [forcibly] reset default environment
env default [-f] var [...] - [forcibly] reset variable(s) to their default values
env delete [-f] var [...] - [forcibly] delete variable(s)
env edit name - edit environment variable
env exists name - tests for existence of variable
env export [-t | -b | -c] [-s size] addr [var ...] - export environment
env import [-d] [-t [-r] | -b | -c] addr [size] [var ...] - import environment
env print [-a | name ...] - print environment
env run var [...] - run commands in an environment variable
env save - save environment
env set [-f] name [arg ...]

=>


How to Default the Boot Environment Variables:
  1. Pull the MicroSD card from the PI.
  2. Type "reset".
  3. Hit the space bar to interrupt boot.
  4. Type "env default -a".
  5. Type "reset".
  6. Hit the space bar to interrupt boot.
  7. Type "printenv" and it should look like the following:
=> printenv
baudrate=115200
bootcmd=run distro_bootcmd
bootdelay=2

Environment size: 62/131068 bytes
=>


After booting "Orangepizero3_1.0.2_debian_bookworm_server_linux6.1.31":

boot_fastboot=fastboot
boot_normal=sunxi_flash read 45000000 boot;bootm 45000000
boot_recovery=sunxi_flash read 45000000 recovery;bootm 45000000
bootcmd=run setargs_nor boot_normal
bootdelay=2
bootreason=unknow
cma=64M
console=tty1
earlyprintk=sunxi-uart,0x05000000
fastboot_key_value_max=0x8
fastboot_key_value_min=0x2
fdtcontroladdr=bbf1aba0
init=/init
initcall_debug=0
keybox_list=hdcpkey,widevine
loglevel=2
mmc_root=/dev/mmcblk0p4
nand_root=/dev/nand0p4
nor_root=/dev/mtdblock4
partitions=boot-resource@mtdblock1:env@mtdblock2:boot@mtdblock3:rootfs@mtdblock4:UDISK@mtdblock5
recovery_key_value_max=0x13
recovery_key_value_min=0x10
selinux=0
setargs_mmc=setenv  bootargs earlyprintk=${earlyprintk} initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${mmc_root} rootwait init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} selinux=${selinux} specialstr=${specialstr} gpt=1
setargs_nand=setenv bootargs earlyprintk=${earlyprintk} initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nand_root} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} selinux=${selinux} specialstr=${specialstr} gpt=1
setargs_nor=setenv bootargs  earlyprintk=${earlyprintk} initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nor_root} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} selinux=${selinux} specialstr=${specialstr} gpt=1
snum=REMOVED (19 characters)


U-Boot Help Menu:

?       		- alias for 'help'
base    		- print or set address offset
bdinfo  		- print Board Info structure
boot    		- boot default, i.e., run 'bootcmd'
bootd   		- boot default, i.e., run 'bootcmd'
bootm   		- boot application image from memory
bootp   		- boot image via network using BOOTP/TFTP protocol
cmp     		- memory compare
coninfo 		- print console devices and information
cp      		- memory copy
crc32   		- checksum calculation
echo    		- echo args to console
editenv 		- edit environment variable
efex    		- run to efex
env     		- environment handling commands
erase   		- erase FLASH memory
fastboot		- fastboot - enter USB Fastboot protocol
fatinfo 		- print information about filesystem
fatload 		- load binary file from a dos filesystem
fatls   		- list files in a directory (default /)
fatsize 		- determine a file's size
fatwrite		- write file into a dos filesystem
fdt     		- flattened device tree utility commands
flinfo  		- print FLASH memory information
go      		- start application at address 'addr'
gpt     		- GUID Partition Table
help    		- print command description/usage
i2c     		- I2C sub-system
itest   		- return true/false on integer compare
loadb   		- load binary file over serial line (kermit mode)
loads  			- load S-Record file over serial line
loadx   		- load binary file over serial line (xmodem mode)
loady   		- load binary file over serial line (ymodem mode)
loop    		- infinite loop on address range
md      		- memory display
memtester		- start application at address 'addr'
mm      		- memory modify (auto-incrementing address)
mmc     		- MMC sub system
mmcinfo 		- display MMC info
mw      		- memory write (fill)
nfs     		- boot image via network using NFS protocol
nm      		- memory modify (constant address)
pbread  		- read data from private data
poweroff		- Perform POWEROFF of the device
printenv		- print environment variables
protect 		- enable or disable FLASH write protection
pst     		- read data from secure storageerase flag in secure storage
reset   		- Perform RESET of the CPU
run     		- run commands in an environment variable
saveenv 		- save environment variables to persistent storage
setenv 			- set environment variables
setexpr	 		- set environment variable as the result of eval expression
sleep   		- delay execution for some time
source  		- run script from memory
sprite_test		- do a sprite test
sunxi_axp		- sunxi_axp sub-system
sunxi_card0_probe       - probe sunxi card0 device
sunxi_flash		- sunxi_flash sub-system
sunxi_so		- sunxi_so sub-system
tftpboot		- boot image via network using TFTP protocol
timer_test		- do a timer and int test
timer_test1		- do a timer and int test
uburn   		- do a burn from boot
version 		- print monitor, compiler and linker version



πŸ‘½

No comments: