u-boot.scm 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 David Craven <david@craven.ch>
  3. ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
  4. ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
  5. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (gnu bootloader u-boot)
  22. #:use-module (gnu bootloader extlinux)
  23. #:use-module (gnu bootloader)
  24. #:use-module (gnu packages bootloaders)
  25. #:use-module (guix gexp)
  26. #:export (u-boot-bootloader
  27. u-boot-a20-olinuxino-lime-bootloader
  28. u-boot-a20-olinuxino-lime2-bootloader
  29. u-boot-a20-olinuxino-micro-bootloader
  30. u-boot-bananapi-m2-ultra-bootloader
  31. u-boot-beaglebone-black-bootloader
  32. u-boot-cubietruck-bootloader
  33. u-boot-firefly-rk3399-bootloader
  34. u-boot-mx6cuboxi-bootloader
  35. u-boot-nintendo-nes-classic-edition-bootloader
  36. u-boot-novena-bootloader
  37. u-boot-pine64-plus-bootloader
  38. u-boot-pine64-lts-bootloader
  39. u-boot-pinebook-bootloader
  40. u-boot-pinebook-pro-rk3399-bootloader
  41. u-boot-puma-rk3399-bootloader
  42. u-boot-rock64-rk3328-bootloader
  43. u-boot-rockpro64-rk3399-bootloader
  44. u-boot-wandboard-bootloader))
  45. (define install-u-boot
  46. #~(lambda (bootloader root-index image)
  47. (if bootloader
  48. (error "Failed to install U-Boot"))))
  49. (define install-beaglebone-black-u-boot
  50. ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
  51. ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
  52. ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
  53. ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
  54. ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
  55. ;; specified DEVICE.
  56. #~(lambda (bootloader root-index image)
  57. (let ((mlo (string-append bootloader "/libexec/MLO"))
  58. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  59. (write-file-on-device mlo (* 256 512)
  60. image (* 256 512))
  61. (write-file-on-device u-boot (* 1024 512)
  62. image (* 768 512)))))
  63. (define install-allwinner-u-boot
  64. #~(lambda (bootloader root-index image)
  65. (let ((u-boot (string-append bootloader
  66. "/libexec/u-boot-sunxi-with-spl.bin")))
  67. (write-file-on-device u-boot (stat:size (stat u-boot))
  68. image (* 8 1024)))))
  69. (define install-allwinner64-u-boot
  70. #~(lambda (bootloader root-index image)
  71. (let ((spl (string-append bootloader "/libexec/u-boot-sunxi-with-spl.fit.itb")))
  72. (write-file-on-device spl (stat:size (stat spl))
  73. image (* 8 1024)))))
  74. (define install-imx-u-boot
  75. #~(lambda (bootloader root-index image)
  76. (let ((spl (string-append bootloader "/libexec/SPL"))
  77. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  78. (write-file-on-device spl (stat:size (stat spl))
  79. image (* 1 1024))
  80. (write-file-on-device u-boot (stat:size (stat u-boot))
  81. image (* 69 1024)))))
  82. (define install-puma-rk3399-u-boot
  83. #~(lambda (bootloader root-index image)
  84. (let ((spl (string-append bootloader "/libexec/idbloader.img"))
  85. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  86. (write-file-on-device spl (stat:size (stat spl))
  87. image (* 64 512))
  88. (write-file-on-device u-boot (stat:size (stat u-boot))
  89. image (* 512 512)))))
  90. (define install-firefly-rk3399-u-boot
  91. #~(lambda (bootloader root-index image)
  92. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  93. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  94. (write-file-on-device idb (stat:size (stat idb))
  95. image (* 64 512))
  96. (write-file-on-device u-boot (stat:size (stat u-boot))
  97. image (* 16384 512)))))
  98. (define install-rock64-rk3328-u-boot
  99. #~(lambda (bootloader root-index image)
  100. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  101. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  102. (write-file-on-device idb (stat:size (stat idb))
  103. image (* 64 512))
  104. (write-file-on-device u-boot (stat:size (stat u-boot))
  105. image (* 16384 512)))))
  106. (define install-rockpro64-rk3399-u-boot
  107. #~(lambda (bootloader root-index image)
  108. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  109. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  110. (write-file-on-device idb (stat:size (stat idb))
  111. image (* 64 512))
  112. (write-file-on-device u-boot (stat:size (stat u-boot))
  113. image (* 16384 512)))))
  114. (define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
  115. ;;;
  116. ;;; Bootloader definitions.
  117. ;;;
  118. (define u-boot-bootloader
  119. (bootloader
  120. (inherit extlinux-bootloader)
  121. (name 'u-boot)
  122. (package #f)
  123. (installer #f)
  124. (disk-image-installer install-u-boot)))
  125. (define u-boot-beaglebone-black-bootloader
  126. (bootloader
  127. (inherit u-boot-bootloader)
  128. (package u-boot-am335x-boneblack)
  129. (disk-image-installer install-beaglebone-black-u-boot)))
  130. (define u-boot-allwinner-bootloader
  131. (bootloader
  132. (inherit u-boot-bootloader)
  133. (disk-image-installer install-allwinner-u-boot)))
  134. (define u-boot-allwinner64-bootloader
  135. (bootloader
  136. (inherit u-boot-bootloader)
  137. (disk-image-installer install-allwinner64-u-boot)))
  138. (define u-boot-imx-bootloader
  139. (bootloader
  140. (inherit u-boot-bootloader)
  141. (disk-image-installer install-imx-u-boot)))
  142. (define u-boot-nintendo-nes-classic-edition-bootloader
  143. (bootloader
  144. (inherit u-boot-allwinner-bootloader)
  145. (package u-boot-nintendo-nes-classic-edition)))
  146. (define u-boot-a20-olinuxino-lime-bootloader
  147. (bootloader
  148. (inherit u-boot-allwinner-bootloader)
  149. (package u-boot-a20-olinuxino-lime)))
  150. (define u-boot-a20-olinuxino-lime2-bootloader
  151. (bootloader
  152. (inherit u-boot-allwinner-bootloader)
  153. (package u-boot-a20-olinuxino-lime2)))
  154. (define u-boot-a20-olinuxino-micro-bootloader
  155. (bootloader
  156. (inherit u-boot-allwinner-bootloader)
  157. (package u-boot-a20-olinuxino-micro)))
  158. (define u-boot-bananapi-m2-ultra-bootloader
  159. (bootloader
  160. (inherit u-boot-allwinner-bootloader)
  161. (package u-boot-bananapi-m2-ultra)))
  162. (define u-boot-cubietruck-bootloader
  163. (bootloader
  164. (inherit u-boot-allwinner-bootloader)
  165. (package u-boot-cubietruck)))
  166. (define u-boot-firefly-rk3399-bootloader
  167. ;; SD and eMMC use the same format
  168. (bootloader
  169. (inherit u-boot-bootloader)
  170. (package u-boot-firefly-rk3399)
  171. (disk-image-installer install-firefly-rk3399-u-boot)))
  172. (define u-boot-mx6cuboxi-bootloader
  173. (bootloader
  174. (inherit u-boot-imx-bootloader)
  175. (package u-boot-mx6cuboxi)))
  176. (define u-boot-wandboard-bootloader
  177. (bootloader
  178. (inherit u-boot-imx-bootloader)
  179. (package u-boot-wandboard)))
  180. (define u-boot-novena-bootloader
  181. (bootloader
  182. (inherit u-boot-imx-bootloader)
  183. (package u-boot-novena)))
  184. (define u-boot-pine64-plus-bootloader
  185. (bootloader
  186. (inherit u-boot-allwinner64-bootloader)
  187. (package u-boot-pine64-plus)))
  188. (define u-boot-pine64-lts-bootloader
  189. (bootloader
  190. (inherit u-boot-allwinner-bootloader)
  191. (package u-boot-pine64-lts)))
  192. (define u-boot-pinebook-bootloader
  193. (bootloader
  194. (inherit u-boot-allwinner64-bootloader)
  195. (package u-boot-pinebook)))
  196. (define u-boot-puma-rk3399-bootloader
  197. (bootloader
  198. (inherit u-boot-bootloader)
  199. (package u-boot-puma-rk3399)
  200. (disk-image-installer install-puma-rk3399-u-boot)))
  201. (define u-boot-rock64-rk3328-bootloader
  202. ;; SD and eMMC use the same format
  203. (bootloader
  204. (inherit u-boot-bootloader)
  205. (package u-boot-rock64-rk3328)
  206. (disk-image-installer install-rock64-rk3328-u-boot)))
  207. (define u-boot-rockpro64-rk3399-bootloader
  208. ;; SD and eMMC use the same format
  209. (bootloader
  210. (inherit u-boot-bootloader)
  211. (package u-boot-rockpro64-rk3399)
  212. (disk-image-installer install-rockpro64-rk3399-u-boot)))
  213. (define u-boot-pinebook-pro-rk3399-bootloader
  214. ;; SD and eMMC use the same format
  215. (bootloader
  216. (inherit u-boot-bootloader)
  217. (package u-boot-pinebook-pro-rk3399)
  218. (disk-image-installer install-pinebook-pro-rk3399-u-boot)))