README.generic-board 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #
  2. # (C) Copyright 2014 Google, Inc
  3. # Simon Glass <sjg@chromium.org>
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. DEPRECATION NOTICE FOR arch/<arch>/lib/board.c
  8. For board maintainers: Please submit patches for boards you maintain before
  9. July 2014, to make them use generic board.
  10. For architecture maintainers: Please submit patches to remove your
  11. architecture-specific board.c file before October 2014.
  12. Background
  13. ----------
  14. U-Boot has traditionally had a board.c file for each architecture. This has
  15. introduced quite a lot of duplication, with each architecture tending to do
  16. initialisation slightly differently. To address this, a new 'generic board
  17. init' feature was introduced a year ago in March 2013 (further motivation is
  18. provided in the cover letter below).
  19. What has changed?
  20. -----------------
  21. The main change is that the arch/<arch>/lib/board.c file is being removed in
  22. favour of common/board_f.c (for pre-relocation init) and common/board_r.c
  23. (for post-relocation init).
  24. Related to this, the global_data and bd_t structures now have a core set of
  25. fields which are common to all architectures. Architecture-specific fields
  26. have been moved to separate structures.
  27. Supported Arcthitectures
  28. ------------------------
  29. If you are unlucky then your architecture may not support generic board.
  30. The following architectures are supported now:
  31. arc
  32. arm
  33. avr32
  34. blackfin
  35. m68k
  36. microblaze
  37. mips
  38. nios2
  39. powerpc
  40. sandbox
  41. x86
  42. If your architecture is not supported, you need to select
  43. HAVE_GENERIC_BOARD in arch/Kconfig
  44. and test it with a suitable board, as follows.
  45. Adding Support for your Board
  46. -----------------------------
  47. To enable generic board for your board, define CONFIG_SYS_GENERIC_BOARD in
  48. your board config header file.
  49. Test that U-Boot still functions correctly on your board, and fix any
  50. problems you find. Don't be surprised if there are no problems - generic
  51. board has had a reasonable amount of testing with common boards.
  52. DeadLine
  53. --------
  54. Please don't take this the wrong way - there is no intent to make your life
  55. miserable, and we have the greatest respect and admiration for U-Boot users.
  56. However, with any migration there has to be a period where the old way is
  57. deprecated and removed. Every patch to the deprecated code introduces a
  58. potential breakage in the new unused code. Therefore:
  59. Boards or architectures not converted over to general board by the
  60. end of 2014 may be forcibly changed over (potentially causing run-time
  61. breakage) or removed.
  62. Further Background
  63. ------------------
  64. The full text of the original generic board series is reproduced below.
  65. --8<-------------
  66. This series creates a generic board.c implementation which contains
  67. the essential functions of the major arch/xxx/lib/board.c files.
  68. What is the motivation for this change?
  69. 1. There is a lot of repeated code in the board.c files. Any change to
  70. things like setting up the baud rate requires a change in 10 separate
  71. places.
  72. 2. Since there are 10 separate files, adding a new feature which requires
  73. initialisation is painful since it must be independently added in 10
  74. places.
  75. 3. As time goes by the architectures naturely diverge since there is limited
  76. pressure to compare features or even CONFIG options against simiilar things
  77. in other board.c files.
  78. 4. New architectures must implement all the features all over again, and
  79. sometimes in subtley different ways. This places an unfair burden on getting
  80. a new architecture fully functional and running with U-Boot.
  81. 5. While it is a bit of a tricky change, I believe it is worthwhile and
  82. achievable. There is no requirement that all code be common, only that
  83. the code that is common should be located in common/board.c rather than
  84. arch/xxx/lib/board.c.
  85. All the functions of board_init_f() and board_init_r() are broken into
  86. separate function calls so that they can easily be included or excluded
  87. for a particular architecture. It also makes it easier to adopt Graeme's
  88. initcall proposal when it is ready.
  89. http://lists.denx.de/pipermail/u-boot/2012-January/114499.html
  90. This series removes the dependency on generic relocation. So relocation
  91. happens as one big chunk and is still completely arch-specific. See the
  92. relocation series for a proposed solution to this for ARM:
  93. http://lists.denx.de/pipermail/u-boot/2011-December/112928.html
  94. or Graeme's recent x86 series v2:
  95. http://lists.denx.de/pipermail/u-boot/2012-January/114467.html
  96. Instead of moving over a whole architecture, this series takes the approach
  97. of simply enabling generic board support for an architecture. It is then up
  98. to each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board
  99. config file. If this is not done, then the code will be generated as
  100. before. This allows both sets of code to co-exist until we are comfortable
  101. with the generic approach, and enough boards run.
  102. ARM is a relatively large board.c file and one which I can test, therefore
  103. I think it is a good target for this series. On the other hand, x86 is
  104. relatively small and simple, but different enough that it introduces a
  105. few issues to be solved. So I have chosen both ARM and x86 for this series.
  106. After a suggestion from Wolfgang I have added PPC also. This is the
  107. largest and most feature-full board, so hopefully we have all bases
  108. covered in this RFC.
  109. A generic global_data structure is also required. This might upset a few
  110. people. Here is my basic reasoning: most fields are the same, all
  111. architectures include and need it, most global_data.h files already have
  112. #ifdefs to select fields for a particular SOC, so it is hard to
  113. see why architecures are different in this area. We can perhaps add a
  114. way to put architecture-specific fields into a separate header file, but
  115. for now I have judged that to be counter-productive.
  116. Similarly we need a generic bd_info structure, since generic code will
  117. be accessing it. I have done this in the same way as global_data and the
  118. same comments apply.
  119. There was dicussion on the list about passing gd_t around as a parameter
  120. to pre-relocation init functions. I think this makes sense, but it can
  121. be done as a separate change, and this series does not require it.
  122. While this series needs to stand on its own (as with the link script
  123. cleanup series and the generic relocation series) the goal is the
  124. unification of the board init code. So I hope we can address issues with
  125. this in mind, rather than focusing too narrowly on particular ARM, x86 or
  126. PPC issues.
  127. I have run-tested ARM on Tegra Seaboard only. To try it out, define
  128. CONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on
  129. x86 and PPC at least it will hang, but if you are lucky it will print
  130. something first :-)
  131. I have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all
  132. ARM, PPC and x86 boards. There are a few failures due to errors in
  133. the board config, which I have sent patches for. The main issue is
  134. just the difference between __bss_end and __bss_end__.
  135. Note: the first group of commits are required for this series to build,
  136. but could be separated out if required. I have included them here for
  137. convenience.
  138. ------------->8--
  139. Simon Glass, sjg@chromium.org
  140. March 2014