summaryrefslogtreecommitdiff
path: root/doc/README.nios
blob: 8765df73918b299a658623df992cfd63a29f8ffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
			   U-Boot for Nios-32

		    Last Update: November 30, 2003
====================================================================

This file contains information regarding U-Boot and the Altera
Nios CPU. For information regarding U-Boot and the Nios Development
Kits see:

  * Cyclone Edition (DK-1C20), see doc/README.dk1c20
  * Stratix Edition (DK-1S10), see doc/README.dk1s10 (TODO)
  * Stratix Edition (DK-1S40), see doc/README.dk1s40 (TODO)
  * Stratix Edition (DK-20K200), see doc/README.dk20k200 (TODO)

For informations regarding Nios Development Kit hardware overview
and the NIOS CPU standard configuration of all known boards made by
Altera see:

  * Development Kit (DK) hardware overview, see doc/README.nios_DK
  * NIOS CPU standard_32 at DK-1C20, see doc/README.dk1c20_std32
  * NIOS CPU standard_32 at DK-1S10, see doc/README.dk1s10_std32
  * NIOS CPU standard_32 at DK-1S40, see doc/README.dk1s40_std32
  * NIOS CPU standard_32 at DK-20K200, see doc/README.dk20k200_std32

For those interested in contributing ... see HELP WANTED below.


1. OVERVIEW
------------

U-Boot has been successfully tested on the Nios Cyclone development
board using both the 'safe' and 'standard 32' configurations with
Nios CPU revision 3.08 (CPU_ID = 0x3008). U-Boot can be used with
or without the GERMS monitor. The initial version of U-Boot for the
Cyclone development kit is about 60 Kbyte and will fit in a single
sector of on-board FLASH. Only the Nios 32-bit CPU is supported.

1.1 GERMS Monitor
------------------
If GERMS is just not enough, then U-Boot is a great antibiotic.
You will be very pleased with its high degree of configurability
and its rich feature set.

A few of the most obvious limitations of GERMS are overcome by
using U-Boot (See 'Brain Damage'). Most notably, you can use
minicom or Hyperterminal (duh).

1.2 Altera Source Code
-----------------------
The Nios port does NOT include ANY sources that Altera has the
copyright. This was a conscious decision ... not an accident.
The Altera license is not clear in terms of distributing Altera
sources (when altera silicon is not involved). This isn't really
a problem as little, if any, of the Altera source contains
features that are not already available in U-Boot.

The Nios port also does not use the long-winded peripheral
structure definitions from the Nios SDK.


2. CONFIGURATION OPTIONS/SETTINGS
----------------------------------

2.1 Nios-specific Options/Settings
-----------------------------------
All configuration options/settings that are specific to Nios begin
with "CONFIG_NIOS_", "CFG_NIOS_", or "CFG_NIOS_CPU_".

The configuration follows a two-stage process. In the first stage
the NIOS CPU core will defined like defined in Alteras SOPC Builder.
At this point we use the "CFG_NIOS_CPU_" defines exclusively. For
more informations about all the definitions you have to setup see
into current board configurations and doc/README.nios_CFG_NIOS_CPU.

In second stage we bring the NIOS CPU configuration in relation to
U-Boot configuration options/settings. The following is a list of
currently defined Nios-specific options/parameters used inside of
U-Boot. If any options are related to Standard-32 Nios SDK
excalibur.h definitions, the related definition follows the
description).

CONFIG_NIOS -- defined for all Nios-32 boards.

CFG_NIOS_CONSOLE -- the base address of the console UART.
	(standard-32: nasys_uart_0 resp. na_uart1_base).

CFG_NIOS_FIXEDBAUD -- defined if the console UART PTF fixed_baud
	parameter is set to '1'.

CFG_NIOS_MULT_HW -- use full hardware multiply (not yet implemented).

CFG_NIOS_MULT_MSTEP -- use hardware assisted multiply using the
	MSTEP instruction (not yet implemented).

CFG_NIOS_TMRBASE -- the base address of the timer used to support
	xxx_timer routines (e.g. set_timer(), get_timer(), etc.).
	(standard-32: nasys_timer_1 resp. na_lo_priority_timer2_base).

CFG_NIOS_TMRIRQ -- the interrupt request (vector number) assigned to
	the timer. (standard-32: nasys_timer_1_irq resp.
	na_low_priority_timer2_irq).

CFG_NIOS_TMRMS -- the period of the timer in milliseconds.

2.2 Differences in U-Boot Options/Settings
-------------------------------------------
Some 'standard' U-Boot options/settings are treated differently in
the Nios port. These are described below.

CFG_GBL_DATA_OFFSET -- in the Nios port, this is the offset of the
	global data structure in the Nios memory space. More simply,
	the address of global data.


3. ASSEMBLY CODING
-------------------

In browsing the assembly source files, you may notice the absence
of the 'magic macros' (e.g. MOVIA, MOVIP, ADDIP etc.). This is
deliberate. The documentation for the magic macros is scant and
it is hard to find ... it does not appear in the Nios programmer's
manual, nor does it appear in the assembler manual. Regardless,
the macros actually do very little to improve readability anyway.

With this in mind, all assembler modules use only instructions that
appear in the Nios programmer's manual OR are directly supported
by the nios-elf toolchain. For example, the 'dec %rB' instruction
is an alias for 'subi %rB,1' that is supported by the assembler
but does not appear in the programmer's manual.


4. BOOT PROCESS
---------------

4.1 Boot process over GERMS
---------------------------
When the NIOS CPU catch a reset signal it will begin to be running
code from CFG_NIOS_CPU_RST_VECT. Normally at this place it will
find the GERMS monitor. That's the case for the generic NIOS CPU
configuration "standard_32". When the GERMS monitor starts running,
it performs important system initializations and then looks for
executable code in flash, using the following steps:

    1. Examining the two bytes at CFG_NIOS_CPU_FLASH_BASE + 0x04000C.
    2. Examining the button 0 on the PIO CFG_NIOS_CPU_BUTTON_PIO.
    3. If the button is not pressed and the two bytes contain 'N'
       and 'i', the monitor executes a CALL to location
       CFG_NIOS_CPU_FLASH_BASE + 0x040000.
    4. If the code is not executed in step 3 or the code returns,
       then prints an 8-digit version number to STDOUT and waits for
       user commands from STDIN.

In normal case, for "standard_32", STDIN and STDOUT are the first
serial port.

4.2 Return to GERMS command line
--------------------------------
During the boot process, the GERMS monitor checks for the existence
of application software in flash memory. If found, the processor
immediately executes the code. To return program execution to the
GERMS monitor (that is, avoid running code stored in flash memory):

    1. Hold down CFG_NIOS_CPU_BUTTON_PIO, button number 0.
    2. Press then release the CPU reset button.
    3. Release CFG_NIOS_CPU_BUTTON_PIO, button number 0.


5. BRAIN DAMAGE
----------------

This section describes some of the unfortunate and avoidable aspects
of working with the Nios CPU ... and some things you can do to
reduce your pain.

5.1 GERMS doesn't work with Hyperterminal
------------------------------------------
GERMS doesn't do CR/LF mapping that is compatible with Hyperterminal
(or minicom) -- geez. Regardless of you opion of Hyperterminal, this
sad design decision is remedied by using U-Boot.

5.2 cygwin Incompatibility
---------------------------
The version of cygwin distributed with the nios GNUPro toolchain is
out-of-date and incompatible with the latest cygwin distributions.
In addition, many of the standard utilities are very dated as well.
If you try to download and build the lastest version of grep for
example, you'll quickly realize that a native gcc is not available
(the next topic) which leads to U-Boot build problems (following
topic).

The solution ... well, you can wait for Altera ... or build as
set of tools for linux.

5.3 No native gcc
------------------
I'm not sure how this one slipped through the cracks ... but it is
a real pain. Basically, if you want to build anything for the native
environment -- forget it! A native (cygwin) gcc is not distributed,
and the old version of cygwin makes locating one challenging.

The solution ... same as above. Just download the gcc source from
Altera and build up a set of cross tools for your favorite linux
distro. Anybody who wants to use an already precompiled NIOS cross
toolchain can it found in the CDK4NIOS project hosted by Source
Forge at http://cdk4nios.sourceforge.net.

5.4 Can't build default U-Boot
-------------------------------
By default, when you build U-Boot you will be building some native
tools along with the target elf, bin, and srec files. Without a
native gcc, this (obviously) causes problems.

For developers using the Altera cygwin tools you can remove the
'tools' directory from SUBDIRS in the top-level Makefile. You will
also have to edit common/Makefile:

Replace:
environment.o: environment.c ../tools/envcrc
	$(CC) $(AFLAGS) -Wa,--no-warn \
		-DENV_CRC=$(shell ../tools/envcrc) \
		-c -o $@ environment.c

With:
environment.o: environment.c ../tools/envcrc
	$(CC) $(AFLAGS) -Wa,--no-warn \
		-DENV_CRC=0 \
		-c -o $@ environment.c

BTW, thats a 'zero' ... not the letter 'O'.


6. HELP WANTED
---------------

There are plenty of areas where help is needed. Here's are some ideas
for those interested in contributing:

-CompactFlash. Port & test CF/FAT.

-ASMI support. Use ASMI for environment, etc.

-Bedbug. Develop bedbug for Nios ... or at least provide a disassemble
 command.

-Add boot support for ucLinux (niosnommu).

-Implement (don't copy Altera code) the __mulxx routines using the
 MSTEP and MUL instructions (e.g. CFG_NIOS_MULT_HW and CFG_NIOS_MULT_MSTEP).


Regards,

--Scott
<smcnutt@psyent.com>

--Stephan
<linz@li-pro.net>