u-boot.scm 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 David Craven <david@craven.ch>
  3. ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (gnu bootloader u-boot)
  20. #:use-module (gnu bootloader extlinux)
  21. #:use-module (gnu bootloader)
  22. #:use-module (gnu packages bootloaders)
  23. #:use-module (guix gexp)
  24. #:export (u-boot-bootloader
  25. u-boot-a20-olinuxino-lime-bootloader
  26. u-boot-a20-olinuxino-lime2-bootloader
  27. u-boot-a20-olinuxino-micro-bootloader
  28. u-boot-bananapi-m2-ultra-bootloader
  29. u-boot-beaglebone-black-bootloader
  30. u-boot-mx6cuboxi-bootloader
  31. u-boot-nintendo-nes-classic-edition-bootloader
  32. u-boot-novena-bootloader
  33. u-boot-pine64-plus-bootloader
  34. u-boot-pinebook-bootloader
  35. u-boot-puma-rk3399-bootloader
  36. u-boot-wandboard-bootloader))
  37. (define install-u-boot
  38. #~(lambda (bootloader device mount-point)
  39. (if bootloader
  40. (error "Failed to install U-Boot"))))
  41. (define install-beaglebone-black-u-boot
  42. ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
  43. ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
  44. ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
  45. ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
  46. ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
  47. ;; specified DEVICE.
  48. #~(lambda (bootloader device mount-point)
  49. (let ((mlo (string-append bootloader "/libexec/MLO"))
  50. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  51. (write-file-on-device mlo (* 256 512)
  52. device (* 256 512))
  53. (write-file-on-device u-boot (* 1024 512)
  54. device (* 768 512)))))
  55. (define install-allwinner-u-boot
  56. #~(lambda (bootloader device mount-point)
  57. (let ((u-boot (string-append bootloader
  58. "/libexec/u-boot-sunxi-with-spl.bin")))
  59. (write-file-on-device u-boot (stat:size (stat u-boot))
  60. device (* 8 1024)))))
  61. (define install-allwinner64-u-boot
  62. #~(lambda (bootloader device mount-point)
  63. (let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
  64. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  65. (write-file-on-device spl (stat:size (stat spl))
  66. device (* 8 1024))
  67. (write-file-on-device u-boot (stat:size (stat u-boot))
  68. device (* 40 1024)))))
  69. (define install-imx-u-boot
  70. #~(lambda (bootloader device mount-point)
  71. (let ((spl (string-append bootloader "/libexec/SPL"))
  72. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  73. (write-file-on-device spl (stat:size (stat spl))
  74. device (* 1 1024))
  75. (write-file-on-device u-boot (stat:size (stat u-boot))
  76. device (* 69 1024)))))
  77. (define install-puma-rk3399-u-boot
  78. #~(lambda (bootloader device mount-point)
  79. (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
  80. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  81. (write-file-on-device spl (stat:size (stat spl))
  82. device (* 64 512))
  83. (write-file-on-device u-boot (stat:size (stat u-boot))
  84. device (* 512 512)))))
  85. ;;;
  86. ;;; Bootloader definitions.
  87. ;;;
  88. (define u-boot-bootloader
  89. (bootloader
  90. (inherit extlinux-bootloader)
  91. (name 'u-boot)
  92. (package #f)
  93. (installer install-u-boot)))
  94. (define u-boot-beaglebone-black-bootloader
  95. (bootloader
  96. (inherit u-boot-bootloader)
  97. (package u-boot-beagle-bone-black)
  98. (installer install-beaglebone-black-u-boot)))
  99. (define u-boot-allwinner-bootloader
  100. (bootloader
  101. (inherit u-boot-bootloader)
  102. (installer install-allwinner-u-boot)))
  103. (define u-boot-allwinner64-bootloader
  104. (bootloader
  105. (inherit u-boot-bootloader)
  106. (installer install-allwinner64-u-boot)))
  107. (define u-boot-imx-bootloader
  108. (bootloader
  109. (inherit u-boot-bootloader)
  110. (installer install-imx-u-boot)))
  111. (define u-boot-nintendo-nes-classic-edition-bootloader
  112. (bootloader
  113. (inherit u-boot-allwinner-bootloader)
  114. (package u-boot-nintendo-nes-classic-edition)))
  115. (define u-boot-a20-olinuxino-lime-bootloader
  116. (bootloader
  117. (inherit u-boot-allwinner-bootloader)
  118. (package u-boot-a20-olinuxino-lime)))
  119. (define u-boot-a20-olinuxino-lime2-bootloader
  120. (bootloader
  121. (inherit u-boot-allwinner-bootloader)
  122. (package u-boot-a20-olinuxino-lime2)))
  123. (define u-boot-a20-olinuxino-micro-bootloader
  124. (bootloader
  125. (inherit u-boot-allwinner-bootloader)
  126. (package u-boot-a20-olinuxino-micro)))
  127. (define u-boot-bananapi-m2-ultra-bootloader
  128. (bootloader
  129. (inherit u-boot-allwinner-bootloader)
  130. (package u-boot-bananapi-m2-ultra)))
  131. (define u-boot-mx6cuboxi-bootloader
  132. (bootloader
  133. (inherit u-boot-imx-bootloader)
  134. (package u-boot-mx6cuboxi)))
  135. (define u-boot-wandboard-bootloader
  136. (bootloader
  137. (inherit u-boot-imx-bootloader)
  138. (package u-boot-wandboard)))
  139. (define u-boot-novena-bootloader
  140. (bootloader
  141. (inherit u-boot-imx-bootloader)
  142. (package u-boot-novena)))
  143. (define u-boot-pine64-plus-bootloader
  144. (bootloader
  145. (inherit u-boot-allwinner64-bootloader)
  146. (package u-boot-pine64-plus)))
  147. (define u-boot-pinebook-bootloader
  148. (bootloader
  149. (inherit u-boot-allwinner64-bootloader)
  150. (package u-boot-pinebook)))
  151. (define u-boot-puma-rk3399-bootloader
  152. (bootloader
  153. (inherit u-boot-bootloader)
  154. (package u-boot-puma-rk3399)
  155. (installer install-puma-rk3399-u-boot)))