u-boot.scm 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.bin"))
  72. (u-boot (string-append bootloader "/libexec/u-boot-sunxi-with-spl.fit.itb")))
  73. (write-file-on-device spl (stat:size (stat spl))
  74. image (* 8 1024))
  75. (write-file-on-device u-boot (stat:size (stat u-boot))
  76. image (* 40 1024)))))
  77. (define install-imx-u-boot
  78. #~(lambda (bootloader root-index image)
  79. (let ((spl (string-append bootloader "/libexec/SPL"))
  80. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  81. (write-file-on-device spl (stat:size (stat spl))
  82. image (* 1 1024))
  83. (write-file-on-device u-boot (stat:size (stat u-boot))
  84. image (* 69 1024)))))
  85. (define install-puma-rk3399-u-boot
  86. #~(lambda (bootloader root-index image)
  87. (let ((spl (string-append bootloader "/libexec/idbloader.img"))
  88. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  89. (write-file-on-device spl (stat:size (stat spl))
  90. image (* 64 512))
  91. (write-file-on-device u-boot (stat:size (stat u-boot))
  92. image (* 512 512)))))
  93. (define install-firefly-rk3399-u-boot
  94. #~(lambda (bootloader root-index image)
  95. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  96. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  97. (write-file-on-device idb (stat:size (stat idb))
  98. image (* 64 512))
  99. (write-file-on-device u-boot (stat:size (stat u-boot))
  100. image (* 16384 512)))))
  101. (define install-rock64-rk3328-u-boot
  102. #~(lambda (bootloader root-index image)
  103. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  104. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  105. (write-file-on-device idb (stat:size (stat idb))
  106. image (* 64 512))
  107. (write-file-on-device u-boot (stat:size (stat u-boot))
  108. image (* 16384 512)))))
  109. (define install-rockpro64-rk3399-u-boot
  110. #~(lambda (bootloader root-index image)
  111. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  112. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  113. (write-file-on-device idb (stat:size (stat idb))
  114. image (* 64 512))
  115. (write-file-on-device u-boot (stat:size (stat u-boot))
  116. image (* 16384 512)))))
  117. (define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
  118. ;;;
  119. ;;; Bootloader definitions.
  120. ;;;
  121. (define u-boot-bootloader
  122. (bootloader
  123. (inherit extlinux-bootloader)
  124. (name 'u-boot)
  125. (package #f)
  126. (installer #f)
  127. (disk-image-installer install-u-boot)))
  128. (define u-boot-beaglebone-black-bootloader
  129. (bootloader
  130. (inherit u-boot-bootloader)
  131. (package u-boot-am335x-boneblack)
  132. (disk-image-installer install-beaglebone-black-u-boot)))
  133. (define u-boot-allwinner-bootloader
  134. (bootloader
  135. (inherit u-boot-bootloader)
  136. (disk-image-installer install-allwinner-u-boot)))
  137. (define u-boot-allwinner64-bootloader
  138. (bootloader
  139. (inherit u-boot-bootloader)
  140. (disk-image-installer install-allwinner64-u-boot)))
  141. (define u-boot-imx-bootloader
  142. (bootloader
  143. (inherit u-boot-bootloader)
  144. (disk-image-installer install-imx-u-boot)))
  145. (define u-boot-nintendo-nes-classic-edition-bootloader
  146. (bootloader
  147. (inherit u-boot-allwinner-bootloader)
  148. (package u-boot-nintendo-nes-classic-edition)))
  149. (define u-boot-a20-olinuxino-lime-bootloader
  150. (bootloader
  151. (inherit u-boot-allwinner-bootloader)
  152. (package u-boot-a20-olinuxino-lime)))
  153. (define u-boot-a20-olinuxino-lime2-bootloader
  154. (bootloader
  155. (inherit u-boot-allwinner-bootloader)
  156. (package u-boot-a20-olinuxino-lime2)))
  157. (define u-boot-a20-olinuxino-micro-bootloader
  158. (bootloader
  159. (inherit u-boot-allwinner-bootloader)
  160. (package u-boot-a20-olinuxino-micro)))
  161. (define u-boot-bananapi-m2-ultra-bootloader
  162. (bootloader
  163. (inherit u-boot-allwinner-bootloader)
  164. (package u-boot-bananapi-m2-ultra)))
  165. (define u-boot-cubietruck-bootloader
  166. (bootloader
  167. (inherit u-boot-allwinner-bootloader)
  168. (package u-boot-cubietruck)))
  169. (define u-boot-firefly-rk3399-bootloader
  170. ;; SD and eMMC use the same format
  171. (bootloader
  172. (inherit u-boot-bootloader)
  173. (package u-boot-firefly-rk3399)
  174. (disk-image-installer install-firefly-rk3399-u-boot)))
  175. (define u-boot-mx6cuboxi-bootloader
  176. (bootloader
  177. (inherit u-boot-imx-bootloader)
  178. (package u-boot-mx6cuboxi)))
  179. (define u-boot-wandboard-bootloader
  180. (bootloader
  181. (inherit u-boot-imx-bootloader)
  182. (package u-boot-wandboard)))
  183. (define u-boot-novena-bootloader
  184. (bootloader
  185. (inherit u-boot-imx-bootloader)
  186. (package u-boot-novena)))
  187. (define u-boot-pine64-plus-bootloader
  188. (bootloader
  189. (inherit u-boot-allwinner64-bootloader)
  190. (package u-boot-pine64-plus)))
  191. (define u-boot-pine64-lts-bootloader
  192. (bootloader
  193. (inherit u-boot-allwinner-bootloader)
  194. (package u-boot-pine64-lts)))
  195. (define u-boot-pinebook-bootloader
  196. (bootloader
  197. (inherit u-boot-allwinner64-bootloader)
  198. (package u-boot-pinebook)))
  199. (define u-boot-puma-rk3399-bootloader
  200. (bootloader
  201. (inherit u-boot-bootloader)
  202. (package u-boot-puma-rk3399)
  203. (disk-image-installer install-puma-rk3399-u-boot)))
  204. (define u-boot-rock64-rk3328-bootloader
  205. ;; SD and eMMC use the same format
  206. (bootloader
  207. (inherit u-boot-bootloader)
  208. (package u-boot-rock64-rk3328)
  209. (disk-image-installer install-rock64-rk3328-u-boot)))
  210. (define u-boot-rockpro64-rk3399-bootloader
  211. ;; SD and eMMC use the same format
  212. (bootloader
  213. (inherit u-boot-bootloader)
  214. (package u-boot-rockpro64-rk3399)
  215. (disk-image-installer install-rockpro64-rk3399-u-boot)))
  216. (define u-boot-pinebook-pro-rk3399-bootloader
  217. ;; SD and eMMC use the same format
  218. (bootloader
  219. (inherit u-boot-bootloader)
  220. (package u-boot-pinebook-pro-rk3399)
  221. (disk-image-installer install-pinebook-pro-rk3399-u-boot)))