cancel
Showing results for 
Search instead for 
Did you mean: 

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

pgspro1
Associate

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

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.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

3 REPLIES 3
Imen.D
ST Employee

Hello,

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

Kind Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

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.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hello,

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

Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen