xref: /OK3568_Linux_fs/u-boot/doc/README.nios2 (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunNios II is a 32-bit embedded-processor architecture designed
2*4882a593Smuzhiyunspecifically for the Altera family of FPGAs.
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunPlease refer to the link for more information on Nios II,
5*4882a593Smuzhiyunhttps://www.altera.com/products/processors/overview.html
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunPlease refer to the link for Linux port and toolchains,
8*4882a593Smuzhiyunhttp://rocketboards.org/foswiki/view/Documentation/NiosIILinuxUserManual
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunThe Nios II port of u-boot is controlled by device tree. Please check
11*4882a593Smuzhiyunout doc/README.fdt-control.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunTo add a new board/configuration (eg, mysystem) to u-boot, you will need
14*4882a593Smuzhiyunthree files.
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun1. The device tree source which describes the hardware, dts file.
17*4882a593Smuzhiyun    arch/nios2/dts/mysystem.dts
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun2. Default configuration of Kconfig, defconfig file.
20*4882a593Smuzhiyun    configs/mysystem_defconfig
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun3. The legacy board header file.
23*4882a593Smuzhiyun    include/configs/mysystem.h
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunThe device tree source must be generated from your qsys/sopc design
26*4882a593Smuzhiyunusing the sopc2dts tool. Then modified to fit your configuration. Please
27*4882a593Smuzhiyunfind the sopc2dts download and usage at the wiki,
28*4882a593Smuzhiyunhttp://www.alterawiki.com/wiki/Sopc2dts
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun$ java -jar sopc2dts.jar --force-altr -i mysystem.sopcinfo -o mysystem.dts
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunYou will need to add additional properties to the dts. Please find an
33*4882a593Smuzhiyunexample at, arch/nios2/dts/10m50_devboard.dts.
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun1. Add "stdout-path=..." property with your serial path to the chosen
36*4882a593Smuzhiyunnode, like this,
37*4882a593Smuzhiyun	chosen {
38*4882a593Smuzhiyun		stdout-path = &uart_0;
39*4882a593Smuzhiyun	};
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun2. If you use SPI/EPCS or I2C, you will need to add aliases to number
42*4882a593Smuzhiyunthe sequence of these devices, like this,
43*4882a593Smuzhiyun	aliases {
44*4882a593Smuzhiyun		spi0 = &epcs_controller;
45*4882a593Smuzhiyun	};
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunNext, you will need a default config file. You may start with
48*4882a593Smuzhiyun10m50_defconfig, modify the options and save it.
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun$ make 10m50_defconfig
51*4882a593Smuzhiyun$ make menuconfig
52*4882a593Smuzhiyun$ make savedefconfig
53*4882a593Smuzhiyun$ cp defconfig configs/mysystem_defconfig
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunYou will need to change the names of board header file and device tree,
56*4882a593Smuzhiyunand select the drivers with menuconfig.
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunNios II architecture  --->
59*4882a593Smuzhiyun  (mysystem) Board header file
60*4882a593SmuzhiyunDevice Tree Control  --->
61*4882a593Smuzhiyun  (mysystem) Default Device Tree for DT control
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunThere is a selection of "Provider of DTB for DT control" in the Device
64*4882a593SmuzhiyunTree Control menu.
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun( ) Separate DTB for DT control, will cat the dtb to end of u-boot
67*4882a593Smuzhiyunbinary, output u-boot-dtb.bin. This should be used for production.
68*4882a593SmuzhiyunIf you use boot copier, like EPCS boot copier, make sure the copier
69*4882a593Smuzhiyuncopies all the u-boot-dtb.bin, not just u-boot.bin.
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun( ) Embedded DTB for DT control, will include the dtb inside the u-boot
72*4882a593Smuzhiyunbinary. This is handy for development, eg, using gdb or nios2-download.
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunThe last thing, legacy board header file describes those config options
75*4882a593Smuzhiyunnot covered in Kconfig yet. You may copy it from 10m50_devboard.h.
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun$ cp include/configs/10m50_devboard.h include/configs/mysystem.h
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunPlease change the SDRAM base and size to match your board. The base
80*4882a593Smuzhiyunshould be cached virtual address, for Nios II with MMU it is 0xCxxx_xxxx
81*4882a593Smuzhiyunto 0xDxxx_xxxx.
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun#define CONFIG_SYS_SDRAM_BASE		0xc8000000
84*4882a593Smuzhiyun#define CONFIG_SYS_SDRAM_SIZE		0x08000000
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunYou will need to change the environment variables location and setting,
87*4882a593Smuzhiyuntoo. You may change other configs to fit your board.
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunAfter all these changes, you may build and test.
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun$ export CROSS_COMPILE=nios2-elf-  (or nios2-linux-gnu-)
92*4882a593Smuzhiyun$ make mysystem_defconfig
93*4882a593Smuzhiyun$ make
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunEnjoy!
96