wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 1 | |
| 2 | U-Boot for Nios-32 |
| 3 | |
wdenk | a3ad8e2 | 2003-10-19 23:22:11 +0000 | [diff] [blame] | 4 | Last Update: October 15, 2003 |
wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 5 | ==================================================================== |
| 6 | |
| 7 | This file contains information regarding U-Boot and the Altera |
| 8 | Nios CPU. For information regarding U-Boot and the Nios Development |
| 9 | Kit, Cyclone Edition (DK-1C20), see doc/README.dk1c20. |
| 10 | |
| 11 | For those interested in contributing ... see HELP WANTED below. |
| 12 | |
| 13 | |
| 14 | 1. OVERVIEW |
| 15 | ------------ |
| 16 | |
| 17 | U-Boot has been successfully tested on the Nios Cyclone development |
| 18 | board using both the 'safe' and 'standard 32' configurations with |
| 19 | Nios CPU revision 3.08 (CPU_ID = 0x3008). U-Boot can be used with |
| 20 | or without the GERMS monitor. The initial version of U-Boot for the |
| 21 | Cyclone development kit is about 60 Kbyte and will fit in a single |
| 22 | sector of on-board FLASH. Only the Nios 32-bit CPU is supported. |
| 23 | |
| 24 | 1.1 GERMS Monitor |
| 25 | ------------------ |
| 26 | If GERMS is just not enough, then U-Boot is a great antibiotic. |
| 27 | You will be very pleased with its high degree of configurability |
| 28 | and its rich feature set. |
| 29 | |
| 30 | A few of the most obvious limitations of GERMS are overcome by |
| 31 | using U-Boot (See 'Brain Damage'). Most notably, you can use |
| 32 | minicom or Hyperterminal (duh). |
| 33 | |
| 34 | 1.2 Altera Source Code |
| 35 | ----------------------- |
| 36 | The Nios port does NOT include ANY sources that Altera has the |
| 37 | copyright. This was a conscious decision ... not an accident. |
| 38 | The Altera license is not clear in terms of distributing Altera |
| 39 | sources (when altera silicon is not involved). This isn't really |
| 40 | a problem as little, if any, of the Altera source contains |
| 41 | features that are not already available in U-Boot. |
| 42 | |
| 43 | The Nios port also does not use the long-winded peripheral |
| 44 | structure definitions from the Nios SDK. |
| 45 | |
| 46 | |
wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 47 | 2. CONFIGURATION OPTIONS/SETTINGS |
| 48 | ---------------------------------- |
| 49 | |
| 50 | 2.1 Nios-specific Options/Settings |
| 51 | ----------------------------------- |
| 52 | All configuration options/settings that are specific to Nios begin |
| 53 | with "CONFIG_NIOS_" or "CFG_NIOS_". The following is a list of |
| 54 | currently defined Nios-specific options/parameters. If any options |
| 55 | are related to Standard-32 Nios SDK excalibur.h definitions, the |
| 56 | related definition follows the description). |
| 57 | |
| 58 | |
| 59 | CONFIG_NIOS -- defined for all Nios-32 boards. |
| 60 | |
| 61 | CFG_NIOS_CONSOLE -- the base address of the console UART. |
| 62 | (standard-32: na_uart1_base). |
| 63 | |
| 64 | CFG_NIOS_FIXEDBAUD -- defined if the console UART PTF fixed_baud |
| 65 | parameter is set to '1'. |
| 66 | |
| 67 | CFG_NIOS_MULT_HW -- use full hardware multiply (not yet implemented). |
| 68 | |
| 69 | CFG_NIOS_MULT_MSTEP -- use hardware assisted multiply using the |
| 70 | MSTEP instruction (not yet implemented). |
| 71 | |
| 72 | CFG_NIOS_TMRBASE -- the base address of the timer used to support |
| 73 | xxx_timer routines (e.g. set_timer(), get_timer(), etc.). |
| 74 | (standard-32: na_lo_priority_timer2_base). |
| 75 | |
| 76 | CFG_NIOS_TMRIRQ -- the interrupt request (vector number) assigned to |
| 77 | the timer. (standard-32: na_low_priority_timer2_irq). |
| 78 | |
| 79 | CFG_NIOS_TMRMS -- the period of the timer in milliseconds. |
| 80 | |
| 81 | 2.2 Differences in U-Boot Options/Settings |
| 82 | ------------------------------------------- |
| 83 | Some 'standard' U-Boot options/settings are treated differently in |
| 84 | the Nios port. These are described below. |
| 85 | |
| 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 | |
| 90 | |
| 91 | 3. ASSEMBLY CODING |
| 92 | ------------------- |
| 93 | |
| 94 | In browsing the assembly source files, you may notice the absence |
| 95 | of the 'magic macros' (e.g. MOVIA, MOVIP, ADDIP etc.). This is |
| 96 | deliberate. The documentation for the magic macros is scant and |
| 97 | it is hard to find ... it does not appear in the Nios programmer's |
| 98 | manual, nor does it appear in the assembler manual. Regardless, |
| 99 | the macros actually do very little to improve readability anyway. |
| 100 | |
| 101 | With this in mind, all assembler modules use only instructions that |
| 102 | appear in the Nios programmer's manual OR are directly supported |
| 103 | by the nios-elf toolchain. For example, the 'dec %rB' instruction |
| 104 | is an alias for 'subi %rB,1' that is supported by the assembler |
| 105 | but does not appear in the programmer's manual. |
| 106 | |
| 107 | |
| 108 | 4. BRAIN DAMAGE |
| 109 | ---------------- |
| 110 | |
| 111 | This section describes some of the unfortunate and avoidable aspects |
| 112 | of working with the Nios CPU ... and some things you can do to |
| 113 | reduce your pain. |
| 114 | |
| 115 | 4.1 GERMS doesn't work with Hyperterminal |
| 116 | ------------------------------------------ |
| 117 | GERMS doesn't do CR/LF mapping that is compatible with Hyperterminal |
| 118 | (or minicom) -- geez. Regardless of you opion of Hyperterminal, this |
| 119 | sad design decision is remedied by using U-Boot. |
| 120 | |
| 121 | 4.2 cygwin Incompatibility |
| 122 | --------------------------- |
| 123 | The version of cygwin distributed with the nios GNUPro toolchain is |
| 124 | out-of-date and incompatible with the latest cygwin distributions. |
| 125 | In addition, many of the standard utilities are very dated as well. |
| 126 | If you try to download and build the lastest version of grep for |
| 127 | example, you'll quickly realize that a native gcc is not available |
| 128 | (the next topic) which leads to U-Boot build problems (following |
| 129 | topic). |
| 130 | |
| 131 | The solution ... well, you can wait for Altera ... or build as |
| 132 | set of tools for linux. |
| 133 | |
| 134 | 4.3 No native gcc |
| 135 | ------------------ |
| 136 | I'm not sure how this one slipped through the cracks ... but it is |
| 137 | a real pain. Basically, if you want to build anything for the native |
| 138 | environment -- forget it! A native (cygwin) gcc is not distributed, |
| 139 | and the old version of cygwin makes locating one challenging. |
| 140 | |
| 141 | The solution ... same as above. Just download the gcc source from |
| 142 | Altera and build up a set of cross tools for your favorite linux |
| 143 | distro. |
| 144 | |
| 145 | 4.4 Can't build default U-Boot |
| 146 | ------------------------------- |
| 147 | By default, when you build U-Boot you will be building some native |
| 148 | tools along with the target elf, bin, and srec files. Without a |
| 149 | native gcc, this (obviously) causes problems. |
| 150 | |
| 151 | For developers using the Altera cygwin tools you can remove the |
| 152 | 'tools' directory from SUBDIRS in the top-level Makefile. You will |
| 153 | also have to edit common/Makefile: |
| 154 | |
| 155 | Replace: |
| 156 | environment.o: environment.c ../tools/envcrc |
| 157 | $(CC) $(AFLAGS) -Wa,--no-warn \ |
| 158 | -DENV_CRC=$(shell ../tools/envcrc) \ |
| 159 | -c -o $@ environment.c |
| 160 | |
| 161 | With: |
| 162 | environment.o: environment.c ../tools/envcrc |
| 163 | $(CC) $(AFLAGS) -Wa,--no-warn \ |
| 164 | -DENV_CRC=0 \ |
| 165 | -c -o $@ environment.c |
| 166 | |
| 167 | BTW, thats a 'zero' ... not the letter 'O'. |
| 168 | |
| 169 | |
| 170 | 5. HELP WANTED |
| 171 | --------------- |
| 172 | |
| 173 | There are plenty of areas where help is needed. Here's are some ideas |
| 174 | for those interested in contributing: |
| 175 | |
wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 176 | -CompactFlash. Port & test CF/FAT. |
| 177 | |
| 178 | -ASMI support. Use ASMI for environment, etc. |
| 179 | |
| 180 | -Bedbug. Develop bedbug for Nios ... or at least provide a disassemble |
| 181 | command. |
| 182 | |
| 183 | -Add boot support for ucLinux (niosnommu). |
| 184 | |
| 185 | -Implement (don't copy Altera code) the __mulxx routines using the |
| 186 | MSTEP and MUL instructions (e.g. CFG_NIOS_MULT_HW and CFG_NIOS_MULT_MSTEP). |
| 187 | |
| 188 | |
wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 189 | Regards, |
| 190 | |
| 191 | --Scott |
| 192 | <smcnutt@psyent.com> |