mtd_progmem.c: Fix calculation of block size
This commit is contained in:
parent
fdb17620a0
commit
2706b4f8aa
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit 8d559bd23293adb14d68d7d6111ecbab40986a5a
|
||||
Subproject commit 24f87df3fa8d9fec9044e2c2bb37d12260fd02de
|
2
configs
2
configs
@ -1 +1 @@
|
||||
Subproject commit 028253362897e3ca895cf772dc817423842e8915
|
||||
Subproject commit 2a4b5e665ac98b72920739eb12144462ca38e675
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user