...
The driver RAM requirement depends on flash parameters such as block size and run-time configurations such as sector size. For a particular instance, a general formula can give an approximate:
No Format |
---|
if (secs_per_blk < 255) {
temp1 = ceil(blk_cnt_used / 8) + (blk_cnt_used * 1);
} else {
temp1 = ceil(blk_cnt_used / 8) + (blk_cnt_used * 2);
}
if (sec_cnt < 65535) {
temp2 = sec_cnt * 2;
} else {
temp2 = sec_cnt * 4;
}
temp3 = sec_size;
TOTAL = temp1 + temp2 + temp3; |
where
secs_per_blk
The number of sectors per block.
...
The sector size configured for the device, in octets.
secs_per_blk
and sec_cnt
can be calculated from more basic parameters :
No Format |
---|
secs_per_blk = floor(blk_size / sec_size);
sec_cnt = secs_per_blk * blk_cnt_used; |
where
blk_size
The size of a block on the device, in octets
Take as an example a 16-Mb NOR that is entirely dedicated to file system usage, with a 64-KB block size, configured with a 512-B sector. The following parameters describe the format :
No Format |
---|
blk_cnt_used = 32;
blk_size = 65536;
sec_size = 512;
secs_per_blk = 65536 / 512 = 128;
sec_cnt = 128 * 32 = 4096; |
and the RAM usage is approximately
No Format |
---|
temp1 = (32 / 8) + (32 * 2) = 68;
temp2 = 4096 * 2 = 8192;
temp3 = 512;
TOTAL = 68 + 8192 + 512 = 8772; |
In this example, as in most situations, increasing the sector size will decrease the RAM usage. If the sector size were 1024-B, only 5188-B would have been needed, but a moderate performance penalty would be paid.