Current section
Files
Jump to
Current section
Files
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 AM62X.
#
# 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.
#
# 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;\
if test ${nerves_fw_active} = "a"; then\
setenv uenv_root /dev/mmcblk1p2;\
setenv bootpart 1:2;\
else\
setenv uenv_root /dev/mmcblk1p3;\
setenv bootpart 1:3;\
fi
#
# AM62X variables with Nerves updates
#
#
# Default Linux commandline:
#
cmdline=\
coherent_pool=1M /* needed for some WiFi drivers */ \
quiet /* limit kernel prints to the console */
# Defaults
console=ttyS2,115200n8
earlycon=ns16550a,mmio32,0x02800000
bootdir=/boot
bootfile=Image
fdtdir=/boot
fdtfile=k3-am625-sk.dtb
devtype=mmc
# Memory offset for loading files
loadaddr=0x82000000
kernel_addr_r=0x82000000
fdtaddr=0x88000000
fdt_addr_r=0x88000000
rdaddr=0x88080000
ramdisk_addr_r=0x88080000
scriptaddr=0x80000000
bootm_size=0x10000000
# Helper functions
args_uenv_root=setenv bootargs console=${console} earlycon=${earlycon} rootfstype=squashfs rootwait ro root=${uenv_root} ${cmdline}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadfdt=\
echo loading ${fdtdir}/${fdtfile} ...;\
load ${devtype} ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}
loadoverlay=echo uboot_overlays: loading ${actual_uboot_overlay} ...;\
load ${devtype} ${bootpart} ${rdaddr} ${actual_uboot_overlay};\
fdt addr ${fdtaddr}; fdt resize ${fdt_buffer};\
fdt apply ${rdaddr}; fdt resize ${fdt_buffer}
uname_boot=\
if test -e ${devtype} ${kernel_bootpart} ${bootdir}/${bootfile}; then\
echo loading ${bootdir}/${bootfile} ...;\
run loadimage;\
run loadfdt;\
run args_uenv_root;\
echo debug: [${bootargs}] ... ;\
echo debug: [booti ${loadaddr} - ${fdtaddr}] ... ;\
booti ${loadaddr} - ${fdtaddr};\
fi
# Boot
bootcmd=run nerves_init uname_boot