imx6: convert ventana images to squashfs+ubifs overlay
[openwrt.git] / target / linux / imx6 / image / bootscript-ventana
1 echo "Gateworks Ventana OpenWrt Boot script v1.00"
2
3 # set some defaults
4 # set some defaults
5 test -n "$fs"    || fs=ext2
6 test -n "$disk"  || disk=0
7 setenv nextcon 0
8 setenv bootargs console=${console},${baudrate}
9 setenv loadaddr 10800000
10 setenv fdt_addr 18000000
11
12 # detect displays in the following priority: HDMI, LVDS
13 # setenv display to override detection for a single display
14 # or setenv video if you want multiple displays
15 if test -n "$video" ; then
16   echo "using video config from env: $video"
17   setenv bootargs "${bootargs}" "${video}"
18 else
19   if test -n "$display" ; then
20     echo "using display from env: $display"
21   elif test -n "$panel" ; then
22     echo "using display from env: $panel"
23     setenv display "$panel"
24   else
25     echo "Detecting displays..."
26     i2c dev 2
27     if hdmidet ; then
28         echo "  HDMI detected"
29         setenv display "HDMI"
30     elif i2c probe 0x04 ; then
31         echo "  Freescale MXC-LVDS1 detected"
32         setenv display "LVDS"
33     elif i2c probe 0x14 ; then
34         echo "  DLC800FIGT3 detected"
35         setenv display "LVDS"
36     elif i2c probe 0x38 ; then
37         echo "  DLC700JMGT4 detected"
38         setenv display "LVDS"
39     fi
40   fi
41
42   # configure displays
43   echo "Configuring kernel bootargs for display(s): $display"
44   for p in ${display}; do
45     if itest.s "x${p}" == "xHannstar-XGA" ; then
46         setenv ptype "LVDS"
47     elif itest.s "x${p}" == "xDLC700JMGT4" ; then
48         setenv ptype "LVDS"
49     elif itest.s "x${p}" == "xDLC800FIGT3" ; then
50         setenv ptype "LVDS"
51     elif itest.s "x${p}" == "xLVDS" ; then
52         setenv ptype "LVDS"
53     elif itest.s "x${p}" == "xHDMI" ; then
54         setenv ptype "HDMI"
55         test -n "$hdmi" || hdmi=1080p
56         if itest.s "x${hdmi}" == "x1080p" ; then
57                 setenv hdmi "1920x1080M@60"
58         elif itest.s "x${hdmi}" == "x720p" ; then
59                 setenv hdmi "1280x720M@60"
60         elif itest.s "x${hdmi}" == "x480p" ; then
61                 setenv hdmi "720x480M@60"
62         fi
63     else
64         echo "${p} not supported"
65     fi
66
67     if itest.s "x${ptype}" == "xLVDS" ; then
68         echo "  mxcfb${nextcon}: LVDS ($p)"
69         setenv bootargs "${bootargs}" video=mxcfb${nextcon}:dev=ldb,bpp=32,if=RGB666
70         setexpr nextcon $nextcon + 1
71     elif itest.s "x${ptype}" == "xHDMI" ; then
72         echo "  mxcfb${nextcon}: HDMI ($hdmi)"
73         setenv bootargs "${bootargs}" video=mxcfb${nextcon}:dev=hdmi,bpp=32,${hdmi},if=RGB24
74         setexpr nextcon $nextcon + 1
75     fi
76
77   done
78
79   # disable remaining mxcfb devices
80   while test "4" -ne $nextcon ; do
81         setenv bootargs "${bootargs}" video=mxcfb${nextcon}:off
82         setexpr nextcon $nextcon + 1
83   done
84 fi
85
86 # detect dtype and bootdev by looking for kernel on media the bootloader
87 # has mounted (in order of preference: usb/mmc/sata)
88 #
89 # This assumes the bootloader has already started the respective subsystem
90 # or mounted the filesystem if appropriate to get to this bootscript
91 #
92 # To Speed up boot set dtype manually
93 if test -n "$dtype" ; then
94         echo "Using dtype from env: $dtype"
95 else
96         echo "Detecting boot device (dtype)..."
97         if ${fs}load usb ${disk}:1 ${loadaddr} ${bootdir}/uImage ; then
98                 dtype=usb
99         elif ${fs}load mmc ${disk}:1 ${loadaddr} ${bootdir}/uImage ; then
100                 dtype=mmc
101         elif ${fs}load sata ${disk}:1 ${loadaddr} ${bootdir}/uImage ; then
102                 dtype=sata
103         elif ubifsload ${loadaddr} ${bootdir}/uImage ; then
104                 dtype=nand
105         fi
106         echo "detected dtype:$dtype"
107 fi
108 if test -n "$bootdev" ; then
109         echo "Using bootdev from env: $bootdev"
110 else
111         if itest.s "x${dtype}" == "xmmc" ; then
112                 bootdev=mmcblk0
113         else
114                 bootdev=sda
115         fi
116 fi
117
118 if itest.s "x${dtype}" == "xnand" ; then
119         echo "Booting from NAND..."
120         # fix partition name
121         #  OpenWrt kernel bug prevents partition name of 'rootfs' from booting
122         #  instead name the partition ubi which is what is looked for by
123         #  procd sysupgrade
124         mtdparts del rootfs && mtdparts add nand0 - ubi
125         echo "mtdparts:${mtdparts}"
126         setenv fsload ubifsload
127         setenv root "ubi0:ubi ubi.mtd=2 rootfstype=squashfs,ubifs"
128 else
129         echo "Booting from block device ${bootdev}..."
130         setenv fsload "${fs}load ${dtype} ${disk}:1"
131         setenv root "root=/dev/${bootdev}"
132 fi
133
134 setenv bootargs "${bootargs}" "${root}" "${extra}"
135 if ${fsload} ${loadaddr} ${bootdir}/uImage; then
136         if ${fsload} ${fdt_addr} ${bootdir}/${fdt_file}; then
137                 echo Loaded DTB from ${bootdir}/${fdt_file}
138                 bootm ${loadaddr} - ${fdt_addr}
139         elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file1}; then
140                 echo Loaded DTB from ${bootdir}/${fdt_file1}
141                 bootm ${loadaddr} - ${fdt_addr}
142         elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file2}; then
143                 echo Loaded DTB from ${bootdir}/${fdt_file2}
144                 bootm ${loadaddr} - ${fdt_addr}
145         else
146                 echo "Error loading device-tree"
147         fi
148 else
149         echo "Error loading kernel image"
150 fi