mtd_progmem.c: Fix calculation of block size

This commit is contained in:
Gregory Nutt
2015-11-13 09:19:25 -06:00
parent fdb17620a0
commit 2706b4f8aa
3 changed files with 13 additions and 4 deletions
+1 -1
Submodule arch updated: 8d559bd232...24f87df3fa
+1 -1
Submodule configs updated: 0282533628...2a4b5e665a
+11 -2
View File
@@ -374,14 +374,23 @@ FAR struct mtd_dev_s *progmem_initialize(void)
if (!g_progmem.initialized)
{
size_t nblocks = up_progmem_npages();
blkshift = progmem_log2(nblocks);
/* Get the size of one block. Here we assume that the block size is
* uniform and that the size of block0 is the same as the size of any
* other block.
*/
size_t blocksize = up_progmem_pagesize(0);
/* Calculate Log2 of the flash block size */
blkshift = progmem_log2(blocksize);
if (blkshift < 0)
{
return NULL;
}
/* Save the configuration data */
g_progmem.blkshift = blkshift;
g_progmem.initialized = true;
}