(define-module (zynqmp packages bootloader) #:use-module (zynqmp packages firmware) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix gexp) #:use-module (guix utils) #:use-module (guix git-download) #:use-module (guix build-system gnu) #:use-module (gnu packages) #:use-module (gnu packages tls) #:use-module (gnu packages bootloaders) #:use-module (gnu packages texinfo) #:use-module (gnu packages cross-base) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages firmware) #:export (u-boot-for-kr260)) (define (search-patch patch) (parameterize ((%patch-path (map (lambda (directory) (string-append directory "/zynqmp/packages/patches")) %load-path))) ((@ (gnu packages) search-patch) patch))) (define-syntax-rule (search-patches file-name ...) "Return the list of absolute file names corresponding to each FILE-NAME found in %PATCH-PATH." (list (search-patch file-name) ...)) ;; (define* (u-boot-for-kria #:configs configs)) (define u-boot-for-kr260 (let ((base (make-u-boot-package "xilinx_zynqmp_kria" "aarch64-linux-gnu" #:configs '("CONFIG_SPL_FS_FAT=y" "CONFIG_SPL_MMC=y" "CONFIG_SPL_FS_LOAD_PAYLOAD_NAME=\"u-boot.itb\"" "CONFIG_PMUFW_INIT_FILE=\"./tmp/pmufw.bin\"" "CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE=\"./tmp/pm_cfg_obj.bin\""))) ;; TODO ... (pmcfg-obj-c (local-file "boards/kr260/pm_cfg_obj.c"))) (package (inherit base) (name "u-boot-for-kr260") (version "2024.01_2024.2") (source (origin ;; (inherit (package-source base)) (method git-fetch) (uri (git-reference (url "https://github.com/Xilinx/u-boot-xlnx") (commit "xlnx_rebase_v2024.01_2024.2"))) (file-name (git-file-name name version)) (sha256 (base32 "1gqcriiy9zglff0f88j6pin230yc10jfysylpga0v0pgj1pazv59")) (patches (append (search-patches "uboot/0001-kbuild-cherry-pick-kbuild-fdtoverlay-changes-from-linux.patch" "uboot/0002-arm64-zynqmp-remove-overlays-and-add-new-dtb-entries-for-zynqmp.patch" "uboot/0003-binman-add-option-for-pointing-to-separate-description.patch" "uboot/0004-arm64-zynqmp-describe-empty-binman-node.patch" "uboot/0005-arm64-zynqmp-add-binman-description-for-som.patch" "uboot/0006-arm64-zynqmp-generate-u-boot.itb-and-qspi-image-via-binman.patch") (origin-patches (package-source base)))))) (native-inputs (modify-inputs (package-native-inputs base) (append openssl))) (inputs (modify-inputs (package-inputs base) (append arm-trusted-firmware-for-zynqmp) (append xilinx-zynqmp-pmufw))) (arguments (substitute-keyword-arguments (package-arguments base) ((#:phases phases #f) #~(modify-phases #$phases (delete 'disable-tools-libcrypto) (add-before 'build 'pmufw-setup (lambda* (#:key native-inputs inputs #:allow-other-keys) (mkdir-p "tmp") (let ((pmufw-elf (search-input-file inputs "pmufw.elf")) (target "tmp/pmufw.bin")) (invoke "objcopy" "-O" "binary" "-I" "elf32-little" pmufw-elf target)) (let ((pmufw-cfg #$pmcfg-obj-c) (target "tmp/pm_cfg_obj.bin")) (invoke (string-append (getcwd) "/tools/zynqmp_pm_cfg_obj_convert.py") pmufw-cfg target)))) ;; Good for booting via JTAG (add-after 'install 'install-uboot-spl-elf (lambda _ (install-file "spl/u-boot-spl" (string-append #$output "/libexec/spl")))) (add-after 'unpack 'set-environment (lambda* (#:key native-inputs inputs #:allow-other-keys) (setenv "BL31" (search-input-file inputs "bl31.bin")))))) ((#:make-flags flags '()) #~(cons* "DEVICE_TREE=zynqmp-sm-k26-revA" #$flags)))))))