flash_internal: don't used unreliable MCUID to figure out flash page size
This commit is contained in:
parent
8142854522
commit
e054774544
|
@ -13,7 +13,6 @@
|
|||
#include <libopencmsis/core_cm3.h> // Cortex M3 utilities
|
||||
#include <libopencm3/stm32/flash.h> // flash utilities
|
||||
#include <libopencm3/stm32/desig.h> // device signature definitions
|
||||
#include <libopencm3/stm32/dbgmcu.h> // debug definitions
|
||||
|
||||
/* own libraries */
|
||||
#include "flash_internal.h" // flash storage library API
|
||||
|
@ -71,18 +70,6 @@ static bool flash_internal_range(uint32_t address, size_t size)
|
|||
uint16_t flash_internal_page_size(void)
|
||||
{
|
||||
if (0 == flash_internal_page) { // we don't know the page size yet
|
||||
switch (DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK) { // get page size based on family code
|
||||
case 0x412: // low-density, 16-32 kB flash
|
||||
case 0x410: // medium-density, 64-128 kB flash
|
||||
flash_internal_page = 1024;
|
||||
break;
|
||||
case 0x414: // high-density, 256-512 kB flash
|
||||
case 0x430: // XL-density, 768-1024 kB flash
|
||||
case 0x418: // connectivity, 64-256 kB flash
|
||||
flash_internal_page = 2048;
|
||||
break;
|
||||
case 0: // DBGMCU_IDCODE is only accessible in debug mode (this is a known issue documented in STM32F10xxC/D/E Errata sheet, without workaround)
|
||||
default: // unknown
|
||||
if (DESIG_FLASH_SIZE < 256) {
|
||||
if ((*(uint32_t*)0x1FFFF000 & 0xFFFE0000) == 0x20000000) { // non-connectivity system memory start detected (MSP address pointing to SRAM
|
||||
flash_internal_page = 1024;
|
||||
|
@ -92,8 +79,6 @@ uint16_t flash_internal_page_size(void)
|
|||
} else {
|
||||
flash_internal_page = 2048;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flash_internal_page;
|
||||
|
|
Loading…
Reference in New Issue