Skip to main content
pgspro1
Visitor II
January 25, 2019
Solved

In stm32l4xx_hal.c, there is a bug with HAL_SYSCFG_EnableMemorySwappingBank().

  • January 25, 2019
  • 3 replies
  • 992 views

The code is identical to the Disable version. The enable swapping is currently this:

void HAL_SYSCFG_EnableMemorySwappingBank(void)

{

 *(__IO uint32_t *)FB_MODE_BB = 0x00000000UL;

}

 and instead of = 0, it should be the equivalent of 0x100.

Also, the lower 3-bits should be maintained since they are MEM_MODE bits. As it turns out, %000 is Main Flash memory, which is probably good for most, but it's still a bad implementation.

This topic has been closed for replies.
Best answer by Imen.D

Hi @pgspro1​ ,

This is a Bit Banding access, not a full register access.

/* Alias word address of FB_MODE bit */
#define MEMRMP_OFFSET SYSCFG_OFFSET
#define FB_MODE_BitNumber 8U
#define FB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32U) + (FB_MODE_BitNumber * 4U))

So, there is a bug and the fix should be :

void HAL_SYSCFG_EnableMemorySwappingBank(void)
{
 *(__IO uint32_t *)FB_MODE_BB = 0x00000001UL;
}

Avantage of the bit banding, No effects on the other bits of the SYSCFG_MEMRMP register with this single instruction.

Thanks for highlighting this issue.

Kind Regards,

Imen.

3 replies

ST Technical Moderator
February 1, 2019

Hello,

We will check this issue internally and we will come back to you.

Kind Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Imen.DBest answer
ST Technical Moderator
February 4, 2019

Hi @pgspro1​ ,

This is a Bit Banding access, not a full register access.

/* Alias word address of FB_MODE bit */
#define MEMRMP_OFFSET SYSCFG_OFFSET
#define FB_MODE_BitNumber 8U
#define FB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32U) + (FB_MODE_BitNumber * 4U))

So, there is a bug and the fix should be :

void HAL_SYSCFG_EnableMemorySwappingBank(void)
{
 *(__IO uint32_t *)FB_MODE_BB = 0x00000001UL;
}

Avantage of the bit banding, No effects on the other bits of the SYSCFG_MEMRMP register with this single instruction.

Thanks for highlighting this issue.

Kind Regards,

Imen.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
ST Technical Moderator
April 15, 2019

Hello,

This issue is fixed with the new release of STM32CubeL4 V1.14.0 available on the ST web site.

Regards,

Imen.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks