u-boot.scm 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. ;;;
  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-firefly-rk3399-bootloader
  31. u-boot-mx6cuboxi-bootloader
  32. u-boot-nintendo-nes-classic-edition-bootloader
  33. u-boot-novena-bootloader
  34. u-boot-pine64-plus-bootloader
  35. u-boot-pine64-lts-bootloader
  36. u-boot-pinebook-bootloader
  37. u-boot-puma-rk3399-bootloader
  38. u-boot-rock64-rk3328-bootloader
  39. u-boot-rockpro64-rk3399-bootloader
  40. u-boot-wandboard-bootloader))
  41. (define install-u-boot
  42. #~(lambda (bootloader device mount-point)
  43. (if bootloader
  44. (error "Failed to install U-Boot"))))
  45. (define install-beaglebone-black-u-boot
  46. ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
  47. ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
  48. ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
  49. ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
  50. ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
  51. ;; specified DEVICE.
  52. #~(lambda (bootloader device mount-point)
  53. (let ((mlo (string-append bootloader "/libexec/MLO"))
  54. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  55. (write-file-on-device mlo (* 256 512)
  56. device (* 256 512))
  57. (write-file-on-device u-boot (* 1024 512)
  58. device (* 768 512)))))
  59. (define install-allwinner-u-boot
  60. #~(lambda (bootloader device mount-point)
  61. (let ((u-boot (string-append bootloader
  62. "/libexec/u-boot-sunxi-with-spl.bin")))
  63. (write-file-on-device u-boot (stat:size (stat u-boot))
  64. device (* 8 1024)))))
  65. (define install-allwinner64-u-boot
  66. #~(lambda (bootloader device mount-point)
  67. (let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
  68. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  69. (write-file-on-device spl (stat:size (stat spl))
  70. device (* 8 1024))
  71. (write-file-on-device u-boot (stat:size (stat u-boot))
  72. device (* 40 1024)))))
  73. (define install-imx-u-boot
  74. #~(lambda (bootloader device mount-point)
  75. (let ((spl (string-append bootloader "/libexec/SPL"))
  76. (u-boot (string-append bootloader "/libexec/u-boot.img")))
  77. (write-file-on-device spl (stat:size (stat spl))
  78. device (* 1 1024))
  79. (write-file-on-device u-boot (stat:size (stat u-boot))
  80. device (* 69 1024)))))
  81. (define install-puma-rk3399-u-boot
  82. #~(lambda (bootloader device mount-point)
  83. (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
  84. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  85. (write-file-on-device spl (stat:size (stat spl))
  86. device (* 64 512))
  87. (write-file-on-device u-boot (stat:size (stat u-boot))
  88. device (* 512 512)))))
  89. (define install-firefly-rk3399-u-boot
  90. #~(lambda (bootloader device mount-point)
  91. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  92. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  93. (write-file-on-device idb (stat:size (stat idb))
  94. device (* 64 512))
  95. (write-file-on-device u-boot (stat:size (stat u-boot))
  96. device (* 16384 512)))))
  97. (define install-rock64-rk3328-u-boot
  98. #~(lambda (bootloader device mount-point)
  99. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  100. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  101. (write-file-on-device idb (stat:size (stat idb))
  102. device (* 64 512))
  103. (write-file-on-device u-boot (stat:size (stat u-boot))
  104. device (* 16384 512)))))
  105. (define install-rockpro64-rk3399-u-boot
  106. #~(lambda (bootloader device mount-point)
  107. (let ((idb (string-append bootloader "/libexec/idbloader.img"))
  108. (u-boot (string-append bootloader "/libexec/u-boot.itb")))
  109. (write-file-on-device idb (stat:size (stat idb))
  110. device (* 64 512))
  111. (write-file-on-device u-boot (stat:size (stat u-boot))
  112. device (* 16384 512)))))
  113. ;;;
  114. ;;; Bootloader definitions.
  115. ;;;
  116. (define u-boot-bootloader
  117. (bootloader
  118. (inherit extlinux-bootloader)
  119. (name 'u-boot)
  120. (package #f)
  121. (installer install-u-boot)))
  122. (define u-boot-beaglebone-black-bootloader
  123. (bootloader
  124. (inherit u-boot-bootloader)
  125. (package u-boot-am335x-boneblack)
  126. (installer install-beaglebone-black-u-boot)))
  127. (define u-boot-allwinner-bootloader
  128. (bootloader
  129. (inherit u-boot-bootloader)
  130. (installer install-allwinner-u-boot)))
  131. (define u-boot-allwinner64-bootloader
  132. (bootloader
  133. (inherit u-boot-bootloader)
  134. (installer install-allwinner64-u-boot)))
  135. (define u-boot-imx-bootloader
  136. (bootloader
  137. (inherit u-boot-bootloader)
  138. (installer install-imx-u-boot)))
  139. (define u-boot-nintendo-nes-classic-edition-bootloader
  140. (bootloader
  141. (inherit u-boot-allwinner-bootloader)
  142. (package u-boot-nintendo-nes-classic-edition)))
  143. (define u-boot-a20-olinuxino-lime-bootloader
  144. (bootloader
  145. (inherit u-boot-allwinner-bootloader)
  146. (package u-boot-a20-olinuxino-lime)))
  147. (define u-boot-a20-olinuxino-lime2-bootloader
  148. (bootloader
  149. (inherit u-boot-allwinner-bootloader)
  150. (package u-boot-a20-olinuxino-lime2)))
  151. (define u-boot-a20-olinuxino-micro-bootloader
  152. (bootloader
  153. (inherit u-boot-allwinner-bootloader)
  154. (package u-boot-a20-olinuxino-micro)))
  155. (define u-boot-bananapi-m2-ultra-bootloader
  156. (bootloader
  157. (inherit u-boot-allwinner-bootloader)
  158. (package u-boot-bananapi-m2-ultra)))
  159. (define u-boot-firefly-rk3399-bootloader
  160. ;; SD and eMMC use the same format
  161. (bootloader
  162. (inherit u-boot-bootloader)
  163. (package u-boot-firefly-rk3399)
  164. (installer install-firefly-rk3399-u-boot)))
  165. (define u-boot-mx6cuboxi-bootloader
  166. (bootloader
  167. (inherit u-boot-imx-bootloader)
  168. (package u-boot-mx6cuboxi)))
  169. (define u-boot-wandboard-bootloader
  170. (bootloader
  171. (inherit u-boot-imx-bootloader)
  172. (package u-boot-wandboard)))
  173. (define u-boot-novena-bootloader
  174. (bootloader
  175. (inherit u-boot-imx-bootloader)
  176. (package u-boot-novena)))
  177. (define u-boot-pine64-plus-bootloader
  178. (bootloader
  179. (inherit u-boot-allwinner64-bootloader)
  180. (package u-boot-pine64-plus)))
  181. (define u-boot-pine64-lts-bootloader
  182. (bootloader
  183. (inherit u-boot-allwinner-bootloader)
  184. (package u-boot-pine64-lts)))
  185. (define u-boot-pinebook-bootloader
  186. (bootloader
  187. (inherit u-boot-allwinner64-bootloader)
  188. (package u-boot-pinebook)))
  189. (define u-boot-puma-rk3399-bootloader
  190. (bootloader
  191. (inherit u-boot-bootloader)
  192. (package u-boot-puma-rk3399)
  193. (installer install-puma-rk3399-u-boot)))
  194. (define u-boot-rock64-rk3328-bootloader
  195. ;; SD and eMMC use the same format
  196. (bootloader
  197. (inherit u-boot-bootloader)
  198. (package u-boot-rock64-rk3328)
  199. (installer install-rock64-rk3328-u-boot)))
  200. (define u-boot-rockpro64-rk3399-bootloader
  201. ;; SD and eMMC use the same format
  202. (bootloader
  203. (inherit u-boot-bootloader)
  204. (package u-boot-rockpro64-rk3399)
  205. (installer install-rockpro64-rk3399-u-boot)))