clearfog: Refactor the U-Boot patches and move extra boot args to an extra variable

Change-Id: I171d92d50d72c82bcb3a0a77a888750f049deffb
diff --git a/board/czechlight/clearfog/patches/u-boot/0001-Unconditionally-enable-watchdog-timer-on-Clearfog.patch b/board/czechlight/clearfog/patches/u-boot/0001-clearfog-Unconditionally-enable-watchdog-timer.patch
similarity index 95%
rename from board/czechlight/clearfog/patches/u-boot/0001-Unconditionally-enable-watchdog-timer-on-Clearfog.patch
rename to board/czechlight/clearfog/patches/u-boot/0001-clearfog-Unconditionally-enable-watchdog-timer.patch
index 3fbf52b..c24ee97 100644
--- a/board/czechlight/clearfog/patches/u-boot/0001-Unconditionally-enable-watchdog-timer-on-Clearfog.patch
+++ b/board/czechlight/clearfog/patches/u-boot/0001-clearfog-Unconditionally-enable-watchdog-timer.patch
@@ -1,7 +1,7 @@
-From 7242f6d20423a7705080d54828468b3a31071566 Mon Sep 17 00:00:00 2001
+From e5d8ae27ae561e760a9a6d0074a4df147a1959cc Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz>
 Date: Fri, 29 Sep 2017 18:11:04 +0200
-Subject: [PATCH] Unconditionally enable watchdog timer on Clearfog
+Subject: [PATCH 1/5] clearfog: Unconditionally enable watchdog timer
 
 We will only be booting kernels that support the watchdog, so there's no
 risk in leaving our WD running while we hand over to the kernel.
diff --git a/board/czechlight/clearfog/patches/u-boot/0002-Add-another-redundant-storage-for-the-environment.patch b/board/czechlight/clearfog/patches/u-boot/0002-clearfog-Add-another-redundant-environment-storage.patch
similarity index 82%
rename from board/czechlight/clearfog/patches/u-boot/0002-Add-another-redundant-storage-for-the-environment.patch
rename to board/czechlight/clearfog/patches/u-boot/0002-clearfog-Add-another-redundant-environment-storage.patch
index da15be1..22233ce 100644
--- a/board/czechlight/clearfog/patches/u-boot/0002-Add-another-redundant-storage-for-the-environment.patch
+++ b/board/czechlight/clearfog/patches/u-boot/0002-clearfog-Add-another-redundant-environment-storage.patch
@@ -1,7 +1,7 @@
-From 3631fab797c4991e04fb8bf984ca53d00aec520f Mon Sep 17 00:00:00 2001
+From 2efee00c747c83a7255c6fabc573da1210d5e45c Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz>
 Date: Tue, 10 Oct 2017 20:49:41 +0200
-Subject: [PATCH 2/2] Add another, redundant storage for the environment
+Subject: [PATCH 2/5] clearfog: Add another, redundant environment storage
 
 ---
  include/configs/clearfog.h | 3 +++
diff --git a/board/czechlight/clearfog/patches/u-boot/0003-clearfog-hard-code-the-RAUC-redundant-boot-to-uboot-.patch b/board/czechlight/clearfog/patches/u-boot/0003-clearfog-hard-code-the-RAUC-redundant-boot-to-uboot-.patch
index 00ccf57..5eb1a7d 100644
--- a/board/czechlight/clearfog/patches/u-boot/0003-clearfog-hard-code-the-RAUC-redundant-boot-to-uboot-.patch
+++ b/board/czechlight/clearfog/patches/u-boot/0003-clearfog-hard-code-the-RAUC-redundant-boot-to-uboot-.patch
@@ -1,7 +1,7 @@
-From 4223232d3fa9b71997ac5d5c890d5bd91c39ce8d Mon Sep 17 00:00:00 2001
+From 9b36966ce24325309993e74df86ec60fe9976964 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz>
 Date: Wed, 11 Oct 2017 11:51:14 +0200
-Subject: [PATCH 3/3] clearfog: hard-code the RAUC redundant boot to uboot's
+Subject: [PATCH 3/5] clearfog: hard-code the RAUC redundant boot to uboot's
  config
 
 ...so that we can save one partition and an extra detour via a boot.scr
diff --git a/board/czechlight/clearfog/patches/u-boot/0004-clearfog-Auto-reboot-on-panic-and-oops.patch b/board/czechlight/clearfog/patches/u-boot/0004-clearfog-Auto-reboot-on-panic-and-oops.patch
index c90fa80..aabbf13 100644
--- a/board/czechlight/clearfog/patches/u-boot/0004-clearfog-Auto-reboot-on-panic-and-oops.patch
+++ b/board/czechlight/clearfog/patches/u-boot/0004-clearfog-Auto-reboot-on-panic-and-oops.patch
@@ -1,7 +1,7 @@
-From 4573fe220f3ea05c0648a0e1776aa64979eff683 Mon Sep 17 00:00:00 2001
+From 7273b75a769bb39315b21159b6bc0d2da43cf01e Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz>
 Date: Wed, 11 Oct 2017 14:42:51 +0200
-Subject: [PATCH 4/4] clearfog: Auto-reboot on panic and oops
+Subject: [PATCH 4/5] clearfog: Auto-reboot on panic and oops
 
 ---
  include/configs/clearfog.h | 2 +-
diff --git a/board/czechlight/clearfog/patches/u-boot/0005-clearfog-Move-all-extra-bootargs-to-a-special-variab.patch b/board/czechlight/clearfog/patches/u-boot/0005-clearfog-Move-all-extra-bootargs-to-a-special-variab.patch
new file mode 100644
index 0000000..71eaaaa
--- /dev/null
+++ b/board/czechlight/clearfog/patches/u-boot/0005-clearfog-Move-all-extra-bootargs-to-a-special-variab.patch
@@ -0,0 +1,44 @@
+From 9b6df01de8944114d5563a434df143be1ed2dad1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz>
+Date: Thu, 19 Oct 2017 11:45:23 +0200
+Subject: [PATCH 5/5] clearfog: Move all extra bootargs to a special variable
+
+I have two reasons for this, and both of them center around making it
+possible to perform changes to the boot process.
+
+It is quite dangerous to attempt to re-flash the entire card, including
+the bootloader, on the fly. Moving as much bits as possible to the
+environment makes it a bit easier to introduce important changes such
+as, for example, volatile rootfs, later on.
+
+The second one is for testing -- it's much easier to just rewrite one
+reasonable variable. Changes no longer require struggling with overly
+long lines (bootcmd), at least.
+---
+ include/configs/clearfog.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h
+index d251278885..04faf5c49f 100644
+--- a/include/configs/clearfog.h
++++ b/include/configs/clearfog.h
+@@ -178,6 +178,7 @@
+ 	RELOCATION_LIMITS_ENV_SETTINGS \
+ 	LOAD_ADDRESS_ENV_SETTINGS \
+ 	"console=ttyS0,115200\0" \
++	"extra_bootargs=panic=10 oops=panic\0" \
+ 	"bootcmd=test -n \"${BOOT_A_LEFT}\" || setenv BOOT_A_LEFT 3;" \
+ 	"test -n \"${BOOT_B_LEFT}\" || setenv BOOT_B_LEFT 3;" \
+ 	"setenv rauc_part;" \
+@@ -209,7 +210,7 @@
+ 	"  saveenv;" \
+ 	"  reset;" \
+ 	"fi;" \
+-	"setenv bootargs root=/dev/mmcblk0p${rauc_part} rauc.slot=${rauc_slot} czechlight=${czechlight} panic=10 oops=panic;" \
++	"setenv bootargs root=/dev/mmcblk0p${rauc_part} rauc.slot=${rauc_slot} czechlight=${czechlight} ${extra_bootargs};" \
+ 	"load mmc 0:${rauc_part} ${fdt_addr_r} /boot/armada-388-clearfog-base.dtb || reset;" \
+ 	"load mmc 0:${rauc_part} ${kernel_addr_r} /boot/zImage || reset;" \
+ 	"bootz ${kernel_addr_r} - ${fdt_addr_r} || reset\0"
+-- 
+2.14.1
+
diff --git a/configs/czechlight_clearfog_defconfig b/configs/czechlight_clearfog_defconfig
index 97c20a8..fb93b45 100644
--- a/configs/czechlight_clearfog_defconfig
+++ b/configs/czechlight_clearfog_defconfig
@@ -43,7 +43,7 @@
 BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
 BR2_TARGET_UBOOT_CUSTOM_VERSION=y
 BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2017.09"
-BR2_TARGET_UBOOT_PATCH="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0001-Unconditionally-enable-watchdog-timer-on-Clearfog.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0002-Add-another-redundant-storage-for-the-environment.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0003-clearfog-hard-code-the-RAUC-redundant-boot-to-uboot-.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0004-clearfog-Auto-reboot-on-panic-and-oops.patch"
+BR2_TARGET_UBOOT_PATCH="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0001-clearfog-Unconditionally-enable-watchdog-timer.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0002-clearfog-Add-another-redundant-environment-storage.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0003-clearfog-hard-code-the-RAUC-redundant-boot-to-uboot-.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0004-clearfog-Auto-reboot-on-panic-and-oops.patch $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/u-boot/0005-clearfog-Move-all-extra-bootargs-to-a-special-variab.patch"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="clearfog"
 BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/uboot.fragment"
 # BR2_TARGET_UBOOT_FORMAT_BIN is not set