- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to write my FPGA configuration file on its EPCS16 flash using Nios processor. The final goal is to use Uart/Usb/Ethernet communication to download the FPGA configuration file on the board. I have implemented an EPCS_Controller on my Nios CPU using SOPC builder, and I'm using 'alt_flash_dev' drivers to access to it. I success to read flash datas. But I have some problems concerning write access : I can't write a block entirely (65536 bytes, I don't have enough memory to store such amount of datas), so I would like to write only part of a block, like this way : my_epcs = alt_flash_open_dev(epcs_controller_name);if(my_epcs) {
printf ("epcs opened successfully!");
ptr = 0;
while (ptr<3146000) { // fichier 3mo maxi
my_data = .. // store 0x2000 datas
ret_code = alt_write_flash(my_epcs, ptr, my_data, 0x2000);
ptr = ptr + 0x2000;
}
alt_flash_close_dev(my_epcs);
}
The problem is that each access with 'alt_write_flash' function seems to erase the entire block/sector of the flash (which represent 0x10000 datas). Is there a solution to my problem ? Thanks, Jérôme
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jérôme,
> I can't write a block entirely (65536 bytes, I don't have enough memory to store such amount of > datas), so I would like to write only part of a block, You can write as little as you like -- but no more than the page size. > The problem is that each access with 'alt_write_flash' function seems to erase the entire > block/sector of the flash Correct. You can either erase a single sector, or the entire device. There's no way to erase anything smaller than a sector. > Is there a solution to my problem ? If you need to preserve some data in the sector, you need to: read--modify--erase sector--write sector. If you don't have enough memory (RAM) to read an entire sector, you'll need to be creative. You could try reserving a sector to hold a copy of the original sector while you perform the update. It's very not pretty -- but it can work. Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by jérôme@Apr 28 2006, 04:19 AM the problem is that each access with 'alt_write_flash'[/b] function seems to erase the entire block/sector of the flash (which represent 0x10000 datas). Is there a solution to my problem ? Thanks, Jérôme <div align='right'><{post_snapback}> (index.php?act=findpost&pid=14815) --- Quote End --- [/b] --- Quote End --- This is the nature of using most any flash device. For your situation, it makes sense to use the alt_write_flash_block() function. It won't automatically erase the flash....like alt_write_flash() does. In this way you could write to the flash in whatever data size you want and detect when a sector erase is necessary yourself. Something like the following should work if you implement it in a loop passing new "data" in with each pass:
if(new_flash_block != current_flash_block)
{
printf("\nFlash Block %d", new_flash_block);
alt_erase_flash_block(fd, (new_flash_block * regions->block_size),
regions->block_size);
current_flash_block = new_flash_block;
}
alt_write_flash_block(fd, (current_flash_block * regions->block_size),
target_addr, data, data_len);
Cheers, - slacker
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page