README.nios 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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_ASMIBASE -- the base address of the ASMI peripheral.
  77. (standard-32: na_asmi_base).
  78. CFG_NIOS_SPIBASE -- the base address of the SPI master (!) peripheral.
  79. (nasys_spi_0)
  80. CFG_NIOS_SPIBITS -- the amount of configured SPI data bits in PTF.
  81. This value can be 8 or 16 only! (PTF: databits)
  82. 2.2 Differences in U-Boot Options/Settings
  83. -------------------------------------------
  84. Some 'standard' U-Boot options/settings are treated differently in
  85. the Nios port. These are described below.
  86. CFG_GBL_DATA_OFFSET -- in the Nios port, this is the offset of the
  87. global data structure in the Nios memory space. More simply,
  88. the address of global data.
  89. 3. ASSEMBLY CODING
  90. -------------------
  91. In browsing the assembly source files, you may notice the absence
  92. of the 'magic macros' (e.g. MOVIA, MOVIP, ADDIP etc.). This is
  93. deliberate. The documentation for the magic macros is scant and
  94. it is hard to find ... it does not appear in the Nios programmer's
  95. manual, nor does it appear in the assembler manual. Regardless,
  96. the macros actually do very little to improve readability anyway.
  97. With this in mind, all assembler modules use only instructions that
  98. appear in the Nios programmer's manual OR are directly supported
  99. by the nios-elf toolchain. For example, the 'dec %rB' instruction
  100. is an alias for 'subi %rB,1' that is supported by the assembler
  101. but does not appear in the programmer's manual.
  102. 4. BOOT PROCESS
  103. ---------------
  104. 4.1 Boot process over GERMS
  105. ---------------------------
  106. When the NIOS CPU catch a reset signal it will begin to be running
  107. code from CFG_NIOS_CPU_RST_VECT. Normally at this place it will
  108. find the GERMS monitor. That's the case for the generic NIOS CPU
  109. configuration "standard_32". When the GERMS monitor starts running,
  110. it performs important system initializations and then looks for
  111. executable code in flash, using the following steps:
  112. 1. Examining the two bytes at CFG_NIOS_CPU_FLASH_BASE + 0x04000C.
  113. 2. Examining the button 0 on the PIO CFG_NIOS_CPU_BUTTON_PIO.
  114. 3. If the button is not pressed and the two bytes contain 'N'
  115. and 'i', the monitor executes a CALL to location
  116. CFG_NIOS_CPU_FLASH_BASE + 0x040000.
  117. 4. If the code is not executed in step 3 or the code returns,
  118. then prints an 8-digit version number to STDOUT and waits for
  119. user commands from STDIN.
  120. In normal case, for "standard_32", STDIN and STDOUT are the first
  121. serial port.
  122. 4.2 Return to GERMS command line
  123. --------------------------------
  124. During the boot process, the GERMS monitor checks for the existence
  125. of application software in flash memory. If found, the processor
  126. immediately executes the code. To return program execution to the
  127. GERMS monitor (that is, avoid running code stored in flash memory):
  128. 1. Hold down CFG_NIOS_CPU_BUTTON_PIO, button number 0.
  129. 2. Press then release the CPU reset button.
  130. 3. Release CFG_NIOS_CPU_BUTTON_PIO, button number 0.
  131. 5. BRAIN DAMAGE
  132. ----------------
  133. This section describes some of the unfortunate and avoidable aspects
  134. of working with the Nios CPU ... and some things you can do to
  135. reduce your pain.
  136. 5.1 GERMS doesn't work with Hyperterminal
  137. ------------------------------------------
  138. GERMS doesn't do CR/LF mapping that is compatible with Hyperterminal
  139. (or minicom) -- geez. Regardless of you opion of Hyperterminal, this
  140. sad design decision is remedied by using U-Boot.
  141. 5.2 cygwin Incompatibility
  142. ---------------------------
  143. The version of cygwin distributed with the nios GNUPro toolchain is
  144. out-of-date and incompatible with the latest cygwin distributions.
  145. In addition, many of the standard utilities are very dated as well.
  146. If you try to download and build the lastest version of grep for
  147. example, you'll quickly realize that a native gcc is not available
  148. (the next topic) which leads to U-Boot build problems (following
  149. topic).
  150. The solution ... well, you can wait for Altera ... or build as
  151. set of tools for linux.
  152. 5.3 No native gcc
  153. ------------------
  154. I'm not sure how this one slipped through the cracks ... but it is
  155. a real pain. Basically, if you want to build anything for the native
  156. environment -- forget it! A native (cygwin) gcc is not distributed,
  157. and the old version of cygwin makes locating one challenging.
  158. The solution ... same as above. Just download the gcc source from
  159. Altera and build up a set of cross tools for your favorite linux
  160. distro. Anybody who wants to use an already precompiled NIOS cross
  161. toolchain can it found in the CDK4NIOS project hosted by Source
  162. Forge at http://cdk4nios.sourceforge.net.
  163. 5.4 Can't build default U-Boot
  164. -------------------------------
  165. By default, when you build U-Boot you will be building some native
  166. tools along with the target elf, bin, and srec files. Without a
  167. native gcc, this (obviously) causes problems.
  168. For developers using the Altera cygwin tools you can remove the
  169. 'tools' directory from SUBDIRS in the top-level Makefile. You will
  170. also have to edit common/Makefile:
  171. Replace:
  172. environment.o: environment.c ../tools/envcrc
  173. $(CC) $(AFLAGS) -Wa,--no-warn \
  174. -DENV_CRC=$(shell ../tools/envcrc) \
  175. -c -o $@ environment.c
  176. With:
  177. environment.o: environment.c ../tools/envcrc
  178. $(CC) $(AFLAGS) -Wa,--no-warn \
  179. -DENV_CRC=0 \
  180. -c -o $@ environment.c
  181. BTW, thats a 'zero' ... not the letter 'O'.
  182. 6. HELP WANTED
  183. ---------------
  184. There are plenty of areas where help is needed. Here's are some ideas
  185. for those interested in contributing:
  186. -CompactFlash. Port & test CF/FAT.
  187. -Bedbug. Develop bedbug for Nios ... or at least provide a disassemble
  188. command.
  189. -Add boot support for ucLinux (niosnommu).
  190. -Implement (don't copy Altera code) the __mulxx routines using the
  191. MSTEP and MUL instructions (e.g. CFG_NIOS_MULT_HW and CFG_NIOS_MULT_MSTEP).
  192. Regards,
  193. --Scott
  194. <smcnutt@psyent.com>
  195. --Stephan
  196. <linz@li-pro.net>