Current section

Files

Jump to
Raw

uboot/uboot.env

# Custom U-Boot base environment for Nerves
# This environment is a majorly trimmed down version of the default
# one that ships with the NPi i.MX6ULL.
#
# Why?
# 1. We want to store settings in the U-boot environment so that they're
# accessible both to Elixir and U-boot.
# 2. This makes us add an environment block.
# 3. Unfortunately, if we point U-Boot to this block, it replaces its
# default environment settings which contain all of the logic to
# boot the boards. Therefore we have to copy/paste the relevant
# parts here.
# 4. We can support more complicated firmware validation methods by
# deferring validation of new software to the application. The
# default below is to automatically validate new software.
#
# See U-Boot/include/configs/ti_armv7_common.h and
# U-Boot/include/configs/am335x_evm.h for most of what's below.
#
# IMPORTANT:
# Calling saveenv saves everything. Some of the variables it saves override
# automatically detected defaults and you can't know whether the variable was
# supplied automatically or via the saved environment. There is no way to
# selectively save environment variables. Here are problematic variables:
#
# * ethaddr
# * eth1addr
# * board_name
# * board_rev
# * board_serial
#
# If you move MicroSD cards around between boards, you currently need to clear
# those variables out so that they're detected again. The most visible issue is
# that Ethernet MAC addresses will travel with MicroSD cards. See
# https://github.com/nerves-project/nerves_system_bbb/issues/151.
#
# Nerves variables
#
nerves_fw_active=a
# nerves_fw_autovalidate controls whether updates are considered valid once
# applied. If set to 0, the user needs to set nerves_fw_validated to 1 in their
# application. If they don't set it before a reboot, then the previous software
# is run. If 1, then no further action needs to be taken.
nerves_fw_autovalidate=1
# nerves_fw_validated is 1 if the current boot selection is accepted It is set
# to 1 here, since this environment is written in the factory, so it is
# implicitly valid.
nerves_fw_validated=1
# nerves_fw_booted is 0 for the first boot and 1 for all reboots after that.
# NOTE: Keep this '0' so that all new boards run a 'saveenv' to exercise the
# code that writes back to the eMMC early on.
nerves_fw_booted=0
# The nerves initialization logic
#
# The nerves_init code is run at boot (see the last line of the file). It
# checks whether this is a first boot or not. If it's not the first boot, then
# the firmware better be validated or it reverts to running the firmware on
# the opposite partition.
nerves_revert=\
if test ${nerves_fw_active} = "a"; then\
echo "Reverting to partition B";\
setenv nerves_fw_active "b";\
else\
echo "Reverting to partition A";\
setenv nerves_fw_active "a";\
fi
nerves_init=\
if test ${nerves_fw_booted} = 1; then\
if test ${nerves_fw_validated} = 0; then\
run nerves_revert;\
setenv nerves_fw_validated 1;\
saveenv;\
fi;\
else\
setenv nerves_fw_booted 1;\
if test ${nerves_fw_autovalidate} = 1; then\
setenv nerves_fw_validated 1;\
fi;\
saveenv;\
fi;\
setenv bootfile zImage.${nerves_fw_active};\
if test ${nerves_fw_active} = "a"; then\
setenv uenv_root /dev/mmcblk0p2;\
else\
setenv uenv_root /dev/mmcblk0p3;\
fi
#
# NPi iMX6ULL variables with Nerves updates
#
#
# Default Linux commandline:
#
# coherent_pool=1M - copied from NPi iMX6ULL defaults. It's needed for some WiFi drivers.
# vt.global_cursor_default=0 - copied from NPi iMX6ULL defaults
# quiet - limit kernel prints to the console
cmdline=coherent_pool=1M vt.global_cursor_default=0 quiet
# Defaults
console=ttymxc0,115200n8
bootdir=
fdtdir=
fdtfile=imx6ull-seeed-npi.dtb
# Enable the I/Os that make the board look more similar to a Raspberry Pi
# LEDs - controllable via /sys/class/leds
# I2C2 - the I2C pins on the "Raspberry Pi" header
# ecspi3 - the SPI pins on the "Raspberry Pi" header
# UART3 - the UART pins on the "Raspberry Pi" header
uboot_overlay_addr0=imx-fire-led-overlay.dtbo
uboot_overlay_addr1=imx-fire-i2c2-overlay.dtbo
uboot_overlay_addr2=imx-fire-ecspi3-overlay.dtbo
uboot_overlay_addr2=imx-fire-uart3-overlay.dtbo
dtb_overlay=
devtype=mmc
# TODO: Bump U-Boot to be able to load from squashfs
bootpart=0:1
# Values from mx6ullevk.h (quite a few of these look like they can be cleaned up)
initrd_addr=0x86800000
initrd_high=0xffffffff
emmc_dev=1
emmc_ack=1
sd_dev=1
panel=TFT43AB
fdt_addr=0x83000000
fdt_addr_r=0x83000000
fdtaddr=0x83000000
fdt_high=0xffffffff
tee_addr=0x84000000
loadaddr=0x80800000
fdt_buffer=0x60000
rdaddr=0x88000000
# Helper functions
args_uenv_root=setenv bootargs console=${console} root=${uenv_root} rootfstype=squashfs rootwait ${cmdline}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadfdt=echo loading ${fdtdir}/${fdtfile} ...; load ${devtype} ${bootpart} ${fdt_addr} ${fdtdir}/${fdtfile}
loadoverlay=echo uboot_overlays: loading ${uboot_overlay} ...;\
load ${devtype} ${bootpart} ${rdaddr} ${uboot_overlay};\
fdt addr ${fdt_addr}; fdt resize ${fdt_buffer};\
fdt apply ${rdaddr}; fdt resize ${fdt_buffer}
virtualloadoverlay=if test -e ${devtype} ${bootpart} ${uboot_overlay}; then\
run loadoverlay;\
else\
echo uboot_overlays: unable to find [${devtype} ${bootpart} ${uboot_overlay}]...;\
fi
capeloadoverlay=if test -e ${devtype} ${bootpart} ${uboot_overlay}; then\
run loadoverlay;\
else\
echo uboot_overlays: unable to find [${devtype} ${bootpart} ${uboot_overlay}]...;\
fi
uname_boot=if test -e ${devtype} ${bootpart} ${bootdir}/${bootfile}; then\
echo loading ${bootdir}/${bootfile} ...;\
run loadimage;\
run loadfdt;\
if test -n ${uboot_overlay_addr0}; then\
if test -n ${disable_uboot_overlay_addr0}; then\
echo uboot_overlays: uboot loading of [${uboot_overlay_addr0}] disabled [disable_uboot_overlay_addr0=1]...;\
else\
setenv uboot_overlay ${uboot_overlay_addr0};\
run capeloadoverlay;\
fi;\
fi;\
if test -n ${uboot_overlay_addr1}; then\
if test -n ${disable_uboot_overlay_addr1}; then\
echo uboot_overlays: uboot loading of [${uboot_overlay_addr1}] disabled [disable_uboot_overlay_addr1=1]...;\
else\
setenv uboot_overlay ${uboot_overlay_addr1};\
run capeloadoverlay;\
fi;\
fi;\
if test -n ${uboot_overlay_addr2}; then\
if test -n ${disable_uboot_overlay_addr2}; then\
echo uboot_overlays: uboot loading of [${uboot_overlay_addr2}] disabled [disable_uboot_overlay_addr2=1]...;\
else\
setenv uboot_overlay ${uboot_overlay_addr2};\
run capeloadoverlay;\
fi;\
fi;\
if test -n ${uboot_overlay_addr3}; then\
if test -n ${disable_uboot_overlay_addr3}; then\
echo uboot_overlays: uboot loading of [${uboot_overlay_addr3}] disabled [disable_uboot_overlay_addr3=1]...;\
else\
setenv uboot_overlay ${uboot_overlay_addr3};\
run capeloadoverlay;\
fi;\
fi;\
if test -n ${uboot_overlay_addr4}; then\
setenv uboot_overlay ${uboot_overlay_addr4};\
run capeloadoverlay;\
fi;\
if test -n ${uboot_overlay_addr5}; then\
setenv uboot_overlay ${uboot_overlay_addr5};\
run capeloadoverlay;\
fi;\
if test -n ${uboot_overlay_addr6}; then\
setenv uboot_overlay ${uboot_overlay_addr6};\
run capeloadoverlay;\
fi;\
if test -n ${uboot_overlay_addr7}; then\
setenv uboot_overlay ${uboot_overlay_addr7};\
run capeloadoverlay;\
fi;\
if test -n ${dtb_overlay}; then\
setenv uboot_overlay ${dtb_overlay};\
echo uboot_overlays: [dtb_overlay=${uboot_overlay}] ... ;\
run capeloadoverlay;\
fi;\
run args_uenv_root;\
echo debug: [${bootargs}] ... ;\
echo debug: [bootz ${loadaddr} - ${fdt_addr}] ... ;\
bootz ${loadaddr} - ${fdt_addr};\
fi
# Boot
bootcmd=run nerves_init uname_boot