#
# U-Boot bootscript for NAND images created by Yocto.
#

# Back up environment variables
setenv ORIG_overlays ${overlays}

#
# Determine overlays to apply depending on the hardware capabilities
# described by the HWID, SOM version, and carrier board version.
#
setexpr module_has_wifi ${hwid_2} \& 20000
setexpr module_has_wifi ${module_has_wifi} / 20000
setexpr module_has_bt ${hwid_2} \& 40000
setexpr module_has_bt ${module_has_bt} / 40000

if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then
	setenv overlays _ov_som_bt_ccmp13.dtbo,${overlays}
fi

if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then
	setenv overlays _ov_som_wifi_ccmp13.dtbo,${overlays}
fi

dboot linux nand ${mtdbootpart}



# We only get here in case of an error on the dboot command.

# Undo changes to environment variables
setenv overlays ${ORIG_overlays}
setenv ORIG_overlays
