README.nios 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. U-Boot for Nios-32
  2. Last Update: February 1, 2004
  3. ====================================================================
  4. This file contains information regarding U-Boot and the Altera
  5. Nios CPU. For information regarding U-Boot and the Nios Development
  6. Kits see:
  7. * Cyclone Edition (DK-1C20), see doc/README.dk1c20
  8. * Stratix Edition (DK-1S10), see doc/README.dk1s10 (TODO)
  9. * Stratix Edition (DK-1S40), see doc/README.dk1s40 (TODO)
  10. * Stratix Edition (DK-20K200), see doc/README.dk20k200 (TODO)
  11. For informations regarding Nios Development Kit hardware overview
  12. and the NIOS CPU standard configuration of all known boards made by
  13. Altera see:
  14. * Development Kit (DK) hardware overview, see doc/README.nios_DK
  15. * NIOS CPU standard_32 at DK-1C20, see doc/README.dk1c20_std32
  16. * NIOS CPU standard_32 at DK-1S10, see doc/README.dk1s10_std32
  17. * NIOS CPU standard_32 at DK-1S40, see doc/README.dk1s40_std32
  18. * NIOS CPU standard_32 at DK-20K200, see doc/README.dk20k200_std32
  19. For those interested in contributing ... see HELP WANTED below.
  20. 1. OVERVIEW
  21. ------------
  22. U-Boot has been successfully tested on the Nios Cyclone development
  23. board using both the 'safe' and 'standard 32' configurations with
  24. Nios CPU revision 3.1 (CPU_ID = 0x3018). U-Boot can be used with
  25. or without the GERMS monitor. The initial version of U-Boot for the
  26. Cyclone development kit is about 60 Kbyte and will fit in a single
  27. sector of on-board FLASH. Only the Nios 32-bit CPU is supported.
  28. 1.1 GERMS Monitor
  29. ------------------
  30. If GERMS is just not enough, then U-Boot is a great antibiotic.
  31. You will be very pleased with its high degree of configurability
  32. and its rich feature set.
  33. A few of the most obvious limitations of GERMS are overcome by
  34. using U-Boot (See 'Brain Damage'). Most notably, you can use
  35. minicom or Hyperterminal (duh).
  36. 1.2 Altera Source Code
  37. -----------------------
  38. The Nios port does NOT include ANY sources that Altera has the
  39. copyright. This was a conscious decision ... not an accident.
  40. The Altera license is not clear in terms of distributing Altera
  41. sources (when altera silicon is not involved). This isn't really
  42. a problem as little, if any, of the Altera source contains
  43. features that are not already available in U-Boot.
  44. 2. CONFIGURATION OPTIONS/SETTINGS
  45. ----------------------------------
  46. 2.1 Nios-specific Options/Settings
  47. -----------------------------------
  48. All configuration options/settings that are specific to Nios begin
  49. with "CONFIG_NIOS_", "CFG_NIOS_", or "CFG_NIOS_CPU_".
  50. The configuration follows a two-stage process. In the first stage
  51. the NIOS CPU core will defined like defined in Alteras SOPC Builder.
  52. At this point we use the "CFG_NIOS_CPU_" defines exclusively. For
  53. more informations about all the definitions you have to setup see
  54. into current board configurations and doc/README.nios_CFG_NIOS_CPU.
  55. In second stage we bring the NIOS CPU configuration in relation to
  56. U-Boot configuration options/settings. The following is a list of
  57. currently defined Nios-specific options/parameters used inside of
  58. U-Boot. If any options are related to Standard-32 Nios SDK
  59. excalibur.h definitions, the related definition follows the
  60. description).
  61. CONFIG_NIOS -- defined for all Nios-32 boards.
  62. CFG_NIOS_CONSOLE -- the base address of the console UART.
  63. (standard-32: nasys_uart_0 resp. na_uart1_base).
  64. CFG_NIOS_FIXEDBAUD -- defined if the console UART PTF fixed_baud
  65. parameter is set to '1'.
  66. CFG_NIOS_MULT_HW -- use full hardware multiply (not yet implemented).
  67. CFG_NIOS_MULT_MSTEP -- use hardware assisted multiply using the
  68. MSTEP instruction (not yet implemented).
  69. CFG_NIOS_TMRBASE -- the base address of the timer used to support
  70. xxx_timer routines (e.g. set_timer(), get_timer(), etc.).
  71. (standard-32: nasys_timer_1 resp. na_lo_priority_timer2_base).
  72. CFG_NIOS_TMRIRQ -- the interrupt request (vector number) assigned to
  73. the timer. (standard-32: nasys_timer_1_irq resp.
  74. na_low_priority_timer2_irq).
  75. CFG_NIOS_TMRMS -- the period of the timer in milliseconds.
  76. CFG_NIOS_TMRCNT -- the preloadable counter value for the timer if it has
  77. no fixed period.
  78. CFG_NIOS_ASMIBASE -- the base address of the ASMI peripheral.
  79. (standard-32: na_asmi_base).
  80. CFG_NIOS_SPIBASE -- the base address of the SPI master (!) peripheral.
  81. (nasys_spi_0)
  82. CFG_NIOS_SPIBITS -- the amount of configured SPI data bits in PTF.
  83. This value can be 8 or 16 only! (PTF: databits)
  84. 2.2 Differences in U-Boot Options/Settings
  85. -------------------------------------------
  86. Some 'standard' U-Boot options/settings are treated differently in
  87. the Nios port. These are described below.
  88. CFG_GBL_DATA_OFFSET -- in the Nios port, this is the offset of the
  89. global data structure in the Nios memory space. More simply,
  90. the address of global data.
  91. 3. ASSEMBLY CODING
  92. -------------------
  93. In browsing the assembly source files, you may notice the absence
  94. of the 'magic macros' (e.g. MOVIA, MOVIP, ADDIP etc.). This is
  95. deliberate. The documentation for the magic macros is scant and
  96. it is hard to find ... it does not appear in the Nios programmer's
  97. manual, nor does it appear in the assembler manual. Regardless,
  98. the macros actually do very little to improve readability anyway.
  99. With this in mind, all assembler modules use only instructions that
  100. appear in the Nios programmer's manual OR are directly supported
  101. by the nios-elf toolchain. For example, the 'dec %rB' instruction
  102. is an alias for 'subi %rB,1' that is supported by the assembler
  103. but does not appear in the programmer's manual.
  104. 4. BOOT PROCESS
  105. ---------------
  106. 4.1 Boot process over GERMS
  107. ---------------------------
  108. When the NIOS CPU catch a reset signal it will begin to be running
  109. code from CFG_NIOS_CPU_RST_VECT. Normally at this place it will
  110. find the GERMS monitor. That's the case for the generic NIOS CPU
  111. configuration "standard_32". When the GERMS monitor starts running,
  112. it performs important system initializations and then looks for
  113. executable code in flash, using the following steps:
  114. 1. Examining the two bytes at CFG_NIOS_CPU_FLASH_BASE + 0x04000C.
  115. 2. Examining the button 0 on the PIO CFG_NIOS_CPU_BUTTON_PIO.
  116. 3. If the button is not pressed and the two bytes contain 'N'
  117. and 'i', the monitor executes a CALL to location
  118. CFG_NIOS_CPU_FLASH_BASE + 0x040000.
  119. 4. If the code is not executed in step 3 or the code returns,
  120. then prints an 8-digit version number to STDOUT and waits for
  121. user commands from STDIN.
  122. In normal case, for "standard_32", STDIN and STDOUT are the first
  123. serial port.
  124. 4.2 Return to GERMS command line
  125. --------------------------------
  126. During the boot process, the GERMS monitor checks for the existence
  127. of application software in flash memory. If found, the processor
  128. immediately executes the code. To return program execution to the
  129. GERMS monitor (that is, avoid running code stored in flash memory):
  130. 1. Hold down CFG_NIOS_CPU_BUTTON_PIO, button number 0.
  131. 2. Press then release the CPU reset button.
  132. 3. Release CFG_NIOS_CPU_BUTTON_PIO, button number 0.
  133. 5. BRAIN DAMAGE
  134. ----------------
  135. This section describes some of the unfortunate and avoidable aspects
  136. of working with the Nios CPU ... and some things you can do to
  137. reduce your pain.
  138. 5.1 GERMS doesn't work with Hyperterminal
  139. ------------------------------------------
  140. GERMS doesn't do CR/LF mapping that is compatible with Hyperterminal
  141. (or minicom) -- geez. Regardless of you opion of Hyperterminal, this
  142. sad design decision is remedied by using U-Boot.
  143. 5.2 cygwin Incompatibility
  144. ---------------------------
  145. The version of cygwin distributed with the nios GNUPro toolchain is
  146. out-of-date and incompatible with the latest cygwin distributions.
  147. In addition, many of the standard utilities are very dated as well.
  148. If you try to download and build the lastest version of grep for
  149. example, you'll quickly realize that a native gcc is not available
  150. (the next topic) which leads to U-Boot build problems (following
  151. topic).
  152. The solution ... well, you can wait for Altera ... or build as
  153. set of tools for linux.
  154. 5.3 No native gcc
  155. ------------------
  156. I'm not sure how this one slipped through the cracks ... but it is
  157. a real pain. Basically, if you want to build anything for the native
  158. environment -- forget it! A native (cygwin) gcc is not distributed,
  159. and the old version of cygwin makes locating one challenging.
  160. The solution ... same as above. Just download the gcc source from
  161. Altera and build up a set of cross tools for your favorite linux
  162. distro. Anybody who wants to use an already precompiled NIOS cross
  163. toolchain can it found in the CDK4NIOS project hosted by Source
  164. Forge at http://cdk4nios.sourceforge.net.
  165. 5.4 Can't build default U-Boot
  166. -------------------------------
  167. By default, when you build U-Boot you will be building some native
  168. tools along with the target elf, bin, and srec files. Without a
  169. native gcc, this (obviously) causes problems.
  170. For developers using the Altera cygwin tools you can remove the
  171. 'tools' directory from SUBDIRS in the top-level Makefile. You will
  172. also have to edit common/Makefile:
  173. Replace:
  174. environment.o: environment.c ../tools/envcrc
  175. $(CC) $(AFLAGS) -Wa,--no-warn \
  176. -DENV_CRC=$(shell ../tools/envcrc) \
  177. -c -o $@ environment.c
  178. With:
  179. environment.o: environment.c ../tools/envcrc
  180. $(CC) $(AFLAGS) -Wa,--no-warn \
  181. -DENV_CRC=0 \
  182. -c -o $@ environment.c
  183. BTW, thats a 'zero' ... not the letter 'O'.
  184. 6. HELP WANTED
  185. ---------------
  186. There are plenty of areas where help is needed. Here's are some ideas
  187. for those interested in contributing:
  188. -CompactFlash. Port & test CF/FAT.
  189. -Bedbug. Develop bedbug for Nios ... or at least provide a disassemble
  190. command.
  191. -Add boot support for ucLinux (niosnommu).
  192. -Implement (don't copy Altera code) the __mulxx routines using the
  193. MSTEP and MUL instructions (e.g. CFG_NIOS_MULT_HW and CFG_NIOS_MULT_MSTEP).
  194. Regards,
  195. --Scott
  196. <smcnutt@psyent.com>
  197. --Stephan
  198. <linz@li-pro.net>