From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUWub-0005U8-Lw for guix-patches@gnu.org; Sun, 17 Jun 2018 08:36:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUWuY-0003Kq-G1 for guix-patches@gnu.org; Sun, 17 Jun 2018 08:36:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:44751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUWuY-0003Kk-Aq for guix-patches@gnu.org; Sun, 17 Jun 2018 08:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fUWuY-0005rw-4a for guix-patches@gnu.org; Sun, 17 Jun 2018 08:36:02 -0400 Subject: [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader. Resent-Message-ID: Date: Sun, 17 Jun 2018 14:35:17 +0200 From: Danny Milosavljevic Message-ID: <20180617143517.433a5ce0@scratchpost.org> In-Reply-To: <20180617022855.671a3ef6@scratchpost.org> References: <20180511143515.23435-1-dannym@scratchpost.org> <20180511143652.26935-1-dannym@scratchpost.org> <20180511143652.26935-3-dannym@scratchpost.org> <87603rnbi5.fsf@gnu.org> <20180513125925.66a91367@scratchpost.org> <87in7qbppv.fsf@gnu.org> <20180514182953.3d4c4f3c@scratchpost.org> <87r2l8wmjk.fsf@gnu.org> <20180617022855.671a3ef6@scratchpost.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/E0ELjbo9teysEvEuqmEpep7"; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 31416@debbugs.gnu.org --Sig_/E0ELjbo9teysEvEuqmEpep7 Content-Type: multipart/mixed; boundary="MP_/9K0XiqAtfURggO+eM8/Cr+B" --MP_/9K0XiqAtfURggO+eM8/Cr+B Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline v2, with u-boot-without-buildroot fallback, attached. --MP_/9K0XiqAtfURggO+eM8/Cr+B Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=QQ2.patch diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm index 52b38dd1a..4213830cd 100644 --- a/gnu/bootloader/u-boot.scm +++ b/gnu/bootloader/u-boot.scm @@ -110,7 +110,7 @@ (define u-boot-beaglebone-black-bootloader (bootloader (inherit u-boot-bootloader) - (package u-boot-beagle-bone-black) + (package u-boot-beaglebone) (installer install-beaglebone-black-u-boot))) =20 (define u-boot-allwinner-bootloader @@ -136,17 +136,17 @@ (define u-boot-a20-olinuxino-lime-bootloader (bootloader (inherit u-boot-allwinner-bootloader) - (package u-boot-a20-olinuxino-lime))) + (package u-boot-olimex-a20-olinuxino-lime))) =20 (define u-boot-a20-olinuxino-lime2-bootloader (bootloader (inherit u-boot-allwinner-bootloader) - (package u-boot-a20-olinuxino-lime2))) + (package u-boot-olimex-a20-olinuxino-lime2))) =20 (define u-boot-a20-olinuxino-micro-bootloader (bootloader (inherit u-boot-allwinner-bootloader) - (package u-boot-a20-olinuxino-micro))) + (package u-boot-olimex-a20-olinuxino-micro))) =20 (define u-boot-banana-pi-m2-ultra-bootloader (bootloader @@ -156,7 +156,7 @@ (define u-boot-mx6cuboxi-bootloader (bootloader (inherit u-boot-imx-bootloader) - (package u-boot-mx6cuboxi))) + (package u-boot-mx6cubox))) =20 (define u-boot-wandboard-bootloader (bootloader @@ -171,7 +171,7 @@ (define u-boot-pine64-plus-bootloader (bootloader (inherit u-boot-allwinner64-bootloader) - (package u-boot-pine64-plus))) + (package u-boot-pine64))) =20 (define u-boot-puma-rk3399-bootloader (bootloader diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index eb1e433ba..7036c6bbc 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -456,6 +456,26 @@ def test_ctrl_c")) also initializes the boards (RAM etc). This package provides its board-independent tools."))) =20 +(define-public buildroot-minimal + (package + (name "buildroot-minimal") + (version "2018.05") + (source (origin + (method url-fetch) + (uri + (string-append + "https://github.com/buildroot/buildroot/archive/" + version ".tar.gz")) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + "002y07c1q3bx2f37ywq0qaj2f4wfn09dia09khnp7sy6ajz3k7p3")))) + (build-system gnu-build-system) + (synopsis "Generate embedded Linux system images") + (description "@code{buildroot} generates embedded Linux system images.= ") + (home-page "https://github.com/buildroot/buildroot") + (license license:gpl2+))) + (define-public (make-u-boot-package board triplet) "Returns a u-boot package for BOARD cross-compiled for TRIPLET." (let ((same-arch? (if (string-prefix? (%current-system) @@ -472,9 +492,12 @@ board-independent tools."))) `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7)) ("cross-binutils" ,(cross-binutils triplet))) `(("gcc-7" ,gcc-7))) + ("buildroot" ,(package-source buildroot-minimal)) ,@(package-native-inputs u-boot))) (arguments - `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-s= ystem)) + `(#:modules + ((ice-9 ftw) (ice-9 rdelim) (ice-9 regex) (guix build utils) + (guix build gnu-build-system)) #:test-target "test" #:make-flags (list "HOSTCC=3Dgcc" @@ -483,16 +506,94 @@ board-independent tools."))) '())) #:phases (modify-phases %standard-phases + (add-after 'unpack 'unpack-buildroot + (lambda* (#:key inputs outputs #:allow-other-keys) + (invoke "tar" "xf" (assoc-ref inputs "buildroot")) + ((@ (ice-9 match) match) (filter (lambda (name) (string-pre= fix? "buildroot" name)) (scandir ".")) + ((name) (symlink name "buildroot"))) + #t)) (replace 'configure - (lambda* (#:key outputs make-flags #:allow-other-keys) - (let ((config-name (string-append ,board "_defconfig"))) - (if (file-exists? (string-append "configs/" config-name)) - (zero? (apply system* "make" `(,@make-flags ,config-n= ame))) - (begin + (lambda* (#:key outputs make-flags #:allow-other-keys) +;; FIXME move out. +(define (load-u-boot-config port) + "Read the u-boot configuration from PORT and return an alist with the +entries." + (let loop ((line (read-line port))) + (if (eof-object? line) + '() + (let ((match (string-match "^([A-Za-z][^=3D]*)=3D(.*)$" line))) + (if match + (cons (cons (match:substring match 1) + (match:substring match 2)) + (loop (read-line port))) + (loop (read-line port))))))) + + (let* ((buildroot-config-basename + (string-append ,board "_defconfig")) + (buildroot-config-dirname "buildroot/") + (buildroot-config-name + (string-append buildroot-config-dirname "configs/" + buildroot-config-basename)) + (buildroot-config + (if (file-exists? buildroot-config-name) + (call-with-input-file buildroot-config-name loa= d-u-boot-config) + #f))) + (cond + (buildroot-config + (let* ((cfg (lambda (name) + (assoc-ref buildroot-config name))) + (u-boot-config-match + (and=3D> (or (cfg "BR2_TARGET_UBOOT_BOARD_DEF= CONFIG") + (cfg "BR2_TARGET_UBOOT_BOARDNAME")) + (lambda (x) + (string-match "^\"(.*)\"$" x)))) + (u-boot-config-name + (and u-boot-config-match + (match:substring u-boot-config-match 1))) + (BR2_ROOTFS_POST_IMAGE_SCRIPT + (cfg "BR2_ROOTFS_POST_IMAGE_SCRIPT")) + (BR2_ROOTFS_POST_SCRIPT_ARGS + (cfg "BR2_ROOTFS_POST_SCRIPT_ARGS")) + (genimage-config-name + (cond + ;; Prefer genimage.sh parameters. + ((and BR2_ROOTFS_POST_IMAGE_SCRIPT + (string=3D? BR2_ROOTFS_POST_IMAGE_SCRI= PT + "\"support/scripts/genimage.= sh\"") + BR2_ROOTFS_POST_SCRIPT_ARGS) + (and=3D> (string-match "^\"-c (.*)\"$" BR2_= ROOTFS_POST_SCRIPT_ARGS) + (lambda (match) (match:substring mat= ch 1)))) + ;; Fall back to the script directory. + (BR2_ROOTFS_POST_IMAGE_SCRIPT + (and=3D> (string-match "^\"(.*)/[^/]*\"$" B= R2_ROOTFS_POST_IMAGE_SCRIPT) + (lambda (match) (string-append (matc= h:substring match 1) + "/genimag= e.cfg")))) + ;; Fall back to no "genimage.cfg". + (else + #f)))) + (if genimage-config-name + (let ((x (string-append buildroot-config-dirname + genimage-config-name))) + (if (file-exists? x) + (copy-file x "genimage.cfg")))) + (if (not u-boot-config-name) + (error "Cannot build U-Boot for this system.")) + (apply invoke "make" + `(,@make-flags + ,(string-append u-boot-config-name + "_defconfig"))))) + ;; Fall back to U-Boot without installer. + ((file-exists? (string-append "configs/" ,board "_defcon= fig")) + (apply invoke "make" + `(,@make-flags + ,(string-append ,board + "_defconfig")))) + (else + (begin (display "Invalid board name. Valid board names are= :" (current-error-port)) (let ((suffix-len (string-length "_defconfig")) - (entries (scandir "configs"))) + (entries (scandir (dirname buildroot-config-n= ame)))) (for-each (lambda (file-name) (when (string-suffix? "_defconfig" fi= le-name) (format (current-error-port) @@ -500,7 +601,8 @@ board-independent tools."))) (string-drop-right file-name suffix-l= en)))) (sort entries string-ci<))) - #f))))) + (error "Invalid board name ~s." + buildroot-config-basename))))))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) @@ -512,6 +614,10 @@ board-independent tools."))) (install-file ".config" libexec) ;; Useful for "qemu -kernel". (install-file "u-boot" libexec) + + (if (file-exists? "genimage.cfg") + (install-file "genimage.cfg" libexec)) + (for-each (lambda (file) (let ((target-file (string-append libexec "/" file))) @@ -519,17 +625,17 @@ board-independent tools."))) (copy-file file target-file))) uboot-files)))))))))) =20 -(define-public u-boot-vexpress - (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf")) +(define-public u-boot-qemu-arm-vexpress + (make-u-boot-package "qemu_arm_vexpress" "arm-linux-gnueabihf")) =20 -(define-public u-boot-malta - (make-u-boot-package "malta" "mips64el-linux-gnuabi64")) +(define-public u-boot-qemu-mips64el-malta + (make-u-boot-package "qemu_mips64el_malta" "mips64el-linux-gnuabi64")) =20 -(define-public u-boot-beagle-bone-black - (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf")) +(define-public u-boot-beaglebone + (make-u-boot-package "beaglebone" "arm-linux-gnueabihf")) =20 -(define-public u-boot-pine64-plus - (let ((base (make-u-boot-package "pine64_plus" "aarch64-linux-gnu"))) +(define-public u-boot-pine64 + (let ((base (make-u-boot-package "pine64" "aarch64-linux-gnu"))) (package (inherit base) (arguments @@ -550,33 +656,38 @@ board-independent tools."))) `(("firmware" ,arm-trusted-firmware-pine64-plus) ,@(package-native-inputs base)))))) =20 +;; MISSING genimage.cfg (define-public u-boot-banana-pi-m2-ultra (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf")) =20 -(define-public u-boot-a20-olinuxino-lime - (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf")) +(define-public u-boot-olimex-a20-olinuxino-lime + (make-u-boot-package "olimex_a20_olinuxino_lime" "arm-linux-gnueabihf")) =20 -(define-public u-boot-a20-olinuxino-lime2 - (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf")) +(define-public u-boot-olimex-a20-olinuxino-lime2 + (make-u-boot-package "olimex_a20_olinuxino_lime2" "arm-linux-gnueabihf")) =20 -(define-public u-boot-a20-olinuxino-micro - (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf")) +(define-public u-boot-olimex-a20-olinuxino-micro + (make-u-boot-package "olimex_a20_olinuxino_micro" "arm-linux-gnueabihf")) =20 +;; MISSING genimage.cfg (define-public u-boot-nintendo-nes-classic-edition (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf= ")) =20 (define-public u-boot-wandboard (make-u-boot-package "wandboard" "arm-linux-gnueabihf")) =20 -(define-public u-boot-mx6cuboxi - (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf")) +(define-public u-boot-mx6cubox + (make-u-boot-package "mx6cubox" "arm-linux-gnueabihf")) =20 +;; MISSING genimage.cfg (define-public u-boot-novena (make-u-boot-package "novena" "arm-linux-gnueabihf")) =20 +;; MISSING genimage.cfg (define-public u-boot-cubieboard (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf")) =20 +;; MISSING genimage.cfg (define-public u-boot-puma-rk3399 (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu"))) (package --MP_/9K0XiqAtfURggO+eM8/Cr+B-- --Sig_/E0ELjbo9teysEvEuqmEpep7 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlsmVYUACgkQ5xo1VCww uqVCKQf+JCFdaA+XuUnHIKhXGRD9xRCBrijMoUaZpYG84/UEg/y0BIteURCtPtqE frhotuhn17aeuJmvJCvT7zQ5TNRZ5zx9dbTTqbatn3VD3K3bOzf5LaDlFMh6T4lm xEi4R4Idmyxe/jPyoRciVFwoX4E/86gWM+oOc01fiSbzUwskbM6kB46JVA3fjDfv gPEOifdOt4f4gNXr6aNxgxEb4F0Yv0RP81ECFoho1ZUzp+pz5uHjPr3TxRF6GI33 H9E/8dD6SedKU1CrjVZmiHrqc65H0yX/7F98aAjNTGS8/zJkX5YZHARH3efqnwSK y1IuV55tD4zUt78huPVU+DED8rpf7A== =7WiX -----END PGP SIGNATURE----- --Sig_/E0ELjbo9teysEvEuqmEpep7--