gxlimg icon indicating copy to clipboard operation
gxlimg copied to clipboard

Build failure to create final boot image

Open phodina opened this issue 3 years ago • 0 comments

Hi @repk , thanks for the tools to package u-boot in libre way on recent Linux.

However, following the instructions in the readme I get the following error when attempting to make the final boot image:

command "gxlimg" "-t" "fip" "--bl2" "fip/bl2.bin.enc" "--bl30" "fip/bl30.bin.enc" "--bl31" "fip/bl31.img.enc" "--bl33" "u-boot.bin.enc" "gxl-boot.bin" failed with status 234

I'm attempting to make package definition for the u-boot on Amlogic SoC s905x for GNU Guix. Here's the definition:

 (define (make-u-boot-amlogic-package board)
  (let ((base (make-u-boot-package
               board "aarch64-linux-gnu" #:append-description %u-boot-amlogic-description-64-bit))
         (commit "e0638f1d09b9e9caead4e3909e7dc8aaa41febe1")
		 (revision "1"))
    (package
      (inherit base)
      (version "202301")
      (source (origin
                (method url-fetch)
                (uri (string-append
				"https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/archive/"
				commit "/u-boot-amlogic-" commit ".tar.gz"))
                (patches (search-patches
                     "u-boot-disable-OpenSSL.patch"))
                (sha256
                 (base32
                  "1idgh8qn073p50pi2fan65nzxj7j3r0pq797zbdbrb7gs555b6zy"))
				))
    (inputs
     (modify-inputs (package-inputs base)
       (append gxlimg linux-libre-headers)))
      (arguments
       (substitute-keyword-arguments (package-arguments base)
         ((#:phases phases)
          #~(modify-phases #$phases
		     (add-after 'unpack 'copy-defconfig
			  (lambda* (#:key inputs #:allow-other-keys)
				 (let ((bl2-dl #$(origin
              (method url-fetch)
              (uri
				 "https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/bl2.bin")
              (sha256
               (base32
                "19pv7v904s66addhxwk9mzybdv26dpkygxc7075xvaqiq2pl9h3b"))))
				 (bl30-dl #$(origin
              (method url-fetch)
              (uri
				 "https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/bl30.bin")
              (sha256
               (base32
                "0839nrfcbkj64nyn3ji7f1j9xa2p1apd3vn7qvpxyfj884ihspiv"))))
				 (bl31-dl #$(origin
              (method url-fetch)
              (uri
				 "https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/bl31.img")
              (sha256
               (base32
                "0gkdcpn9rvglcpb1h76pb13d718g1vi8qviqzwj8c7fv0n6xs149")))))
			   (substitute* "Makefile"
			   ((".bin.pwd") (search-input-file inputs "bin/pwd"))
			   ((".bin.bash") (search-input-file inputs "bin/bash")))
			   (install-file bl2-dl "fip")
			   (install-file bl30-dl "fip")
			   (install-file bl31-dl "fip")
			   (rename-file (string-append "fip/" (basename bl2-dl))
			   "fip/bl2.bin")
			   (rename-file (string-append "fip/" (basename bl30-dl))
			   "fip/bl30.bin")
			   (rename-file (string-append "fip/" (basename bl31-dl))
			   "fip/bl31.img")
			   )))
             (add-before 'install 'package
               (lambda* (#:key native-inputs inputs #:allow-other-keys)
                 (let ((fip (string-append (getcwd) "/fip"))
				       (gxlimg (search-input-file inputs "/bin/gxlimg")))
				 ;; Sign BL2
				 (invoke "gxlimg" "-t" "bl2" "-s" "fip/bl2.bin" "fip/bl2.bin.enc")


  ;; Encrypt BL3*
  (invoke "gxlimg" "-t" "bl3x" "-c" "fip/bl30.bin" "fip/bl30.bin.enc")
   (invoke "gxlimg" "-t" "bl3x" "-c" "fip/bl31.img" "fip/bl31.img.enc")
   ;; Encrypt u-boot
   (invoke "gxlimg" "-t" "bl3x" "-c" "u-boot.bin" "u-boot.bin.enc")
   ;; Create the final boot image
   (invoke "gxlimg" "-t" "fip" "--bl2" "fip/bl2.bin.enc" "--bl30"
   "fip/bl30.bin.enc"
     "--bl31" "fip/bl31.img.enc" "--bl33" "u-boot.bin.enc" "gxl-boot.bin")
	 (delete-file-recursively "fip")
	 ;; Create USB boot files
	 (invoke "dd" "if=gxl-boot.bin" "of=u-boot.bin.usb.bl2" "bs=49152" "count=1")
	 (invoke "dd" "if=gxl-boot.bin" "of=u-boot.bin.usb.tpl" "skip=49152" "bs=1")
;; Install files
   (install-file "u-boot.bin.usb.bl2" (string-append #$output "/libexec"))
   (install-file "u-boot.bin.usb.tpl" (string-append #$output "/libexec"))
   (install-file "gxl-boot.bin" (string-append #$output "/libexec"))
   ))))))))))

The important parts are https://source.denx.de/u-boot/custodians/u-boot-amlogic as u-boot source with commit e0638f1d09b9e9caead4e3909e7dc8aaa41febe1. This builds okay without any additional steps.

But I wanted to have already the bootloader in the format the HW expects it so I added additional stage to download the binaries from https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/* (bl2.bin, bl30.bin and bl31.img).

Then I follow the instructions and run the commands you listed.

Any idea what's wrong?

phodina avatar Dec 31 '22 09:12 phodina