File size: 2,047 Bytes
2db1521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
fdt_addr=0x43000000
image=Image
script=boot.scr
mmc_root="PARTUUID=70672ec3-5eee-49ff-b3b1-eb1fbd406bf5"
sd_root="/dev/mmcblk1p2"

# Check boot device to decide which root partition to use
if test ${bootdev} = 1; then
    setenv root ${sd_root}
else
    setenv root ${mmc_root}
fi

if test ${baseboardid} = 1; then
    setenv fdt_file fsl-imx8mq-phanbell.dtb
elif test ${baseboardid} = 2; then
    setenv fdt_file fsl-imx8mq-yorktown.dtb
else
    # EVT Boards have quirky baseboard ID resistors, so fall back
    # to phanbell if we're unsure what the board is.
    echo "Unknown baseboard revision, selecting phanbell dtb."
    setenv fdt_file fsl-imx8mq-phanbell.dtb
fi

cmdline="console=ttymxc0,115200 console=tty0 earlycon=ec_imx6q,0x30860000,115200 root=${root} rootfstype=ext4 rw rootwait init=/sbin/init net.ifnames=0 pci=pcie_bus_perf"

ext2load mmc ${bootdev}:1 ${loadaddr} ${image}
setenv bootargs ${cmdline} ${extra_bootargs}

#Load base device tree.
ext2load mmc ${bootdev}:1 ${fdt_addr} ${fdt_file}
fdt addr ${fdt_addr}
fdt resize 4096 # PORTILOOP: Add extra 4096 bytes to fit overlay

# Load overlays to arbitrary address beyond fdt location (will apply them later).
setexpr fdtovaddr ${fdt_addr} + F000

# Parse overlays.txt and apply individual overlays.
if ext2load mmc ${bootdev}:1 ${fdtovaddr} overlays.txt && env import -t ${fdtovaddr} ${filesize} && test -n ${overlay}; then
	echo loaded overlay.txt: ${overlay}
	for ov in ${overlay}; do
		if ext2load mmc ${bootdev}:1 ${fdtovaddr} ${ov}.dtbo && fdt apply ${fdtovaddr}; then
			echo overlay of ${ov} successful
		else
			echo overlay failed, reverting to original device tree
			ext2load mmc ${bootdev}:1 ${fdt_addr} ${fdt_file}
			booti ${loadaddr} - ${fdt_addr}
		fi
	done
fi

if printenv m4enabled; then
	if test ${m4enabled} = 1; then
		if ext2load mmc ${bootdev}:1 ${fdtovaddr} fsl-imx8mq-phanbell-m4.dtbo && fdt apply ${fdtovaddr}; then
			echo M4 overlay loaded, starting core
			run m4boot
		else
			echo M4 overlay failed
		fi
	fi
fi

booti ${loadaddr} - ${fdt_addr}