Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

NAND flash booting problem

Honored Contributor II

We made a custom board by using Cyclone5 SE device,as a booting option, provision is given for NAND flash only and there is no other boot option on the board. 

we are able to load the the preloader image file successfully into the NAND flash,but when iam observing messages on the Hyper terminal only one message is displaying i.e  

U-Boot SPL 2012.10 (Nov 04 2013 - 19:29:22) 


There is no other messages are displaying,as per my expectations some of other messages has to be displayed on the terminal like clock configuration history and DDR calibration success.....etc. 

The same preloader code,when iam debugging through the JTAG it is working fine and all the above mentioned messages are coming on the hyperterminal. 

Please guide me where iam doing the mistake or is there any basic procedural mistake for the NAND flash booting. 






0 Kudos
8 Replies
Honored Contributor II

Its due to semihosting. 

Semihosting works well when debugger is available. 

But without debugger, it will cause exception. 

Do try it again by disabling the semihosting support
Honored Contributor II

Thank you very much for your advise,by disabling the semi hosting pre-loader is booting from NAND.

Honored Contributor II

After successful pre-loader booting,we tried for bare metal application from NAND. 

As per our expectation,pre-loader has jump to bare-metal application. 


Our bare metal application is not running after successful run of pre-loader. 


The following procedure is ,please correct me if any thing is doing wrong. 


1) Conversion of baremetal .axf to .bin(by using arm-altera-eabi-objcopy.... etc command) 

2) Conversion of baremetal .bin to .img (by using mkimage tool) 

3) Conversion of .img to .bin (by changing the file extention) 

4) Finally .bin file is writing into NAND from 0xc0000 address. 


With the above, pre-loader is running properly and bare metal code is not running. 

Please suggest where we are doing the mistake.
Honored Contributor II

Is your application expected to be unhosted/standalone? There are some differences for hosted and unhosted ones in linker script .ld file as you should know.  

Have you tried to load your application manually via DS-5 debugger after preloader had executed?  

And also please show us your mkimage command. There is an issue with entry point. In Altera unhosted example entry point is set to 0x0 but I had to change it to 0x100040 (in my case) and after that my app started successfully from SDMMC FAT.
Honored Contributor II

i am unable to conforming whether my application is unhosted or standalone? and how can i know that?. 

Here i am attaching my application related .ld file. 


My application is working properly through DS-5(.ds file is attaching for your reference ) 


The following mkimage command i am using for .bin to .img 

mkimage -A arm -T standalone -C none -a 0x100040 -e 0 -n "baremetal image" -d .bin .img 


This project developed by using existing example project, "Altera-SoCFPGA-HardwareLib-GNU".
Honored Contributor II

Take the project called "unhosted" from [here] ( to use it as a reference one. You can compare your linker script and this one with any diff program to find some differences. Also the file io.c from the example is useful for standalone applications to redirect printf() output to UART instead of JTAG.  


In mkimage command you should write -e 0x100040 instead of -e 0x0 to force application to execute from entry point. It helped me. Today I can run both preloader and application from NAND flash on our custom board (at last!) so it works. 


Hope it helps to you too.
Honored Contributor II



Am facing problem with u-boot loading from NAND Flash. As recommended am placing preloader image at 0x0 adress, and u-boot image at 0xC0000. 


Preloader is booting without any problem. But U-Boot is not running fully(on the hyper terminal, after 6 - 10 lines of u-boot nothing is coming). Its stopping in middle of the code. Each time at random timings its hanging. While the same code u-boot is working fine when i debug through DS-5. Once see the terminal window image, attached here. 


Pleae help me to solve the issue. Thank you in advance.
Honored Contributor II



Am able to solve the problem, which mentioned here earlier. That problem was solved by changing the Environment variables offset location(in spl_bsp/uboot-socfpga/include/configs/socfpga-common.h).  


Now i want run my custom application (hello.c) in the place of u-boot. In the place of u-boot am placing the hello-mkimage.bin(which was generated using mkimage tool). But its not running my application. 


here is my mkimage tool command: 

mkimage -A arm -T standalone -C none -a 0x2000040 -e 0x0 -n "baremetal image" -d hello.bin hello-mkimage.bin 


The things i observed is: 

Case 1: 

a) i have eraised entire NAND and i have placed my application image(hello-mkimage.bin) only at 0xC0000. 

b) Then i debugged the preloader through DS-5. and i allowed preloader to boot the next image from NAND flash.(i have used preloadr.ds file) 

--> its copying entire image including header part of the image. this thing i observed when the control entered into uboot-socfpga/common/spl/spl.c, in the function 

spl_parse_image_header(); its not entering into the first if statement. i.e., if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) becoming false. 

--> Load address is becoming 0x2000000, and entry point is 0x2000040. (no change in these values when i changed the value of -e in mkimage cmd). 


Case 2: 

when i executed my application in debug mode(this time image is loaded using debug-hosted.ds file for debugging, no image in my NAND, and in debug configuration i have selected "debug from entry point"). the hello.bin file is loaded at 0x2000000 loaction,entry point is from 0x2000040. This i observed in disassembly window and memory window. 


In both the cases entry point is same i.e 0x2000040. But what ever the instruction or opcode is not same at 0x2000040. The opcode which is in debug mode is located at 0x2000080 loaction when i loaded the image from NAND. This is due to copying of image including header. To shift my entry point i have added/subtracted 0x40 from entry point(edited in this function spl_parse_image_header();). but its giving CRC error for image entry point. 



Can anyone solve my issue... Please tell me if am doing any mistake. 

Thank you in advance.