if part uuid ${devtype} ${devnum}:${distro_bootpart} bootuuid; then
	if test "${bootfstype}" = "btrfs"; then
		# Original BTRFS partition layout
		rootdev="PARTUUID=${bootuuid}"
		rootflags="commit=5,subvol=@"
		bootpath="/@/boot"
	else
		# OpenWrt default ext4 bootpart + rootpart layout
		setexpr rootpart ${distro_bootpart} + 1
		rootdev="/dev/mmcblk0p${rootpart}"
		rootflags="commit=5"
		bootpath="/"
	fi

	load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${bootpath}/armada-3720-atlas-v5.dtb
	if test "$filesize" != "0"; then
		has_dtb=1
	else
		setenv has_dtb 0
		echo "Cannot find device tree binary!"
	fi

	if test $has_dtb -eq 1; then
		load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${bootpath}/Image
		if test "$filesize" = "0"; then
			echo "Failed to load ${bootpath}/Image"
			echo "Now trying ${bootpath}/Image.lzma"
			tmp_addr_r=0x10000000
			load ${devtype} ${devnum}:${distro_bootpart} ${tmp_addr_r} ${bootpath}/Image.lzma
			if test "$filesize" != "0"; then
				if lzmadec ${tmp_addr_r} ${kernel_addr_r}; then
					echo "Successfully decompressed Image.lzma"
				else
					echo "Failed decompressing Image.lzma"
					filesize=0
				fi
			else
				echo "Failed to load ${subvol}/boot/Image.lzma"
			fi
		fi
		if test "$filesize" != "0"; then
			setenv bootargs "earlyprintk console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000 rootfstype=${bootfstype} root=${rootdev} rootflags=${rootflags} rootwait ${contract} rw cfg80211.freg=${regdomain} ${quirks}"
			booti ${kernel_addr_r} - ${fdt_addr_r}
			echo "Booting Image failed"
		else
			echo "Cannot load kernel binary"
		fi
	fi

	env delete bootuuid rootpart
fi
