Forum Discussion
Altera_Forum
Honored Contributor
21 years agoProgram UBoot
Hi all,
A couple of questions that people might be able to help me out with. There seems to be a common issue with setting up the initial boot sequence for a NIOS boot loader and whilst there is a lot of information out there I seem to be going around in circles at the moment. Here is what I'm after. I have the following system: Flash, 0x00000000 to 0x007FFFFF (i.e. 8Mb worth) SDRAM, 0x01000000 to 0x01FFFFFF (i.e. 16Mb worth) EPCS mapped in as EPCS controller peripheral at location 0x00810800 NIOS II f core with flash/tri-state bridge and EPCS controller Reset address is set to the EPCS controller base address Exception address is set to 0x0100020 (i.e. into SDRAM) Now I want to put the configuration data (.sof) into the EPCS with a UBoot on top of it so that at boot up U-Boot will fire up from the EPCS, it (U-Boot) will then load an elf executable from the flash into sdram and execute it at a later point. When I boot up my current system I have succeeded in getting U-boot to be placed in the FLASH but not into the EPCS, in this arrangement it comes up correctly and the EPCS boot loader correctly loads u-boot out of flash and executes it. The problem I am having is getting all the parameters correct for scripting all of this so that I can get U-boot to come out of the epcs, can anyone suggest the correct steps to take (in script) to make the build happen, obviously I want to automate the, but it is being troublesome getting the correct parameters, also the quartus_pgm utility doesn't like running from within cygwin so this means having to shell out to win32 cmd to execute that, again anyway way around this? Regards, DW21 Replies
- Altera_Forum
Honored Contributor
Hi DW,
I just started playing with this myself ... I'll let you know if I learn anything. --Scott - Altera_Forum
Honored Contributor
Hi DW,
> Now I want to put the configuration data (.sof) into the EPCS with a > UBoot on top of it so that at boot up U-Boot will fire up from the EPCS ... snip ... > can anyone suggest the correct steps to take (in script) to make the > build happen 1. create the u-boot flash file with elf2flash and these parameters: --epcs --base=0x0 --end=0x7fffffff --flash=<the epcs chip designator> --input=u-boot --outfile=u-boot.flash --boot=<path to epcs bootloader srec> The bootloader srec is in the {install}/altera/kits/nios2/components/altera_nios2/boot_loader_epcs.srec 2. download u-boot to the epcs device. $ nios2-flash-programmer --epcs --input=u-boot.flash --sof=<path to pgm sof> 3. create the configuration flash file. $ sof2flash --epcs --input=<path to your system sof> --ofset=0x0 --output=config.flash 4. download the configuration flash file to the epcs device. $ nios2-flash-programmer --epcs --input=config.flash --sof=<path to pgm sof> --relocate Don't forget the "--relocate -- it's important ;-) ... and you should be good-to-go at this point. Hope this helps. Regards, --Scott - Altera_Forum
Honored Contributor
Sorry ... something I forgot ... you must define the symbol "__reset"
in u-boot to keep elf2flash happy: In file cpu/start.S:
Although this does seem a bit odd to me since using the --reset option with elf2flash when --epcs is specified causes an error. Regards --Scott.text .global _start .global __reset __reset: _start: - Altera_Forum
Honored Contributor
Ahhhh, that got it.
I had got a little bit further but the specific set of commands I was using resulted in it being unable to fit the config and u-boot into the epcs4.. now it all fits, Thanks a lot.. regards, DW - Altera_Forum
Honored Contributor
> being unable to fit the config and u-boot into the epcs4.
Wow ... big design ... I'm using a full-blown u-boot (network support, jffs2/cramfs, hush parser, etc -- about 128K) and a design that's about 9K LEs ... it only occupies about half of my epcs4. Are you using compressed bit streams? Regards, --Scott - Altera_Forum
Honored Contributor
No I think the problem with it not fitting was the order of programming, which was basically plain wrong. Now it seems to fit fine, full featured U-Boot, and a config of about 12000 LEs,
takes up about 300k bits so not too bad. Mind you I can't get the damn ethernet to work yet, but I think if I just threaten it with a large stick it'll be okay. Cheers for the help Scott, - Altera_Forum
Honored Contributor
Hi,
I am using stratix NIOS board, new to uClinux and NIOS. I want to know which version of u-boot should I use. Can I get any guidelines on how to bring up u-boot on NIOS stratix board. regards, Rajendra - Altera_Forum
Honored Contributor
Hi Rajendra,
If you're using Nios, you can simply download u-boot from: http://www.sourceforge.net/projects/u-boot (http://www.sourceforge.net/projects/u-boot) then follow the directions in doc/README.dk1sxx. For Nios-II the source at: http://www.psyent.com/download (http://www.psyent.com/download) is the best bet. Build u-boot for the PK1C20 board: $ make distclean $ make PK1C20_config $ make You will need to edit include/configs/PK1C20.h to match you hardware configuration. Regards, --Scott - Altera_Forum
Honored Contributor
I am also thinking of putting u-boot in the EPCS. Is there any documentation that talks about the EPCS bootloader and how it works?
I am unclear on how it fits in/replaces the standard booting scheme and what the active players are. Do I need to have an ASMI or EPCS module in my project to make this work? - Altera_Forum
Honored Contributor
Hi tns1,
> I am also thinking of putting u-boot in the EPCS. I'm doing this now on one of my boards ... it works very nicely -- kudos to Altera :-) > Is there any documentation that talks about the EPCS > bootloader and how it works? See Chapter 12 of the "Nios II Processor Reference Handbook", and 1-6 of the "Nios II Flash Programmer User Guide" for a description: http://www.altera.com/literature/hb/nios2/...pu_nii51012.pdf (http://www.altera.com/literature/hb/nios2/n2cpu_nii51012.pdf) http://www.altera.com/literature/ug/ug_nio..._programmer.pdf (http://www.altera.com/literature/ug/ug_nios2_flash_programmer.pdf) > I am unclear on how it fits in/replaces the standard booting scheme > and what the active players are. Do I need to have an ASMI or EPCS > module in my project to make this work? Yes you need the EPCS component and you need to set your reset address in the EPCS component memory. The bootloader code in the EPCS component will then do its thing on reset. The actual code is in: {INSTALL_DIR}\kits\nios2\components\altera_nios2\sdk\src\boot_loader_sources - boot_loader.S (generic code for CFI or EPCS) - boot_loader_epcs_bits.S (epcs-specific code) The thing I like most about the EPCS bootloader : I can eliminate parallel flash altogether for some apps (or just de-pop) ... an epcs and some PSRAM & I'm done :-) Regards, --Scott