以前做过STM32的IAP,没有能发现一些问题。可是今天再读IAP的软件包。不明白下面这段代码的原理。- /* Get the number of block (4 or 2 pages) from where the user program will be loaded */
- BlockNbr = (FlashDestination - 0x08000000) >> 12;
- /* Compute the mask to test if the Flash memory, where the user program will be
- loaded, is write protected */
- #if defined (STM32F10X_MD) || defined (STM32F10X_MD_VL)
- UserMemoryMask = ((uint32_t)~((1 << BlockNbr) - 1));
- #else /* USE_STM3210E_EVAL */
- if (BlockNbr < 62)
- {
- UserMemoryMask = ((uint32_t)~((1 << BlockNbr) - 1));
- }
- else
- {
- UserMemoryMask = ((uint32_t)0x80000000);
- }
- #endif /* (STM32F10X_MD) || (STM32F10X_MD_VL) */
- /* Test if any page of Flash memory where program user will be loaded is write protected */
- if ((FLASH_GetWriteProtectionOptionByte() & UserMemoryMask) != UserMemoryMask)
- {
- FlashProtection = 1;
- }
- else
- {
- FlashProtection = 0;
- }
复制代码 |