Code: Select all
#elif defined(STM32F439xx) || defined(STM32F429xx)
#define STM32F429_439xx
#define STM32F4XX
#elif defined(STM32F437xx) || defined(STM32F427xx)
#define STM32F427_437xx
#define STM32F4XX
...
/*===========================================================================*/
/* STM32F439xx, STM32F429xx, STM32F437xx, STM32F427xx. */
/*===========================================================================*/
#if defined(STM32F429_439xx) || defined(STM32F427_437xx)
...
#endif /* defined(STM32F429_439xx) || defined(STM32F427_437xx) */
becomes...
Code: Select all
#elif defined(STM32F439xG) || defined(STM32F429xG)
#define STM32F429_439xG
#define STM32F4XX
#elif defined(STM32F437xG) || defined(STM32F427xG)
#define STM32F427_437xG
#define STM32F4XX
#elif defined(STM32F439xI) || defined(STM32F429xI)
#define STM32F429_439xI
#define STM32F4XX
#elif defined(STM32F437xI) || defined(STM32F427xI)
#define STM32F427_437xI
#define STM32F4XX
...
/*===========================================================================*/
/* STM32F439xG, STM32F429xG, STM32F437xG, STM32F427xG. */
/*===========================================================================*/
#if defined(STM32F429_439xG) || defined(STM32F427_437xG)
...
/* Flash attributes.*/
#define STM32_FLASH_DUAL_BANK_PERMANENT FALSE
...
#endif /* defined(STM32F429_439xG) || defined(STM32F427_437xG) */
/*===========================================================================*/
/* STM32F439xI, STM32F429xI, STM32F437xI, STM32F427xI. */
/*===========================================================================*/
#if defined(STM32F429_439xI) || defined(STM32F427_437xI)
...
/* Flash attributes.*/
#define STM32_FLASH_DUAL_BANK_PERMANENT TRUE
...
#endif /* defined(STM32F429_439xI) || defined(STM32F427_437xI) */
We then need to go and edit os/common/ext/ST/STM32F4xx/stm32f4xx.h to change the check for these defined values to have the correct suffix for all 4 device types, and update all respective demo applications and board files to also use these suffix. However, this may also break any other projects that depend on ChibiOS that define STM32F427xx STM32F429xx STM32F437xx or STM32F439xx. Unless we don't change the original registry definition and instead just have that default to false? So effectively we'd have...
Code: Select all
#elif defined(STM32F439xx) || defined(STM32F429xx)
#define STM32F429_439xx
#define STM32F4XX
#elif defined(STM32F437xx) || defined(STM32F427xx)
#define STM32F427_437xx
#define STM32F4XX
#elif defined(STM32F439xI) || defined(STM32F429xI)
#define STM32F429_439xI
#define STM32F4XX
#elif defined(STM32F437xI) || defined(STM32F427xI)
#define STM32F427_437xI
#define STM32F4XX
...
/*===========================================================================*/
/* STM32F439xx, STM32F429xx, STM32F437xx, STM32F427xx. */
/*===========================================================================*/
#if defined(STM32F429_439xx) || defined(STM32F427_437xx)
...
/* Flash attributes.*/
#define STM32_FLASH_DUAL_BANK_PERMANENT FALSE
...
#endif /* defined(STM32F429_439xx) || defined(STM32F427_437xx) */
/*===========================================================================*/
/* STM32F439xI, STM32F429xI, STM32F437xI, STM32F427xI. */
/*===========================================================================*/
#if defined(STM32F429_439xI) || defined(STM32F427_437xI)
...
/* Flash attributes.*/
#define STM32_FLASH_DUAL_BANK_PERMANENT TRUE
...
#endif /* defined(STM32F429_439xI) || defined(STM32F427_437xI) */
If this was the case then it's up to the application developer to ensure they define the correct value in their board files.
It almost seems like it'd be more manageable to just check the flash size register (defined by FLASHSIZE_BASE), and if it's 2048 the function just returns true. The example implementation I presented above indirectly does this because the flash_descriptor_t "size" member will equal the scaled FLASH SIZE register value. But if it's preferred to offload this work to the compiler and we don't mind changing os/common/ext/ST/STM32F4xx/stm32f4xx.h, I can investigate the registry method further.