Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions hal_st/stm32fxxx/FlashInternalStm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@

namespace
{
#if defined(STM32H5)
#if defined(FLASH_DBANK_SUPPORT) || defined(FLASH_BANK_SIZE)
uint32_t GetBank(const uint8_t* memoryBegin)
{
auto address = reinterpret_cast<uint32_t>(memoryBegin);
if (READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_SWAP_BANK) == 0)
{
// No Bank swap
return (address < (FLASH_BASE + FLASH_BANK_SIZE)) ? FLASH_BANK_1 : FLASH_BANK_2;
}
else
{
// Bank swap
return (address < (FLASH_BASE + FLASH_BANK_SIZE)) ? FLASH_BANK_2 : FLASH_BANK_1;
}
#if defined(FLASH_OPTSR_SWAP_BANK)
// Bank swap
if (READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_SWAP_BANK))
return (address < (FLASH_BASE + FLASH_BANK_SIZE)) ? FLASH_BANK_2 : FLASH_BANK_1;
#endif

return (address < (FLASH_BASE + FLASH_BANK_SIZE)) ? FLASH_BANK_1 : FLASH_BANK_2;

Check failure on line 18 in hal_st/stm32fxxx/FlashInternalStm.cpp

View workflow job for this annotation

GitHub Actions / Embedded Build (RelWithDebInfo, 10.3-2021.10, stm32wb55)

'FLASH_BANK_2' was not declared in this scope; did you mean 'FLASH_BASE'?

Check failure on line 18 in hal_st/stm32fxxx/FlashInternalStm.cpp

View workflow job for this annotation

GitHub Actions / Embedded Build (RelWithDebInfo, 10.3-2021.10, stm32wb55)

'FLASH_BANK_1' was not declared in this scope; did you mean 'FLASH_BASE'?

Check failure on line 18 in hal_st/stm32fxxx/FlashInternalStm.cpp

View workflow job for this annotation

GitHub Actions / Embedded Build (RelWithDebInfo, 10.3-2021.10, stm32wba52)

'FLASH_BANK_2' was not declared in this scope; did you mean 'FLASH_BANK_1'?

Check failure on line 18 in hal_st/stm32fxxx/FlashInternalStm.cpp

View workflow job for this annotation

GitHub Actions / Embedded Build (RelWithDebInfo, 10.3-2021.10, stm32g071)

'FLASH_BANK_2' was not declared in this scope; did you mean 'FLASH_BANK_1'?

Check failure on line 18 in hal_st/stm32fxxx/FlashInternalStm.cpp

View workflow job for this annotation

GitHub Actions / Embedded Build (RelWithDebInfo, 10.3-2021.10, stm32g070)

'FLASH_BANK_2' was not declared in this scope; did you mean 'FLASH_BANK_1'?
}
#endif

Expand Down Expand Up @@ -47,7 +44,7 @@

const auto flashBegin = reinterpret_cast<uint32_t>(flashMemory.begin());

#if defined(STM32WBA) || defined(STM32H5)
#if defined(FLASH_TYPEPROGRAM_QUADWORD)
detail::AlignedWriteBuffer<uint128_t, FLASH_TYPEPROGRAM_QUADWORD, true>(buffer, address, flashBegin);
#elif defined(STM32WB) || defined(STM32G4) || defined(STM32G0)
detail::AlignedWriteBuffer<uint64_t, FLASH_TYPEPROGRAM_DOUBLEWORD, false>(buffer, address, flashBegin);
Expand Down Expand Up @@ -96,6 +93,9 @@
eraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
eraseInitStruct.Page = beginIndex;
eraseInitStruct.NbPages = endIndex - beginIndex;
#if defined(FLASH_DBANK_SUPPORT) || defined(FLASH_BANK_BOTH)
eraseInitStruct.Banks = GetBank(flashMemory.begin());

Check failure on line 97 in hal_st/stm32fxxx/FlashInternalStm.cpp

View workflow job for this annotation

GitHub Actions / Embedded Build (RelWithDebInfo, 10.3-2021.10, stm32wba52)

'struct FLASH_EraseInitTypeDef' has no member named 'Banks'
#endif

auto result = HAL_FLASHEx_Erase(&eraseInitStruct, &pageError);
really_assert(result == HAL_OK);
Expand Down
Loading