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

nios ii flash programming error

Altera_Forum
Honored Contributor II
5,540 Views

Hi: 

When I program *.elf to flash ,there something wrong with it. 

The infomation like 

# !/bin/sh# # This file was automatically generated by the Nios II IDE Flash Programmer.# # It will be overwritten when the flash programmer options change.#  

cd E:/altera/80/workplace/RA8835/hello_world_1/Debug# Creating .flash file for the project 

"$SOPC_KIT_NIOS2/bin/elf2flash" --base=0x00200000 --end=0x3fffff --reset=0x20000 

0 --input="hello_world_1.elf" --output="cfi_flash.flash" --boot="E:/altera/80/ip 

/nios2_ip/altera_nios2/boot_loader_cfi.srec"# Programming flash with the project 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x00200000 --sidp=0x000010b0 

--id=148608136 --timestamp=1252545047 --instance=0 "cfi_flash.flash" 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

Reading System ID at address 0x000010B0: verified 

: Checksumming existing contents  

00000000 : Reading existing contents  

00004000 : Reading existing contents  

Checksummed/read 7kB in 0.2s  

00000000 ( 0%): Erasing  

00004000 (66%): Erasing  

Erased 24kB in 0.4s (60.0kB/s)  

00000000 ( 0%): Programming  

00004000 (66%): Programming  

Programmed 18KB +6KB in 0.3s (80.0KB/s)  

Verify failed at offset 0 

Verify failed at offset 4000 

Leaving target processor paused 

 

 

//end 

Who can help me resave it?Please! 

Thanks
0 Kudos
20 Replies
Altera_Forum
Honored Contributor II
3,475 Views

I think you have to set the proper offset for the flash. It is 0x20000. 

 

And also check whether you reset address in the SOPC builder system (cpu configuration) points to your flash.
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

The offset for the flash must be 0x20000 ? Thanks I will try!

0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

I have checked it,but when I run Auto-Assign-Base Address,the offset for flash will be set as 0x200000 and end address 0x3fffff. 

And I have also checked that my reset address in the SOPC builder system points to my flash! 

I think the information when I program show that the nios(cpu) has found the flash device!
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Obviously the NIOS isn't able to program the flash. 

 

Either: 

1 - The interface to the flash is bad (like incorrect connections, pin assignments, not meeting timing, bad timing parameters etc.) 

2 - The flash is write protected. 

3 - The flash is corrupt. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

#!/bin/sh 

# This file was automatically generated by the Nios II IDE Flash Programmer. 

# It will be overwritten when the flash programmer options change. 

 

cd D:/NIOS_II/SRAM_FLASH/SopcLed/hello_world_small_0/Release 

 

# Creating .flash file for the project 

"$SOPC_KIT_NIOS2/bin/elf2flash" --base=0x00200000 --end=0x3fffff --reset=0x48000 

0 --input="hello_world_small_0.elf" --output="cfi_flash.flash" --boot="E:/altera 

/80/ip/nios2_ip/altera_nios2/boot_loader_cfi.srec" 

 

# Programming flash with the project 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x00200000 --instance=0 "cfi 

_flash.flash" 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

 

: Checksumming existing contents  

 

00000000 : Reading existing contents  

 

Checksummed/read 16kB in 0.4s  

 

00000000 ( 0%): Erasing  

 

Erased 16kB in 0.2s (80.0kB/s)  

 

00000000 ( 0%): Programming  

 

Programmed 1KB +15KB in 0.3s (53.3KB/s)  

Device contents checksummed OK 

Leaving target processor paused 

 

This means flash program OK?
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Sure looks like it. 

 

Oh I just remembered something. What flash device are you using. I know starting with version 7.1, the flash programmer started having problems with some Intel flash parts. Are you perhaps using a J3v.D Intel flash part? 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

No,Because I test it with one project ,it shows us the information : 

 

 

 

 

cd D:/NIOS_II/SRAM_FLASH/SopcLed/hello_world_small_0/Release 

 

 

 

# Creating .flash file for the project 

 

 

"$SOPC_KIT_NIOS2/bin/elf2flash" --base=0x00200000 --end=0x3fffff --reset=0x48000 

 

 

0 --input="hello_world_small_0.elf" --output="cfi_flash.flash" --boot="E:/altera 

 

 

/80/ip/nios2_ip/altera_nios2/boot_loader_cfi.srec" 

 

 

 

# Programming flash with the project 

 

 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x00200000 --instance=0 "cfi 

 

 

_flash.flash" 

 

 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

 

 

Resetting and pausing target processor: OK 

 

 

 

: Checksumming existing contents  

 

 

 

00000000 : Reading existing contents  

 

 

 

Checksummed/read 16kB in 0.4s  

 

 

 

00000000 ( 0%): Erasing  

 

 

 

Erased 16kB in 0.2s (80.0kB/s)  

 

 

 

00000000 ( 0%): Programming  

 

 

 

Programmed 1KB +15KB in 0.3s (53.3KB/s)  

 

 

Device contents checksummed OK 

 

 

Leaving target processor paused 

 

//END 

 

But when I use other project build by myself,it shows information like: 

 

#!/bin/sh 

 

 

 

 

# This file was automatically generated by the Nios II IDE Flash Programmer. 

 

 

 

 

# It will be overwritten when the flash programmer options change. 

 

 

 

 

cd E:/altera/80/workplace/RA8835/hello_world_1/Debug 

 

 

 

# Creating .flash file for the project 

 

 

"$SOPC_KIT_NIOS2/bin/elf2flash" --base=0x00200000 --end=0x3fffff --reset=0x20000 

 

 

0 --input="hello_world_1.elf" --output="cfi_flash.flash" --boot="E:/altera/80/ip 

 

 

/nios2_ip/altera_nios2/boot_loader_cfi.srec" 

 

 

 

# Programming flash with the project 

 

 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x00200000 --sidp=0x000010b0 

 

 

--id=148608136 --timestamp=1252506938 --instance=0 "cfi_flash.flash" 

 

 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

 

 

Resetting and pausing target processor: OK 

 

 

Reading System ID at address 0x000010B0: verified 

 

 

 

: Checksumming existing contents  

 

 

 

00000000 : Reading existing contents  

 

 

 

00004000 : Reading existing contents  

 

 

 

00006000 : Reading existing contents  

 

 

 

Checksummed/read 5kB in 0.1s  

 

 

 

00000000 ( 0%): Erasing  

 

 

 

00004000 (50%): Erasing  

 

 

 

00006000 (75%): Erasing  

 

 

 

Erased 32kB in 0.7s (45.7kB/s)  

 

 

 

00000000 ( 0%): Programming  

 

 

 

00004000 (50%): Programming  

 

 

 

00006000 (75%): Programming  

 

 

 

Programmed 28KB +4KB in 0.5s (64.0KB/s)  

 

 

Verify failed at offset 0 

 

 

Verify failed at offset 4000 

 

 

Verify failed at offset 6000 

 

Leaving target processor paused 

 

//END
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Shenhuan, 

 

Maybe I explain this incorrectly, but I meant flash offset - Offset within the flash memory device where the FPGA configuration is to be programmed, not the base adderess of the Flash in the SOPC builder system. The offset is the relative address within the memory device where the configuration image is located. it is done in the flash programmer dialog window of the NiosII EDS or in the command line it is for example: 

sof2flash --activeparallel --offset=0x20000 --input=niosII_lab.sof --output=hardware_image.flash 

So you will have  

# Creating .flash file for the FPGA configuration 

"$SOPC_KIT_NIOS2/bin/sof2flash" --offset=0x20000 --input="C:/Trainings/nios_II_lab/niosII_lab.sof" --output="niosII_lab.flash 

"  

Info: ******************************************************************* 

Info: Running Quartus II Convert_programming_file 

Info: Command: quartus_cpf --no_banner --convert  

 

# Programming flash with the FPGA configuration 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x01000000 --sidp=0x02401098 

--id=43463617 --timestamp=1248819551 --instance=0 "niosII_lab.flash" 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

Reading System ID at address 0x02401098: verified 

 

: Checksumming existing contents  

 

etc 

this specifies hardware-image region of the flash memory. 

 

Maybe this is not your case, but its worth to try to play with it. What offset are you specifying now? 

0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

uilka_b, 

Thanks for your explanation. 

I know the offset means you told,but I am programming *.elf to flash not FPGA configuration file,so my flash base address is 0x200000. 

I set the Nios II Processor in the sopc_builder system like this: 

Reset Vector: Memory:cfi_flash Offset:0x0 (Do you mean this place should be set as 0x2000??) 

Exception Vector: Memory: sram Offset:ox20 

//end 

shenhuan:)
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

I thought you program both sof and elf to flash. 

 

So I meant offset to specify hardware image region in the flash memory. 

not addressing in the SOPC builder system. 

Please describe step-by-step how you run your project in the board and how you configure your flash.
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

I program sof to EPCS4 first ,and then program *.elf to flash by NIOS_IDE_flash_programmer. 

Something wrong with me?
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Can you provide more details?

0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

First ,in a new project,I build a sopc_builder system,and add CPU,tristate_bridge,cfi_flash,sram and some PIOs. 

In nios_processor setting ,reset vector set as cfi_flash, offset set as 0x0 

,then run Auto_assign_Base_address and Auto_assign_IRQs in System_view, 

last I generate the nios_system. 

After generate OK and assign Pins OK! I compile quartus_project! 

Then open the nios_ide,build software_project,set system_library_propetities, 

compile system.When does this OK,I program quartus_project first and then program elf to flash by NIOS_TOOL_FLASH_PROGRAMMER.
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Have you tried to run your program without using the flash? 

Just normally after programming hardware, launch Run as-> Nios II hardware. 

Does it work?
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Yes ,it works well!

0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

What hardware do u use? A dev-kit or your own PCB?

0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

My own pcb!

0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

Hi! I have the same problem!! 

# !/bin/sh# # This file was automatically generated by the Nios II IDE Flash Programmer.# # It will be overwritten when the flash programmer options change.#  

cd G:/nios_ii_sw/led_blink_8bit/software/led_blink_8bit/Debug# Creating .flash file for the project 

"$SOPC_KIT_NIOS2/bin/elf2flash" --base=0x02400000 --end=0x27fffff --reset=0x2400 

000 --input="led_blink_8bit.elf" --output="cfi_flash.flash" --boot="D:/altera/90 

/ip/altera/nios2_ip/altera_nios2/boot_loader_cfi.srec"# Programming flash with the project 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x02400000 --cable='USB-Blas 

ter [USB-0]' --sidp=0x02801010 --id=2017564571 --timestamp=1277911500 --instance 

=0 "cfi_flash.flash" 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

Reading System ID at address 0x02801010: verified 

: Checksumming existing contents  

00004000 : Verifying existing contents  

00006000 : Verifying existing contents  

00008000 : Verifying existing contents  

00000000 : Reading existing contents  

Checksummed/read 46kB in 4.9s  

00000000 ( 0%): Erasing  

Erased 16kB in 0.5s (32.0kB/s)  

00000000 ( 0%): Programming  

00004000 (25%): Programming  

00006000 (25%): Programming  

00008000 (25%): Programming  

Programmed 62KB in 0.9s (68.8KB/s)  

Verify failed at offset 4000 

Verify failed at offset 6000 

Verify failed at offset 8000 

Leaving target processor paused 

 

 

//////////////////////////////////////// 

 

Have you solved this problem? 

 

My flash is set the 8bit databus connect to FPGA(EP2C5),when 16bit databus is no this problem. 

 

further more this problem usually appear when I compile the code and first download the .elf; when I download the same .elf to the flash in the secondtime ,it works. 

 

This is very strange!!
0 Kudos
Altera_Forum
Honored Contributor II
3,475 Views

The secondtime download ,it works: 

# !/bin/sh# # This file was automatically generated by the Nios II IDE Flash Programmer.# # It will be overwritten when the flash programmer options change.#  

cd G:/nios_ii_sw/led_blink_8bit/software/led_blink_8bit/Debug# Creating .flash file for the project 

"$SOPC_KIT_NIOS2/bin/elf2flash" --base=0x02400000 --end=0x27fffff --reset=0x2400 

000 --input="led_blink_8bit.elf" --output="cfi_flash.flash" --boot="D:/altera/90 

/ip/altera/nios2_ip/altera_nios2/boot_loader_cfi.srec"# Programming flash with the project 

"$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --base=0x02400000 --cable='USB-Blas 

ter [USB-0]' --sidp=0x02801010 --id=2017564571 --timestamp=1277911500 --instance 

=0 "cfi_flash.flash" 

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00 

Resetting and pausing target processor: OK 

Reading System ID at address 0x02801010: verified 

: Checksumming existing contents  

00000000 : Verifying existing contents  

Checksummed/read 16kB in 2.1s  

Erase not required 

00000000 ( 0%): Programming  

00004000 ( 0%): Programming  

00006000 (12%): Programming  

00008000 (25%): Programming  

Programmed 62KB in 2.5s (24.8KB/s)  

Device contents checksummed OK 

Leaving target processor paused
0 Kudos
Altera_Forum
Honored Contributor II
3,359 Views

@shiy 

I also have the same problem ....Can you please me tell me how you solved the problem....
0 Kudos
Reply