* [bug#31599] [PATCH] system: Add u-boot-puma-rk3399.
@ 2018-05-25 22:29 Vagrant Cascadian
2018-05-26 7:19 ` Danny Milosavljevic
0 siblings, 1 reply; 7+ messages in thread
From: Vagrant Cascadian @ 2018-05-25 22:29 UTC (permalink / raw)
To: 31599
[-- Attachment #1.1: Type: text/plain, Size: 957 bytes --]
The attached patch enables u-boot for puma-rk3399. It enables a build of
the vendor's arm-trusted-firmware/rk3399-cortex-m0, and the installation
offsets to install the u-boot to microSD.
Tested running on a puma-rk3399-haikou board running GuixSD!
There is one glitch, which is that the fdtfile variable in u-boot
(rockchip/rk3399-puma-ddr1600.dtb) does not match the device-tree
present in linux-libre (rockchip/rk3399-puma-haikou.dtb), so the fdtfile
u-boot variable needs to manually be set at boot to match
linux-libre. This is likely to be fixed in future u-boot versions.
Vagrant Cascadian (1):
system: Add u-boot-puma-rk3399.
gnu/bootloader/u-boot.scm | 16 +++++++++++
gnu/packages/bootloaders.scm | 36 ++++++++++++++++++++++++-
gnu/packages/firmware.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++
gnu/system/install.scm | 6 +++++
4 files changed, 121 insertions(+), 1 deletion(-)
--
2.11.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-system-Add-u-boot-puma-rk3399.patch --]
[-- Type: text/x-diff, Size: 8792 bytes --]
From 1e070fe4c33c774992cb712bd78745b91ccef307 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
Date: Fri, 25 May 2018 13:04:17 -0700
Subject: [PATCH 1/1] system: Add u-boot-puma-rk3399.
* gnu/packages/bootloaders.scm (u-boot-puma-rk3399): New variable.
(make-u-boot-package)[arguments]: Add '.rksd' files to the files installed
during custom 'install phase.
* gnu/bootloader/u-boot.scm (u-boot-puma-rk3399-bootloader):
New exported variable.
* gnu/system/install.scm (rk3399-puma-installation-os):
New exported variable.
* gnu/packages/firmware.scm (arm-trusted-firmware-puma-rk3399): New variable.
(rk3399-cortex-m0): New variable.
---
gnu/bootloader/u-boot.scm | 16 +++++++++++
gnu/packages/bootloaders.scm | 36 ++++++++++++++++++++++++-
gnu/packages/firmware.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++
gnu/system/install.scm | 6 +++++
4 files changed, 121 insertions(+), 1 deletion(-)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index ea0f67b3c..52b38dd1a 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -37,6 +37,7 @@
u-boot-nintendo-nes-classic-edition-bootloader
u-boot-novena-bootloader
u-boot-pine64-plus-bootloader
+ u-boot-puma-rk3399-bootloader
u-boot-wandboard-bootloader))
(define install-u-boot
@@ -84,6 +85,15 @@
(write-file-on-device u-boot (stat:size (stat u-boot))
device (* 69 1024)))))
+(define install-puma-rk3399-u-boot
+ #~(lambda (bootloader device mount-point)
+ (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
+ (u-boot (string-append bootloader "/libexec/u-boot.itb")))
+ (write-file-on-device spl (stat:size (stat spl))
+ device (* 64 512))
+ (write-file-on-device u-boot (stat:size (stat u-boot))
+ device (* 512 512)))))
+
\f
;;;
@@ -162,3 +172,9 @@
(bootloader
(inherit u-boot-allwinner64-bootloader)
(package u-boot-pine64-plus)))
+
+(define u-boot-puma-rk3399-bootloader
+ (bootloader
+ (inherit u-boot-bootloader)
+ (package u-boot-puma-rk3399)
+ (installer install-puma-rk3399-u-boot)))
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 333f30e72..3c76b8b3d 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -450,7 +450,7 @@ board-independent tools.")))
(let* ((out (assoc-ref outputs "out"))
(libexec (string-append out "/libexec"))
(uboot-files (append
- (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb)$")
+ (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$")
(find-files "." "^(MLO|SPL)$"))))
(mkdir-p libexec)
(install-file ".config" libexec)
@@ -521,6 +521,40 @@ board-independent tools.")))
(define-public u-boot-cubieboard
(make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
+(define-public u-boot-puma-rk3399
+ (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
+ (package
+ (inherit base)
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'unpack 'set-environment
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Need to copy the firmware into u-boot build
+ ;; directory.
+ (copy-file (string-append (assoc-ref inputs "firmware")
+ "/bl31.bin") "bl31-rk3399.bin")
+ (copy-file (string-append (assoc-ref inputs "firmware-m0")
+ "/rk3399m0.bin") "rk3399m0.bin")))
+ (add-after 'build 'builditb
+ (lambda* (#:key make-flags #:allow-other-keys)
+ ;; The u-boot.itb is not built by default
+ (zero? (apply system* "make" `(,@make-flags ,"u-boot.itb")))))
+ (add-after 'builditb 'buildrksd
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Build rockchip SD card images.
+ (zero? (apply system*
+ (string-append
+ (assoc-ref inputs "u-boot-tools") "/bin/mkimage")
+ `(,"-T" ,"rksd" ,"-n" ,"rk3399" ,"-d"
+,"spl/u-boot-spl.bin" ,"u-boot-spl.rksd")))))))))
+ (native-inputs
+ `(("firmware" ,arm-trusted-firmware-puma-rk3399)
+ ("firmware-m0" ,rk3399-cortex-m0)
+ ("u-boot-tools" ,u-boot-tools)
+ ,@(package-native-inputs base))))))
+
(define-public vboot-utils
(package
(name "vboot-utils")
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 9e91ceca4..7bc12de38 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -404,3 +404,67 @@ such as:
(sha256
(base32
"0r4xnlq7v9khjfcg6gqp7nmrmnw4z1r8bipwdr07png1dcbb8214")))))))
+
+(define-public arm-trusted-firmware-puma-rk3399
+ (let ((base (make-arm-trusted-firmware "rk3399"))
+ ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
+ (commit "d71e6d83612df896774ec4c03d49500312d2c324")
+ (revision "1"))
+ (package
+ (inherit base)
+ (name "arm-trusted-firmware-puma-rk3399")
+ (version (string-append "1.3-" revision "." (string-take commit 7)))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
+
+(define-public rk3399-cortex-m0
+ (package
+ (name "rk3399-cortex-m0")
+ (version "1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name "rk3399-cortex-m0" version))
+ (sha256
+ (base32
+ "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
+ (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
+ (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
+ (description
+ "Cortex-M0 firmware used with the RK3399 to implement
+power-management functionality and helpers (e.g. DRAM frequency
+switching support).\n")
+ (license license:bsd-3)
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (delete 'check)
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
+ (for-each
+ (lambda (file)
+ (install-file file out))
+ mzerofiles))
+ #t))
+ (add-before 'build 'setenv
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "CROSS_COMPILE" "arm-none-eabi-")
+ #t)))))
+ (native-inputs `(
+ ("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
+ ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index 3efff915a..51f9e55ed 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -53,6 +53,7 @@
nintendo-nes-classic-edition-installation-os
novena-installation-os
pine64-plus-installation-os
+ rk3399-puma-installation-os
wandboard-installation-os))
;;; Commentary:
@@ -453,6 +454,11 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
"/dev/mmcblk0" ; SD card storage
"ttyS0"))
+(define rk3399-puma-installation-os
+ (embedded-installation-os u-boot-puma-rk3399-bootloader
+ "/dev/mmcblk0" ; SD card storage
+ "ttyS0"))
+
(define wandboard-installation-os
(embedded-installation-os u-boot-wandboard-bootloader
"/dev/mmcblk0" ; SD card storage
--
2.11.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#31599] [PATCH] system: Add u-boot-puma-rk3399.
2018-05-25 22:29 [bug#31599] [PATCH] system: Add u-boot-puma-rk3399 Vagrant Cascadian
@ 2018-05-26 7:19 ` Danny Milosavljevic
2018-05-26 16:46 ` Vagrant Cascadian
0 siblings, 1 reply; 7+ messages in thread
From: Danny Milosavljevic @ 2018-05-26 7:19 UTC (permalink / raw)
To: Vagrant Cascadian; +Cc: 31599
[-- Attachment #1: Type: text/plain, Size: 1985 bytes --]
Hi,
On Fri, 25 May 2018 15:29:40 -0700
Vagrant Cascadian <vagrant@debian.org> wrote:
> Tested running on a puma-rk3399-haikou board running GuixSD!
Cool!
> [fdtfile u-boot variable needs to manually be set at boot]
>This is likely to be fixed in future u-boot versions.
Does upstream know about it?
>+ ;; The u-boot.itb is not built by default
??? How can that be? Isn't it required for booting?
I checked the source code - apparently they use mkimage
to build the itb from the its. So now we are using two
"different" mkimage tools. OK I guess - but weird.
All they'd have to do is add
ALL-y += u-boot.itb
to the Makefile. Does upstream know about it?
>+ (zero? (apply system* "make" `(,@make-flags ,"u-boot.itb")))))
Please use "invoke". It's shorthand for (zero? (system* ...)) but it also
raises an exception on error.
That's easier to maintain (when people add a second invocation they
don't have to add "(and ...)").
So here it would be (apply invoke "make" `(,@make-flags ,"u-boot.itb")))) .
>(add-after 'unpack 'set-environment
>+ (lambda* (#:key inputs #:allow-other-keys)
>+ ;; Need to copy the firmware into u-boot build
>+ ;; directory.
>+ (copy-file (string-append (assoc-ref inputs "firmware")
>+ "/bl31.bin") "bl31-rk3399.bin")
>+ (copy-file (string-append (assoc-ref inputs "firmware-m0")
>+ "/rk3399m0.bin") "rk3399m0.bin")))
Please end this phase with "#t".
>+ (version (string-append "1.3-" revision "." (string-take commit 7)))
Please use (git-version "1.3" revision commit) instead of
(string-append "1.3-" revision "." (string-take commit 7))
> [...]
Sometimes the indentation you used is slightly off, like this:
`((foo)
(bar))
It should be
`((foo)
(bar))
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#31599] [PATCH] system: Add u-boot-puma-rk3399.
2018-05-26 7:19 ` Danny Milosavljevic
@ 2018-05-26 16:46 ` Vagrant Cascadian
2018-05-26 17:12 ` Danny Milosavljevic
0 siblings, 1 reply; 7+ messages in thread
From: Vagrant Cascadian @ 2018-05-26 16:46 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 31599
[-- Attachment #1: Type: text/plain, Size: 3072 bytes --]
On 2018-05-26, Danny Milosavljevic wrote:
> On Fri, 25 May 2018 15:29:40 -0700
> Vagrant Cascadian <vagrant@debian.org> wrote:
>> [fdtfile u-boot variable needs to manually be set at boot]
>>This is likely to be fixed in future u-boot versions.
>
> Does upstream know about it?
A couple hours after I submitted this a patch was submitted upstream
that fixes the issue:
https://patchwork.ozlabs.org/patch/920785/
>>+ ;; The u-boot.itb is not built by default
>
> ??? How can that be? Isn't it required for booting?
There may be other implementations of boot firmware that consume the
various parts of u-boot and don't use u-boot.itb.
The Debian u-boot package, for example, does not yet have
arm-trusted-frimware or the cortex-m0 firmware available, so it needs to
build without it and let the user build the other components and
manually construct the u-boot.itb.
> I checked the source code - apparently they use mkimage
> to build the itb from the its. So now we are using two
> "different" mkimage tools. OK I guess - but weird.
An earlier patch I did added the tools directory to PATH and used the
in-tree mkimage, but I opted for using the mkimage from u-boot-tools
when I submitted. Wasn't sure which was better.
> All they'd have to do is add
>
> ALL-y += u-boot.itb
>
> to the Makefile. Does upstream know about it?
I'll bring the issue upstream; it may need to be added conditionally, as
not all u-boot targets support generating a u-boot.itb.
>>+ (zero? (apply system* "make" `(,@make-flags ,"u-boot.itb")))))
>
> Please use "invoke". It's shorthand for (zero? (system* ...)) but it also
> raises an exception on error.
> That's easier to maintain (when people add a second invocation they
> don't have to add "(and ...)").
>
> So here it would be (apply invoke "make" `(,@make-flags ,"u-boot.itb")))) .
Ok.
>>(add-after 'unpack 'set-environment
>>+ (lambda* (#:key inputs #:allow-other-keys)
>>+ ;; Need to copy the firmware into u-boot build
>>+ ;; directory.
>>+ (copy-file (string-append (assoc-ref inputs "firmware")
>>+ "/bl31.bin") "bl31-rk3399.bin")
>>+ (copy-file (string-append (assoc-ref inputs "firmware-m0")
>>+ "/rk3399m0.bin") "rk3399m0.bin")))
>
> Please end this phase with "#t".
Please forgive my ignorance, but I'm not sure where it belongs or even
why... just a rank beginner with this. :)
>>+ (version (string-append "1.3-" revision "." (string-take commit 7)))
>
> Please use (git-version "1.3" revision commit) instead of
>
> (string-append "1.3-" revision "." (string-take commit 7))
Will do.
> Sometimes the indentation you used is slightly off, like this:
>
> `((foo)
> (bar))
>
> It should be
>
> `((foo)
> (bar))
Will try to sort those out...
Thanks for the review!
live well,
vagrant
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#31599] [PATCH] system: Add u-boot-puma-rk3399.
2018-05-26 16:46 ` Vagrant Cascadian
@ 2018-05-26 17:12 ` Danny Milosavljevic
2018-05-29 4:10 ` [bug#31599] [PATCH v2] " Vagrant Cascadian
0 siblings, 1 reply; 7+ messages in thread
From: Danny Milosavljevic @ 2018-05-26 17:12 UTC (permalink / raw)
To: Vagrant Cascadian; +Cc: 31599
[-- Attachment #1: Type: text/plain, Size: 3420 bytes --]
> A couple hours after I submitted this a patch was submitted upstream
> that fixes the issue:
>
> https://patchwork.ozlabs.org/patch/920785/
Good.
> >>+ ;; The u-boot.itb is not built by default
> >
> > ??? How can that be? Isn't it required for booting?
>
> There may be other implementations of boot firmware that consume the
> various parts of u-boot and don't use u-boot.itb.
>
> The Debian u-boot package, for example, does not yet have
> arm-trusted-frimware or the cortex-m0 firmware available, so it needs to
> build without it and let the user build the other components and
> manually construct the u-boot.itb.
I see. OK, I'm fine with building u-boot.itb manually for now. I just asked
because when we aren't careful we get into whack-a-mole quickly.
(There's a huge amount of ARM boards and we shouldn't do the u-boot maintainer's
job for them. It's more work *and* eventually we'd diverge from each other)
> An earlier patch I did added the tools directory to PATH and used the
> in-tree mkimage, but I opted for using the mkimage from u-boot-tools
> when I submitted. Wasn't sure which was better.
Right now, they are the same because u-boot-tools derives from u-boot in Guix.
That said, for the sake of modularization I'd use the package-local mkimage
if there is one. One reason is that there are weird u-boot forks for some
boards (mainline u-boot doesn't work for them). These might have local
quirks in mkimage and it's better to track these quirks when building that
u-boot.
(As long as we know the above in the back of our heads as a potential source
of problems it doesn't matter much which mkimage we use in practice)
u-boot-tools is meant for the end user. I didn't intend it to be used
by the u-boots themselves (not that it's bad--but it's redundant right now).
> >>(add-after 'unpack 'set-environment
> >>+ (lambda* (#:key inputs #:allow-other-keys)
> >>+ ;; Need to copy the firmware into u-boot build
> >>+ ;; directory.
> >>+ (copy-file (string-append (assoc-ref inputs "firmware")
> >>+ "/bl31.bin") "bl31-rk3399.bin")
> >>+ (copy-file (string-append (assoc-ref inputs "firmware-m0")
> >>+ "/rk3399m0.bin") "rk3399m0.bin")))
> >
> > Please end this phase with "#t".
> Please forgive my ignorance, but I'm not sure where it belongs or even
> why... just a rank beginner with this. :)
Earlier guile didn't support exceptions--so phases have to return a boolean
(whether the phase succeeded or not).
In a lambda, the return value is the value of the last expression.
There's an effort in core-updates to get it all up-to-speed so that these
all actually return a boolean--and long term we'd get rid of this requirement.
Some procedures are written especially for phases ("invoke" is, for example)
and do what you'd expect (return #t if OK, otherwise raise exception).
Other procedures you have to be careful what they actually return.
In this case, copy-file's documentation[1] states "The return value is
unspecified" (that implies that error handling is via exceptions).
The unspecified return value is clearly not good.
[1] https://www.gnu.org/software/guile/manual/html_node/File-System.html
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#31599] [PATCH v2] system: Add u-boot-puma-rk3399.
2018-05-26 17:12 ` Danny Milosavljevic
@ 2018-05-29 4:10 ` Vagrant Cascadian
2018-05-29 8:51 ` bug#31599: " Danny Milosavljevic
0 siblings, 1 reply; 7+ messages in thread
From: Vagrant Cascadian @ 2018-05-29 4:10 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 31599
[-- Attachment #1.1: Type: text/plain, Size: 436 bytes --]
Thanks for the review!
I think the attached patch addresses the issues raised:
* Fix several indentation and numerous whitespace issues.
* u-boot-puma-rk3399: Drop use of u-boot-tools as an input, calling
./tools/mkimage directly.
* arm-trusted-firmware-puma-rk3399: Use git-version to set version.
* u-boot-puma-rk3399: Complete block using #t
* u-boot-puma-rk3399: Use "apply invoke" to make system calls.
live well,
vagrant
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-system-Add-u-boot-puma-rk3399.patch --]
[-- Type: text/x-diff, Size: 8694 bytes --]
From 23bcb1e653f771aae3781ce665728283c3076b76 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
Date: Mon, 28 May 2018 18:28:13 -0700
Subject: [PATCH 1/1] system: Add u-boot-puma-rk3399.
* gnu/packages/bootloaders.scm (u-boot-puma-rk3399): New variable.
(make-u-boot-package)[arguments]: Add '.rksd' files to the files installed
during custom 'install phase.
* gnu/bootloader/u-boot.scm (u-boot-puma-rk3399-bootloader):
New exported variable.
* gnu/system/install.scm (rk3399-puma-installation-os):
New exported variable.
* gnu/packages/firmware.scm (arm-trusted-firmware-puma-rk3399): New variable.
(rk3399-cortex-m0): New variable.
---
gnu/bootloader/u-boot.scm | 16 +++++++++++
gnu/packages/bootloaders.scm | 33 ++++++++++++++++++++++-
gnu/packages/firmware.scm | 63 ++++++++++++++++++++++++++++++++++++++++++++
gnu/system/install.scm | 6 +++++
4 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index ea0f67b3c..52b38dd1a 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -37,6 +37,7 @@
u-boot-nintendo-nes-classic-edition-bootloader
u-boot-novena-bootloader
u-boot-pine64-plus-bootloader
+ u-boot-puma-rk3399-bootloader
u-boot-wandboard-bootloader))
(define install-u-boot
@@ -84,6 +85,15 @@
(write-file-on-device u-boot (stat:size (stat u-boot))
device (* 69 1024)))))
+(define install-puma-rk3399-u-boot
+ #~(lambda (bootloader device mount-point)
+ (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
+ (u-boot (string-append bootloader "/libexec/u-boot.itb")))
+ (write-file-on-device spl (stat:size (stat spl))
+ device (* 64 512))
+ (write-file-on-device u-boot (stat:size (stat u-boot))
+ device (* 512 512)))))
+
\f
;;;
@@ -162,3 +172,9 @@
(bootloader
(inherit u-boot-allwinner64-bootloader)
(package u-boot-pine64-plus)))
+
+(define u-boot-puma-rk3399-bootloader
+ (bootloader
+ (inherit u-boot-bootloader)
+ (package u-boot-puma-rk3399)
+ (installer install-puma-rk3399-u-boot)))
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 2dd530125..6ff26d0dc 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -489,7 +489,7 @@ board-independent tools.")))
(let* ((out (assoc-ref outputs "out"))
(libexec (string-append out "/libexec"))
(uboot-files (append
- (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb)$")
+ (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$")
(find-files "." "^(MLO|SPL)$"))))
(mkdir-p libexec)
(install-file ".config" libexec)
@@ -560,6 +560,37 @@ board-independent tools.")))
(define-public u-boot-cubieboard
(make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
+(define-public u-boot-puma-rk3399
+ (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
+ (package
+ (inherit base)
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'unpack 'set-environment
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Need to copy the firmware into u-boot build
+ ;; directory.
+ (copy-file (string-append (assoc-ref inputs "firmware")
+ "/bl31.bin") "bl31-rk3399.bin")
+ (copy-file (string-append (assoc-ref inputs "firmware-m0")
+ "/rk3399m0.bin") "rk3399m0.bin")
+ #t))
+ (add-after 'build 'builditb
+ (lambda* (#:key make-flags #:allow-other-keys)
+ ;; The u-boot.itb is not built by default
+ (apply invoke "make" `(,@make-flags ,"u-boot.itb"))))
+ (add-after 'builditb 'buildrksd
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Build rockchip SD card images.
+ (apply invoke "./tools/mkimage"
+ `(,"-T" ,"rksd" ,"-n" ,"rk3399" ,"-d" ,"spl/u-boot-spl.bin" ,"u-boot-spl.rksd"))))))))
+ (native-inputs
+ `(("firmware" ,arm-trusted-firmware-puma-rk3399)
+ ("firmware-m0" ,rk3399-cortex-m0)
+ ,@(package-native-inputs base))))))
+
(define-public vboot-utils
(package
(name "vboot-utils")
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 9e91ceca4..986e1d621 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -404,3 +404,66 @@ such as:
(sha256
(base32
"0r4xnlq7v9khjfcg6gqp7nmrmnw4z1r8bipwdr07png1dcbb8214")))))))
+
+(define-public arm-trusted-firmware-puma-rk3399
+ (let ((base (make-arm-trusted-firmware "rk3399"))
+ ;; Vendor's arm trusted firmware branch hasn't been upstreamed yet.
+ (commit "d71e6d83612df896774ec4c03d49500312d2c324")
+ (revision "1"))
+ (package
+ (inherit base)
+ (name "arm-trusted-firmware-puma-rk3399")
+ (version (git-version "1.3" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.theobroma-systems.com/arm-trusted-firmware.git")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0vqhwqqh8h9qlkpybg2v94911091c1418bc4pnzq5fd7zf0fjkf8")))))))
+
+(define-public rk3399-cortex-m0
+ (package
+ (name "rk3399-cortex-m0")
+ (version "1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.theobroma-systems.com/rk3399-cortex-m0.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name "rk3399-cortex-m0" version))
+ (sha256
+ (base32
+ "02wz1vkf4j3zc8rx289z76xhrf71jhb2p05lvmygky393a9gjh9w"))))
+ (home-page "https://git.theobroma-systems.com/rk3399-cortex-m0.git/about/")
+ (synopsis "PMU Cortex M0 firmware for RK3399 Q7 (Puma)")
+ (description
+ "Cortex-M0 firmware used with the RK3399 to implement
+power-management functionality and helpers (e.g. DRAM frequency
+switching support).\n")
+ (license license:bsd-3)
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (delete 'check)
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (mzerofiles (find-files "." "rk3399m0.(elf|bin)$")))
+ (for-each
+ (lambda (file)
+ (install-file file out))
+ mzerofiles))
+ #t))
+ (add-before 'build 'setenv
+ (lambda* (#:key inputs #:allow-other-keys)
+ (setenv "CROSS_COMPILE" "arm-none-eabi-")
+ #t)))))
+ (native-inputs `(("cross-gcc" ,(cross-gcc "arm-none-eabi" #:xgcc gcc-7))
+ ("cross-binutils" ,(cross-binutils "arm-none-eabi"))))))
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index acc9f15e0..35f4ba9c2 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -53,6 +53,7 @@
nintendo-nes-classic-edition-installation-os
novena-installation-os
pine64-plus-installation-os
+ rk3399-puma-installation-os
wandboard-installation-os))
;;; Commentary:
@@ -451,6 +452,11 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
"/dev/mmcblk0" ; SD card storage
"ttyS0"))
+(define rk3399-puma-installation-os
+ (embedded-installation-os u-boot-puma-rk3399-bootloader
+ "/dev/mmcblk0" ; SD card storage
+ "ttyS0"))
+
(define wandboard-installation-os
(embedded-installation-os u-boot-wandboard-bootloader
"/dev/mmcblk0" ; SD card storage
--
2.11.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#31599: [PATCH v2] system: Add u-boot-puma-rk3399.
2018-05-29 4:10 ` [bug#31599] [PATCH v2] " Vagrant Cascadian
@ 2018-05-29 8:51 ` Danny Milosavljevic
2018-06-17 12:15 ` [bug#31599] " Danny Milosavljevic
0 siblings, 1 reply; 7+ messages in thread
From: Danny Milosavljevic @ 2018-05-29 8:51 UTC (permalink / raw)
To: Vagrant Cascadian; +Cc: 31599-done
[-- Attachment #1: Type: text/plain, Size: 573 bytes --]
On Mon, 28 May 2018 21:10:15 -0700
Vagrant Cascadian <vagrant@debian.org> wrote:
> + (apply invoke "./tools/mkimage"
> + `(,"-T" ,"rksd" ,"-n" ,"rk3399" ,"-d" ,"spl/u-boot-spl.bin" ,"u-boot-spl.rksd")
Heh, this is neutral. So
(invoke "./tools/mkimage" "-T" "rksd" "-n" "rk3399" "-d" "spl/u-boot-spl.bin" "u-boot-spl.rksd")
works fine. So I've changed it to that.
I've pushed it to guix master.
Let's see what our aarch64 machines say about the cross-compilation (probably doesn't work yet - but meh).
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#31599] [PATCH v2] system: Add u-boot-puma-rk3399.
2018-05-29 8:51 ` bug#31599: " Danny Milosavljevic
@ 2018-06-17 12:15 ` Danny Milosavljevic
0 siblings, 0 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2018-06-17 12:15 UTC (permalink / raw)
To: Vagrant Cascadian; +Cc: 31599-done
[-- Attachment #1.1: Type: text/plain, Size: 972 bytes --]
Hi Vagrant,
could you send a patch adding puma-rk3399 to buildroot?
I'm thinking of using buildroot for the u-boot installation in GuixSD
instead of our DIY installers (in the long term).
Puma-rk3399 is one of the few u-boots that isn't in buildroot yet.
I've attached an example patch adding Bananapi M2 Ultra.
In order to build this example:
$ git clone git://git.buildroot.net/buildroot
$ cd buildroot
$ patch -p1 < .../0001-Added-support-for-Sinovoip-BananaPi-M2-Ultra-board.patch
$ make bananapi_m2_ultra_defconfig
$ make # takes extremely long and takes lots of space
I'm planning to copy genimage.cfg from buildroot - not everything.
That would enable us to have a generic install-u-boot.
Buildroot: https://buildroot.org/
Git web: https://git.busybox.net/buildroot/
Git: git clone git://git.buildroot.net/buildroot
Git: git clone https://git.buildroot.net/buildroot
Patches: http://lists.buildroot.org/mailman/listinfo/buildroot
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Added-support-for-Sinovoip-BananaPi-M2-Ultra-board.patch --]
[-- Type: text/x-patch, Size: 3193 bytes --]
From 95be66f410ea89a72c77695dacce938edf97e9d0 Mon Sep 17 00:00:00 2001
From: Danny Milosavljevic <dannym@scratchpost.org>
Date: Sat, 16 Jun 2018 23:47:35 +0200
Subject: [PATCH 1/1] Added support for Sinovoip BananaPi M2 Ultra board.
Tags: patch
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
---
board/sinovoip/m2-ultra/boot.cmd | 7 +++++++
board/sinovoip/m2-ultra/genimage.cfg | 33 +++++++++++++++++++++++++++++++++
configs/bananapi_m2_ultra_defconfig | 27 +++++++++++++++++++++++++++
3 files changed, 67 insertions(+)
create mode 100644 board/sinovoip/m2-ultra/boot.cmd
create mode 100644 board/sinovoip/m2-ultra/genimage.cfg
create mode 100644 configs/bananapi_m2_ultra_defconfig
diff --git a/board/sinovoip/m2-ultra/boot.cmd b/board/sinovoip/m2-ultra/boot.cmd
new file mode 100644
index 0000000000..9c24eabff6
--- /dev/null
+++ b/board/sinovoip/m2-ultra/boot.cmd
@@ -0,0 +1,7 @@
+setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait
+
+mmc dev 0
+fatload mmc 0 $kernel_addr_r zImage
+fatload mmc 0 $fdt_addr_r sun8i-r40-bananapi-m2-ultra.dtb
+
+bootz $kernel_addr_r - $fdt_addr_r
diff --git a/board/sinovoip/m2-ultra/genimage.cfg b/board/sinovoip/m2-ultra/genimage.cfg
new file mode 100644
index 0000000000..675253af23
--- /dev/null
+++ b/board/sinovoip/m2-ultra/genimage.cfg
@@ -0,0 +1,33 @@
+image boot.vfat {
+ vfat {
+ files = {
+ "zImage",
+ "sun8i-r40-bananapi-m2-ultra.dtb",
+ "boot.scr"
+ }
+ }
+ size = 64M
+}
+
+image sdcard.img {
+ hdimage {
+ }
+
+ partition u-boot {
+ in-partition-table = "no"
+ image = "u-boot-sunxi-with-spl.bin"
+ offset = 8192
+ size = 1040384 # 1MB - 8192
+ }
+
+ partition boot {
+ partition-type = 0xC
+ bootable = "true"
+ image = "boot.vfat"
+ }
+
+ partition rootfs {
+ partition-type = 0x83
+ image = "rootfs.ext4"
+ }
+}
diff --git a/configs/bananapi_m2_ultra_defconfig b/configs/bananapi_m2_ultra_defconfig
new file mode 100644
index 0000000000..a86d5923c6
--- /dev/null
+++ b/configs/bananapi_m2_ultra_defconfig
@@ -0,0 +1,27 @@
+BR2_arm=y
+BR2_cortex_a7=y
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y
+BR2_TARGET_GENERIC_ISSUE="Welcome to Bananapi M2 Ultra"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/sinovoip/m2-ultra/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=n
+BR2_LINUX_KERNEL_DEFCONFIG="sunxi"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="sun8i-r40-bananapi-m2-ultra"
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION=n
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="Bananapi_M2_Ultra"
+BR2_TARGET_UBOOT_NEEDS_DTC=y
+BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y
+BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
+BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-sunxi-with-spl.bin"
+BR2_TARGET_UBOOT_BOOT_SCRIPT=y
+BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE="board/sinovoip/m2-ultra/boot.cmd"
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-06-17 12:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-25 22:29 [bug#31599] [PATCH] system: Add u-boot-puma-rk3399 Vagrant Cascadian
2018-05-26 7:19 ` Danny Milosavljevic
2018-05-26 16:46 ` Vagrant Cascadian
2018-05-26 17:12 ` Danny Milosavljevic
2018-05-29 4:10 ` [bug#31599] [PATCH v2] " Vagrant Cascadian
2018-05-29 8:51 ` bug#31599: " Danny Milosavljevic
2018-06-17 12:15 ` [bug#31599] " Danny Milosavljevic
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).