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++
12606 Discussions

help me please!!! alt_flash_open_dev return error

Altera_Forum
Honored Contributor II
3,437 Views

I use sst flash 39vf6401 on my borad.When I need to progamme the flash, I should add a CFI table .Then I can download the programme to the flash successfully. 

 

But I can not open the flash while alt_flash_open_dev(). The return value of alt_flash_open_dev() is always wrong. 

 

If any one know something about it, please help me ,Thank you !
0 Kudos
15 Replies
Altera_Forum
Honored Contributor II
1,000 Views

who can help me? 

 

Please say someting
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

You've got all the C source for the code you are running - so you should be able to track down which test is failing - so what data is incorrect. No one else can know!

0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

if I use open epcs via alt_flash_open_dev(), I can get the right value, and I can read and write epcs memory successfully. 

 

but I can't open my flash use alt_flash_open_dev()
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

Hi 

Can you run the memory test - take altera example. It wil show whether you hvae problems with EPCS. Maybe it is some hw problem or pins connection- you have your custom board. 

You should check from the software side too - i remind you should use not reduced device drivers (or reduced, i don't remember exactly this should be on altera web-site). Aslo check if epcs device is initialized as the device in the alt_sys_init.c function. 

Let me know if you solved your problem.
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

Hi uilka_b (http://www.alteraforum.com/forum/member.php?u=10640)! 

 

Thank you very much for you reply!!! 

 

In my project, the reset vector is define to a flash , and I can programe the flash through the nios flash programing. But I have to add CFI table for the SST flash. Can I say my flash was correctly used? 

 

I have seen some people say that if the reset vector is to one flash, this flash can not be open in nios by alt_flash_open_dev. Is that true? 

 

By the way, I can use the same code to open and control my epcs all correctly,(because I have not use the epcs as the boot loader flash?) 

 

Can you give me some advice about how to open my boot loader flash? Because the epcs flash is to slow to erase and write. 

 

Thanks again!
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

this page is a friend who cant open epcs device when reset vector is epcs controller  

http://www.alteraforum.com/forum/showthread.php?t=21484
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

In my opinion, there are two posibble reason for the fault of open my CFI flash.  

 

1, I use my CFI flash as boot loader flash(reset vector=CFI flash) 

 

2, my CFI flash need add a CFI table for programing, but when i use alt_flash_open_dev ,no CFI table was added automatically.
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

 

--- Quote Start ---  

In my opinion, there are two posibble reason for the fault of open my CFI flash.  

 

1, I use my CFI flash as boot loader flash(reset vector=CFI flash) 

 

2, my CFI flash need add a CFI table for programing, but when i use alt_flash_open_dev ,no CFI table was added automatically. 

--- Quote End ---  

 

delphicgp, 

sorry i mixed something up I thought you use EPCS memory. But anyway it doesn't matter. 

It looks like it is a case - if the reset vector is in the some specific flash you can't open it using open() function.  

Is it a question of the Altera's boot loader implementation? Maybe you need a custom boot loader then. I'm not sure how it works. 

 

Anyway, could you have your reset vector in EPCS and when use the CFI flash for the rest of the program?
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

 

--- Quote Start ---  

delphicgp, 

sorry i mixed something up I thought you use EPCS memory. But anyway it doesn't matter. 

It looks like it is a case - if the reset vector is in the some specific flash you can't open it using open() function.  

Is it a question of the Altera's boot loader implementation? Maybe you need a custom boot loader then. I'm not sure how it works. 

 

Anyway, could you have your reset vector in EPCS and when use the CFI flash for the rest of the program? 

--- Quote End ---  

 

delphicgp, 

no it is not the case. 

I had some time to create a design with CFI flash and SDRAM and I put the reset vector to the cfi_flash and i was able to test this flash using Altera memtest. 

The proof: 

Select Choice (a-b): b Enter the name of the CFI flash device to be opened, or just press <enter> to open "/dev/ext_flash" > /dev/cfi_flash -Successfully opened /dev/cfi_flash -Region 0 contains 8 blocks. -Checking Region 0 for erased blocks. -Block 1, at address 0x2000 identified. -Would you like to test this block? (y/n) y -Starting Flash Test. -Testing "alt_write_flash" and "alt_read_flash". pass 1 - passed. pass 2 - passed. -Testing "alt_erase_flash_block". passed. -Testing "alt_write_flash_block". passed. -Testing unaligned writes. passed. -Returning block 1 to its erased state. -Flash tests complete. -Closing flash device "/dev/cfi_flash".  

I use Terasic DE0 board as a hardware - you can check on their website how flash is connected. 

U
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

 

--- Quote Start ---  

delphicgp, 

no it is not the case. 

I had some time to create a design with CFI flash and SDRAM and I put the reset vector to the cfi_flash and i was able to test this flash using Altera memtest. 

The proof: 

Select Choice (a-b): b Enter the name of the CFI flash device to be opened, or just press <enter> to open "/dev/ext_flash" > /dev/cfi_flash -Successfully opened /dev/cfi_flash -Region 0 contains 8 blocks. -Checking Region 0 for erased blocks. -Block 1, at address 0x2000 identified. -Would you like to test this block? (y/n) y -Starting Flash Test. -Testing "alt_write_flash" and "alt_read_flash". pass 1 - passed. pass 2 - passed. -Testing "alt_erase_flash_block". passed. -Testing "alt_write_flash_block". passed. -Testing unaligned writes. passed. -Returning block 1 to its erased state. -Flash tests complete. -Closing flash device "/dev/cfi_flash".  

I use Terasic DE0 board as a hardware - you can check on their website how flash is connected. 

--- Quote End ---  

 

 

 

 

 

Thanks for your reply!!! 

 

I have never successfully open my CFI flash when I run memtest. 

 

Do you know why?
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

But as I understand you can flash the cfi flash using the Flash programmer, don't you? 

What specific problem do you have so you need to write theCFI table to your flash?
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

 

--- Quote Start ---  

But as I understand you can flash the cfi flash using the Flash programmer, don't you? 

What specific problem do you have so you need to write theCFI table to your flash? 

--- Quote End ---  

 

 

 

thank you! 

 

if I don't add cfi table,I will fail to program the flash. 

 

my problem is that I can not open the flash in nios.the return value of alt_flash_open_dev is always '0'
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

 

--- Quote Start ---  

thank you! 

 

if I don't add cfi table,I will fail to program the flash. 

 

my problem is that I can not open the flash in nios.the return value of alt_flash_open_dev is always '0' 

--- Quote End ---  

 

delphicgp, do you use "reduced device drivers" option in the BSP?
0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

try different and slow serial frequencies. I had the same problem and when I reduce the freq it start working.

0 Kudos
Altera_Forum
Honored Contributor II
1,000 Views

Call the alt_flash_open_dev function only when operating in single-threaded mode.

0 Kudos
Reply