Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] Add rockpro64 packages
@ 2021-10-09 14:53 tiemenwerkman
  2021-10-09 18:13 ` [PR REVIEW] " CameronNemo
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-09 14:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

There is a new pull request by tiemenwerkman against master on the void-packages repository

https://github.com/tiemenwerkman/void-packages master
https://github.com/void-linux/void-packages/pull/33444

Add rockpro64 packages
#### General
- [X] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [X] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] I built this PR locally for my native architecture, (ARCH-LIBC)
- [X] I built this PR locally for these architectures (if supported. mark crossbuilds): crossbuilds on amd64
  - [ ] aarch64-musl
  - [ ] armv7l
  - [ ] armv6l-musl


A patch file from https://github.com/void-linux/void-packages/pull/33444.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-33444.patch --]
[-- Type: text/x-diff, Size: 16234 bytes --]

From 575d9b102387e2ccba6271a5325f9c00fe66c1ef Mon Sep 17 00:00:00 2001
From: Tiemen Werkman <tiemen@void-tiemen.opifexonline.com>
Date: Sat, 9 Oct 2021 10:35:37 +0200
Subject: [PATCH] RockPro64 platform packages for Void Linux.

Committer: Tiemen Werkman <tiemen@opifexonline.com>
---
 srcpkgs/rockpro64-base/INSTALL                |   8 ++
 srcpkgs/rockpro64-base/template               |  11 ++
 .../patches/phy-rockchip-inno-usb2.c.patch    |  75 ++++++++++++
 .../rockpro64-uboot/patches/rk3399.c.patch    |  51 +++++++++
 .../patches/rockpro64-rk3399.c.patch          |  48 ++++++++
 .../patches/rockpro64-rk3399.h.patch          |  33 ++++++
 .../patches/rockpro64-rk3399_defconfig.patch  | 108 ++++++++++++++++++
 srcpkgs/rockpro64-uboot/template              |  47 ++++++++
 srcpkgs/rockpro64-uboot/update                |   1 +
 9 files changed, 382 insertions(+)
 create mode 100644 srcpkgs/rockpro64-base/INSTALL
 create mode 100644 srcpkgs/rockpro64-base/template
 create mode 100644 srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
 create mode 100644 srcpkgs/rockpro64-uboot/template
 create mode 100644 srcpkgs/rockpro64-uboot/update

diff --git a/srcpkgs/rockpro64-base/INSTALL b/srcpkgs/rockpro64-base/INSTALL
new file mode 100644
index 000000000000..7e67f362c796
--- /dev/null
+++ b/srcpkgs/rockpro64-base/INSTALL
@@ -0,0 +1,8 @@
+if [ "${UPDATE}" = "no" ] && [ "${ACTION}" = "post" ]; then
+	mkdir -p etc/runit/runsvdir/default/
+	mkdir -p etc/sv/agetty-ttyS2/
+	ln -sf /etc/sv/sshd etc/runit/runsvdir/default/
+	ln -sf /etc/sv/dhcpcd etc/runit/runsvdir/default/
+	ln -sf /etc/sv/agetty-ttyS2 etc/runit/runsvdir/default/
+	cd etc/sv/agetty-ttyS2/ && ln -sf ../agetty-serial/conf conf && ln -sf ../agetty-generic/finish finish && ln -sf ../agetty-serial/run run && ln -sf /run/runit/supervise.agetty-ttyS2
+fi
diff --git a/srcpkgs/rockpro64-base/template b/srcpkgs/rockpro64-base/template
new file mode 100644
index 000000000000..e90db4f4396d
--- /dev/null
+++ b/srcpkgs/rockpro64-base/template
@@ -0,0 +1,11 @@
+# Template file for 'rockpro64-base'
+pkgname=rockpro64-base
+version=1
+revision=1
+archs="aarch64*"
+build_style=meta
+depends="rockpro64-uboot u-boot-menu dracut"
+short_desc="Void Linux RockPro64 platform package"
+maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
+license="Public Domain"
+homepage="https://www.voidlinux.org"
diff --git a/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
new file mode 100644
index 000000000000..1f9839889f0d
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
@@ -0,0 +1,75 @@
+    Fix USB on RockPro64:
+    Without this patch uboot crashes when resetting usb, preventing the kernel
+    from loading.
+    The only alternative to this patch is to disable Preboot or OHCI which 
+    also leaves you with no console keyboard.
+
+    https://patchwork.ozlabs.org/project/uboot/patch/20210406151059.1187379-1-icenowy@aosc.io/
+
+diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+index 62b8ba3a4a..be9cc99d90 100644
+--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
++++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+@@ -62,6 +62,8 @@ struct rockchip_usb2phy {
+ 	void *reg_base;
+ 	struct clk phyclk;
+ 	const struct rockchip_usb2phy_cfg *phy_cfg;
++	int init_count;
++	int power_on_count;
+ };
+ 
+ static inline int property_enable(void *reg_base,
+@@ -92,6 +94,10 @@ static int rockchip_usb2phy_power_on(struct phy *phy)
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 
++	priv->power_on_count++;
++	if (priv->power_on_count != 1)
++		return 0;
++
+ 	property_enable(priv->reg_base, &port_cfg->phy_sus, false);
+ 
+ 	/* waiting for the utmi_clk to become stable */
+@@ -106,6 +112,10 @@ static int rockchip_usb2phy_power_off(struct phy *phy)
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 
++	priv->power_on_count--;
++	if (priv->power_on_count != 0)
++		return 0;
++
+ 	property_enable(priv->reg_base, &port_cfg->phy_sus, true);
+ 
+ 	return 0;
+@@ -118,6 +128,10 @@ static int rockchip_usb2phy_init(struct phy *phy)
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 	int ret;
+ 
++	priv->init_count++;
++	if (priv->init_count != 1)
++		return 0;
++
+ 	ret = clk_enable(&priv->phyclk);
+ 	if (ret) {
+ 		dev_err(phy->dev, "failed to enable phyclk (ret=%d)\n", ret);
+@@ -140,6 +154,10 @@ static int rockchip_usb2phy_exit(struct phy *phy)
+ 	struct udevice *parent = dev_get_parent(phy->dev);
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 
++	priv->init_count--;
++	if (priv->init_count != 0)
++		return 0;
++
+ 	clk_disable(&priv->phyclk);
+ 
+ 	return 0;
+@@ -212,6 +230,9 @@ static int rockchip_usb2phy_probe(struct udevice *dev)
+ 		return ret;
+ 	}
+ 
++	priv->power_on_count = 0;
++	priv->init_count = 0;
++
+ 	return 0;
+ }
+ 
diff --git a/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
new file mode 100644
index 000000000000..f3c08bf33c61
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
@@ -0,0 +1,51 @@
+From 1a01021c9361c4e017cb5b032300f5555c393710 Mon Sep 17 00:00:00 2001
+From: dhivael <dhivael.git@eno.space>
+Date: Sat, 11 Jan 2020 15:04:46 +0100
+Subject: rk3399: light pinebook power and standby leds during early boot
+
+this is a hack, but it works for now.
+---
+ arch/arm/mach-rockchip/rk3399/rk3399.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
+index 863024d071..cf37129d55 100644
+--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
++++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
+@@ -15,6 +15,8 @@
+ #include <asm/arch-rockchip/grf_rk3399.h>
+ #include <asm/arch-rockchip/hardware.h>
+ #include <power/regulator.h>
++#include <dt-bindings/gpio/gpio.h>
++#include <dt-bindings/pinctrl/rockchip.h>
+ 
+ DECLARE_GLOBAL_DATA_PTR;
+ 
+@@ -115,8 +117,8 @@ void board_debug_uart_init(void)
+ 	struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
+ #ifdef CONFIG_TARGET_CHROMEBOOK_BOB
+ 	struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
+-	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
+ #endif
++	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
+ 
+ #if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff180000)
+ 	/* Enable early UART0 on the RK3399 */
+@@ -149,6 +151,14 @@ void board_debug_uart_init(void)
+ 	spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_B, 4), GPIO_PULL_NORMAL);
+ #endif /* CONFIG_TARGET_CHROMEBOOK_BOB */
+ 
++	{
++		// set GPIO0_A2/B3 to GPIO_ACTIVE_HIGH
++		// set GPIO0_A2/B3 to OUTPUT
++		int mask = (1UL << RK_PA2) | (1UL << RK_PB3);
++		setbits_le32(&gpio->swport_dr, mask);
++		setbits_le32(&gpio->swport_ddr, mask);
++	}
++
+ 	/* Enable early UART2 channel C on the RK3399 */
+ 	rk_clrsetreg(&grf->gpio4c_iomux,
+ 		     GRF_GPIO4C3_SEL_MASK,
+-- 
+cgit v1.2.3
+
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
new file mode 100644
index 000000000000..5fb9b65c8ef2
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
@@ -0,0 +1,48 @@
+diff --git a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
+index d79084614f..6f7f661154 100644
+--- a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
++++ b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
+@@ -5,6 +5,9 @@
+ 
+ #include <common.h>
+ #include <dm.h>
++#include <fdt_support.h>
++#include <jffs2/load_kernel.h>
++#include <mtd_node.h>
+ #include <init.h>
+ #include <syscon.h>
+ #include <asm/io.h>
+@@ -16,6 +19,33 @@
+ #define GRF_IO_VSEL_BT565_SHIFT 0
+ #define PMUGRF_CON0_VSEL_SHIFT 8
+ 
++#ifdef CONFIG_OF_BOARD_SETUP
++int ft_board_setup(void *blob, struct bd_info *bd)
++{
++#ifdef CONFIG_FDT_FIXUP_PARTITIONS
++	int ret, noff;
++	static const struct node_info nodes[] = {
++		{ "jedec,spi-nor", MTD_DEV_TYPE_NOR, },
++	};
++
++	noff = fdt_node_offset_by_compatible(blob, -1, nodes[0].compat);
++	if (noff != -FDT_ERR_NOTFOUND) {
++		ret = fdt_setprop_u32(blob, noff, "#size-cells", 1);
++		if (ret)
++			return ret;
++		ret = fdt_setprop_u32(blob, noff, "#address-cells", 1);
++		if (ret)
++			return ret;
++	} else {
++		return -ENODEV;
++	}
++
++	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
++#endif
++	return 0;
++}
++#endif
++
+ #ifdef CONFIG_MISC_INIT_R
+ static void setup_iodomain(void)
+ {
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
new file mode 100644
index 000000000000..d784a696e852
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
@@ -0,0 +1,33 @@
+    rockchip: Pinebook Pro: fix mmc boot ordering
+    
+    On the Pinebook Pro, and perhaps some other boards, the mmc indices are
+    opposite from what is implied by the comment in
+    include/configs/rockchip-common.h.
+    
+    This commit fixes the boot ordering to prioritize the SD card over eMMC.
+    
+    Most distributions of U-Boot that actually target rk3399 boards apply a
+    similar patch, such as Manjaro (shipped by default on PBP) and armbian.
+    
+    https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-pinebookpro/-/blob/60ed56b9bf8809309ec6252bfc45bca38c2b858a/0002-Correct-boot-order-to-be-USB-SD-eMMC.patch
+    https://github.com/armbian/build/blob/5a2b2c360b9c26ca4bd0d309af7cd3994fd08b7d/patch/u-boot/u-boot-rockchip64-mainline/general-prioritize-sd.patch
+    
+diff --git a/include/configs/rockpro64_rk3399.h b/include/configs/rockpro64_rk3399.h
+index 903e9df527..7c8f30dbaf 100644
+--- a/include/configs/rockpro64_rk3399.h
++++ b/include/configs/rockpro64_rk3399.h
+@@ -12,6 +12,14 @@
+ 	"stderr=serial,vidconsole\0"
+ 
+ #include <configs/rk3399_common.h>
++ 
++/* On RockPro64, mmc1 is SD and mmc0 is eMMC */
++#if CONFIG_IS_ENABLED(CMD_MMC)
++	#undef BOOT_TARGET_MMC
++	#define BOOT_TARGET_MMC(func) \
++		func(MMC, mmc, 1) \
++		func(MMC, mmc, 0)
++#endif
+ 
+ #define SDRAM_BANK_SIZE			(2UL << 30)
+ 
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
new file mode 100644
index 000000000000..af207a228085
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
@@ -0,0 +1,108 @@
+
+Autoboot
+	Disable bootdelay. Boot can be interrupted by pressing either <q> or
+	<ctrl-c>.
+
+Baudrate
+	Set baudrate to 115200 to prevent garbled output and improve
+	compatibility. The default baud rate is 1500000 bps. This produces
+	garbled output on many serial adapters and is a non-standard speed.
+
+Supported features
+	The following features have been enabled and are supported:
+	- NVME support.
+	- AHCI over PCIE.
+	- USB3 and keyboard support.
+	- fdt overlay.
+	- MDT partitions.
+	- BTRFS support enabled.
+
+diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig
+index ae11a8f5eb..827d37eb72 100644
+--- a/configs/rockpro64-rk3399_defconfig
++++ b/configs/rockpro64-rk3399_defconfig
+@@ -4,14 +4,17 @@ CONFIG_SYS_TEXT_BASE=0x00200000
+ CONFIG_NR_DRAM_BANKS=1
+ CONFIG_ENV_SIZE=0x8000
+ CONFIG_ENV_OFFSET=0x3F8000
+-CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
+ CONFIG_ROCKCHIP_RK3399=y
+ CONFIG_TARGET_ROCKPRO64_RK3399=y
+ CONFIG_DEBUG_UART_BASE=0xFF1A0000
+ CONFIG_DEBUG_UART_CLOCK=24000000
+ CONFIG_SPL_SPI_FLASH_SUPPORT=y
+ CONFIG_SPL_SPI_SUPPORT=y
++CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
+ CONFIG_DEBUG_UART=y
++CONFIG_AHCI=y
++CONFIG_OF_BOARD_SETUP=y
++CONFIG_BOOTDELAY=0
+ CONFIG_USE_PREBOOT=y
+ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
+ CONFIG_DISPLAY_BOARDINFO_LATE=y
+@@ -20,29 +23,40 @@ CONFIG_MISC_INIT_R=y
+ CONFIG_SPL_STACK_R=y
+ CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
+ CONFIG_SPL_SPI_LOAD=y
++# CONFIG_SPL_ATF_NO_PLATFORM_PARAM is not set
+ CONFIG_TPL=y
+ CONFIG_CMD_BOOTZ=y
++CONFIG_CMD_BOOTMENU=y
+ CONFIG_CMD_GPT=y
+ CONFIG_CMD_MMC=y
+ CONFIG_CMD_PCI=y
+ CONFIG_CMD_USB=y
+-# CONFIG_CMD_SETEXPR is not set
+ CONFIG_CMD_TIME=y
++CONFIG_CMD_MTDPARTS=y
++CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
++CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:384k(u-boot-spl),3680k(u-boot),32k(u-boot-env),-(user)"
+ CONFIG_SPL_OF_CONTROL=y
+ CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
+ CONFIG_ENV_IS_IN_SPI_FLASH=y
+ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+ CONFIG_SPL_DM_SEQ_ALIAS=y
++CONFIG_SCSI_AHCI=y
++CONFIG_AHCI_PCI=y
+ CONFIG_ROCKCHIP_GPIO=y
+ CONFIG_SYS_I2C_ROCKCHIP=y
++CONFIG_DM_KEYBOARD=y
++CONFIG_LED=y
++CONFIG_LED_GPIO=y
+ CONFIG_MISC=y
+ CONFIG_ROCKCHIP_EFUSE=y
+ CONFIG_MMC_DW=y
+ CONFIG_MMC_DW_ROCKCHIP=y
+ CONFIG_MMC_SDHCI=y
+ CONFIG_MMC_SDHCI_ROCKCHIP=y
++CONFIG_MTD=y
+ CONFIG_SF_DEFAULT_BUS=1
+ CONFIG_SPI_FLASH_GIGADEVICE=y
++CONFIG_SPI_FLASH_MTD=y
+ CONFIG_DM_ETH=y
+ CONFIG_ETH_DESIGNWARE=y
+ CONFIG_GMAC_ROCKCHIP=y
+@@ -58,7 +72,9 @@ CONFIG_RAM_RK3399_LPDDR4=y
+ CONFIG_DM_RESET=y
+ CONFIG_DM_RNG=y
+ CONFIG_RNG_ROCKCHIP=y
+-CONFIG_BAUDRATE=1500000
++CONFIG_SCSI=y
++CONFIG_DM_SCSI=y
++CONFIG_BAUDRATE=115200
+ CONFIG_DEBUG_UART_SHIFT=2
+ CONFIG_ROCKCHIP_SPI=y
+ CONFIG_SYSRESET=y
+@@ -82,5 +98,12 @@ CONFIG_DM_VIDEO=y
+ CONFIG_DISPLAY=y
+ CONFIG_VIDEO_ROCKCHIP=y
+ CONFIG_DISPLAY_ROCKCHIP_HDMI=y
++CONFIG_FS_BTRFS=y
+ CONFIG_SPL_TINY_MEMSET=y
+ CONFIG_ERRNO_STR=y
++CONFIG_OF_LIBFDT_OVERLAY=y
++CONFIG_FDT_FIXUP_PARTITIONS=y
++CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds... press q or Ctrl-C to interrupt\n"
++CONFIG_AUTOBOOT_KEYED=y
++CONFIG_AUTOBOOT_STOP_STR="q"
++CONFIG_AUTOBOOT_KEYED_CTRLC=y
diff --git a/srcpkgs/rockpro64-uboot/template b/srcpkgs/rockpro64-uboot/template
new file mode 100644
index 000000000000..10daa7174b83
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/template
@@ -0,0 +1,47 @@
+# Template file for 'rockpro64-uboot'
+pkgname=rockpro64-uboot
+version=2021.07
+revision=1
+archs="aarch64*"
+wrksrc="u-boot-${version}"
+hostmakedepends="flex bc dtc python3"
+makedepends="atf-rk3399-bl31"
+depends="u-boot-tools"
+short_desc="Das U-Boot for the RockPro64 SBC"
+maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
+license="GPL-2.0-or-later, BSD-3-Clause"
+homepage="https://www.denx.de/wiki/U-Boot/"
+distfiles="https://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"
+checksum=312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e
+
+do_configure() {
+	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+	make ${makejobs} rockpro64-rk3399_defconfig
+}
+
+do_build() {
+	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+	if [ "$CROSS_BUILD" ]; then
+		export CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
+	fi
+	make ${makejobs} EXTRAVERSION=-${revision} \
+		BL31=${XBPS_CROSS_BASE}/usr/lib/trusted-firmware-a/rk3399/bl31.elf
+}
+
+do_install() {
+	vinstall idbloader.img 0644 usr/lib/rockpro64-uboot
+	vinstall u-boot.itb 0644 usr/lib/rockpro64-uboot
+	vlicense Licenses/Exceptions
+	vlicense Licenses/OFL.txt
+	vlicense Licenses/README
+	vlicense Licenses/bsd-2-clause.txt
+	vlicense Licenses/bsd-3-clause.txt
+	vlicense Licenses/eCos-2.0.txt
+	vlicense Licenses/gpl-2.0.txt
+	vlicense Licenses/ibm-pibs.txt
+	vlicense Licenses/isc.txt
+	vlicense Licenses/lgpl-2.0.txt
+	vlicense Licenses/lgpl-2.1.txt
+	vlicense Licenses/r8a779x_usb3.txt
+	vlicense Licenses/x11.txt
+}
diff --git a/srcpkgs/rockpro64-uboot/update b/srcpkgs/rockpro64-uboot/update
new file mode 100644
index 000000000000..cfcfccd3fb43
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/update
@@ -0,0 +1 @@
+pkgname="u-boot"

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
@ 2021-10-09 18:13 ` CameronNemo
  2021-10-09 18:14 ` CameronNemo
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: CameronNemo @ 2021-10-09 18:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725519174

Comment:
what does this do, where does it come from?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
  2021-10-09 18:13 ` [PR REVIEW] " CameronNemo
@ 2021-10-09 18:14 ` CameronNemo
  2021-10-09 18:17 ` CameronNemo
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: CameronNemo @ 2021-10-09 18:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725519256

Comment:
you sure we need this patch? there are no LEDs on the RP64 AFAIK.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
  2021-10-09 18:13 ` [PR REVIEW] " CameronNemo
  2021-10-09 18:14 ` CameronNemo
@ 2021-10-09 18:17 ` CameronNemo
  2021-10-09 18:18 ` CameronNemo
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: CameronNemo @ 2021-10-09 18:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725519646

Comment:
hmm what kernel are you using? the rock64 can use the vanilla Void kernel, but the PBP needs a custom kernel (for a few patches and for some Kconfig settings). Have you tested the vanilla kernel? I can try to help get it working if you need (although you may be able to just look at the Kconfig for the PBP kernel and compare to the vanilla void kernel config). Feel free to ping me in #xbps if you need.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (2 preceding siblings ...)
  2021-10-09 18:17 ` CameronNemo
@ 2021-10-09 18:18 ` CameronNemo
  2021-10-09 18:20 ` [PR REVIEW] " CameronNemo
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: CameronNemo @ 2021-10-09 18:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

New comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#issuecomment-939340160

Comment:
You need two commits with the following messages:

* New package: rockpro64-uboot
* New package: rockpro64-base

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (3 preceding siblings ...)
  2021-10-09 18:18 ` CameronNemo
@ 2021-10-09 18:20 ` CameronNemo
  2021-10-09 18:49 ` tiemenwerkman
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: CameronNemo @ 2021-10-09 18:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 221 bytes --]

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725519837

Comment:
2021.10 is out now, right? might want to use that version if it works.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (4 preceding siblings ...)
  2021-10-09 18:20 ` [PR REVIEW] " CameronNemo
@ 2021-10-09 18:49 ` tiemenwerkman
  2021-10-09 18:52 ` tiemenwerkman
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-09 18:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

New review comment by tiemenwerkman on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725522918

Comment:
I've tested mostly with kernel 5.10, but every now and then it wil crash during boot (about 1 in 10 boots), and still produces some errors at loglevel 4. Kernel versions 5.13 and 5.14 also boot just fine and produce fewer errors, specifically the panfrost and usb phy errors are gone. I tested mostly with 5.10 because it's an LTS kernel version and the only one I could build the zfs dkms module for.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (5 preceding siblings ...)
  2021-10-09 18:49 ` tiemenwerkman
@ 2021-10-09 18:52 ` tiemenwerkman
  2021-10-09 19:03 ` tiemenwerkman
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-09 18:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

New review comment by tiemenwerkman on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725523323

Comment:
The RP64 has several leds, amoung which two related to power, a white and a red one. This patch enables them immediatlly at poweron, otherwise you have to wait until the os has fully loaded before the white led lights up. It's annoying without this patch because you have no way of seeing if a crash occurred or if it even booted.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (6 preceding siblings ...)
  2021-10-09 18:52 ` tiemenwerkman
@ 2021-10-09 19:03 ` tiemenwerkman
  2021-10-09 19:05 ` tiemenwerkman
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-09 19:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

New review comment by tiemenwerkman on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725524439

Comment:
My apologies, I seem to have forgotten to annotate  this patch, It comes from [Sigmaris fork of U-Boot](https://github.com/sigmaris/u-boot/) and is required to update SPI flash partitions in the devicetree. Granted I have no idea what that means but it sounds important.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR REVIEW] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (7 preceding siblings ...)
  2021-10-09 19:03 ` tiemenwerkman
@ 2021-10-09 19:05 ` tiemenwerkman
  2021-10-10  7:53 ` [PR PATCH] [Updated] " tiemenwerkman
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-09 19:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

New review comment by tiemenwerkman on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#discussion_r725524621

Comment:
I had noticed, and I've even tested it. It seems to run fine, but I opted to leave it for now.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR PATCH] [Updated] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (8 preceding siblings ...)
  2021-10-09 19:05 ` tiemenwerkman
@ 2021-10-10  7:53 ` tiemenwerkman
  2021-10-10  8:07 ` tiemenwerkman
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-10  7:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]

There is an updated pull request by tiemenwerkman against master on the void-packages repository

https://github.com/tiemenwerkman/void-packages master
https://github.com/void-linux/void-packages/pull/33444

Add rockpro64 packages
#### General
- [X] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [X] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] I built this PR locally for my native architecture, (ARCH-LIBC)
- [X] I built this PR locally for these architectures (if supported. mark crossbuilds): crossbuilds on amd64
  - [ ] aarch64-musl
  - [ ] armv7l
  - [ ] armv6l-musl

This is my first pull request so I imagine there are probably a few things off with it.
I only started using git this week, I'm learning as I go.
I started putting these two packages together two weeks ago, I've tested mostly with emmc and sd cards and some usb thumb drives. I don't yet have pcie sata or nvme card to test.
I've also tested the usb-keyboard and HDMI output, the keyboard is fine and the HDMI output is mostly fine. HDMI immediately comes up but does not return by itself when loading the kernel (any version). It returns though when either the cable is reseated or the monitor is turned off and on again.
The nic works fine and so do the usb ports.
I opted not to create a kernel specific package as I think this makes it easier to update to newer versions, moreover it does not seem to be necessary. The only thing I ran into is that on versions 5.13 and 5.14 I am unable to build the zfs dkms module (no, I did not forget the headers).
Any feedback from testers would be welcome!   

A patch file from https://github.com/void-linux/void-packages/pull/33444.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-33444.patch --]
[-- Type: text/x-diff, Size: 16234 bytes --]

From 575d9b102387e2ccba6271a5325f9c00fe66c1ef Mon Sep 17 00:00:00 2001
From: Tiemen Werkman <tiemen@void-tiemen.opifexonline.com>
Date: Sat, 9 Oct 2021 10:35:37 +0200
Subject: [PATCH] RockPro64 platform packages for Void Linux.

Committer: Tiemen Werkman <tiemen@opifexonline.com>
---
 srcpkgs/rockpro64-base/INSTALL                |   8 ++
 srcpkgs/rockpro64-base/template               |  11 ++
 .../patches/phy-rockchip-inno-usb2.c.patch    |  75 ++++++++++++
 .../rockpro64-uboot/patches/rk3399.c.patch    |  51 +++++++++
 .../patches/rockpro64-rk3399.c.patch          |  48 ++++++++
 .../patches/rockpro64-rk3399.h.patch          |  33 ++++++
 .../patches/rockpro64-rk3399_defconfig.patch  | 108 ++++++++++++++++++
 srcpkgs/rockpro64-uboot/template              |  47 ++++++++
 srcpkgs/rockpro64-uboot/update                |   1 +
 9 files changed, 382 insertions(+)
 create mode 100644 srcpkgs/rockpro64-base/INSTALL
 create mode 100644 srcpkgs/rockpro64-base/template
 create mode 100644 srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
 create mode 100644 srcpkgs/rockpro64-uboot/template
 create mode 100644 srcpkgs/rockpro64-uboot/update

diff --git a/srcpkgs/rockpro64-base/INSTALL b/srcpkgs/rockpro64-base/INSTALL
new file mode 100644
index 000000000000..7e67f362c796
--- /dev/null
+++ b/srcpkgs/rockpro64-base/INSTALL
@@ -0,0 +1,8 @@
+if [ "${UPDATE}" = "no" ] && [ "${ACTION}" = "post" ]; then
+	mkdir -p etc/runit/runsvdir/default/
+	mkdir -p etc/sv/agetty-ttyS2/
+	ln -sf /etc/sv/sshd etc/runit/runsvdir/default/
+	ln -sf /etc/sv/dhcpcd etc/runit/runsvdir/default/
+	ln -sf /etc/sv/agetty-ttyS2 etc/runit/runsvdir/default/
+	cd etc/sv/agetty-ttyS2/ && ln -sf ../agetty-serial/conf conf && ln -sf ../agetty-generic/finish finish && ln -sf ../agetty-serial/run run && ln -sf /run/runit/supervise.agetty-ttyS2
+fi
diff --git a/srcpkgs/rockpro64-base/template b/srcpkgs/rockpro64-base/template
new file mode 100644
index 000000000000..e90db4f4396d
--- /dev/null
+++ b/srcpkgs/rockpro64-base/template
@@ -0,0 +1,11 @@
+# Template file for 'rockpro64-base'
+pkgname=rockpro64-base
+version=1
+revision=1
+archs="aarch64*"
+build_style=meta
+depends="rockpro64-uboot u-boot-menu dracut"
+short_desc="Void Linux RockPro64 platform package"
+maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
+license="Public Domain"
+homepage="https://www.voidlinux.org"
diff --git a/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
new file mode 100644
index 000000000000..1f9839889f0d
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
@@ -0,0 +1,75 @@
+    Fix USB on RockPro64:
+    Without this patch uboot crashes when resetting usb, preventing the kernel
+    from loading.
+    The only alternative to this patch is to disable Preboot or OHCI which 
+    also leaves you with no console keyboard.
+
+    https://patchwork.ozlabs.org/project/uboot/patch/20210406151059.1187379-1-icenowy@aosc.io/
+
+diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+index 62b8ba3a4a..be9cc99d90 100644
+--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
++++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+@@ -62,6 +62,8 @@ struct rockchip_usb2phy {
+ 	void *reg_base;
+ 	struct clk phyclk;
+ 	const struct rockchip_usb2phy_cfg *phy_cfg;
++	int init_count;
++	int power_on_count;
+ };
+ 
+ static inline int property_enable(void *reg_base,
+@@ -92,6 +94,10 @@ static int rockchip_usb2phy_power_on(struct phy *phy)
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 
++	priv->power_on_count++;
++	if (priv->power_on_count != 1)
++		return 0;
++
+ 	property_enable(priv->reg_base, &port_cfg->phy_sus, false);
+ 
+ 	/* waiting for the utmi_clk to become stable */
+@@ -106,6 +112,10 @@ static int rockchip_usb2phy_power_off(struct phy *phy)
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 
++	priv->power_on_count--;
++	if (priv->power_on_count != 0)
++		return 0;
++
+ 	property_enable(priv->reg_base, &port_cfg->phy_sus, true);
+ 
+ 	return 0;
+@@ -118,6 +128,10 @@ static int rockchip_usb2phy_init(struct phy *phy)
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 	int ret;
+ 
++	priv->init_count++;
++	if (priv->init_count != 1)
++		return 0;
++
+ 	ret = clk_enable(&priv->phyclk);
+ 	if (ret) {
+ 		dev_err(phy->dev, "failed to enable phyclk (ret=%d)\n", ret);
+@@ -140,6 +154,10 @@ static int rockchip_usb2phy_exit(struct phy *phy)
+ 	struct udevice *parent = dev_get_parent(phy->dev);
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 
++	priv->init_count--;
++	if (priv->init_count != 0)
++		return 0;
++
+ 	clk_disable(&priv->phyclk);
+ 
+ 	return 0;
+@@ -212,6 +230,9 @@ static int rockchip_usb2phy_probe(struct udevice *dev)
+ 		return ret;
+ 	}
+ 
++	priv->power_on_count = 0;
++	priv->init_count = 0;
++
+ 	return 0;
+ }
+ 
diff --git a/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
new file mode 100644
index 000000000000..f3c08bf33c61
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
@@ -0,0 +1,51 @@
+From 1a01021c9361c4e017cb5b032300f5555c393710 Mon Sep 17 00:00:00 2001
+From: dhivael <dhivael.git@eno.space>
+Date: Sat, 11 Jan 2020 15:04:46 +0100
+Subject: rk3399: light pinebook power and standby leds during early boot
+
+this is a hack, but it works for now.
+---
+ arch/arm/mach-rockchip/rk3399/rk3399.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
+index 863024d071..cf37129d55 100644
+--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
++++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
+@@ -15,6 +15,8 @@
+ #include <asm/arch-rockchip/grf_rk3399.h>
+ #include <asm/arch-rockchip/hardware.h>
+ #include <power/regulator.h>
++#include <dt-bindings/gpio/gpio.h>
++#include <dt-bindings/pinctrl/rockchip.h>
+ 
+ DECLARE_GLOBAL_DATA_PTR;
+ 
+@@ -115,8 +117,8 @@ void board_debug_uart_init(void)
+ 	struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
+ #ifdef CONFIG_TARGET_CHROMEBOOK_BOB
+ 	struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
+-	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
+ #endif
++	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
+ 
+ #if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff180000)
+ 	/* Enable early UART0 on the RK3399 */
+@@ -149,6 +151,14 @@ void board_debug_uart_init(void)
+ 	spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_B, 4), GPIO_PULL_NORMAL);
+ #endif /* CONFIG_TARGET_CHROMEBOOK_BOB */
+ 
++	{
++		// set GPIO0_A2/B3 to GPIO_ACTIVE_HIGH
++		// set GPIO0_A2/B3 to OUTPUT
++		int mask = (1UL << RK_PA2) | (1UL << RK_PB3);
++		setbits_le32(&gpio->swport_dr, mask);
++		setbits_le32(&gpio->swport_ddr, mask);
++	}
++
+ 	/* Enable early UART2 channel C on the RK3399 */
+ 	rk_clrsetreg(&grf->gpio4c_iomux,
+ 		     GRF_GPIO4C3_SEL_MASK,
+-- 
+cgit v1.2.3
+
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
new file mode 100644
index 000000000000..5fb9b65c8ef2
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
@@ -0,0 +1,48 @@
+diff --git a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
+index d79084614f..6f7f661154 100644
+--- a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
++++ b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
+@@ -5,6 +5,9 @@
+ 
+ #include <common.h>
+ #include <dm.h>
++#include <fdt_support.h>
++#include <jffs2/load_kernel.h>
++#include <mtd_node.h>
+ #include <init.h>
+ #include <syscon.h>
+ #include <asm/io.h>
+@@ -16,6 +19,33 @@
+ #define GRF_IO_VSEL_BT565_SHIFT 0
+ #define PMUGRF_CON0_VSEL_SHIFT 8
+ 
++#ifdef CONFIG_OF_BOARD_SETUP
++int ft_board_setup(void *blob, struct bd_info *bd)
++{
++#ifdef CONFIG_FDT_FIXUP_PARTITIONS
++	int ret, noff;
++	static const struct node_info nodes[] = {
++		{ "jedec,spi-nor", MTD_DEV_TYPE_NOR, },
++	};
++
++	noff = fdt_node_offset_by_compatible(blob, -1, nodes[0].compat);
++	if (noff != -FDT_ERR_NOTFOUND) {
++		ret = fdt_setprop_u32(blob, noff, "#size-cells", 1);
++		if (ret)
++			return ret;
++		ret = fdt_setprop_u32(blob, noff, "#address-cells", 1);
++		if (ret)
++			return ret;
++	} else {
++		return -ENODEV;
++	}
++
++	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
++#endif
++	return 0;
++}
++#endif
++
+ #ifdef CONFIG_MISC_INIT_R
+ static void setup_iodomain(void)
+ {
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
new file mode 100644
index 000000000000..d784a696e852
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
@@ -0,0 +1,33 @@
+    rockchip: Pinebook Pro: fix mmc boot ordering
+    
+    On the Pinebook Pro, and perhaps some other boards, the mmc indices are
+    opposite from what is implied by the comment in
+    include/configs/rockchip-common.h.
+    
+    This commit fixes the boot ordering to prioritize the SD card over eMMC.
+    
+    Most distributions of U-Boot that actually target rk3399 boards apply a
+    similar patch, such as Manjaro (shipped by default on PBP) and armbian.
+    
+    https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-pinebookpro/-/blob/60ed56b9bf8809309ec6252bfc45bca38c2b858a/0002-Correct-boot-order-to-be-USB-SD-eMMC.patch
+    https://github.com/armbian/build/blob/5a2b2c360b9c26ca4bd0d309af7cd3994fd08b7d/patch/u-boot/u-boot-rockchip64-mainline/general-prioritize-sd.patch
+    
+diff --git a/include/configs/rockpro64_rk3399.h b/include/configs/rockpro64_rk3399.h
+index 903e9df527..7c8f30dbaf 100644
+--- a/include/configs/rockpro64_rk3399.h
++++ b/include/configs/rockpro64_rk3399.h
+@@ -12,6 +12,14 @@
+ 	"stderr=serial,vidconsole\0"
+ 
+ #include <configs/rk3399_common.h>
++ 
++/* On RockPro64, mmc1 is SD and mmc0 is eMMC */
++#if CONFIG_IS_ENABLED(CMD_MMC)
++	#undef BOOT_TARGET_MMC
++	#define BOOT_TARGET_MMC(func) \
++		func(MMC, mmc, 1) \
++		func(MMC, mmc, 0)
++#endif
+ 
+ #define SDRAM_BANK_SIZE			(2UL << 30)
+ 
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
new file mode 100644
index 000000000000..af207a228085
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
@@ -0,0 +1,108 @@
+
+Autoboot
+	Disable bootdelay. Boot can be interrupted by pressing either <q> or
+	<ctrl-c>.
+
+Baudrate
+	Set baudrate to 115200 to prevent garbled output and improve
+	compatibility. The default baud rate is 1500000 bps. This produces
+	garbled output on many serial adapters and is a non-standard speed.
+
+Supported features
+	The following features have been enabled and are supported:
+	- NVME support.
+	- AHCI over PCIE.
+	- USB3 and keyboard support.
+	- fdt overlay.
+	- MDT partitions.
+	- BTRFS support enabled.
+
+diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig
+index ae11a8f5eb..827d37eb72 100644
+--- a/configs/rockpro64-rk3399_defconfig
++++ b/configs/rockpro64-rk3399_defconfig
+@@ -4,14 +4,17 @@ CONFIG_SYS_TEXT_BASE=0x00200000
+ CONFIG_NR_DRAM_BANKS=1
+ CONFIG_ENV_SIZE=0x8000
+ CONFIG_ENV_OFFSET=0x3F8000
+-CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
+ CONFIG_ROCKCHIP_RK3399=y
+ CONFIG_TARGET_ROCKPRO64_RK3399=y
+ CONFIG_DEBUG_UART_BASE=0xFF1A0000
+ CONFIG_DEBUG_UART_CLOCK=24000000
+ CONFIG_SPL_SPI_FLASH_SUPPORT=y
+ CONFIG_SPL_SPI_SUPPORT=y
++CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
+ CONFIG_DEBUG_UART=y
++CONFIG_AHCI=y
++CONFIG_OF_BOARD_SETUP=y
++CONFIG_BOOTDELAY=0
+ CONFIG_USE_PREBOOT=y
+ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
+ CONFIG_DISPLAY_BOARDINFO_LATE=y
+@@ -20,29 +23,40 @@ CONFIG_MISC_INIT_R=y
+ CONFIG_SPL_STACK_R=y
+ CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
+ CONFIG_SPL_SPI_LOAD=y
++# CONFIG_SPL_ATF_NO_PLATFORM_PARAM is not set
+ CONFIG_TPL=y
+ CONFIG_CMD_BOOTZ=y
++CONFIG_CMD_BOOTMENU=y
+ CONFIG_CMD_GPT=y
+ CONFIG_CMD_MMC=y
+ CONFIG_CMD_PCI=y
+ CONFIG_CMD_USB=y
+-# CONFIG_CMD_SETEXPR is not set
+ CONFIG_CMD_TIME=y
++CONFIG_CMD_MTDPARTS=y
++CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
++CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:384k(u-boot-spl),3680k(u-boot),32k(u-boot-env),-(user)"
+ CONFIG_SPL_OF_CONTROL=y
+ CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
+ CONFIG_ENV_IS_IN_SPI_FLASH=y
+ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+ CONFIG_SPL_DM_SEQ_ALIAS=y
++CONFIG_SCSI_AHCI=y
++CONFIG_AHCI_PCI=y
+ CONFIG_ROCKCHIP_GPIO=y
+ CONFIG_SYS_I2C_ROCKCHIP=y
++CONFIG_DM_KEYBOARD=y
++CONFIG_LED=y
++CONFIG_LED_GPIO=y
+ CONFIG_MISC=y
+ CONFIG_ROCKCHIP_EFUSE=y
+ CONFIG_MMC_DW=y
+ CONFIG_MMC_DW_ROCKCHIP=y
+ CONFIG_MMC_SDHCI=y
+ CONFIG_MMC_SDHCI_ROCKCHIP=y
++CONFIG_MTD=y
+ CONFIG_SF_DEFAULT_BUS=1
+ CONFIG_SPI_FLASH_GIGADEVICE=y
++CONFIG_SPI_FLASH_MTD=y
+ CONFIG_DM_ETH=y
+ CONFIG_ETH_DESIGNWARE=y
+ CONFIG_GMAC_ROCKCHIP=y
+@@ -58,7 +72,9 @@ CONFIG_RAM_RK3399_LPDDR4=y
+ CONFIG_DM_RESET=y
+ CONFIG_DM_RNG=y
+ CONFIG_RNG_ROCKCHIP=y
+-CONFIG_BAUDRATE=1500000
++CONFIG_SCSI=y
++CONFIG_DM_SCSI=y
++CONFIG_BAUDRATE=115200
+ CONFIG_DEBUG_UART_SHIFT=2
+ CONFIG_ROCKCHIP_SPI=y
+ CONFIG_SYSRESET=y
+@@ -82,5 +98,12 @@ CONFIG_DM_VIDEO=y
+ CONFIG_DISPLAY=y
+ CONFIG_VIDEO_ROCKCHIP=y
+ CONFIG_DISPLAY_ROCKCHIP_HDMI=y
++CONFIG_FS_BTRFS=y
+ CONFIG_SPL_TINY_MEMSET=y
+ CONFIG_ERRNO_STR=y
++CONFIG_OF_LIBFDT_OVERLAY=y
++CONFIG_FDT_FIXUP_PARTITIONS=y
++CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds... press q or Ctrl-C to interrupt\n"
++CONFIG_AUTOBOOT_KEYED=y
++CONFIG_AUTOBOOT_STOP_STR="q"
++CONFIG_AUTOBOOT_KEYED_CTRLC=y
diff --git a/srcpkgs/rockpro64-uboot/template b/srcpkgs/rockpro64-uboot/template
new file mode 100644
index 000000000000..10daa7174b83
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/template
@@ -0,0 +1,47 @@
+# Template file for 'rockpro64-uboot'
+pkgname=rockpro64-uboot
+version=2021.07
+revision=1
+archs="aarch64*"
+wrksrc="u-boot-${version}"
+hostmakedepends="flex bc dtc python3"
+makedepends="atf-rk3399-bl31"
+depends="u-boot-tools"
+short_desc="Das U-Boot for the RockPro64 SBC"
+maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
+license="GPL-2.0-or-later, BSD-3-Clause"
+homepage="https://www.denx.de/wiki/U-Boot/"
+distfiles="https://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"
+checksum=312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e
+
+do_configure() {
+	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+	make ${makejobs} rockpro64-rk3399_defconfig
+}
+
+do_build() {
+	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+	if [ "$CROSS_BUILD" ]; then
+		export CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
+	fi
+	make ${makejobs} EXTRAVERSION=-${revision} \
+		BL31=${XBPS_CROSS_BASE}/usr/lib/trusted-firmware-a/rk3399/bl31.elf
+}
+
+do_install() {
+	vinstall idbloader.img 0644 usr/lib/rockpro64-uboot
+	vinstall u-boot.itb 0644 usr/lib/rockpro64-uboot
+	vlicense Licenses/Exceptions
+	vlicense Licenses/OFL.txt
+	vlicense Licenses/README
+	vlicense Licenses/bsd-2-clause.txt
+	vlicense Licenses/bsd-3-clause.txt
+	vlicense Licenses/eCos-2.0.txt
+	vlicense Licenses/gpl-2.0.txt
+	vlicense Licenses/ibm-pibs.txt
+	vlicense Licenses/isc.txt
+	vlicense Licenses/lgpl-2.0.txt
+	vlicense Licenses/lgpl-2.1.txt
+	vlicense Licenses/r8a779x_usb3.txt
+	vlicense Licenses/x11.txt
+}
diff --git a/srcpkgs/rockpro64-uboot/update b/srcpkgs/rockpro64-uboot/update
new file mode 100644
index 000000000000..cfcfccd3fb43
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/update
@@ -0,0 +1 @@
+pkgname="u-boot"

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR PATCH] [Updated] Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (9 preceding siblings ...)
  2021-10-10  7:53 ` [PR PATCH] [Updated] " tiemenwerkman
@ 2021-10-10  8:07 ` tiemenwerkman
  2021-10-10  8:08 ` [PR PATCH] [Closed]: " tiemenwerkman
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-10  8:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]

There is an updated pull request by tiemenwerkman against master on the void-packages repository

https://github.com/tiemenwerkman/void-packages master
https://github.com/void-linux/void-packages/pull/33444

Add rockpro64 packages
#### General
- [X] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [X] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] I built this PR locally for my native architecture, (ARCH-LIBC)
- [X] I built this PR locally for these architectures (if supported. mark crossbuilds): crossbuilds on amd64
  - [ ] aarch64-musl
  - [ ] armv7l
  - [ ] armv6l-musl

This is my first pull request so I imagine there are probably a few things off with it.
I only started using git this week, I'm learning as I go.
I started putting these two packages together two weeks ago, I've tested mostly with emmc and sd cards and some usb thumb drives. I don't yet have pcie sata or nvme card to test.
I've also tested the usb-keyboard and HDMI output, the keyboard is fine and the HDMI output is mostly fine. HDMI immediately comes up but does not return by itself when loading the kernel (any version). It returns though when either the cable is reseated or the monitor is turned off and on again.
The nic works fine and so do the usb ports.
I opted not to create a kernel specific package as I think this makes it easier to update to newer versions, moreover it does not seem to be necessary. The only thing I ran into is that on versions 5.13 and 5.14 I am unable to build the zfs dkms module (no, I did not forget the headers).
Any feedback from testers would be welcome!   

A patch file from https://github.com/void-linux/void-packages/pull/33444.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-33444.patch --]
[-- Type: text/x-diff, Size: 32503 bytes --]

From 575d9b102387e2ccba6271a5325f9c00fe66c1ef Mon Sep 17 00:00:00 2001
From: Tiemen Werkman <tiemen@void-tiemen.opifexonline.com>
Date: Sat, 9 Oct 2021 10:35:37 +0200
Subject: [PATCH 1/2] RockPro64 platform packages for Void Linux.

Committer: Tiemen Werkman <tiemen@opifexonline.com>
---
 srcpkgs/rockpro64-base/INSTALL                |   8 ++
 srcpkgs/rockpro64-base/template               |  11 ++
 .../patches/phy-rockchip-inno-usb2.c.patch    |  75 ++++++++++++
 .../rockpro64-uboot/patches/rk3399.c.patch    |  51 +++++++++
 .../patches/rockpro64-rk3399.c.patch          |  48 ++++++++
 .../patches/rockpro64-rk3399.h.patch          |  33 ++++++
 .../patches/rockpro64-rk3399_defconfig.patch  | 108 ++++++++++++++++++
 srcpkgs/rockpro64-uboot/template              |  47 ++++++++
 srcpkgs/rockpro64-uboot/update                |   1 +
 9 files changed, 382 insertions(+)
 create mode 100644 srcpkgs/rockpro64-base/INSTALL
 create mode 100644 srcpkgs/rockpro64-base/template
 create mode 100644 srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
 create mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
 create mode 100644 srcpkgs/rockpro64-uboot/template
 create mode 100644 srcpkgs/rockpro64-uboot/update

diff --git a/srcpkgs/rockpro64-base/INSTALL b/srcpkgs/rockpro64-base/INSTALL
new file mode 100644
index 000000000000..7e67f362c796
--- /dev/null
+++ b/srcpkgs/rockpro64-base/INSTALL
@@ -0,0 +1,8 @@
+if [ "${UPDATE}" = "no" ] && [ "${ACTION}" = "post" ]; then
+	mkdir -p etc/runit/runsvdir/default/
+	mkdir -p etc/sv/agetty-ttyS2/
+	ln -sf /etc/sv/sshd etc/runit/runsvdir/default/
+	ln -sf /etc/sv/dhcpcd etc/runit/runsvdir/default/
+	ln -sf /etc/sv/agetty-ttyS2 etc/runit/runsvdir/default/
+	cd etc/sv/agetty-ttyS2/ && ln -sf ../agetty-serial/conf conf && ln -sf ../agetty-generic/finish finish && ln -sf ../agetty-serial/run run && ln -sf /run/runit/supervise.agetty-ttyS2
+fi
diff --git a/srcpkgs/rockpro64-base/template b/srcpkgs/rockpro64-base/template
new file mode 100644
index 000000000000..e90db4f4396d
--- /dev/null
+++ b/srcpkgs/rockpro64-base/template
@@ -0,0 +1,11 @@
+# Template file for 'rockpro64-base'
+pkgname=rockpro64-base
+version=1
+revision=1
+archs="aarch64*"
+build_style=meta
+depends="rockpro64-uboot u-boot-menu dracut"
+short_desc="Void Linux RockPro64 platform package"
+maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
+license="Public Domain"
+homepage="https://www.voidlinux.org"
diff --git a/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
new file mode 100644
index 000000000000..1f9839889f0d
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
@@ -0,0 +1,75 @@
+    Fix USB on RockPro64:
+    Without this patch uboot crashes when resetting usb, preventing the kernel
+    from loading.
+    The only alternative to this patch is to disable Preboot or OHCI which 
+    also leaves you with no console keyboard.
+
+    https://patchwork.ozlabs.org/project/uboot/patch/20210406151059.1187379-1-icenowy@aosc.io/
+
+diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+index 62b8ba3a4a..be9cc99d90 100644
+--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
++++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+@@ -62,6 +62,8 @@ struct rockchip_usb2phy {
+ 	void *reg_base;
+ 	struct clk phyclk;
+ 	const struct rockchip_usb2phy_cfg *phy_cfg;
++	int init_count;
++	int power_on_count;
+ };
+ 
+ static inline int property_enable(void *reg_base,
+@@ -92,6 +94,10 @@ static int rockchip_usb2phy_power_on(struct phy *phy)
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 
++	priv->power_on_count++;
++	if (priv->power_on_count != 1)
++		return 0;
++
+ 	property_enable(priv->reg_base, &port_cfg->phy_sus, false);
+ 
+ 	/* waiting for the utmi_clk to become stable */
+@@ -106,6 +112,10 @@ static int rockchip_usb2phy_power_off(struct phy *phy)
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 
++	priv->power_on_count--;
++	if (priv->power_on_count != 0)
++		return 0;
++
+ 	property_enable(priv->reg_base, &port_cfg->phy_sus, true);
+ 
+ 	return 0;
+@@ -118,6 +128,10 @@ static int rockchip_usb2phy_init(struct phy *phy)
+ 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
+ 	int ret;
+ 
++	priv->init_count++;
++	if (priv->init_count != 1)
++		return 0;
++
+ 	ret = clk_enable(&priv->phyclk);
+ 	if (ret) {
+ 		dev_err(phy->dev, "failed to enable phyclk (ret=%d)\n", ret);
+@@ -140,6 +154,10 @@ static int rockchip_usb2phy_exit(struct phy *phy)
+ 	struct udevice *parent = dev_get_parent(phy->dev);
+ 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
+ 
++	priv->init_count--;
++	if (priv->init_count != 0)
++		return 0;
++
+ 	clk_disable(&priv->phyclk);
+ 
+ 	return 0;
+@@ -212,6 +230,9 @@ static int rockchip_usb2phy_probe(struct udevice *dev)
+ 		return ret;
+ 	}
+ 
++	priv->power_on_count = 0;
++	priv->init_count = 0;
++
+ 	return 0;
+ }
+ 
diff --git a/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
new file mode 100644
index 000000000000..f3c08bf33c61
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
@@ -0,0 +1,51 @@
+From 1a01021c9361c4e017cb5b032300f5555c393710 Mon Sep 17 00:00:00 2001
+From: dhivael <dhivael.git@eno.space>
+Date: Sat, 11 Jan 2020 15:04:46 +0100
+Subject: rk3399: light pinebook power and standby leds during early boot
+
+this is a hack, but it works for now.
+---
+ arch/arm/mach-rockchip/rk3399/rk3399.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
+index 863024d071..cf37129d55 100644
+--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
++++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
+@@ -15,6 +15,8 @@
+ #include <asm/arch-rockchip/grf_rk3399.h>
+ #include <asm/arch-rockchip/hardware.h>
+ #include <power/regulator.h>
++#include <dt-bindings/gpio/gpio.h>
++#include <dt-bindings/pinctrl/rockchip.h>
+ 
+ DECLARE_GLOBAL_DATA_PTR;
+ 
+@@ -115,8 +117,8 @@ void board_debug_uart_init(void)
+ 	struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
+ #ifdef CONFIG_TARGET_CHROMEBOOK_BOB
+ 	struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
+-	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
+ #endif
++	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
+ 
+ #if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff180000)
+ 	/* Enable early UART0 on the RK3399 */
+@@ -149,6 +151,14 @@ void board_debug_uart_init(void)
+ 	spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_B, 4), GPIO_PULL_NORMAL);
+ #endif /* CONFIG_TARGET_CHROMEBOOK_BOB */
+ 
++	{
++		// set GPIO0_A2/B3 to GPIO_ACTIVE_HIGH
++		// set GPIO0_A2/B3 to OUTPUT
++		int mask = (1UL << RK_PA2) | (1UL << RK_PB3);
++		setbits_le32(&gpio->swport_dr, mask);
++		setbits_le32(&gpio->swport_ddr, mask);
++	}
++
+ 	/* Enable early UART2 channel C on the RK3399 */
+ 	rk_clrsetreg(&grf->gpio4c_iomux,
+ 		     GRF_GPIO4C3_SEL_MASK,
+-- 
+cgit v1.2.3
+
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
new file mode 100644
index 000000000000..5fb9b65c8ef2
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
@@ -0,0 +1,48 @@
+diff --git a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
+index d79084614f..6f7f661154 100644
+--- a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
++++ b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
+@@ -5,6 +5,9 @@
+ 
+ #include <common.h>
+ #include <dm.h>
++#include <fdt_support.h>
++#include <jffs2/load_kernel.h>
++#include <mtd_node.h>
+ #include <init.h>
+ #include <syscon.h>
+ #include <asm/io.h>
+@@ -16,6 +19,33 @@
+ #define GRF_IO_VSEL_BT565_SHIFT 0
+ #define PMUGRF_CON0_VSEL_SHIFT 8
+ 
++#ifdef CONFIG_OF_BOARD_SETUP
++int ft_board_setup(void *blob, struct bd_info *bd)
++{
++#ifdef CONFIG_FDT_FIXUP_PARTITIONS
++	int ret, noff;
++	static const struct node_info nodes[] = {
++		{ "jedec,spi-nor", MTD_DEV_TYPE_NOR, },
++	};
++
++	noff = fdt_node_offset_by_compatible(blob, -1, nodes[0].compat);
++	if (noff != -FDT_ERR_NOTFOUND) {
++		ret = fdt_setprop_u32(blob, noff, "#size-cells", 1);
++		if (ret)
++			return ret;
++		ret = fdt_setprop_u32(blob, noff, "#address-cells", 1);
++		if (ret)
++			return ret;
++	} else {
++		return -ENODEV;
++	}
++
++	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
++#endif
++	return 0;
++}
++#endif
++
+ #ifdef CONFIG_MISC_INIT_R
+ static void setup_iodomain(void)
+ {
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
new file mode 100644
index 000000000000..d784a696e852
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
@@ -0,0 +1,33 @@
+    rockchip: Pinebook Pro: fix mmc boot ordering
+    
+    On the Pinebook Pro, and perhaps some other boards, the mmc indices are
+    opposite from what is implied by the comment in
+    include/configs/rockchip-common.h.
+    
+    This commit fixes the boot ordering to prioritize the SD card over eMMC.
+    
+    Most distributions of U-Boot that actually target rk3399 boards apply a
+    similar patch, such as Manjaro (shipped by default on PBP) and armbian.
+    
+    https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-pinebookpro/-/blob/60ed56b9bf8809309ec6252bfc45bca38c2b858a/0002-Correct-boot-order-to-be-USB-SD-eMMC.patch
+    https://github.com/armbian/build/blob/5a2b2c360b9c26ca4bd0d309af7cd3994fd08b7d/patch/u-boot/u-boot-rockchip64-mainline/general-prioritize-sd.patch
+    
+diff --git a/include/configs/rockpro64_rk3399.h b/include/configs/rockpro64_rk3399.h
+index 903e9df527..7c8f30dbaf 100644
+--- a/include/configs/rockpro64_rk3399.h
++++ b/include/configs/rockpro64_rk3399.h
+@@ -12,6 +12,14 @@
+ 	"stderr=serial,vidconsole\0"
+ 
+ #include <configs/rk3399_common.h>
++ 
++/* On RockPro64, mmc1 is SD and mmc0 is eMMC */
++#if CONFIG_IS_ENABLED(CMD_MMC)
++	#undef BOOT_TARGET_MMC
++	#define BOOT_TARGET_MMC(func) \
++		func(MMC, mmc, 1) \
++		func(MMC, mmc, 0)
++#endif
+ 
+ #define SDRAM_BANK_SIZE			(2UL << 30)
+ 
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
new file mode 100644
index 000000000000..af207a228085
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
@@ -0,0 +1,108 @@
+
+Autoboot
+	Disable bootdelay. Boot can be interrupted by pressing either <q> or
+	<ctrl-c>.
+
+Baudrate
+	Set baudrate to 115200 to prevent garbled output and improve
+	compatibility. The default baud rate is 1500000 bps. This produces
+	garbled output on many serial adapters and is a non-standard speed.
+
+Supported features
+	The following features have been enabled and are supported:
+	- NVME support.
+	- AHCI over PCIE.
+	- USB3 and keyboard support.
+	- fdt overlay.
+	- MDT partitions.
+	- BTRFS support enabled.
+
+diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig
+index ae11a8f5eb..827d37eb72 100644
+--- a/configs/rockpro64-rk3399_defconfig
++++ b/configs/rockpro64-rk3399_defconfig
+@@ -4,14 +4,17 @@ CONFIG_SYS_TEXT_BASE=0x00200000
+ CONFIG_NR_DRAM_BANKS=1
+ CONFIG_ENV_SIZE=0x8000
+ CONFIG_ENV_OFFSET=0x3F8000
+-CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
+ CONFIG_ROCKCHIP_RK3399=y
+ CONFIG_TARGET_ROCKPRO64_RK3399=y
+ CONFIG_DEBUG_UART_BASE=0xFF1A0000
+ CONFIG_DEBUG_UART_CLOCK=24000000
+ CONFIG_SPL_SPI_FLASH_SUPPORT=y
+ CONFIG_SPL_SPI_SUPPORT=y
++CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
+ CONFIG_DEBUG_UART=y
++CONFIG_AHCI=y
++CONFIG_OF_BOARD_SETUP=y
++CONFIG_BOOTDELAY=0
+ CONFIG_USE_PREBOOT=y
+ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
+ CONFIG_DISPLAY_BOARDINFO_LATE=y
+@@ -20,29 +23,40 @@ CONFIG_MISC_INIT_R=y
+ CONFIG_SPL_STACK_R=y
+ CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
+ CONFIG_SPL_SPI_LOAD=y
++# CONFIG_SPL_ATF_NO_PLATFORM_PARAM is not set
+ CONFIG_TPL=y
+ CONFIG_CMD_BOOTZ=y
++CONFIG_CMD_BOOTMENU=y
+ CONFIG_CMD_GPT=y
+ CONFIG_CMD_MMC=y
+ CONFIG_CMD_PCI=y
+ CONFIG_CMD_USB=y
+-# CONFIG_CMD_SETEXPR is not set
+ CONFIG_CMD_TIME=y
++CONFIG_CMD_MTDPARTS=y
++CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
++CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:384k(u-boot-spl),3680k(u-boot),32k(u-boot-env),-(user)"
+ CONFIG_SPL_OF_CONTROL=y
+ CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
+ CONFIG_ENV_IS_IN_SPI_FLASH=y
+ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+ CONFIG_SPL_DM_SEQ_ALIAS=y
++CONFIG_SCSI_AHCI=y
++CONFIG_AHCI_PCI=y
+ CONFIG_ROCKCHIP_GPIO=y
+ CONFIG_SYS_I2C_ROCKCHIP=y
++CONFIG_DM_KEYBOARD=y
++CONFIG_LED=y
++CONFIG_LED_GPIO=y
+ CONFIG_MISC=y
+ CONFIG_ROCKCHIP_EFUSE=y
+ CONFIG_MMC_DW=y
+ CONFIG_MMC_DW_ROCKCHIP=y
+ CONFIG_MMC_SDHCI=y
+ CONFIG_MMC_SDHCI_ROCKCHIP=y
++CONFIG_MTD=y
+ CONFIG_SF_DEFAULT_BUS=1
+ CONFIG_SPI_FLASH_GIGADEVICE=y
++CONFIG_SPI_FLASH_MTD=y
+ CONFIG_DM_ETH=y
+ CONFIG_ETH_DESIGNWARE=y
+ CONFIG_GMAC_ROCKCHIP=y
+@@ -58,7 +72,9 @@ CONFIG_RAM_RK3399_LPDDR4=y
+ CONFIG_DM_RESET=y
+ CONFIG_DM_RNG=y
+ CONFIG_RNG_ROCKCHIP=y
+-CONFIG_BAUDRATE=1500000
++CONFIG_SCSI=y
++CONFIG_DM_SCSI=y
++CONFIG_BAUDRATE=115200
+ CONFIG_DEBUG_UART_SHIFT=2
+ CONFIG_ROCKCHIP_SPI=y
+ CONFIG_SYSRESET=y
+@@ -82,5 +98,12 @@ CONFIG_DM_VIDEO=y
+ CONFIG_DISPLAY=y
+ CONFIG_VIDEO_ROCKCHIP=y
+ CONFIG_DISPLAY_ROCKCHIP_HDMI=y
++CONFIG_FS_BTRFS=y
+ CONFIG_SPL_TINY_MEMSET=y
+ CONFIG_ERRNO_STR=y
++CONFIG_OF_LIBFDT_OVERLAY=y
++CONFIG_FDT_FIXUP_PARTITIONS=y
++CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds... press q or Ctrl-C to interrupt\n"
++CONFIG_AUTOBOOT_KEYED=y
++CONFIG_AUTOBOOT_STOP_STR="q"
++CONFIG_AUTOBOOT_KEYED_CTRLC=y
diff --git a/srcpkgs/rockpro64-uboot/template b/srcpkgs/rockpro64-uboot/template
new file mode 100644
index 000000000000..10daa7174b83
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/template
@@ -0,0 +1,47 @@
+# Template file for 'rockpro64-uboot'
+pkgname=rockpro64-uboot
+version=2021.07
+revision=1
+archs="aarch64*"
+wrksrc="u-boot-${version}"
+hostmakedepends="flex bc dtc python3"
+makedepends="atf-rk3399-bl31"
+depends="u-boot-tools"
+short_desc="Das U-Boot for the RockPro64 SBC"
+maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
+license="GPL-2.0-or-later, BSD-3-Clause"
+homepage="https://www.denx.de/wiki/U-Boot/"
+distfiles="https://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"
+checksum=312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e
+
+do_configure() {
+	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+	make ${makejobs} rockpro64-rk3399_defconfig
+}
+
+do_build() {
+	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+	if [ "$CROSS_BUILD" ]; then
+		export CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
+	fi
+	make ${makejobs} EXTRAVERSION=-${revision} \
+		BL31=${XBPS_CROSS_BASE}/usr/lib/trusted-firmware-a/rk3399/bl31.elf
+}
+
+do_install() {
+	vinstall idbloader.img 0644 usr/lib/rockpro64-uboot
+	vinstall u-boot.itb 0644 usr/lib/rockpro64-uboot
+	vlicense Licenses/Exceptions
+	vlicense Licenses/OFL.txt
+	vlicense Licenses/README
+	vlicense Licenses/bsd-2-clause.txt
+	vlicense Licenses/bsd-3-clause.txt
+	vlicense Licenses/eCos-2.0.txt
+	vlicense Licenses/gpl-2.0.txt
+	vlicense Licenses/ibm-pibs.txt
+	vlicense Licenses/isc.txt
+	vlicense Licenses/lgpl-2.0.txt
+	vlicense Licenses/lgpl-2.1.txt
+	vlicense Licenses/r8a779x_usb3.txt
+	vlicense Licenses/x11.txt
+}
diff --git a/srcpkgs/rockpro64-uboot/update b/srcpkgs/rockpro64-uboot/update
new file mode 100644
index 000000000000..cfcfccd3fb43
--- /dev/null
+++ b/srcpkgs/rockpro64-uboot/update
@@ -0,0 +1 @@
+pkgname="u-boot"

From 0e6bc6d0fac8273b8f7b8d20fc6be111f7b13a90 Mon Sep 17 00:00:00 2001
From: Tiemen Werkman <tiemen@void-tiemen.opifexonline.com>
Date: Sun, 10 Oct 2021 10:04:26 +0200
Subject: [PATCH 2/2] Create distinct branches for distinct packages to
 facilitate distinct pull requests.

---
 srcpkgs/rockpro64-base/INSTALL                |   8 --
 srcpkgs/rockpro64-base/template               |  11 --
 .../patches/phy-rockchip-inno-usb2.c.patch    |  75 ------------
 .../rockpro64-uboot/patches/rk3399.c.patch    |  51 ---------
 .../patches/rockpro64-rk3399.c.patch          |  48 --------
 .../patches/rockpro64-rk3399.h.patch          |  33 ------
 .../patches/rockpro64-rk3399_defconfig.patch  | 108 ------------------
 srcpkgs/rockpro64-uboot/template              |  47 --------
 srcpkgs/rockpro64-uboot/update                |   1 -
 9 files changed, 382 deletions(-)
 delete mode 100644 srcpkgs/rockpro64-base/INSTALL
 delete mode 100644 srcpkgs/rockpro64-base/template
 delete mode 100644 srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
 delete mode 100644 srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
 delete mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
 delete mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
 delete mode 100644 srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
 delete mode 100644 srcpkgs/rockpro64-uboot/template
 delete mode 100644 srcpkgs/rockpro64-uboot/update

diff --git a/srcpkgs/rockpro64-base/INSTALL b/srcpkgs/rockpro64-base/INSTALL
deleted file mode 100644
index 7e67f362c796..000000000000
--- a/srcpkgs/rockpro64-base/INSTALL
+++ /dev/null
@@ -1,8 +0,0 @@
-if [ "${UPDATE}" = "no" ] && [ "${ACTION}" = "post" ]; then
-	mkdir -p etc/runit/runsvdir/default/
-	mkdir -p etc/sv/agetty-ttyS2/
-	ln -sf /etc/sv/sshd etc/runit/runsvdir/default/
-	ln -sf /etc/sv/dhcpcd etc/runit/runsvdir/default/
-	ln -sf /etc/sv/agetty-ttyS2 etc/runit/runsvdir/default/
-	cd etc/sv/agetty-ttyS2/ && ln -sf ../agetty-serial/conf conf && ln -sf ../agetty-generic/finish finish && ln -sf ../agetty-serial/run run && ln -sf /run/runit/supervise.agetty-ttyS2
-fi
diff --git a/srcpkgs/rockpro64-base/template b/srcpkgs/rockpro64-base/template
deleted file mode 100644
index e90db4f4396d..000000000000
--- a/srcpkgs/rockpro64-base/template
+++ /dev/null
@@ -1,11 +0,0 @@
-# Template file for 'rockpro64-base'
-pkgname=rockpro64-base
-version=1
-revision=1
-archs="aarch64*"
-build_style=meta
-depends="rockpro64-uboot u-boot-menu dracut"
-short_desc="Void Linux RockPro64 platform package"
-maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
-license="Public Domain"
-homepage="https://www.voidlinux.org"
diff --git a/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch b/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
deleted file mode 100644
index 1f9839889f0d..000000000000
--- a/srcpkgs/rockpro64-uboot/patches/phy-rockchip-inno-usb2.c.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-    Fix USB on RockPro64:
-    Without this patch uboot crashes when resetting usb, preventing the kernel
-    from loading.
-    The only alternative to this patch is to disable Preboot or OHCI which 
-    also leaves you with no console keyboard.
-
-    https://patchwork.ozlabs.org/project/uboot/patch/20210406151059.1187379-1-icenowy@aosc.io/
-
-diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
-index 62b8ba3a4a..be9cc99d90 100644
---- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
-+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
-@@ -62,6 +62,8 @@ struct rockchip_usb2phy {
- 	void *reg_base;
- 	struct clk phyclk;
- 	const struct rockchip_usb2phy_cfg *phy_cfg;
-+	int init_count;
-+	int power_on_count;
- };
- 
- static inline int property_enable(void *reg_base,
-@@ -92,6 +94,10 @@ static int rockchip_usb2phy_power_on(struct phy *phy)
- 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
- 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
- 
-+	priv->power_on_count++;
-+	if (priv->power_on_count != 1)
-+		return 0;
-+
- 	property_enable(priv->reg_base, &port_cfg->phy_sus, false);
- 
- 	/* waiting for the utmi_clk to become stable */
-@@ -106,6 +112,10 @@ static int rockchip_usb2phy_power_off(struct phy *phy)
- 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
- 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
- 
-+	priv->power_on_count--;
-+	if (priv->power_on_count != 0)
-+		return 0;
-+
- 	property_enable(priv->reg_base, &port_cfg->phy_sus, true);
- 
- 	return 0;
-@@ -118,6 +128,10 @@ static int rockchip_usb2phy_init(struct phy *phy)
- 	const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy);
- 	int ret;
- 
-+	priv->init_count++;
-+	if (priv->init_count != 1)
-+		return 0;
-+
- 	ret = clk_enable(&priv->phyclk);
- 	if (ret) {
- 		dev_err(phy->dev, "failed to enable phyclk (ret=%d)\n", ret);
-@@ -140,6 +154,10 @@ static int rockchip_usb2phy_exit(struct phy *phy)
- 	struct udevice *parent = dev_get_parent(phy->dev);
- 	struct rockchip_usb2phy *priv = dev_get_priv(parent);
- 
-+	priv->init_count--;
-+	if (priv->init_count != 0)
-+		return 0;
-+
- 	clk_disable(&priv->phyclk);
- 
- 	return 0;
-@@ -212,6 +230,9 @@ static int rockchip_usb2phy_probe(struct udevice *dev)
- 		return ret;
- 	}
- 
-+	priv->power_on_count = 0;
-+	priv->init_count = 0;
-+
- 	return 0;
- }
- 
diff --git a/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
deleted file mode 100644
index f3c08bf33c61..000000000000
--- a/srcpkgs/rockpro64-uboot/patches/rk3399.c.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 1a01021c9361c4e017cb5b032300f5555c393710 Mon Sep 17 00:00:00 2001
-From: dhivael <dhivael.git@eno.space>
-Date: Sat, 11 Jan 2020 15:04:46 +0100
-Subject: rk3399: light pinebook power and standby leds during early boot
-
-this is a hack, but it works for now.
----
- arch/arm/mach-rockchip/rk3399/rk3399.c | 12 +++++++++++-
- 1 file changed, 11 insertions(+), 1 deletion(-)
-
-diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
-index 863024d071..cf37129d55 100644
---- a/arch/arm/mach-rockchip/rk3399/rk3399.c
-+++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
-@@ -15,6 +15,8 @@
- #include <asm/arch-rockchip/grf_rk3399.h>
- #include <asm/arch-rockchip/hardware.h>
- #include <power/regulator.h>
-+#include <dt-bindings/gpio/gpio.h>
-+#include <dt-bindings/pinctrl/rockchip.h>
- 
- DECLARE_GLOBAL_DATA_PTR;
- 
-@@ -115,8 +117,8 @@ void board_debug_uart_init(void)
- 	struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
- #ifdef CONFIG_TARGET_CHROMEBOOK_BOB
- 	struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
--	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
- #endif
-+	struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
- 
- #if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff180000)
- 	/* Enable early UART0 on the RK3399 */
-@@ -149,6 +151,14 @@ void board_debug_uart_init(void)
- 	spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_B, 4), GPIO_PULL_NORMAL);
- #endif /* CONFIG_TARGET_CHROMEBOOK_BOB */
- 
-+	{
-+		// set GPIO0_A2/B3 to GPIO_ACTIVE_HIGH
-+		// set GPIO0_A2/B3 to OUTPUT
-+		int mask = (1UL << RK_PA2) | (1UL << RK_PB3);
-+		setbits_le32(&gpio->swport_dr, mask);
-+		setbits_le32(&gpio->swport_ddr, mask);
-+	}
-+
- 	/* Enable early UART2 channel C on the RK3399 */
- 	rk_clrsetreg(&grf->gpio4c_iomux,
- 		     GRF_GPIO4C3_SEL_MASK,
--- 
-cgit v1.2.3
-
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
deleted file mode 100644
index 5fb9b65c8ef2..000000000000
--- a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.c.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-diff --git a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
-index d79084614f..6f7f661154 100644
---- a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
-+++ b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
-@@ -5,6 +5,9 @@
- 
- #include <common.h>
- #include <dm.h>
-+#include <fdt_support.h>
-+#include <jffs2/load_kernel.h>
-+#include <mtd_node.h>
- #include <init.h>
- #include <syscon.h>
- #include <asm/io.h>
-@@ -16,6 +19,33 @@
- #define GRF_IO_VSEL_BT565_SHIFT 0
- #define PMUGRF_CON0_VSEL_SHIFT 8
- 
-+#ifdef CONFIG_OF_BOARD_SETUP
-+int ft_board_setup(void *blob, struct bd_info *bd)
-+{
-+#ifdef CONFIG_FDT_FIXUP_PARTITIONS
-+	int ret, noff;
-+	static const struct node_info nodes[] = {
-+		{ "jedec,spi-nor", MTD_DEV_TYPE_NOR, },
-+	};
-+
-+	noff = fdt_node_offset_by_compatible(blob, -1, nodes[0].compat);
-+	if (noff != -FDT_ERR_NOTFOUND) {
-+		ret = fdt_setprop_u32(blob, noff, "#size-cells", 1);
-+		if (ret)
-+			return ret;
-+		ret = fdt_setprop_u32(blob, noff, "#address-cells", 1);
-+		if (ret)
-+			return ret;
-+	} else {
-+		return -ENODEV;
-+	}
-+
-+	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
-+#endif
-+	return 0;
-+}
-+#endif
-+
- #ifdef CONFIG_MISC_INIT_R
- static void setup_iodomain(void)
- {
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
deleted file mode 100644
index d784a696e852..000000000000
--- a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399.h.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-    rockchip: Pinebook Pro: fix mmc boot ordering
-    
-    On the Pinebook Pro, and perhaps some other boards, the mmc indices are
-    opposite from what is implied by the comment in
-    include/configs/rockchip-common.h.
-    
-    This commit fixes the boot ordering to prioritize the SD card over eMMC.
-    
-    Most distributions of U-Boot that actually target rk3399 boards apply a
-    similar patch, such as Manjaro (shipped by default on PBP) and armbian.
-    
-    https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-pinebookpro/-/blob/60ed56b9bf8809309ec6252bfc45bca38c2b858a/0002-Correct-boot-order-to-be-USB-SD-eMMC.patch
-    https://github.com/armbian/build/blob/5a2b2c360b9c26ca4bd0d309af7cd3994fd08b7d/patch/u-boot/u-boot-rockchip64-mainline/general-prioritize-sd.patch
-    
-diff --git a/include/configs/rockpro64_rk3399.h b/include/configs/rockpro64_rk3399.h
-index 903e9df527..7c8f30dbaf 100644
---- a/include/configs/rockpro64_rk3399.h
-+++ b/include/configs/rockpro64_rk3399.h
-@@ -12,6 +12,14 @@
- 	"stderr=serial,vidconsole\0"
- 
- #include <configs/rk3399_common.h>
-+ 
-+/* On RockPro64, mmc1 is SD and mmc0 is eMMC */
-+#if CONFIG_IS_ENABLED(CMD_MMC)
-+	#undef BOOT_TARGET_MMC
-+	#define BOOT_TARGET_MMC(func) \
-+		func(MMC, mmc, 1) \
-+		func(MMC, mmc, 0)
-+#endif
- 
- #define SDRAM_BANK_SIZE			(2UL << 30)
- 
diff --git a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch b/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
deleted file mode 100644
index af207a228085..000000000000
--- a/srcpkgs/rockpro64-uboot/patches/rockpro64-rk3399_defconfig.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-
-Autoboot
-	Disable bootdelay. Boot can be interrupted by pressing either <q> or
-	<ctrl-c>.
-
-Baudrate
-	Set baudrate to 115200 to prevent garbled output and improve
-	compatibility. The default baud rate is 1500000 bps. This produces
-	garbled output on many serial adapters and is a non-standard speed.
-
-Supported features
-	The following features have been enabled and are supported:
-	- NVME support.
-	- AHCI over PCIE.
-	- USB3 and keyboard support.
-	- fdt overlay.
-	- MDT partitions.
-	- BTRFS support enabled.
-
-diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig
-index ae11a8f5eb..827d37eb72 100644
---- a/configs/rockpro64-rk3399_defconfig
-+++ b/configs/rockpro64-rk3399_defconfig
-@@ -4,14 +4,17 @@ CONFIG_SYS_TEXT_BASE=0x00200000
- CONFIG_NR_DRAM_BANKS=1
- CONFIG_ENV_SIZE=0x8000
- CONFIG_ENV_OFFSET=0x3F8000
--CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
- CONFIG_ROCKCHIP_RK3399=y
- CONFIG_TARGET_ROCKPRO64_RK3399=y
- CONFIG_DEBUG_UART_BASE=0xFF1A0000
- CONFIG_DEBUG_UART_CLOCK=24000000
- CONFIG_SPL_SPI_FLASH_SUPPORT=y
- CONFIG_SPL_SPI_SUPPORT=y
-+CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
- CONFIG_DEBUG_UART=y
-+CONFIG_AHCI=y
-+CONFIG_OF_BOARD_SETUP=y
-+CONFIG_BOOTDELAY=0
- CONFIG_USE_PREBOOT=y
- CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
- CONFIG_DISPLAY_BOARDINFO_LATE=y
-@@ -20,29 +23,40 @@ CONFIG_MISC_INIT_R=y
- CONFIG_SPL_STACK_R=y
- CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
- CONFIG_SPL_SPI_LOAD=y
-+# CONFIG_SPL_ATF_NO_PLATFORM_PARAM is not set
- CONFIG_TPL=y
- CONFIG_CMD_BOOTZ=y
-+CONFIG_CMD_BOOTMENU=y
- CONFIG_CMD_GPT=y
- CONFIG_CMD_MMC=y
- CONFIG_CMD_PCI=y
- CONFIG_CMD_USB=y
--# CONFIG_CMD_SETEXPR is not set
- CONFIG_CMD_TIME=y
-+CONFIG_CMD_MTDPARTS=y
-+CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
-+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:384k(u-boot-spl),3680k(u-boot),32k(u-boot-env),-(user)"
- CONFIG_SPL_OF_CONTROL=y
- CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
- CONFIG_ENV_IS_IN_SPI_FLASH=y
- CONFIG_SYS_RELOC_GD_ENV_ADDR=y
- CONFIG_SPL_DM_SEQ_ALIAS=y
-+CONFIG_SCSI_AHCI=y
-+CONFIG_AHCI_PCI=y
- CONFIG_ROCKCHIP_GPIO=y
- CONFIG_SYS_I2C_ROCKCHIP=y
-+CONFIG_DM_KEYBOARD=y
-+CONFIG_LED=y
-+CONFIG_LED_GPIO=y
- CONFIG_MISC=y
- CONFIG_ROCKCHIP_EFUSE=y
- CONFIG_MMC_DW=y
- CONFIG_MMC_DW_ROCKCHIP=y
- CONFIG_MMC_SDHCI=y
- CONFIG_MMC_SDHCI_ROCKCHIP=y
-+CONFIG_MTD=y
- CONFIG_SF_DEFAULT_BUS=1
- CONFIG_SPI_FLASH_GIGADEVICE=y
-+CONFIG_SPI_FLASH_MTD=y
- CONFIG_DM_ETH=y
- CONFIG_ETH_DESIGNWARE=y
- CONFIG_GMAC_ROCKCHIP=y
-@@ -58,7 +72,9 @@ CONFIG_RAM_RK3399_LPDDR4=y
- CONFIG_DM_RESET=y
- CONFIG_DM_RNG=y
- CONFIG_RNG_ROCKCHIP=y
--CONFIG_BAUDRATE=1500000
-+CONFIG_SCSI=y
-+CONFIG_DM_SCSI=y
-+CONFIG_BAUDRATE=115200
- CONFIG_DEBUG_UART_SHIFT=2
- CONFIG_ROCKCHIP_SPI=y
- CONFIG_SYSRESET=y
-@@ -82,5 +98,12 @@ CONFIG_DM_VIDEO=y
- CONFIG_DISPLAY=y
- CONFIG_VIDEO_ROCKCHIP=y
- CONFIG_DISPLAY_ROCKCHIP_HDMI=y
-+CONFIG_FS_BTRFS=y
- CONFIG_SPL_TINY_MEMSET=y
- CONFIG_ERRNO_STR=y
-+CONFIG_OF_LIBFDT_OVERLAY=y
-+CONFIG_FDT_FIXUP_PARTITIONS=y
-+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds... press q or Ctrl-C to interrupt\n"
-+CONFIG_AUTOBOOT_KEYED=y
-+CONFIG_AUTOBOOT_STOP_STR="q"
-+CONFIG_AUTOBOOT_KEYED_CTRLC=y
diff --git a/srcpkgs/rockpro64-uboot/template b/srcpkgs/rockpro64-uboot/template
deleted file mode 100644
index 10daa7174b83..000000000000
--- a/srcpkgs/rockpro64-uboot/template
+++ /dev/null
@@ -1,47 +0,0 @@
-# Template file for 'rockpro64-uboot'
-pkgname=rockpro64-uboot
-version=2021.07
-revision=1
-archs="aarch64*"
-wrksrc="u-boot-${version}"
-hostmakedepends="flex bc dtc python3"
-makedepends="atf-rk3399-bl31"
-depends="u-boot-tools"
-short_desc="Das U-Boot for the RockPro64 SBC"
-maintainer="Tiemen Werkman <tiemen@opifexonline.com>"
-license="GPL-2.0-or-later, BSD-3-Clause"
-homepage="https://www.denx.de/wiki/U-Boot/"
-distfiles="https://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"
-checksum=312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e
-
-do_configure() {
-	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
-	make ${makejobs} rockpro64-rk3399_defconfig
-}
-
-do_build() {
-	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
-	if [ "$CROSS_BUILD" ]; then
-		export CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
-	fi
-	make ${makejobs} EXTRAVERSION=-${revision} \
-		BL31=${XBPS_CROSS_BASE}/usr/lib/trusted-firmware-a/rk3399/bl31.elf
-}
-
-do_install() {
-	vinstall idbloader.img 0644 usr/lib/rockpro64-uboot
-	vinstall u-boot.itb 0644 usr/lib/rockpro64-uboot
-	vlicense Licenses/Exceptions
-	vlicense Licenses/OFL.txt
-	vlicense Licenses/README
-	vlicense Licenses/bsd-2-clause.txt
-	vlicense Licenses/bsd-3-clause.txt
-	vlicense Licenses/eCos-2.0.txt
-	vlicense Licenses/gpl-2.0.txt
-	vlicense Licenses/ibm-pibs.txt
-	vlicense Licenses/isc.txt
-	vlicense Licenses/lgpl-2.0.txt
-	vlicense Licenses/lgpl-2.1.txt
-	vlicense Licenses/r8a779x_usb3.txt
-	vlicense Licenses/x11.txt
-}
diff --git a/srcpkgs/rockpro64-uboot/update b/srcpkgs/rockpro64-uboot/update
deleted file mode 100644
index cfcfccd3fb43..000000000000
--- a/srcpkgs/rockpro64-uboot/update
+++ /dev/null
@@ -1 +0,0 @@
-pkgname="u-boot"

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PR PATCH] [Closed]: Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (10 preceding siblings ...)
  2021-10-10  8:07 ` tiemenwerkman
@ 2021-10-10  8:08 ` tiemenwerkman
  2021-10-10  8:09 ` tiemenwerkman
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-10  8:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1984 bytes --]

There's a closed pull request on the void-packages repository

Add rockpro64 packages
https://github.com/void-linux/void-packages/pull/33444

Description:
#### General
- [X] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [X] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] I built this PR locally for my native architecture, (ARCH-LIBC)
- [X] I built this PR locally for these architectures (if supported. mark crossbuilds): crossbuilds on amd64
  - [ ] aarch64-musl
  - [ ] armv7l
  - [ ] armv6l-musl

This is my first pull request so I imagine there are probably a few things off with it.
I only started using git this week, I'm learning as I go.
I started putting these two packages together two weeks ago, I've tested mostly with emmc and sd cards and some usb thumb drives. I don't yet have pcie sata or nvme card to test.
I've also tested the usb-keyboard and HDMI output, the keyboard is fine and the HDMI output is mostly fine. HDMI immediately comes up but does not return by itself when loading the kernel (any version). It returns though when either the cable is reseated or the monitor is turned off and on again.
The nic works fine and so do the usb ports.
I opted not to create a kernel specific package as I think this makes it easier to update to newer versions, moreover it does not seem to be necessary. The only thing I ran into is that on versions 5.13 and 5.14 I am unable to build the zfs dkms module (no, I did not forget the headers).
Any feedback from testers would be welcome!   

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (11 preceding siblings ...)
  2021-10-10  8:08 ` [PR PATCH] [Closed]: " tiemenwerkman
@ 2021-10-10  8:09 ` tiemenwerkman
  2021-10-10 13:29 ` Duncaen
  2021-10-10 13:30 ` Duncaen
  14 siblings, 0 replies; 16+ messages in thread
From: tiemenwerkman @ 2021-10-10  8:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 221 bytes --]

New comment by tiemenwerkman on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#issuecomment-939427973

Comment:
I'm going to create separate branches and pull requests for both packages.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (12 preceding siblings ...)
  2021-10-10  8:09 ` tiemenwerkman
@ 2021-10-10 13:29 ` Duncaen
  2021-10-10 13:30 ` Duncaen
  14 siblings, 0 replies; 16+ messages in thread
From: Duncaen @ 2021-10-10 13:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#issuecomment-939482722

Comment:
There is no reason to do separate pull requests for related packages, just one commit per package.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Add rockpro64 packages
  2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
                   ` (13 preceding siblings ...)
  2021-10-10 13:29 ` Duncaen
@ 2021-10-10 13:30 ` Duncaen
  14 siblings, 0 replies; 16+ messages in thread
From: Duncaen @ 2021-10-10 13:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/33444#issuecomment-939482722

Comment:
There is no reason to do separate pull requests for related packages, just one commit per package. If they depend on each other, then a separate PR is even worse because CI can't build the package with a missing dependency.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-10-10 13:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-09 14:53 [PR PATCH] Add rockpro64 packages tiemenwerkman
2021-10-09 18:13 ` [PR REVIEW] " CameronNemo
2021-10-09 18:14 ` CameronNemo
2021-10-09 18:17 ` CameronNemo
2021-10-09 18:18 ` CameronNemo
2021-10-09 18:20 ` [PR REVIEW] " CameronNemo
2021-10-09 18:49 ` tiemenwerkman
2021-10-09 18:52 ` tiemenwerkman
2021-10-09 19:03 ` tiemenwerkman
2021-10-09 19:05 ` tiemenwerkman
2021-10-10  7:53 ` [PR PATCH] [Updated] " tiemenwerkman
2021-10-10  8:07 ` tiemenwerkman
2021-10-10  8:08 ` [PR PATCH] [Closed]: " tiemenwerkman
2021-10-10  8:09 ` tiemenwerkman
2021-10-10 13:29 ` Duncaen
2021-10-10 13:30 ` Duncaen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).