Das u-boot is a fancy bootloader with net support and scripting capabilities.
nios2-generic : a new approach to nios2 u-boot
This is a new approach to port u-boot for nios2 boards. We can generate base address and driver declaraiotn from the sopc file, instead of input them by hand. It works with both mmu or nommu.
The base address and driver information is generated from your sopc XML file (quartus v8.1 or later). If your project was built using earlier quartus which use ptf only, you can convert ptf to sopc using a later quartus. If your project uses sopc of ealier version, you should open and save the sopc using a later quartus. You don't need to regenerate or sythesis hardware.
You will need to install the perl-XML-LibXML package.
yum install perl-XML-LibXML
Get the source
You can clone the git from denx server and create the branch,
git clone -n git://git.denx.de/u-boot.git cd u-boot
Or if you installed from the nios2-linux tarball as InstallNios2Linux,
cd nios2-linux/toolchain-build git pull origin cd nios2-linux/u-boot git fetch origin git checkout -b my_nios2 origin/master
The default compiler is nios2-elf-gcc, which comes with nios2eds.
If you want to use nios2-linux-gnu-gcc to build u-boot, you may set,
Or if you want to use nios2-linux-uclibc-gcc to build u-boot, you may set,
Please note, the object code from the nios2-linux-gnu-gcc, gcc4 compiler may not run well on hardware generated using nios2eds v7.1 or earlier. You will need to regenerate the hardware using later sopc builder. Though using nios2-elf-gcc doesnn't have such issue, the new gcc4 generates smaller code size.
Adding new target for your design
1. add an target entry to the file boards.cfg in u-boot directory after the line containing nios2-generic, like this my_nios2,
nios2-generic nios2 nios2 nios2-generic altera my_nios2 nios2 nios2 nios2-generic altera
2. generate the fpga parameter file from sopc file, and copy it to u-boot board dir.If you installed from nios2-linux tarball, the script is available at nios2-linux/toolchain-build/tools. Otherwise you can download from the link and chmod +x.
If you have more than one timer in your system, keep only one and remove other timers in the generated header file. If you system uses older ptf file (quartus 7.1 or earlier), you can convert the ptf to sopc with sopc builder of quartus v8.1 or later. You don't need to regenerate or synthesis the hardware.
sopc-create-config-files my_nios2_sopc.sopc my_nios2_fpga.h
cp my_nios2_fpga.h nios2-linux/u-boot/board/altera/nios2-generic/
3. in the include/configs dir, copy nios2-generic.h to my_nios2.h . Modify my_nios2.h to include your generated header.
-#include "../board/altera/nios2-generic/custom_fpga.h" -#define CONFIG_BOARD_NAME "nios2-generic" +#include "../board/altera/nios2-generic/my_nios2_fpga.h" +#define CONFIG_BOARD_NAME "my_nios2"
More details on u-boot config.
4. configure and build,
make clean make my_nios2_config make
You should configure sof first.
nios2-configure-sof my_nios2.sof nios2-download -g u-boot nios2-terminal
Please note, the u-boot's networking is active only when you run a network command. So you cannot ping u-boot, but u-boot can ping out.
At first, the env is empty. You should set ethaddr (MAC), ipaddr, serverip and saveenv.
Addressing for devices : very Important !
All the devices you referred, must be properly virtual addressed. The cache bypassing macro, ldbio/stbio, may NOT be used for some drivers.
Kernel region, cached : only for sdram (sdram | 0x0) for nommu, (sdram | 0xc0000000) for mmu.
IO region, uncached: all the others, including cfi flash, epcs/spi flash, uart, jtaguart, timer, lan, cf ,etc.
(port | 0x80000000) for nommu, (port | 0xe0000000) for mmu.
For exmaple, if the cfi flash is located at physical address 0x04000000, now you should refer to address 0x84000000 for nommu or 0xe4000000 for mmu. eg,
- bitrev.c - bit reversal in a byte
- Intel_P30_(2).c - Flash file for Intel StrataFlash P30 found on EP3C25 Embedded Evaluation Kit