gpio-button-hotplug: remove duplicate logging text
[openwrt/staging/wigyori.git] / package / boot / uboot-imx6 / patches / 0001-imx6-apalis-Make-the-boot-process-more-generic.patch
1 From 42cc2cffb6d550fbb21dad033d2564d4da571015 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz@true.cz>
3 Date: Sat, 1 Dec 2018 12:46:37 +0100
4 Subject: [PATCH] imx6: apalis: Make the boot process more generic
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 I'm preparing support for Apalis imx6 boards in OpenWrt and I've ended
10 up with quite huge patchset against upstream U-Boot 2018.03, so I'm
11 trying to propose more generic way of boot process handling.
12
13 In OpenWrt we usually have kernel, dtbs and U-Boot boot script in boot
14 partition with ext4fs, so for some use cases it would be handy to be
15 able to replace some of the files in the boot partion, that's why I've
16 added write support to the ext4.
17
18 I've added `set_blkcnt` environment variable which is needed for every
19 `mmc write` command as we need to always specify size in block count.
20 This is copy&pasted from official Toradex's flashing scripts, so all the
21 credits for this work belongs to them.
22
23 Currently the rootfs location is passed via mmcblk number and the
24 problem with this approach is that the mmcblk number for the boot device
25 changes depending on the kernel version and imx6 SoC type. In order to
26 avoid such issues, use the UUID method to specify the rootfs location.
27
28 I've added new boot sequence, where we first try to load and run boot
29 script defined in the new `script` variable, so the boot process could
30 be more generic and overridden by the distro. When the boot script isn't
31 loaded, it will use the previous boot sequence so it should be backward
32 compatible.
33
34 For the recovery purposes and better end user experience I've added boot
35 from SDP as the last boot command if every other boot option fails. I
36 plan to use SDP as official flashing/recovery procedure in OpenWrt for
37 Apalis imx6 boards.
38
39 I've copy&pasted almost everything from the `f086812a mx6sxsabresd: Use
40 PARTUUID to specify the rootfs location` commit, so credits for the rest
41 of this patch belongs to Fabio.
42
43 Cc: Stefan Agner <stefan.agner@toradex.com>
44 Cc: Max Krummenacher <max.krummenacher@toradex.com>
45 Signed-off-by: Petr Štetiar <ynezz@true.cz>
46 ---
47 configs/apalis_imx6_defconfig | 2 ++
48 include/configs/apalis_imx6.h | 26 +++++++++++++++++++++-----
49 2 files changed, 23 insertions(+), 5 deletions(-)
50
51 --- a/configs/apalis_imx6_defconfig
52 +++ b/configs/apalis_imx6_defconfig
53 @@ -40,6 +40,7 @@ CONFIG_CMD_DFU=y
54 CONFIG_CMD_GPIO=y
55 CONFIG_CMD_I2C=y
56 CONFIG_CMD_MMC=y
57 +CONFIG_CMD_PART=y
58 CONFIG_CMD_USB=y
59 CONFIG_CMD_USB_SDP=y
60 CONFIG_CMD_USB_MASS_STORAGE=y
61 @@ -49,6 +50,7 @@ CONFIG_CMD_PING=y
62 CONFIG_CMD_BMP=y
63 CONFIG_CMD_CACHE=y
64 CONFIG_CMD_EXT4=y
65 +CONFIG_CMD_EXT4_WRITE=y
66 CONFIG_CMD_FAT=y
67 CONFIG_CMD_FS_GENERIC=y
68 CONFIG_ENV_IS_IN_MMC=y
69 --- a/include/configs/apalis_imx6.h
70 +++ b/include/configs/apalis_imx6.h
71 @@ -138,9 +138,9 @@
72 "imx6q-colibri-cam-eval-v3.dtb fat 0 1"
73
74 #define EMMC_BOOTCMD \
75 - "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext3 " \
76 + "emmcargs=ip=off root=PARTUUID=${uuid} rw,noatime rootfstype=ext3 " \
77 "rootwait\0" \
78 - "emmcboot=run setup; " \
79 + "emmcboot=run setup; run finduuid;" \
80 "setenv bootargs ${defargs} ${emmcargs} ${setupargs} " \
81 "${vidargs}; echo Booting from internal eMMC chip...; " \
82 "run emmcdtbload; load mmc 0:1 ${kernel_addr_r} " \
83 @@ -197,10 +197,17 @@
84 #define FDT_FILE "imx6q-apalis_v1_0-eval.dtb"
85 #endif
86 #define CONFIG_EXTRA_ENV_SETTINGS \
87 - "bootcmd=run emmcboot ; echo ; echo emmcboot failed ; " \
88 + "script=boot.scr\0" \
89 + "finduuid=part uuid mmc 0:2 uuid\0" \
90 + "loadbootscript=" \
91 + "load mmc 0:1 ${loadaddr} ${script};\0" \
92 + "bootscript=echo Running bootscript from mmc ...; " \
93 + "source\0" \
94 + "bootcmd_default=run emmcboot ; echo ; echo emmcboot failed ; " \
95 "run nfsboot ; echo ; echo nfsboot failed ; " \
96 "usb start ;" \
97 - "setenv stdout serial,vga ; setenv stdin serial,usbkbd\0" \
98 + "setenv stdout serial,vga ; setenv stdin serial,usbkbd;" \
99 + "sdp 0\0" \
100 "boot_file=uImage\0" \
101 "console=ttymxc0\0" \
102 "defargs=enable_wait_mode=off vmalloc=400M\0" \
103 @@ -228,7 +235,16 @@
104 "vidargs=mxc_hdmi.only_cea=1 " \
105 "video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24 " \
106 "video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off " \
107 - "fbmem=32M\0 "
108 + "fbmem=32M\0 " \
109 + "set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200\0"
110 +
111 +#define CONFIG_BOOTCOMMAND \
112 + "mmc dev 0;" \
113 + "if run loadbootscript; then " \
114 + "run bootscript; " \
115 + "else " \
116 + "run bootcmd_default; " \
117 + "fi; "
118
119 /* Miscellaneous configurable options */
120 #undef CONFIG_SYS_CBSIZE
121 --
122 1.9.1
123