~ruther/guix-kria

guix-kria/modules/zynqmp/packages/microblaze.scm -rw-r--r-- 5.6 KiB
79fd3786 — Rutherther chore: Add script to build the final image 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
(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))