From 8e3b064430300bba4ef15e99ddcda3d861e8e264 Mon Sep 17 00:00:00 2001
From: Paul Kocialkowski <contact@paulk.fr>
Date: Tue, 19 Apr 2016 18:09:30 +0200
Subject: Coreboot, vboot and depthcharge updates to Coreboot 4.3 for CrOS
 devices

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 ...armv7-a-march-abi-flag-for-ARMv7-hardware.patch |   6 +-
 .../0002-Coreboot-image-integration-removal.patch  |   6 +-
 .../patch/0003-DOTCONFIG-location-correction.patch |   6 +-
 ...for-a-read-only-boot-path-when-no-vboot-h.patch |   6 +-
 ...ware-index-report-for-read-only-boot-path.patch |  70 ------
 .../0005-vboot-Only-initialize-cparams-once.patch  |  34 +++
 ...ware-index-report-for-read-only-boot-path.patch |  70 ++++++
 ...tile-context-storage-report-to-mkbp-for-E.patch |  30 ---
 ...tile-context-storage-report-to-mkbp-for-E.patch |  30 +++
 ...ay-callbacks-for-developer-and-recovery-m.patch | 219 ------------------
 ...ay-callbacks-for-developer-and-recovery-m.patch | 251 +++++++++++++++++++++
 11 files changed, 397 insertions(+), 331 deletions(-)
 delete mode 100644 resources/depthcharge/patch/0005-Proper-firmware-index-report-for-read-only-boot-path.patch
 create mode 100644 resources/depthcharge/patch/0005-vboot-Only-initialize-cparams-once.patch
 create mode 100644 resources/depthcharge/patch/0006-Proper-firmware-index-report-for-read-only-boot-path.patch
 delete mode 100644 resources/depthcharge/patch/0006-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch
 create mode 100644 resources/depthcharge/patch/0007-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch
 delete mode 100644 resources/depthcharge/patch/0007-vboot-Display-callbacks-for-developer-and-recovery-m.patch
 create mode 100644 resources/depthcharge/patch/0008-vboot-Display-callbacks-for-developer-and-recovery-m.patch

(limited to 'resources/depthcharge')

diff --git a/resources/depthcharge/patch/0001-arm-armv7-a-march-abi-flag-for-ARMv7-hardware.patch b/resources/depthcharge/patch/0001-arm-armv7-a-march-abi-flag-for-ARMv7-hardware.patch
index f295a63e..d99a574d 100644
--- a/resources/depthcharge/patch/0001-arm-armv7-a-march-abi-flag-for-ARMv7-hardware.patch
+++ b/resources/depthcharge/patch/0001-arm-armv7-a-march-abi-flag-for-ARMv7-hardware.patch
@@ -1,7 +1,7 @@
-From 095ae6281bb2d5bdab288fa042e5c4daa05c5ca3 Mon Sep 17 00:00:00 2001
+From 80e3428c2e50b5a6838d71a89007f610eda5e2dc Mon Sep 17 00:00:00 2001
 From: Paul Kocialkowski <contact@paulk.fr>
 Date: Mon, 3 Aug 2015 14:39:42 +0200
-Subject: [PATCH 1/7] arm: armv7-a march abi flag for ARMv7 hardware
+Subject: [PATCH 1/8] arm: armv7-a march abi flag for ARMv7 hardware
 
 Specifying the march is required to get depthcharge to build with e.g. the arm
 toolchain built by coreboot's crossgcc script. Without this flag, the toolchain
@@ -26,5 +26,5 @@ index b2fce32..455e370 100644
  
  ifeq ($(CONFIG_ARCH_ARM_V8),y)
 -- 
-1.9.1
+2.8.0
 
diff --git a/resources/depthcharge/patch/0002-Coreboot-image-integration-removal.patch b/resources/depthcharge/patch/0002-Coreboot-image-integration-removal.patch
index 28ee21ad..611be4ff 100644
--- a/resources/depthcharge/patch/0002-Coreboot-image-integration-removal.patch
+++ b/resources/depthcharge/patch/0002-Coreboot-image-integration-removal.patch
@@ -1,7 +1,7 @@
-From 4e7d727edf1939904bc516d569ceef9e295f454c Mon Sep 17 00:00:00 2001
+From f095d901afe02728fb0471d51e02553036cd2538 Mon Sep 17 00:00:00 2001
 From: Paul Kocialkowski <contact@paulk.fr>
 Date: Mon, 3 Aug 2015 14:49:34 +0200
-Subject: [PATCH 2/7] Coreboot image integration removal
+Subject: [PATCH 2/8] Coreboot image integration removal
 
 There is no need to integrate the built depthcharge binary inside a coreboot
 image right after building it, coreboot will handle this on its own.
@@ -29,5 +29,5 @@ index a73785b..564dd13 100644
  $(notdir $1)_unified: $1.bin $1.payload
  PHONY += $(notdir $1)_unified
 -- 
-1.9.1
+2.8.0
 
diff --git a/resources/depthcharge/patch/0003-DOTCONFIG-location-correction.patch b/resources/depthcharge/patch/0003-DOTCONFIG-location-correction.patch
index af070de5..d4b6ae98 100644
--- a/resources/depthcharge/patch/0003-DOTCONFIG-location-correction.patch
+++ b/resources/depthcharge/patch/0003-DOTCONFIG-location-correction.patch
@@ -1,7 +1,7 @@
-From 72bb1a69cf6c0f58d3c1a8f6ba98334640818566 Mon Sep 17 00:00:00 2001
+From dfdcd8c218215df4e1523bf6dd11270bc4f52605 Mon Sep 17 00:00:00 2001
 From: Paul Kocialkowski <contact@paulk.fr>
 Date: Sun, 9 Aug 2015 12:06:28 +0200
-Subject: [PATCH 3/7] DOTCONFIG location correction
+Subject: [PATCH 3/8] DOTCONFIG location correction
 
 The configuration file doesn't have to be in src and HAVE_DOTCONFIG holds its
 current location.
@@ -25,5 +25,5 @@ index a1a9d33..13305cd 100644
  ifeq ($(CONFIG_ARCH_X86),y)
  ARCH = x86
 -- 
-1.9.1
+2.8.0
 
diff --git a/resources/depthcharge/patch/0004-Adaptation-for-a-read-only-boot-path-when-no-vboot-h.patch b/resources/depthcharge/patch/0004-Adaptation-for-a-read-only-boot-path-when-no-vboot-h.patch
index 890791b2..ed491a4c 100644
--- a/resources/depthcharge/patch/0004-Adaptation-for-a-read-only-boot-path-when-no-vboot-h.patch
+++ b/resources/depthcharge/patch/0004-Adaptation-for-a-read-only-boot-path-when-no-vboot-h.patch
@@ -1,7 +1,7 @@
-From 5ad9900434045ea97c536c98cb514bdb43114c12 Mon Sep 17 00:00:00 2001
+From 0ec9edead1d9de5f913333e6aa77bcd3de83a617 Mon Sep 17 00:00:00 2001
 From: Paul Kocialkowski <contact@paulk.fr>
 Date: Sun, 9 Aug 2015 12:09:35 +0200
-Subject: [PATCH 4/7] Adaptation for a read-only boot path when no vboot
+Subject: [PATCH 4/8] Adaptation for a read-only boot path when no vboot
  handoff data is found
 
 When no vboot handoff data is found, this makes the unified depthcharge build
@@ -128,5 +128,5 @@ index 10fcb93..575dcfd 100644
  	return 0;
  }
 -- 
-1.9.1
+2.8.0
 
diff --git a/resources/depthcharge/patch/0005-Proper-firmware-index-report-for-read-only-boot-path.patch b/resources/depthcharge/patch/0005-Proper-firmware-index-report-for-read-only-boot-path.patch
deleted file mode 100644
index d883cbdf..00000000
--- a/resources/depthcharge/patch/0005-Proper-firmware-index-report-for-read-only-boot-path.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-From dce70fb042d91ba74359a6dfb519f31d77e2c328 Mon Sep 17 00:00:00 2001
-From: Paul Kocialkowski <contact@paulk.fr>
-Date: Mon, 10 Aug 2015 20:24:50 +0200
-Subject: [PATCH 5/7] Proper firmware index report for read-only boot path
-
-When booting from a read-only boot path, the active firmware to report is RO.
-This is detected with the lack of a vboot handoff pointer.
-
-Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
----
- src/vboot/crossystem/fdt.c | 2 +-
- src/vboot/firmware_id.c    | 6 +++++-
- src/vboot/firmware_id.h    | 1 +
- 3 files changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/src/vboot/crossystem/fdt.c b/src/vboot/crossystem/fdt.c
-index ca39dac..a79b192 100644
---- a/src/vboot/crossystem/fdt.c
-+++ b/src/vboot/crossystem/fdt.c
-@@ -73,7 +73,7 @@ static int install_crossystem_data(DeviceTreeFixup *fixup, DeviceTree *tree)
- 				nvstorage_flash_get_blob_size());
- 	}
- 
--	int fw_index = vdat->firmware_index;
-+	int fw_index = get_active_fw_index(vdat);
- 	const char *fwid;
- 	int fwid_size;
- 
-diff --git a/src/vboot/firmware_id.c b/src/vboot/firmware_id.c
-index 3662921..955bc84 100644
---- a/src/vboot/firmware_id.c
-+++ b/src/vboot/firmware_id.c
-@@ -36,6 +36,7 @@ static struct fwid {
- } fw_fmap_ops[] = {
- 	{VDAT_RW_A, "RW_FWID_A", NULL, 0, "RW A: ID NOT FOUND"},
- 	{VDAT_RW_B, "RW_FWID_B", NULL, 0, "RW B: ID NOT FOUND"},
-+	{VDAT_RO, "RO_FRID", NULL, 0, "RO: ID NOT FOUND"},
- 	{VDAT_RECOVERY, "RO_FRID", NULL, 0, "RO: ID NOT FOUND"},
- };
- 
-@@ -130,10 +131,13 @@ static VbSharedDataHeader *get_vdat(void)
- 	return NULL;
- }
- 
--static inline int get_active_fw_index(VbSharedDataHeader *vdat)
-+int get_active_fw_index(VbSharedDataHeader *vdat)
- {
- 	int fw_index = VDAT_UNKNOWN;
- 
-+	if (lib_sysinfo.vboot_handoff == NULL)
-+		return VDAT_RO;
-+
- 	if (vdat)
- 		fw_index = vdat->firmware_index;
- 
-diff --git a/src/vboot/firmware_id.h b/src/vboot/firmware_id.h
-index fb6f206..090e9d1 100644
---- a/src/vboot/firmware_id.h
-+++ b/src/vboot/firmware_id.h
-@@ -49,6 +49,7 @@ int get_rwb_fw_size(void);
-  * Get firmware details for currently active fw type. It looks up vdat,
-  * identifies fw_index and returns appropriate id and size for that index.
-  */
-+int get_active_fw_index(VbSharedDataHeader *vdat);
- const char *get_active_fw_id(void);
- int get_active_fw_size(void);
- 
--- 
-1.9.1
-
diff --git a/resources/depthcharge/patch/0005-vboot-Only-initialize-cparams-once.patch b/resources/depthcharge/patch/0005-vboot-Only-initialize-cparams-once.patch
new file mode 100644
index 00000000..8bc56a73
--- /dev/null
+++ b/resources/depthcharge/patch/0005-vboot-Only-initialize-cparams-once.patch
@@ -0,0 +1,34 @@
+From 40668e8b5fb9a9e07a3b1ddf334bd4e12a38525f Mon Sep 17 00:00:00 2001
+From: Paul Kocialkowski <contact@paulk.fr>
+Date: Mon, 18 Apr 2016 11:14:19 +0200
+Subject: [PATCH 5/8] vboot: Only initialize cparams once
+
+Calling common_params_init multiple times in a row results in emptying cparams
+each time, causing the GBB data to be lost as it is only read once (the first
+time).
+
+Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
+---
+ src/vboot/util/commonparams.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/vboot/util/commonparams.c b/src/vboot/util/commonparams.c
+index 9f29473..3a71a8b 100644
+--- a/src/vboot/util/commonparams.c
++++ b/src/vboot/util/commonparams.c
+@@ -159,8 +159,10 @@ int is_cparams_initialized(void)
+ int common_params_init(int clear_shared_data)
+ {
+ 	// Set up the common param structure.
+-	memset(&cparams, 0, sizeof(cparams));
+-	cparams_initialized = 1;
++	if (!is_cparams_initialized()) {
++		memset(&cparams, 0, sizeof(cparams));
++		cparams_initialized = 1;
++	}
+ 
+ 	if (gbb_init())
+ 		return 1;
+-- 
+2.8.0
+
diff --git a/resources/depthcharge/patch/0006-Proper-firmware-index-report-for-read-only-boot-path.patch b/resources/depthcharge/patch/0006-Proper-firmware-index-report-for-read-only-boot-path.patch
new file mode 100644
index 00000000..7692ff2b
--- /dev/null
+++ b/resources/depthcharge/patch/0006-Proper-firmware-index-report-for-read-only-boot-path.patch
@@ -0,0 +1,70 @@
+From 8acd4854603672dd1bc16900c9eb58dd5c8c342d Mon Sep 17 00:00:00 2001
+From: Paul Kocialkowski <contact@paulk.fr>
+Date: Mon, 10 Aug 2015 20:24:50 +0200
+Subject: [PATCH 6/8] Proper firmware index report for read-only boot path
+
+When booting from a read-only boot path, the active firmware to report is RO.
+This is detected with the lack of a vboot handoff pointer.
+
+Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
+---
+ src/vboot/crossystem/fdt.c | 2 +-
+ src/vboot/firmware_id.c    | 6 +++++-
+ src/vboot/firmware_id.h    | 1 +
+ 3 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/src/vboot/crossystem/fdt.c b/src/vboot/crossystem/fdt.c
+index ca39dac..a79b192 100644
+--- a/src/vboot/crossystem/fdt.c
++++ b/src/vboot/crossystem/fdt.c
+@@ -73,7 +73,7 @@ static int install_crossystem_data(DeviceTreeFixup *fixup, DeviceTree *tree)
+ 				nvstorage_flash_get_blob_size());
+ 	}
+ 
+-	int fw_index = vdat->firmware_index;
++	int fw_index = get_active_fw_index(vdat);
+ 	const char *fwid;
+ 	int fwid_size;
+ 
+diff --git a/src/vboot/firmware_id.c b/src/vboot/firmware_id.c
+index 3662921..955bc84 100644
+--- a/src/vboot/firmware_id.c
++++ b/src/vboot/firmware_id.c
+@@ -36,6 +36,7 @@ static struct fwid {
+ } fw_fmap_ops[] = {
+ 	{VDAT_RW_A, "RW_FWID_A", NULL, 0, "RW A: ID NOT FOUND"},
+ 	{VDAT_RW_B, "RW_FWID_B", NULL, 0, "RW B: ID NOT FOUND"},
++	{VDAT_RO, "RO_FRID", NULL, 0, "RO: ID NOT FOUND"},
+ 	{VDAT_RECOVERY, "RO_FRID", NULL, 0, "RO: ID NOT FOUND"},
+ };
+ 
+@@ -130,10 +131,13 @@ static VbSharedDataHeader *get_vdat(void)
+ 	return NULL;
+ }
+ 
+-static inline int get_active_fw_index(VbSharedDataHeader *vdat)
++int get_active_fw_index(VbSharedDataHeader *vdat)
+ {
+ 	int fw_index = VDAT_UNKNOWN;
+ 
++	if (lib_sysinfo.vboot_handoff == NULL)
++		return VDAT_RO;
++
+ 	if (vdat)
+ 		fw_index = vdat->firmware_index;
+ 
+diff --git a/src/vboot/firmware_id.h b/src/vboot/firmware_id.h
+index fb6f206..090e9d1 100644
+--- a/src/vboot/firmware_id.h
++++ b/src/vboot/firmware_id.h
+@@ -49,6 +49,7 @@ int get_rwb_fw_size(void);
+  * Get firmware details for currently active fw type. It looks up vdat,
+  * identifies fw_index and returns appropriate id and size for that index.
+  */
++int get_active_fw_index(VbSharedDataHeader *vdat);
+ const char *get_active_fw_id(void);
+ int get_active_fw_size(void);
+ 
+-- 
+2.8.0
+
diff --git a/resources/depthcharge/patch/0006-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch b/resources/depthcharge/patch/0006-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch
deleted file mode 100644
index 7b39db6b..00000000
--- a/resources/depthcharge/patch/0006-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 9eb389b0273cf07add859cd162c1411d15806149 Mon Sep 17 00:00:00 2001
-From: Paul Kocialkowski <contact@paulk.fr>
-Date: Mon, 10 Aug 2015 20:30:14 +0200
-Subject: [PATCH 6/7] fdt: nonvolatile-context-storage report to mkbp for EC NV
- storage
-
-This allows old versions of crossystem to detect that it should use mosys to
-access NV storage in case it is stored on the EC.
-
-Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
----
- src/vboot/crossystem/fdt.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/vboot/crossystem/fdt.c b/src/vboot/crossystem/fdt.c
-index a79b192..0487513 100644
---- a/src/vboot/crossystem/fdt.c
-+++ b/src/vboot/crossystem/fdt.c
-@@ -56,7 +56,7 @@ static int install_crossystem_data(DeviceTreeFixup *fixup, DeviceTree *tree)
- 		dt_add_string_prop(node, "nonvolatile-context-storage","nvram");
- 	} else if (CONFIG_NV_STORAGE_CROS_EC) {
- 		dt_add_string_prop(node,
--				"nonvolatile-context-storage", "cros-ec");
-+				"nonvolatile-context-storage", "mkbp");
- 	} else if (CONFIG_NV_STORAGE_DISK) {
- 		dt_add_string_prop(node, "nonvolatile-context-storage", "disk");
- 		dt_add_u32_prop(node, "nonvolatile-context-lba",
--- 
-1.9.1
-
diff --git a/resources/depthcharge/patch/0007-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch b/resources/depthcharge/patch/0007-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch
new file mode 100644
index 00000000..bfbe96b8
--- /dev/null
+++ b/resources/depthcharge/patch/0007-fdt-nonvolatile-context-storage-report-to-mkbp-for-E.patch
@@ -0,0 +1,30 @@
+From ff08bf3966b3c299d6ead9707cc17a71ff9e50c7 Mon Sep 17 00:00:00 2001
+From: Paul Kocialkowski <contact@paulk.fr>
+Date: Mon, 10 Aug 2015 20:30:14 +0200
+Subject: [PATCH 7/8] fdt: nonvolatile-context-storage report to mkbp for EC NV
+ storage
+
+This allows old versions of crossystem to detect that it should use mosys to
+access NV storage in case it is stored on the EC.
+
+Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
+---
+ src/vboot/crossystem/fdt.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/vboot/crossystem/fdt.c b/src/vboot/crossystem/fdt.c
+index a79b192..0487513 100644
+--- a/src/vboot/crossystem/fdt.c
++++ b/src/vboot/crossystem/fdt.c
+@@ -56,7 +56,7 @@ static int install_crossystem_data(DeviceTreeFixup *fixup, DeviceTree *tree)
+ 		dt_add_string_prop(node, "nonvolatile-context-storage","nvram");
+ 	} else if (CONFIG_NV_STORAGE_CROS_EC) {
+ 		dt_add_string_prop(node,
+-				"nonvolatile-context-storage", "cros-ec");
++				"nonvolatile-context-storage", "mkbp");
+ 	} else if (CONFIG_NV_STORAGE_DISK) {
+ 		dt_add_string_prop(node, "nonvolatile-context-storage", "disk");
+ 		dt_add_u32_prop(node, "nonvolatile-context-lba",
+-- 
+2.8.0
+
diff --git a/resources/depthcharge/patch/0007-vboot-Display-callbacks-for-developer-and-recovery-m.patch b/resources/depthcharge/patch/0007-vboot-Display-callbacks-for-developer-and-recovery-m.patch
deleted file mode 100644
index ea061212..00000000
--- a/resources/depthcharge/patch/0007-vboot-Display-callbacks-for-developer-and-recovery-m.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-From 541a3f09ecb062e3f0778eb9846732cfabcbfbba Mon Sep 17 00:00:00 2001
-From: Paul Kocialkowski <contact@paulk.fr>
-Date: Tue, 11 Aug 2015 11:22:54 +0200
-Subject: [PATCH 7/7] vboot: Display callbacks for developer and recovery mode
- screens
-
-We don't want to use bitmaps stored in GBB since they recommend the use of non-
-free software (Chrome OS), so this implements a text-based interface instead.
-
-Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
----
- src/vboot/callbacks/display.c | 168 +++++++++++++++++++++++++++++++++++++++---
- 1 file changed, 156 insertions(+), 12 deletions(-)
-
-diff --git a/src/vboot/callbacks/display.c b/src/vboot/callbacks/display.c
-index efa0691..b659f7b 100644
---- a/src/vboot/callbacks/display.c
-+++ b/src/vboot/callbacks/display.c
-@@ -84,9 +84,17 @@ void print_on_center(const char *msg)
- 	print_string(msg);
- }
- 
--VbError_t VbExDisplayScreen(uint32_t screen_type)
-+VbError_t VbExDisplayScreen(uint32_t screen_type, VbNvContext *vnc)
- {
--	const char *msg = NULL;
-+	unsigned int rows, cols;
-+	uint32_t boot_signed_only = 0;
-+	uint32_t boot_usb = 0;
-+	uint32_t boot_legacy = 0;
-+	const char *fw_id;
-+	int fw_index;
-+	void *blob = NULL;
-+	int size = 0;
-+	char *msg;
- 
- 	/*
- 	 * Show the debug messages for development. It is a backup method
-@@ -98,31 +106,167 @@ VbError_t VbExDisplayScreen(uint32_t screen_type)
- 		video_console_clear();
- 		break;
- 	case VB_SCREEN_DEVELOPER_WARNING:
--		msg = "developer mode warning";
-+		video_console_clear();
-+		video_console_set_cursor(0, 0);
-+
-+		if (vnc != NULL) {
-+			VbNvGet(vnc, VBNV_DEV_BOOT_SIGNED_ONLY,
-+				&boot_signed_only);
-+
-+			VbNvGet(vnc, VBNV_DEV_BOOT_USB, &boot_usb);
-+			VbNvGet(vnc, VBNV_DEV_BOOT_LEGACY, &boot_legacy);
-+		}
-+
-+		print_string(
-+			"Welcome to developer mode!\n\n"
-+			"Useful key combinations:\n"
-+			"- Ctrl + H: Hold developer mode\n"
-+			"- Ctrl + D: Boot from internal storage\n");
-+
-+		if (boot_usb)
-+			print_string("- Ctrl + U: Boot from external media\n");
-+
-+		if (boot_legacy)
-+			print_string("- Ctrl + L: Boot from legacy payload\n");
-+
-+		print_string(
-+			"- Ctrl + I: Show device information\n"
-+			"- Space: Disable developer mode\n\n"
-+			"This screen is shown for 3 seconds (if not held)."
-+			"\n\n");
-+
-+		if (vnc != NULL) {
-+			if (!boot_signed_only)
-+				print_string(
-+					"Warning: this device will boot kernels"
-+					" without verifying their signature!"
-+					"\n");
-+
-+			if (boot_usb)
-+				print_string(
-+					"Warning: this device will boot from "
-+					"external media!\n");
-+
-+			if (boot_legacy)
-+				print_string(
-+					"Warning: this device will boot legacy "
-+					"payloads!\n");
-+
-+			if (!boot_signed_only || boot_usb)
-+				print_string("\n");
-+		}
-+
-+		find_common_params(&blob, &size);
-+
-+		if (blob != NULL) {
-+			VbSharedDataHeader *vdat = (VbSharedDataHeader *) blob;
-+			fw_index = get_active_fw_index(vdat);
-+			fw_id = get_fw_id(fw_index);
-+
-+			if (fw_id == NULL)
-+				fw_id = "NOT FOUND";
-+
-+			print_string("Active firmware id: ");
-+			print_string(fw_id);
-+
-+			switch (fw_index) {
-+				case VDAT_RW_A:
-+					print_string(" (RW A)\n");
-+					break;
-+				case VDAT_RW_B:
-+					print_string(" (RW A)\n");
-+					break;
-+				case VDAT_RO:
-+					print_string(" (RO)\n");
-+					break;
-+				default:
-+					print_string(" (UNKNOWN)\n");
-+					break;
-+			}
-+		}
- 		break;
- 	case VB_SCREEN_DEVELOPER_EGG:
--		msg = "easter egg";
-+		video_console_clear();
-+		print_on_center("Free as in Freedom!");
- 		break;
- 	case VB_SCREEN_RECOVERY_REMOVE:
--		msg = "remove inserted devices";
-+		video_console_clear();
-+		print_on_center(
-+			"Please remove any external media before accessing "
-+			"recovery screen.");
- 		break;
- 	case VB_SCREEN_RECOVERY_INSERT:
--		msg = "insert recovery image";
--		break;
- 	case VB_SCREEN_RECOVERY_NO_GOOD:
--		msg = "insert image invalid";
-+		video_console_clear();
-+		print_string(
-+			"Welcome to recovery mode!\n\n"
-+			"Useful key combinations:\n"
-+			"- Ctrl + D: Enable developer mode (if possible)\n\n");
-+
-+		if (screen_type == VB_SCREEN_RECOVERY_NO_GOOD)
-+			print_on_center(
-+				"Invalid recovery media, please instert a "
-+				"valid one.");
-+		else
-+			print_on_center(
-+				"Please insert an external recovery media.");
-+		break;
-+	case VB_SCREEN_RECOVERY_TO_DEV:
-+		video_console_clear();
-+		video_get_rows_cols(&rows, &cols);
-+
-+		video_console_set_cursor(0, 0);
-+
-+		print_string(
-+			"Enabling developer mode will allow booting unsigned "
-+			"kernels and booting from external media (when enabled "
-+			"with crossystem).\n\n"
-+			"Developer mode can be disabled via the developer mode "
-+			"screen.");
-+
-+		msg = "Developer mode will be enabled.";
-+		video_console_set_cursor((cols - strlen(msg)) / 2, rows / 2);
-+		print_string(msg);
-+
-+		msg = "Press enter to confirm or escape to go back.";
-+		video_console_set_cursor((cols - strlen(msg)) / 2,
-+					 rows / 2 + 2);
-+		print_string(msg);
-+		break;
-+	case VB_SCREEN_DEVELOPER_TO_NORM:
-+		video_console_clear();
-+		video_get_rows_cols(&rows, &cols);
-+
-+		video_console_set_cursor(0, 0);
-+
-+		print_string(
-+			"Disabling developer mode will restrict boot to signed "
-+			"kernels stored on internal memory only.\n\n"
-+			"Developer mode can be enabled again via the recovery "
-+			"mode screen.");
-+
-+		msg = "Developer mode will be disabled.";
-+		video_console_set_cursor((cols - strlen(msg)) / 2, rows / 2);
-+		print_string(msg);
-+
-+		msg = "Press enter to confirm or escape to go back.";
-+		video_console_set_cursor((cols - strlen(msg)) / 2,
-+					 rows / 2 + 2);
-+		print_string(msg);
- 		break;
- 	case VB_SCREEN_WAIT:
--		msg = "wait for ec update";
-+		video_console_clear();
-+		print_on_center("Waiting for EC update...");
-+		break;
-+	case VB_SCREEN_TO_NORM_CONFIRMED:
-+		video_console_clear();
-+		print_on_center("Disabling developer mode.");
- 		break;
- 	default:
- 		printf("Not a valid screen type: %d.\n", screen_type);
- 		return VBERROR_INVALID_SCREEN_INDEX;
- 	}
- 
--	if (msg)
--		print_on_center(msg);
--
- 	return VBERROR_SUCCESS;
- }
- 
--- 
-1.9.1
-
diff --git a/resources/depthcharge/patch/0008-vboot-Display-callbacks-for-developer-and-recovery-m.patch b/resources/depthcharge/patch/0008-vboot-Display-callbacks-for-developer-and-recovery-m.patch
new file mode 100644
index 00000000..cacc3ecd
--- /dev/null
+++ b/resources/depthcharge/patch/0008-vboot-Display-callbacks-for-developer-and-recovery-m.patch
@@ -0,0 +1,251 @@
+From 50a27cb948d3e944e3e466146b0d81939e8ce9a5 Mon Sep 17 00:00:00 2001
+From: Paul Kocialkowski <contact@paulk.fr>
+Date: Tue, 11 Aug 2015 11:22:54 +0200
+Subject: [PATCH 8/8] vboot: Display callbacks for developer and recovery mode
+ screens
+
+We don't want to use bitmaps stored in GBB since they recommend the use of non-
+free software (Chrome OS), so this implements a text-based interface instead.
+
+Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
+---
+ src/vboot/callbacks/display.c | 200 ++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 185 insertions(+), 15 deletions(-)
+
+diff --git a/src/vboot/callbacks/display.c b/src/vboot/callbacks/display.c
+index 183e278..ece9140 100644
+--- a/src/vboot/callbacks/display.c
++++ b/src/vboot/callbacks/display.c
+@@ -86,12 +86,19 @@ void print_on_center(const char *msg)
+ 	print_string(msg);
+ }
+ 
+-VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale)
++VbError_t VbExDisplayScreen(uint32_t screen_type, VbNvContext *vnc,
++                            uint32_t locale)
+ {
+-	const char *msg = NULL;
+-
+-	if (vboot_draw_screen(screen_type, locale) == CBGFX_SUCCESS)
+-		return VBERROR_SUCCESS;
++	unsigned int rows, cols;
++	uint32_t default_boot = 0;
++	uint32_t boot_signed_only = 0;
++	uint32_t boot_usb = 0;
++	uint32_t boot_legacy = 0;
++	const char *fw_id;
++	int fw_index;
++	void *blob = NULL;
++	int size = 0;
++	char *msg;
+ 
+ 	/*
+ 	 * Show the debug messages for development. It is a backup method
+@@ -103,31 +110,194 @@ VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale)
+ 		video_console_clear();
+ 		break;
+ 	case VB_SCREEN_DEVELOPER_WARNING:
+-		msg = "developer mode warning";
++		video_console_clear();
++		video_console_set_cursor(0, 0);
++
++		if (vnc != NULL) {
++			VbNvGet(vnc, VBNV_DEV_BOOT_SIGNED_ONLY,
++				&boot_signed_only);
++
++			VbNvGet(vnc, VBNV_DEV_BOOT_USB, &boot_usb);
++			VbNvGet(vnc, VBNV_DEV_BOOT_LEGACY, &boot_legacy);
++
++			VbNvGet(vnc, VBNV_DEV_DEFAULT_BOOT, &default_boot);
++		}
++
++		print_string(
++			"Welcome to developer mode!\n\n"
++			"Useful key combinations:\n"
++			"- Ctrl + H: Hold developer mode\n"
++			"- Ctrl + D: Boot from internal storage\n");
++
++		if (boot_usb)
++			print_string("- Ctrl + U: Boot from external media\n");
++
++		if (boot_legacy)
++			print_string("- Ctrl + L: Boot from legacy payload\n");
++
++		print_string(
++			"- Ctrl + I: Show device information\n"
++			"- Space: Disable developer mode\n\n"
++			"This screen is shown for 3 seconds (if not held)."
++			"\n\n");
++
++		if (vnc != NULL) {
++			if (!boot_signed_only)
++				print_string(
++					"Warning: this device will boot kernels"
++					" without verifying their signature!"
++					"\n");
++
++			if (boot_usb)
++				print_string(
++					"Warning: this device will boot from "
++					"external media!\n");
++
++			if (boot_legacy)
++				print_string(
++					"Warning: this device will boot legacy "
++					"payloads!\n");
++
++			if (!boot_signed_only || boot_usb)
++				print_string("\n");
++
++			print_string("Default boot medium: ");
++
++			switch (default_boot) {
++				case VBNV_DEV_DEFAULT_BOOT_DISK:
++					print_string("internal storage");
++					break;
++				case VBNV_DEV_DEFAULT_BOOT_USB:
++					print_string("external media");
++					break;
++				case VBNV_DEV_DEFAULT_BOOT_LEGACY:
++					print_string("legacy payload");
++					break;
++				default:
++					print_string("unknown");
++					break;
++			}
++
++			print_string("\n");
++		}
++
++		find_common_params(&blob, &size);
++
++		if (blob != NULL) {
++			VbSharedDataHeader *vdat = (VbSharedDataHeader *) blob;
++			fw_index = get_active_fw_index(vdat);
++			fw_id = get_fw_id(fw_index);
++
++			if (fw_id == NULL)
++				fw_id = "NOT FOUND";
++
++			print_string("Active firmware id: ");
++			print_string(fw_id);
++
++			switch (fw_index) {
++				case VDAT_RW_A:
++					print_string(" (RW A)\n");
++					break;
++				case VDAT_RW_B:
++					print_string(" (RW A)\n");
++					break;
++				case VDAT_RO:
++					print_string(" (RO)\n");
++					break;
++				default:
++					print_string(" (UNKNOWN)\n");
++					break;
++			}
++		}
+ 		break;
+ 	case VB_SCREEN_DEVELOPER_EGG:
+-		msg = "easter egg";
++		video_console_clear();
++		print_on_center("Free as in Freedom!");
+ 		break;
+ 	case VB_SCREEN_RECOVERY_REMOVE:
+-		msg = "remove inserted devices";
++		video_console_clear();
++		print_on_center(
++			"Please remove any external media before accessing "
++			"recovery screen.");
+ 		break;
+ 	case VB_SCREEN_RECOVERY_INSERT:
+-		msg = "insert recovery image";
+-		break;
+ 	case VB_SCREEN_RECOVERY_NO_GOOD:
+-		msg = "insert image invalid";
++		video_console_clear();
++		print_string(
++			"Welcome to recovery mode!\n\n"
++			"Useful key combinations:\n"
++			"- Ctrl + D: Enable developer mode (if possible)\n\n");
++
++		if (screen_type == VB_SCREEN_RECOVERY_NO_GOOD)
++			print_on_center(
++				"Invalid recovery media, please instert a "
++				"valid one.");
++		else
++			print_on_center(
++				"Please insert an external recovery media.");
++		break;
++	case VB_SCREEN_RECOVERY_TO_DEV:
++		video_console_clear();
++		video_get_rows_cols(&rows, &cols);
++
++		video_console_set_cursor(0, 0);
++
++		print_string(
++			"Enabling developer mode will allow booting unsigned "
++			"kernels and booting from external media (when enabled "
++			"with crossystem).\n\n"
++			"Developer mode can be disabled via the developer mode "
++			"screen.");
++
++		msg = "Developer mode will be enabled.";
++		video_console_set_cursor((cols - strlen(msg)) / 2, rows / 2);
++		print_string(msg);
++
++		msg = "Press enter to confirm or escape to go back.";
++		video_console_set_cursor((cols - strlen(msg)) / 2,
++					 rows / 2 + 2);
++		print_string(msg);
++		break;
++	case VB_SCREEN_DEVELOPER_TO_NORM:
++		video_console_clear();
++		video_get_rows_cols(&rows, &cols);
++
++		video_console_set_cursor(0, 0);
++
++		print_string(
++			"Disabling developer mode will restrict boot to signed "
++			"kernels stored on internal memory only.\n\n"
++			"Developer mode can be enabled again via the recovery "
++			"mode screen.");
++
++		msg = "Developer mode will be disabled.";
++		video_console_set_cursor((cols - strlen(msg)) / 2, rows / 2);
++		print_string(msg);
++
++		msg = "Press enter to confirm or escape to go back.";
++		video_console_set_cursor((cols - strlen(msg)) / 2,
++					 rows / 2 + 2);
++		print_string(msg);
+ 		break;
+ 	case VB_SCREEN_WAIT:
+-		msg = "wait for ec update";
++		video_console_clear();
++		print_on_center("Waiting for EC update...");
++		break;
++	case VB_SCREEN_TO_NORM_CONFIRMED:
++		video_console_clear();
++		print_on_center("Disabling developer mode.");
++		break;
++	case VB_SCREEN_OS_BROKEN:
++		video_console_clear();
++		print_on_center(
++			"Something went wrong and the device cannot boot.\n"
++			"Press Escape + Refresh + Power to access recovery.");
+ 		break;
+ 	default:
+ 		printf("Not a valid screen type: %d.\n", screen_type);
+ 		return VBERROR_INVALID_SCREEN_INDEX;
+ 	}
+ 
+-	if (msg)
+-		print_on_center(msg);
+-
+ 	return VBERROR_SUCCESS;
+ }
+ 
+-- 
+2.8.0
+
-- 
cgit v1.2.3-70-g09d2