Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Custom Boot Loading

Altera_Forum
Honored Contributor II
1,559 Views

Boot-Loader Application Notes

 

Search words: boot, boot-loader, boot loader, boot loading, boot-loading, boot application

 

(This technique of boot-loading was obtained from www.niosforum.com, search word: ‘rasdan’ (author collaborating with altera).

 

Caveat:

 

The following notes, code, ramblings and self-reminders are what was necessary to get ‘my’ application running via a boot-loader. Some notes may not apply or be reasonable for your usage. The following is not set-in-stone or necessarily even correct but should help you if you need to use a similar approach.

 

Normal/Standard Nios II boot-loading.

 

Normally, a NiosII boot-loader is automatically built as part of a NiosII project. It is provided by Altera and is written in assembly language. These assembly source files may be viewed at ‘\altera\kits\nios2\components\altera_nios2\sdk\sr c\boot_loader_sources’ on your hard-drive. See ‘boot_load_cfi_bits.s’ or ‘boot_loader_epcs_bits.s’ in the above directory.

 

There are two boot loaders that are provided with the NiosII IDE:

• An epcs bootloader used for booting out of an epcs serial flash. 

• A CFI parallel flash bootloader.

 

Using either an epcs or cfi device as a booting device requires no additional work for the NiosII code writer (ie. An human). The Quartus/SOPC environment generates its own boot-loader hex file that is loaded as part of the hardware image. For example if an internal fpga memory device were named ‘onchip_memory_0’, the hex file generated and used by the hardware image would be named ‘onchip_memory_0.hex’. This hex file is the representation of the assembly language boot-loader. Therefore, the boot-loader basically lives as part of the hardware image and is therefore always available upon a power cycle or reset. Again, the standard Altera boot-loader is automatic because the Quartus/SOPC environment directly knows about the boot-loading device(epcs or cfi) flash device.

 

However, if one desires to boot-load from a parallel or serial port from a boot-loading device, such as an external micro-controller, Altera unfortunately has no direct solution. Therefore, we must build our own custom boot-loader solution that can receive Nios application code from an external device.

 

 

<attachment>

0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
491 Views

This is excellent info, and well-written too. Thanks for sharing it!

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Thanks for providing this info. It was really helpful. 

Regarding the Chicken vs Egg section of your post. This is the order I use and it works for me. 

Generate the .ptf file in SOPC builder. 

Compile your bootloader in the Nios IDE which will create the .hex file. 

Compile the Quartus project which generates your .sof file. (You may need to do an &#39;update symbol or block&#39; first to bring in the changes made from SOPC builder.) 

And you&#39;re ready to program the chip.
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

I too have noticed many gaping holes in the Altera documentation regarding boot loaders. I am beginning my own design and am considering the use of a boot loader. I am a newbie on this sort of FPGA/NIOS based design and need some assistance in consdering all of the pitfalls I may run into on this. There is some great info in this post, but at this time is over my head. What other resources can I refer to while I come up to speed??  

 

I have already obtained quite a bit of the Altera documentation regarding Serial Configuration Devices and have read them over thoroughly. My intent is to use a single NIOS in a system to reprogram the Serial Device itself. One thing I don&#39;t know at this time if I need a separate FLASH component to do this trick or not. I have a NIOS dev kit with Quartus 7.0 and will be experimenting on this very soon. 

 

Any input to this will be greatly appreciated. 

Thanks in advance.
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

You don&#39;t need another flash device. You are not running program directly on EPCS. You usually load from EPCS to some other memory and run. So you can run your flash writing program from onchip memory or other external memory. 

 

If you will run uClinux, I posted some guide on the wiki, 

http://nioswiki.jot.com/wikihome/operating...flashprogrammer (http://nioswiki.jot.com/wikihome/operatingsystems/flashprogrammer)
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Hi 

 

i bringing this discussion back from the dead for a question: 

 

do I need to load the SW from a different interface(UART SPI etc.) or is it possible to use the passive serial interface? 

when I connect EPCS device in AS mode I don't need a custom boot loader at all, why can't I use the generic boot loader for PS configuration? 

 

thanks in advance
0 Kudos
Reply