mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
mtd_progmem.c: Fix calculation of block size
This commit is contained in:
+1
-1
Submodule arch updated: 8d559bd232...24f87df3fa
+1
-1
Submodule configs updated: 0282533628...2a4b5e665a
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user