cancel
Showing results for 
Search instead for 
Did you mean: 

Nor Flash

kachna5247
New Contributor II

Hello all,

I am writing to you again as I have another problem with the Spansion FFS example on the S256FL256LAGMFI  Nor Flash. I now have the example with sample_spn_fs() working. If I start it one time and format the flash, I can write and read the example data - it works corrrectly.

However, when I start the example another time (even after MCU reset), sample_spn_fs() fails with IONFS_ERRNO because the data that it writes are not read back correctly. When I start the example another time or two times, ionFS_mount() returns IONFS_ENOFMT. That is the end and after this I must always start the formatting again. This procedure is not always the same as sometimes I get the error ENOFMT even right after the first run, as you can see from the following screenshot.

 

example_fail.png

I know one thing, ionFS_mount() fails because it cannot find the boot sector where there should be written 0x55aa at the end. There are zeroes only even though ionFS_format() writes to it correctly. Another thing I want to mention is that decreasing the used size of the flash by lowering NUMBER_OF_ERASE_BLOCKS in Flash.h seems to almost fix the issue.

eb.png

I had some problems with the stack size as the filesystem has some very large buffers defined in the functions, but I hopefully fixed those by setting stack size to 36 kilo. My idea is that this whole issue somehow related to write buffers not being flushed correctly to the flash, but I am not really sure.

I attach the whole sample_spn_fs.c file, but I almost did not change it from default. Also, I tried to get some output from the example with all calls to the slld_hal layer, but the output is fairly incomplete so I doubt it will be of any use for you.

Do you have any idea what could be reason for this? I would appreciate any input as I am, once again, stuck on this one.

 

Thanks and regards,

Karel

0 Likes
1 Solution
kachna5247
New Contributor II

Hi Takashiro,

 

yeah I tried that but it did not solve it. However, I have probably found the issue. I have set EBLOCK_SIZE to 64 KB, so the formatting is trying to erase whole blocks but it is using Sector Erase command, which is obviously wrong on this memory. I think it is a bug in function Flash_Erase() in ftl_flash.c, line 1604 looks like this:

ftl_flash_bad.png

when there should be the block erase command:

ftl_flash_good.png

 

Also, in the function slld_BlockEraseOp() in slld.c, there is missing an ifdef for 4 bytes addressing:

blockerase_bad.png

when it should look similar to other functions where there is possible 4 byte addressing:

blockerase_good.png

With those edits, the example is working correctly now.

So I have probably last question, do I have the correct settings in the Format.h function? My understanding is that I set EBLOCK_SIZE to largest erasable block size of the flash, which is 64 kilo. Then, I set NUMBER_OF_BYTES_PER_SECTOR and NUMBER_OF_BYTES_PER_SECTOR for the filesystem to use, in my case I have it set to 512 and 8 respectively, so resulting page size is 4 KB. Is that correct?

format2.png

 

Regards,

Karel

View solution in original post

0 Likes
2 Replies
TakahiroK_16
Employee

Hi Karel,

 

In FTL/source/include/ftl_if_ex.h, please define FTL_TRUE for both 'CACHE_RAM_BD_MODULE' and 'CACHE_MINIMUM_RAM'. It reduces RAM usage and may fix the issue.

 

Thanks,

Takahiro

 

0 Likes
kachna5247
New Contributor II

Hi Takashiro,

 

yeah I tried that but it did not solve it. However, I have probably found the issue. I have set EBLOCK_SIZE to 64 KB, so the formatting is trying to erase whole blocks but it is using Sector Erase command, which is obviously wrong on this memory. I think it is a bug in function Flash_Erase() in ftl_flash.c, line 1604 looks like this:

ftl_flash_bad.png

when there should be the block erase command:

ftl_flash_good.png

 

Also, in the function slld_BlockEraseOp() in slld.c, there is missing an ifdef for 4 bytes addressing:

blockerase_bad.png

when it should look similar to other functions where there is possible 4 byte addressing:

blockerase_good.png

With those edits, the example is working correctly now.

So I have probably last question, do I have the correct settings in the Format.h function? My understanding is that I set EBLOCK_SIZE to largest erasable block size of the flash, which is 64 kilo. Then, I set NUMBER_OF_BYTES_PER_SECTOR and NUMBER_OF_BYTES_PER_SECTOR for the filesystem to use, in my case I have it set to 512 and 8 respectively, so resulting page size is 4 KB. Is that correct?

format2.png

 

Regards,

Karel

View solution in original post

0 Likes