blob: 34a75e7fb0076271af75e320ee38b4b0050e534a [file] [log] [blame]
Bin Meng862f9922019-07-18 00:34:29 -07001.. SPDX-License-Identifier: GPL-2.0+
2
3Nios II
4=======
5
6Nios II is a 32-bit embedded-processor architecture designed
7specifically for the Altera family of FPGAs.
8
9Please refer to the link for more information on Nios II:
10https://www.altera.com/products/processors/overview.html
11
12Please refer to the link for Linux port and toolchains:
13http://rocketboards.org/foswiki/view/Documentation/NiosIILinuxUserManual
14
15The Nios II port of u-boot is controlled by device tree. Please check
16out doc/README.fdt-control.
17
18To add a new board/configuration (eg, mysystem) to u-boot, you will need
19three files.
20
211. The device tree source which describes the hardware, dts file:
22 arch/nios2/dts/mysystem.dts
23
242. Default configuration of Kconfig, defconfig file:
25 configs/mysystem_defconfig
26
273. The legacy board header file:
28 include/configs/mysystem.h
29
30The device tree source must be generated from your qsys/sopc design
31using the sopc2dts tool. Then modified to fit your configuration.
32
33Please find the sopc2dts download and usage at the wiki:
34http://www.alterawiki.com/wiki/Sopc2dts
35
36.. code-block:: none
37
38 $ java -jar sopc2dts.jar --force-altr -i mysystem.sopcinfo -o mysystem.dts
39
40You will need to add additional properties to the dts. Please find an
41example at, arch/nios2/dts/10m50_devboard.dts.
42
431. Add "stdout-path=..." property with your serial path to the chosen
44 node, like this::
45
46 chosen {
47 stdout-path = &uart_0;
48 };
49
502. If you use SPI/EPCS or I2C, you will need to add aliases to number
51 the sequence of these devices, like this::
52
53 aliases {
54 spi0 = &epcs_controller;
55 };
56
57Next, you will need a default config file. You may start with
5810m50_defconfig, modify the options and save it.
59
60.. code-block:: none
61
62 $ make 10m50_defconfig
63 $ make menuconfig
64 $ make savedefconfig
65 $ cp defconfig configs/mysystem_defconfig
66
67You will need to change the names of board header file and device tree,
68and select the drivers with menuconfig.
69
70.. code-block:: none
71
72 Nios II architecture --->
73 (mysystem) Board header file
74 Device Tree Control --->
75 (mysystem) Default Device Tree for DT control
76
77There is a selection of "Provider of DTB for DT control" in the Device
78Tree Control menu.
79
80 * Separate DTB for DT control, will cat the dtb to end of u-boot
81 binary, output u-boot-dtb.bin. This should be used for production.
82 If you use boot copier, like EPCS boot copier, make sure the copier
83 copies all the u-boot-dtb.bin, not just u-boot.bin.
84
85 * Embedded DTB for DT control, will include the dtb inside the u-boot
86 binary. This is handy for development, eg, using gdb or nios2-download.
87
88The last thing, legacy board header file describes those config options
89not covered in Kconfig yet. You may copy it from 10m50_devboard.h::
90
91 $ cp include/configs/10m50_devboard.h include/configs/mysystem.h
92
93Please change the SDRAM base and size to match your board. The base
94should be cached virtual address, for Nios II with MMU it is 0xCxxx_xxxx
95to 0xDxxx_xxxx.
96
97.. code-block:: c
98
Tom Riniaa6e94d2022-11-16 13:10:37 -050099 #define CFG_SYS_SDRAM_BASE 0xc8000000
100 #define CFG_SYS_SDRAM_SIZE 0x08000000
Bin Meng862f9922019-07-18 00:34:29 -0700101
102You will need to change the environment variables location and setting,
103too. You may change other configs to fit your board.
104
105After all these changes, you may build and test::
106
107 $ export CROSS_COMPILE=nios2-elf- (or nios2-linux-gnu-)
108 $ make mysystem_defconfig
109 $ make
110
111Enjoy!