Skip to content

Commit b79be41

Browse files
jeromecoutantbcostm
authored andcommitted
Dual Bank Flash support update
1 parent cc14540 commit b79be41

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

targets/TARGET_STM/TARGET_STM32F7/TARGET_STM32F767xI/device/flash_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// 1) enable the FLASH_DUAL_BANK configuration using a json file
4444
// 2) enable the nDBANK option byte using STLink-Utility software
4545
//=====================================================================
46-
#ifdef MBED_CONF_TARGET_FLASH_DUAL_BANK
46+
#if MBED_CONF_TARGET_FLASH_DUAL_BANK
4747

4848
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base address of Sector 0, 16 Kbytes */
4949
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base address of Sector 1, 16 Kbytes */

targets/TARGET_STM/TARGET_STM32F7/TARGET_STM32F769xI/device/flash_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// 1) enable the FLASH_DUAL_BANK configuration using a json file
4444
// 2) enable the nDBANK option byte using STLink-Utility software
4545
//=====================================================================
46-
#ifdef MBED_CONF_TARGET_FLASH_DUAL_BANK
46+
#if MBED_CONF_TARGET_FLASH_DUAL_BANK
4747

4848
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base address of Sector 0, 16 Kbytes */
4949
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base address of Sector 1, 16 Kbytes */

targets/TARGET_STM/TARGET_STM32F7/flash_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int32_t flash_init(flash_t *obj)
4848
HAL_FLASHEx_OBGetConfig(&OBInit);
4949
/* Allow Access to option bytes sector */
5050
HAL_FLASH_OB_Lock();
51-
#ifdef MBED_CONF_TARGET_FLASH_DUAL_BANK
51+
#if MBED_CONF_TARGET_FLASH_DUAL_BANK
5252
if ((OBInit.USERConfig & OB_NDBANK_SINGLE_BANK) == OB_NDBANK_SINGLE_BANK)
5353
{
5454
error("The Dual Bank mode option byte (nDBANK) must be enabled (box unchecked)\n");
@@ -62,7 +62,7 @@ int32_t flash_init(flash_t *obj)
6262
}
6363
#endif
6464
#else // Devices supporting Single Bank only
65-
#ifdef MBED_CONF_TARGET_FLASH_DUAL_BANK
65+
#if MBED_CONF_TARGET_FLASH_DUAL_BANK
6666
#error "The Dual Bank configuration is not supported on this device."
6767
#endif
6868
#endif
@@ -207,7 +207,7 @@ static uint32_t GetSector(uint32_t address)
207207
{
208208
uint32_t sector = 0;
209209
uint32_t tmp = address - ADDR_FLASH_SECTOR_0;
210-
#if defined(MBED_CONF_TARGET_FLASH_DUAL_BANK) && defined(FLASH_OPTCR_nDBANK)
210+
#if (MBED_CONF_TARGET_FLASH_DUAL_BANK) && defined(FLASH_OPTCR_nDBANK)
211211
if (address < ADDR_FLASH_SECTOR_4) { // Sectors 0 to 3
212212
sector += tmp >> 14;
213213
} else if (address < ADDR_FLASH_SECTOR_5) { // Sector 4
@@ -244,7 +244,7 @@ static uint32_t GetSector(uint32_t address)
244244
static uint32_t GetSectorSize(uint32_t Sector)
245245
{
246246
uint32_t sectorsize = 0x00;
247-
#if defined(MBED_CONF_TARGET_FLASH_DUAL_BANK) && defined(FLASH_OPTCR_nDBANK)
247+
#if (MBED_CONF_TARGET_FLASH_DUAL_BANK) && defined(FLASH_OPTCR_nDBANK)
248248
if ((Sector == FLASH_SECTOR_0) || (Sector == FLASH_SECTOR_1) ||\
249249
(Sector == FLASH_SECTOR_2) || (Sector == FLASH_SECTOR_3) ||\
250250
(Sector == FLASH_SECTOR_12) || (Sector == FLASH_SECTOR_13) ||\

targets/targets.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,10 @@
14321432
"core": "Cortex-M7FD",
14331433
"extra_labels_add": ["STM32F7", "STM32F767", "STM32F767xI", "STM32F767ZI", "STM_EMAC"],
14341434
"config": {
1435+
"flash_dual_bank": {
1436+
"help": "Default board configuration is Single Bank Flash. If you enable Dual Bank with ST Link Utility, set value to 1",
1437+
"value": "0"
1438+
},
14351439
"d11_configuration": {
14361440
"help": "Value: PA_7 for the default board configuration, PB_5 in case of solder bridge update (SB121 off/ SB122 on)",
14371441
"value": "PA_7",
@@ -1932,6 +1936,10 @@
19321936
"extra_labels_add": ["STM32F7", "STM32F769", "STM32F769xI", "STM32F769NI", "STM_EMAC"],
19331937
"supported_form_factors": ["ARDUINO"],
19341938
"config": {
1939+
"flash_dual_bank": {
1940+
"help": "Default board configuration is Single Bank Flash. If you enable Dual Bank with ST Link Utility, set value to 1",
1941+
"value": "0"
1942+
},
19351943
"clock_source": {
19361944
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL | USE_PLL_HSI",
19371945
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",

0 commit comments

Comments
 (0)