diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c index f85f765cdb..95050f33cf 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c @@ -558,3 +558,20 @@ unsigned int stm32_rand_generate_nonblocking(unsigned char* output, unsigned int } #endif // #if HAL_USE_HW_RNG && defined(RNG) + +/* + see if we should limit flash to 1M on devices with older revisions of STM32F427 + */ +bool check_limit_flash_1M(void) +{ +#ifdef STM32F427xx + const uint16_t revid = (*(uint32_t *)DBGMCU_BASE) >> 16; + static const uint16_t badrevs[4] = { 0x1000, 0x1001, 0x1003, 0x1007 }; + for (uint8_t i=0; i<4; i++) { + if (revid == badrevs[i]) { + return true; + } + } +#endif + return false; +} diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h index 437bc91a01..8424a370be 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h @@ -54,6 +54,11 @@ uint64_t stm32_get_utc_usec(void); // hook for FAT timestamps uint32_t get_fattime(void); +/* + see if we should limit flash to 1M on devices with older revisions of STM32F427 + */ +bool check_limit_flash_1M(void); + // one-time programmable area #if defined(FLASH_OTP_BASE) #define OTP_BASE FLASH_OTP_BASE