Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BLE,Build): Fix default PAL_NVM_SIZE, add compiler checks for NVM erase functions #776

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Libraries/Cordio/platform/targets/maxim/build/cordio.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ PLATFORM := maxim
RTOS ?= baremetal

# Used for storing pairing/bonding information
PAL_NVM_SIZE ?= 0x2000
PAL_NVM_SIZE ?= 0x4000

CFG_DEV := BT_VER=$(BT_VER)
CFG_DEV += SCH_CHECK_LIST_INTEGRITY=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void PalFlashWrite(void *pBuf, uint32_t size, uint32_t dstAddr)
/*!
* \brief Erase sector.
*
* \param[in] size Data size in bytes to be erased.
* \param[in] size Data size in sectors to be erased.
* \param[in] startAddr Word aligned address.
*
* \return None.
Expand All @@ -195,18 +195,25 @@ void PalFlashWrite(void *pBuf, uint32_t size, uint32_t dstAddr)
void PalFlashEraseSector(uint32_t size, uint32_t startAddr)
{
if(!PAL_NVM_IS_SECTOR_ALIGNED(startAddr)) {
WSF_ASSERT(FALSE);
PalSysAssertTrap();
}

/* Offset the address into flash */
#if defined (__GNUC__)
startAddr += (uint32_t)&__pal_nvm_db_start__;
#elif defined (__CC_ARM)
startAddr += (uint32_t)__pal_nvm_db_start__;
#elif defined (__ICCARM__)
startAddr += (uint32_t)__pal_nvm_db_start__;
#endif

while(size) {
WsfCsEnter();
MXC_FLC_PageErase(startAddr);
WsfCsExit();

startAddr += MXC_FLASH_PAGE_SIZE;
size -= MXC_FLASH_PAGE_SIZE;
size --;
}
}

Expand All @@ -221,15 +228,26 @@ void PalFlashEraseChip(void)
{
uint32_t startAddr, size;

#if defined (__GNUC__)
/* Offset the address into flash */
startAddr = (uint32_t)&__pal_nvm_db_start__;
size = (uint32_t)&__pal_nvm_db_end__ - (uint32_t)&__pal_nvm_db_start__;
#elif defined (__CC_ARM)
/* Offset the address into flash */
startAddr = (uint32_t)__pal_nvm_db_start__;
size = (uint32_t)__pal_nvm_db_end__ - (uint32_t)__pal_nvm_db_start__;
#elif defined (__ICCARM__)
/* Offset the address into flash */
startAddr = (uint32_t)__pal_nvm_db_start__;
size = (uint32_t)__pal_nvm_db_end__ - (uint32_t)__pal_nvm_db_start__ -1;
#endif

while(size) {
WsfCsEnter();
MXC_FLC_PageErase(startAddr);
WsfCsExit();

startAddr += MXC_FLASH_PAGE_SIZE;
size -= MXC_FLASH_PAGE_SIZE;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,19 @@ void PalFlashEraseSector(uint32_t size, uint32_t startAddr)
}

/* Offset the address into flash */
#if defined (__GNUC__)
startAddr += (uint32_t)&__pal_nvm_db_start__;
#elif defined (__CC_ARM)
startAddr += (uint32_t)__pal_nvm_db_start__;
#elif defined (__ICCARM__)
startAddr += (uint32_t)__pal_nvm_db_start__;
#endif

while(size) {
WsfCsEnter();
MXC_FLC_PageErase(startAddr);
WsfCsExit();

startAddr += MXC_FLASH_PAGE_SIZE;
size --;
}
Expand All @@ -217,12 +226,25 @@ void PalFlashEraseChip(void)
{
uint32_t startAddr, size;

#if defined (__GNUC__)
/* Offset the address into flash */
startAddr = (uint32_t)&__pal_nvm_db_start__;
size = (uint32_t)&__pal_nvm_db_end__ - (uint32_t)&__pal_nvm_db_start__;
#elif defined (__CC_ARM)
/* Offset the address into flash */
startAddr = (uint32_t)__pal_nvm_db_start__;
size = (uint32_t)__pal_nvm_db_end__ - (uint32_t)__pal_nvm_db_start__;
#elif defined (__ICCARM__)
/* Offset the address into flash */
startAddr = (uint32_t)__pal_nvm_db_start__;
size = (uint32_t)__pal_nvm_db_end__ - (uint32_t)__pal_nvm_db_start__ -1;
#endif

while(size) {
WsfCsEnter();
MXC_FLC_PageErase(startAddr);
WsfCsExit();

startAddr += MXC_FLASH_PAGE_SIZE;
size -= MXC_FLASH_PAGE_SIZE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void PalFlashWrite(void *pBuf, uint32_t size, uint32_t dstAddr)
/*!
* \brief Erase sector.
*
* \param[in] size Data size in bytes to be erased.
* \param[in] size Data size in sectors to be erased.
* \param[in] startAddr Word aligned address.
*
* \return None.
Expand All @@ -246,7 +246,7 @@ void PalFlashEraseSector(uint32_t size, uint32_t startAddr)
WsfCsExit();

startAddr += MXC_FLASH_PAGE_SIZE;
size -= MXC_FLASH_PAGE_SIZE;
size --;
}
}

Expand Down