Subject: [PATCH v4 1/3] gnu: bootloader: Add nanopi-r4s-rk3399-ddr3 bootloader.

From: Herman Rimm <[email-masked]>
Date: Mon, 31 Mar 2025 20:19:25 +0200

* gnu/bootloader/u-boot.scm (u-boot-nanopi-r4s-rk3399-ddr3-bootloader):
Add variable.
* gnu/packages/bootloaders.scm (u-boot-nanopi-r4s-rk3399-ddr3): Add
variable.
* gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch: Add file.
* gnu/local.mk (dist_patch_DATA): Register patch.

Change-Id: I6d4cb098727fe4027aea33a39c59d34000dfc4db
---
 gnu/bootloader/u-boot.scm                     |  6 ++++
 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 10 ++++++
 .../patches/u-boot-nanopi-r4s-ddr3.patch      | 33 +++++++++++++++++++
 4 files changed, 50 insertions(+)
 create mode 100644 gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 64fb319f50f..a7c73093bd6 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -38,6 +38,7 @@ (define-module (gnu bootloader u-boot)
             u-boot-cubietruck-bootloader
             u-boot-firefly-rk3399-bootloader
             u-boot-mx6cuboxi-bootloader
+            u-boot-nanopi-r4s-rk3399-ddr3-bootloader
             u-boot-nintendo-nes-classic-edition-bootloader
             u-boot-novena-bootloader
             u-boot-orangepi-r1-plus-lts-rk3328-bootloader
@@ -221,6 +222,11 @@ (define u-boot-novena-bootloader
    (inherit u-boot-imx-bootloader)
    (package u-boot-novena)))
 
+(define u-boot-nanopi-r4s-rk3399-ddr3-bootloader
+  (bootloader
+   (inherit u-boot-rockchip-bootloader)
+   (package u-boot-nanopi-r4s-rk3399-ddr3)))
+
 (define u-boot-orangepi-r1-plus-lts-rk3328-bootloader
   (bootloader
    (inherit u-boot-rockchip-bootloader)
diff --git a/gnu/local.mk b/gnu/local.mk
index f03fcb14fcc..955b8fb1ddf 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2342,6 +2342,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/u-boot-allow-disabling-openssl.patch	\
   %D%/packages/patches/u-boot-nintendo-nes-serial.patch		\
   %D%/packages/patches/u-boot-rockchip-inno-usb.patch		\
+  %D%/packages/patches/u-boot-nanopi-r4s-ddr3.patch		\
   %D%/packages/patches/ucx-tcp-iface-ioctl.patch		\
   %D%/packages/patches/ultrastar-deluxe-no-freesans.patch		\
   %D%/packages/patches/ungoogled-chromium-extension-search-path.patch	\
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 8ece61f11c3..1953222ae12 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1303,6 +1303,16 @@ (define-public u-boot-novena
 version, contrary to Novena upstream, does not load u-boot.img from the first
 partition."))
 
+(define-public u-boot-nanopi-r4s-rk3399-ddr3
+  (let ((base (make-u-boot-rockchip-package "nanopi-r4s" 'rk3399)))
+    (package
+      (inherit base)
+      (source
+       (origin
+         (inherit (package-source base))
+         (patches (cons (search-patch "u-boot-nanopi-r4s-ddr3.patch")
+                        (origin-patches (package-source base)))))))))
+
 (define-public u-boot-orangepi-r1-plus-lts-rk3328
   (make-u-boot-rockchip-package "orangepi-r1-plus-lts" 'rk3328))
 
diff --git a/gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch b/gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch
new file mode 100644
index 00000000000..435ffd55546
--- /dev/null
+++ b/gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch
@@ -0,0 +1,33 @@
+From: Herman Rimm <[email-masked]>
+Date: Sun, 2 Jul 2023 13:43:18 +0200
+Subject: [PATCH] Configure the Nano Pi R4S with DDR3.
+
+---
+This patch should be removed once something like this is upstream:
+https://github.com/anaelorlinski/OpenWrt-NanoPi-R2S-R4S-Builds/commit/9d836044340ddef53f5d9f1946ac48c946a78284
+
+diff --git a/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi b/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi
+index 69800cc368d..a3054849f88 100644
+--- a/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi
++++ b/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi
+@@ -13,7 +13,7 @@
+  */
+ 
+ #include "rk3399-nanopi4-u-boot.dtsi"
+-#include "rk3399-sdram-lpddr4-100.dtsi"
++#include "rk3399-sdram-ddr3-1866.dtsi"
+ 
+ / {
+ 	smbios {
+diff --git a/configs/nanopi-r4s-rk3399_defconfig b/configs/nanopi-r4s-rk3399_defconfig
+index ada04b46cb1..b39e350bbed 100644
+--- a/configs/nanopi-r4s-rk3399_defconfig
++++ b/configs/nanopi-r4s-rk3399_defconfig
+@@ -48,7 +48,6 @@ CONFIG_PMIC_RK8XX=y
+ CONFIG_SPL_DM_REGULATOR_FIXED=y
+ CONFIG_REGULATOR_RK8XX=y
+ CONFIG_PWM_ROCKCHIP=y
+-CONFIG_RAM_ROCKCHIP_LPDDR4=y
+ CONFIG_BAUDRATE=1500000
+ CONFIG_DEBUG_UART_SHIFT=2
+ CONFIG_SYS_NS16550_MEM32=y
-- 
2.48.1