Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21605 Discussions

Flash Programming

Altera_Forum
Honored Contributor II
1,563 Views

I dont want to use a flash programmer to download my .flash file to CFI flash. 

 

I am able download the .flash file to CFI flash succesfully, using the  

alt_write_flash. 

 

When i power up the board, i expect my program to run from the flash and print hello world.Unfortunatly it code is running . 

 

Please let me know in case if im missing something.
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
826 Views

 

--- Quote Start ---  

 

When i power up the board, i expect my program to run from the flash and print hello world.Unfortunatly it code is running . 

 

Please let me know in case if im missing something. 

--- Quote End ---  

 

 

If I understand you right, the code is not running. 

Are you sure the FPGA configures? 

Please check the CONF_DONE and nSTATUS pins (and INIT_DONE, if used). 

These should be high after correct configuration. 

 

Success, Ton
0 Kudos
Altera_Forum
Honored Contributor II
826 Views

Thanks ton for the reply, 

 

If i use the flash programmer to download my software(*.flash) to CFI flash, the code runs properly after power up. 

 

 

Actually, But if i try to download the (*.flash) file using alt_write_flash API, it downloads it properly to CFI flash, ( i confirmed it by reading it back and comparing it with original (*.flash file). 

 

but when i power up , code doesnt run at all. 

 

Do you still think , its something to with FPGA configuration?
0 Kudos
Altera_Forum
Honored Contributor II
826 Views

Indeed, that's what I suspect. 

Debugging is done step by step. You made a good first step, to compare the downloaded version with the original. Make the second step as I've suggested. 

 

BTW Which FGPA are you using? Are you sure the MSEL pins are correctly set? 

 

Success, Ton
0 Kudos
Altera_Forum
Honored Contributor II
826 Views

Ton,  

 

I am using cyclone I. I am not a FPGA guy. 

 

check this out: 

 

The line of *.flash file generated by the Nios II IDE says: "S32500000000140084003A48011004F8BF1016FDBF0034804000140840083A6800080000000010" 

 

i tried to read back the same file from nios2 programmer using  

 

nios2-flash-programmer --base=0x02000000 --read read_flash.txt 

 

and its reads as 

 

"S1230000140084003A48011004F8BF1016FDBF0034804000140840083A6800080000000012" 

 

The difference i see is S1230000 and rest of the packets seems is ok. 

 

This is the extract of the working code.( if i use the flash programmer.) 

 

When i read by (*.flash file) nios 2 programmer it says 

"S12300203030383430303341343830313130303446384246313031364644424630303334E3" 

if you carefully observe here, S1230020 is ok, but then 533030 is nothing but ASCII values. 

 

I think i got the problem,  

 

I am sending the packets thru RS232 and saving it in a large buffer inside my code and then i am using the Flash API to download it into flash, when i do this , its not stored as HEX values instead its stored in equvivalent ASCII value.  

 

For eg: if original (*.flash) is 0x06 then my code stores it as 0x36.  

 

Any idea how i can download in proper HEX format?
0 Kudos
Altera_Forum
Honored Contributor II
826 Views

The ".flash" file is basically an SREC (SRecord). What you want to do is parse the binary data from the SREC (containing either SOF or ELF content) and program THAT into flash. This is what the flash programmer does and this is what the BUP (board update portal) or webserver with flash update/reconfig does as well. 

 

Alternately, you could use objcopy to convert the SREC to binary format on your PC...avoiding the SREC parsing by Nios II. 

 

Best Regards, 

 

--slacker
0 Kudos
Altera_Forum
Honored Contributor II
826 Views

I used objcopy , BINGO!!!, it worked. Thanks for the suggestion. 

 

Is it possible to configure the NIOS 2 IDE to generate the binary file along with *.flash, and *.elf file?  

 

If Yes, then please let me know. 

 

I just want to avoid using flash programmer to use objcopy. 

 

Thanks in advance!
0 Kudos
Reply