From 995fb2905f5994fa89571a1eaf07ab9c63a81a11 Mon Sep 17 00:00:00 2001
From: Michael Cullen <michael@michaelcullen.name>
Date: Sat, 29 Jun 2019 19:32:37 +0100
Subject: [PATCH] package/rpi-firmware: bump version for pi4 support

This commit pulls in the latest version of rpi-firmware to enable
support for the new Pi4

Additionally, it copies the RPi4 start files if selected.

Signed-off-by: Michael Cullen <michael@michaelcullen.name>
---
 package/rpi-firmware/Config.in         | 31 ++++++++++++++++++++++++--
 package/rpi-firmware/rpi-firmware.hash |  2 +-
 package/rpi-firmware/rpi-firmware.mk   | 10 ++++++---
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/package/rpi-firmware/Config.in b/package/rpi-firmware/Config.in
index 0ebbe7a4cd..aeac6ece95 100644
--- a/package/rpi-firmware/Config.in
+++ b/package/rpi-firmware/Config.in
@@ -11,6 +11,26 @@ config BR2_PACKAGE_RPI_FIRMWARE
 
 if BR2_PACKAGE_RPI_FIRMWARE
 
+choice
+	bool "Boot Files to Install"
+	default BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI
+	help
+		The Raspberry Pi 4 introduced a slightly different
+		naming convention and set of boot files. This option
+		selects which format to install.
+
+config BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI
+	bool "Pi 1/2/3"
+	help
+		The default set of files, for versions pre-4
+
+config BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4
+	bool "Pi 4"
+	help
+		The Raspberry Pi 4 boot files
+
+endchoice
+
 choice
 	bool "Firmware to boot"
 	default BR2_PACKAGE_RPI_FIRMWARE_DEFAULT
@@ -45,8 +65,15 @@ endchoice
 config BR2_PACKAGE_RPI_FIRMWARE_BOOT
 	string
 	default ""      if BR2_PACKAGE_RPI_FIRMWARE_DEFAULT
-	default "_x"    if BR2_PACKAGE_RPI_FIRMWARE_X
-	default "_cd"   if BR2_PACKAGE_RPI_FIRMWARE_CD
+	default "_x"    if BR2_PACKAGE_RPI_FIRMWARE_X && BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI
+	default "x"     if BR2_PACKAGE_RPI_FIRMWARE_X && BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4
+	default "_cd"   if BR2_PACKAGE_RPI_FIRMWARE_CD && BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI
+	default "cd"    if BR2_PACKAGE_RPI_FIRMWARE_CD && BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4
+
+config BR2_PACKAGE_RPI_FIRMWARE_BOOT_SUFFIX
+	string
+	default ""      if BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI
+	default "4"     if BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4
 
 config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS
 	bool "Install Device Tree Blobs (DTBs)"
diff --git a/package/rpi-firmware/rpi-firmware.hash b/package/rpi-firmware/rpi-firmware.hash
index d719fa6e08..0d7ce949a2 100644
--- a/package/rpi-firmware/rpi-firmware.hash
+++ b/package/rpi-firmware/rpi-firmware.hash
@@ -1,2 +1,2 @@
 # Locally computed
-sha256 e911f6342ea8aa9380cae97c6f5ac4ddd370527265f23d5b5d4b2c6f679d4ba8 rpi-firmware-ebf7b40cdc6effe7ffa3fd5195e8be01b94f80da.tar.gz
+sha256 c82c40cf37fac36160a7f6b9c314506beb942bf113a55d30fa163c56a4f98946 rpi-firmware-bcf40b5c2b94178c7564fb451098d44968e44af5.tar.gz
diff --git a/package/rpi-firmware/rpi-firmware.mk b/package/rpi-firmware/rpi-firmware.mk
index 272db1c321..5aae939503 100644
--- a/package/rpi-firmware/rpi-firmware.mk
+++ b/package/rpi-firmware/rpi-firmware.mk
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-RPI_FIRMWARE_VERSION = ebf7b40cdc6effe7ffa3fd5195e8be01b94f80da
+RPI_FIRMWARE_VERSION = bcf40b5c2b94178c7564fb451098d44968e44af5
 RPI_FIRMWARE_SITE = $(call github,raspberrypi,firmware,$(RPI_FIRMWARE_VERSION))
 RPI_FIRMWARE_LICENSE = BSD-3-Clause
 RPI_FIRMWARE_LICENSE_FILES = boot/LICENCE.broadcom
@@ -43,8 +43,12 @@ endif # INSTALL_VCDBG
 
 define RPI_FIRMWARE_INSTALL_IMAGES_CMDS
 	$(INSTALL) -D -m 0644 $(@D)/boot/bootcode.bin $(BINARIES_DIR)/rpi-firmware/bootcode.bin
-	$(INSTALL) -D -m 0644 $(@D)/boot/start$(BR2_PACKAGE_RPI_FIRMWARE_BOOT).elf $(BINARIES_DIR)/rpi-firmware/start.elf
-	$(INSTALL) -D -m 0644 $(@D)/boot/fixup$(BR2_PACKAGE_RPI_FIRMWARE_BOOT).dat $(BINARIES_DIR)/rpi-firmware/fixup.dat
+	$(INSTALL) -D -m 0644 \
+		$(@D)/boot/start$(BR2_PACKAGE_RPI_FIRMWARE_BOOT_SUFFIX)$(BR2_PACKAGE_RPI_FIRMWARE_BOOT).elf \
+		$(BINARIES_DIR)/rpi-firmware/start$(BR2_PACKAGE_RPI_FIRMWARE_BOOT_SUFFIX).elf
+	$(INSTALL) -D -m 0644 \
+		$(@D)/boot/fixup$(BR2_PACKAGE_RPI_FIRMWARE_BOOT_SUFFIX)$(BR2_PACKAGE_RPI_FIRMWARE_BOOT).dat \
+		$(BINARIES_DIR)/rpi-firmware/fixup$(BR2_PACKAGE_RPI_FIRMWARE_BOOT_SUFFIX).dat
 	$(INSTALL) -D -m 0644 package/rpi-firmware/config.txt $(BINARIES_DIR)/rpi-firmware/config.txt
 	$(INSTALL) -D -m 0644 package/rpi-firmware/cmdline.txt $(BINARIES_DIR)/rpi-firmware/cmdline.txt
 	$(RPI_FIRMWARE_INSTALL_DTB)
-- 
2.17.1

