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