From 73539bc4910b374d8ac896911b80100d6c928aec Mon Sep 17 00:00:00 2001
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
Date: Sun, 13 Mar 2016 23:25:49 +0100
Subject: [PATCH] rpi3 support

This patch cherry-picks the following commits to upstream Buildroot that
haven't been officially released yet:

41276ae rpi-firmware: unbreak _INSTALL_VCDBG logic
cf66157 package/rpi-userland: bump version
e4a5ea9 package/rpi-firmware: bump version, add support for rpi-3

It also bumps the rpi-userland and rpi-firmware to pull in the serial
port fix.
---
 package/rpi-firmware/rpi-firmware.mk               |  6 ++---
 ...make-vmcs.cmake-allow-to-override-VMCS_IN.patch | 27 ----------------------
 ...ting-type-qualifiers-errors-when-building.patch | 23 ------------------
 package/rpi-userland/rpi-userland.mk               |  2 +-
 4 files changed, 4 insertions(+), 54 deletions(-)
 delete mode 100644 package/rpi-userland/0002-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch
 delete mode 100644 package/rpi-userland/0006-Fix-conflicting-type-qualifiers-errors-when-building.patch

diff --git a/package/rpi-firmware/rpi-firmware.mk b/package/rpi-firmware/rpi-firmware.mk
index 4b92a50..0bbd990 100644
--- a/package/rpi-firmware/rpi-firmware.mk
+++ b/package/rpi-firmware/rpi-firmware.mk
@@ -4,11 +4,10 @@
 #
 ################################################################################
 
-RPI_FIRMWARE_VERSION = 22d8c910f4c53118f9cf85c038d7d8e307efc110
+RPI_FIRMWARE_VERSION = 0a96f63b75d23567320e74767d3ce11002397af7
 RPI_FIRMWARE_SITE = $(call github,raspberrypi,firmware,$(RPI_FIRMWARE_VERSION))
 RPI_FIRMWARE_LICENSE = BSD-3c
 RPI_FIRMWARE_LICENSE_FILES = boot/LICENCE.broadcom
-RPI_FIRMWARE_INSTALL_TARGET = NO
 RPI_FIRMWARE_INSTALL_IMAGES = YES
 
 RPI_FIRMWARE_DEPENDENCIES += host-rpi-firmware
@@ -18,6 +17,7 @@ define RPI_FIRMWARE_INSTALL_DTB
 	$(INSTALL) -D -m 0644 $(@D)/boot/bcm2708-rpi-b.dtb $(BINARIES_DIR)/rpi-firmware/bcm2708-rpi-b.dtb
 	$(INSTALL) -D -m 0644 $(@D)/boot/bcm2708-rpi-b-plus.dtb $(BINARIES_DIR)/rpi-firmware/bcm2708-rpi-b-plus.dtb
 	$(INSTALL) -D -m 0644 $(@D)/boot/bcm2709-rpi-2-b.dtb $(BINARIES_DIR)/rpi-firmware/bcm2709-rpi-2-b.dtb
+	$(INSTALL) -D -m 0644 $(@D)/boot/bcm2710-rpi-3-b.dtb $(BINARIES_DIR)/rpi-firmware/bcm2710-rpi-3-b.dtb
 endef
 endif
 
@@ -31,7 +31,7 @@ endif
 
 ifeq ($(BR2_PACKAGE_RPI_FIRMWARE_INSTALL_VCDBG),y)
 define RPI_FIRMWARE_INSTALL_TARGET_CMDS
-	$(INSTALL) -d -m 0700 $(@D)/$(if BR2_ARM_EABIHF,hardfp/)opt/vc/bin/vcdbg \
+	$(INSTALL) -D -m 0700 $(@D)/$(if BR2_ARM_EABIHF,hardfp/)opt/vc/bin/vcdbg \
 		$(TARGET_DIR)/usr/sbin/vcdbg
 endef
 endif # INSTALL_VCDBG
diff --git a/package/rpi-userland/0002-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch b/package/rpi-userland/0002-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch
deleted file mode 100644
index c218898..0000000
--- a/package/rpi-userland/0002-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 8894136ff80a8c6eeadf1799af59aa3aa7b87827 Mon Sep 17 00:00:00 2001
-From: Samuel Martin <s.martin49@gmail.com>
-Date: Sat, 24 Jan 2015 19:44:50 +0100
-Subject: [PATCH] makefiles/cmake/vmcs.cmake: allow to override
- VMCS_INSTALL_PREFIX
-
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
----
- makefiles/cmake/vmcs.cmake | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/makefiles/cmake/vmcs.cmake b/makefiles/cmake/vmcs.cmake
-index 0f8641b..cc70cca 100644
---- a/makefiles/cmake/vmcs.cmake
-+++ b/makefiles/cmake/vmcs.cmake
-@@ -9,7 +9,7 @@ INCLUDE(CPack)
- # Where shall we install?
- if (ANDROID)
-   SET(VMCS_INSTALL_PREFIX "/vendor/brcm/islands" CACHE PATH "Prefix prepended to install directories" FORCE)
--else()
-+elseif(NOT DEFINED VMCS_INSTALL_PREFIX)
-   SET(VMCS_INSTALL_PREFIX "/opt/vc" CACHE PATH "Prefix prepended to install directories" FORCE)
- endif()
- 
--- 
-1.9.1
-
diff --git a/package/rpi-userland/0006-Fix-conflicting-type-qualifiers-errors-when-building.patch b/package/rpi-userland/0006-Fix-conflicting-type-qualifiers-errors-when-building.patch
deleted file mode 100644
index 4db6014..0000000
--- a/package/rpi-userland/0006-Fix-conflicting-type-qualifiers-errors-when-building.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-Fix conflicting type qualifiers errors when building with musl.
-
-Signed-off-by: Sergio Prado <sergio.prado@e-labworks.com>
----
- host_applications/linux/apps/raspicam/RaspiVidYUV.c | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/host_applications/linux/apps/raspicam/RaspiVidYUV.c b/host_applications/linux/apps/raspicam/RaspiVidYUV.c
-index b340d63c913f..13e6a6ccf5bf 100644
---- a/host_applications/linux/apps/raspicam/RaspiVidYUV.c
-+++ b/host_applications/linux/apps/raspicam/RaspiVidYUV.c
-@@ -106,8 +106,6 @@ const int ABORT_INTERVAL = 100; // ms
- /// Run/record forever
- #define WAIT_METHOD_FOREVER        4
- 
--extern FILE *stderr, *stdout;
--
- int mmal_status_to_int(MMAL_STATUS_T status);
- static void signal_handler(int signal_number);
- 
--- 
-1.9.1
-
diff --git a/package/rpi-userland/rpi-userland.mk b/package/rpi-userland/rpi-userland.mk
index fbf6fb4..ab2cb61 100644
--- a/package/rpi-userland/rpi-userland.mk
+++ b/package/rpi-userland/rpi-userland.mk
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-RPI_USERLAND_VERSION = 8306b7c757f4b8e8d9148789eeb64c666d9244a5
+RPI_USERLAND_VERSION = 770f2bd9cc4ae57a682e7b0635bc1214aa082bbe
 RPI_USERLAND_SITE = $(call github,raspberrypi,userland,$(RPI_USERLAND_VERSION))
 RPI_USERLAND_LICENSE = BSD-3c
 RPI_USERLAND_LICENSE_FILES = LICENCE
-- 
2.5.0

