README.nios 9.4 KB

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