(define-module (zynqmp packages microblaze) #:use-module (zynqmp packages microblaze) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix memoization) #:use-module (guix download) #:use-module (guix build utils) #:use-module (guix gexp) #:use-module (guix utils) #:use-module (guix git-download) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #: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) #:use-module (zynqmp patches) #:export (binutils-2.43 microblazeel-xilinx-elf-gcc microblazeel-xilinx-elf-newlib microblazeel-xilinx-elf-toolchain)) (define binutils-2.43 (package (inherit binutils) (name "binutils") (version "2.43") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/binutils/binutils-" version ".tar.bz2")) (sha256 (base32 "0l77cprf7d7zff5ygrdlrcy5jxrjqnw81c27mahs9xqdgw3w7lzy")) (patches (search-patches "binutils-loongson-workaround.patch")))))) (define microblazeel-xilinx-elf-newlib (let* ((target "microblazeel-xilinx-elf") (xgcc (cross-gcc target)) (xbinutils (cross-binutils target #:binutils binutils-2.43))) (package (name "microblazeel-xilinx-newlib") (version "4.5.0.20241231") (native-search-paths (list (search-path-specification (variable "CROSS_C_INCLUDE_PATH") (files '("microblazeel-xilinx-elf/include"))) (search-path-specification (variable "CROSS_LIBRARY_PATH") (files '("microblazeel-xilinx-elf/lib"))))) (source (origin (method url-fetch) (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-" version ".tar.gz")) (sha256 (base32 "0ln8r0p0yqy0p1diy04r2zwhlfs67qmkih95djcnaj85w02jdw9k")) (patches (list (my-search-patch "0001-libgloss-doc-fix-direntry-definition.patch"))))) (build-system gnu-build-system) (arguments (list ;; The configure flags are identical to the flags used by the "GCC ARM ;; embedded" project. #:configure-flags #~(list #$(string-append "--target=" target) "--enable-newlib-io-long-long" "--enable-newlib-register-fini" "--disable-newlib-supplied-syscalls" "--disable-nls") #:make-flags ''("MAKE_INFO=TRUE") #:phases #~(modify-phases %standard-phases (add-after 'unpack 'fix-references-to-/bin/sh (lambda _ (substitute* (find-files "libgloss" "^Makefile\\.in$") (("/bin/sh") (which "sh"))) #t))))) (native-inputs `(("xbinutils" ,xbinutils) ("xgcc" ,xgcc) ("texinfo" ,texinfo))) (home-page "https://www.sourceware.org/newlib/") (synopsis "C library for use on embedded systems") (description "Newlib is a C library intended for use on embedded systems. It is a conglomeration of several library parts that are easily usable on embedded products.") (license (license:non-copyleft "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))) (define make-microblaze-toolchain (mlambda (xgcc newlib) "Produce a cross-compiler toolchain package with the compiler XGCC and the C library variant NEWLIB." (let* ((nano? (string=? (package-name newlib) "newlib-nano")) (newlib-with-xgcc (package (inherit newlib) (native-inputs (alist-replace "xgcc" (list xgcc) (package-native-inputs newlib)))))) (package (name "miroblazeel-xilinx-elf-toolchain") (version (package-version xgcc)) (source #f) (build-system trivial-build-system) (arguments '(#:modules ((guix build union)) #:builder (begin (use-modules (ice-9 match) (guix build union)) (match %build-inputs (((names . directories) ...) (union-build (assoc-ref %outputs "out") directories)))))) (propagated-inputs `(("binutils" ,microblazeel-xilinx-elf-binutils) ("gcc" ,xgcc) ("newlib" ,newlib-with-xgcc))) (synopsis "Complete GCC tool chain for Microblaze bare metal development") (description "This package provides a complete GCC tool chain for Microblaze bare metal development. This includes the GCC microblazeel-xilinx-elf cross compiler and newlib as the C library. The supported programming languages are C and C++.") (home-page (package-home-page xgcc)) (license (package-license xgcc)))))) (define microblazeel-xilinx-elf-binutils (cross-binutils "microblazeel-xilinx-elf" #:binutils binutils-2.43)) (define microblazeel-xilinx-elf-gcc (cross-gcc "microblazeel-xilinx-elf" #:xbinutils microblazeel-xilinx-elf-binutils)) (define microblazeel-xilinx-elf-toolchain (make-microblaze-toolchain microblazeel-xilinx-elf-gcc microblazeel-xilinx-elf-newlib))