Current section

Files

Jump to
nerves_system_srhub uboot uboot.env
Raw

uboot/uboot.env

# Custom U-Boot environment
# This script is invoked from the built-in u-boot script.
# It has been simplified to just support the SmartRent Hub.
#
# 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=0
# 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;\
setenv bootpart 0:2;\
else\
setenv uenv_root /dev/mmcblk0p3;\
setenv bootpart 0:3;\
fi
#
# Linux commandline:
#
# coherent_pool=1M - copied from Beaglebone defaults. It's needed for some WiFi drivers.
# net.ifnames=0 - copied from Beaglebone defaults
# omap_wdt.early_enable=1 - turn on the internal watchdog timer asap
# omap_wdt.timer_margin=120 - Erlang heart has 120 seconds to start petting the timer
# console=ttyS0,115200n8 - Turn on debug UART via test points
# quiet - limit kernel prints to the console
cmdline=coherent_pool=1M net.ifnames=0 omap_wdt.early_enable=1 omap_wdt.timer_margin=120 console=ttyS0,115200n8 quiet
fdtfile=am335x-smartrent-hub.dtb
fdtaddr=0x88000000
loadaddr=0x82000000
mmcargs=setenv bootargs ${cmdline} root=${uenv_root} rootfstype=squashfs rootwait
mmc_loadfdt=load mmc ${bootpart} ${fdtaddr} /boot/${fdtfile}
mmc_loadk=fatload mmc 0:1 ${loadaddr} /zImage.${nerves_fw_active}
led_red=gpio clear 115;gpio set 116
#led_green=gpio set 115;gpio clear 116
# Flash the lights yellow very briefly and then switch to solid red. Linux will
# blink the LEDs. If Linux doesn't boot, then the lights remain solid red and
# that indicates a boot issue.
bootcmd=run led_red;run nerves_init mmcargs; if run mmc_loadk; then if run mmc_loadfdt; then bootz ${loadaddr} - ${fdtaddr}; fi; fi