cancel
Showing results for 
Search instead for 
Did you mean: 

STM32l073RZ dual boot, bank 2 not work.

João Baptista
Associate II

Dear.

I work with stm32l073RZ and I have a blinking led code and that code works on bank1, but it doesn't work on bank2. The strangest thing is that I also used the sample code for a flashing led from stmcubel0 and it worked. I think it may be because of stmcubel0 v12.

Can someone help me?

4 REPLIES 4
Imen.D
ST Employee

Hello @Jo�o Baptista​ ,

Please, have a look to the STM32L073 errata sheet to check if you have the same conditions as described in the note about this issue :

2.1.2 BFB2 bit does not select boot from Bank 2 system memory

So, this document describe the workaround.

If you still have this problem, please provide more information on the steps to understand your case.

Let me know if the issue occurs or not with the FLASH example available within STM32CubeL0 for the NUCLEO-L073RZ?

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
João Baptista
Associate II

Hello @Imen DAHMEN​ .

Thanks for your awnser.

I will test the solution on the errata sheet and count the results.

The example of Flash in stm32cubeL0 I think it has no problem because I can change the banks, but after solving the problem with bank2 I tell you new information.

Regards.

João Baptista

João Baptista
Associate II

Hello @Imen DAHMEN​ .

I changed the code in systeminit () and downloaded a blinking led code in bank 2. I used the stmprogram to change the bfb2 bit and continued not to execute the code.

Below I leave the code of the function that I did for you to see if I did something wrong.

#define BANK2_START_ADDRESS_128KB 0x08010000 /* Bank 2 Start Address
(128KB) */
#define FLASH_START_ADDRESS 0x08000000 /* Flash Start Address
(Bank1) */
#define ENGI_SALESTYPE_ADDRESS 0x1FF80034
#define ENGI_SALESTYPE_MASK 0x00000C00
#define ENGI_SALESTYPE_192KB 0x00000000
#define ENGI_SALESTYPE_128K 0x00000400
#define ENGI_SALESTYPE_64K 0x00000C00
#define SALESTYPE_192KB_DB 0x11001100
#define SALESTYPE_128K_DB 0x22002200
#define SALESTYPE_64K_SB 0x33003300
#define SYSCFG_MEMRMP_ADDRESS 0x40010000
#define SYSCFG_MEMMODE_MASK 0x00000003
#define SYSCFG_MEMMODE_SYSMEM 0x00000001
#define SYSCFG_FBMODE_MASK 0x00000008
#define DATA_VALUE_SELECT 0x08080000 /* Location where to store
the value allowing to boot on Bank2 and Bank1 */
#define DATA_BANK2_SELECTED 0x37 /* This value indicates that
boot from Bank2 is required */
#define DATA_BANK1_SELECTED 0x73 /* This value indicates that
boot from Bank1 is required */
/* Non user defines: these values must not be modified by user */
#define BANK2_START_ADDRESS_192KB 0x08018000 /* Bank 2 Start Address
(192KB) */
 
 
void SystemInit (void)
{
	uint32_t SalesType,Bank2Addr;
	void (*start_of_bootloader)(void);
 
	start_of_bootloader = (void(*)(void))*(unsigned int*)0x1FF00004; /*
	0x1FF00004 is the reset vector of the system flash*/
	 /* Check what is the device salestype (192KB, 128KB or 64KB) */
	 	 if (((*(__IO uint32_t *) (ENGI_SALESTYPE_ADDRESS)) & ENGI_SALESTYPE_MASK) == ENGI_SALESTYPE_192KB)
	 	 {
	 /* If 192KB salestype */
	 		 SalesType = SALESTYPE_192KB_DB;
	 	 }
	 	 else if (( (*(__IO uint32_t *) (ENGI_SALESTYPE_ADDRESS)) & ENGI_SALESTYPE_MASK) == ENGI_SALESTYPE_128K)
	 	 {
	 		 /* If 128KB salestype */
	 		 SalesType = SALESTYPE_128K_DB;
	 	 }
	 	 else
	 	 {
	 		 /* If 64KB salestype */
	 		 SalesType = SALESTYPE_64K_SB;
	 	 }
 
	 	 /* Enable the SYSCFG APB Clock */
	 *(__IO uint32_t *) 0x40021034 |= ((uint32_t)0x00000001);
 
	 /************************ Get salestype ***********************/
 
	  /* Manage case when single bank salestypes are used */
	 	 if (SalesType != SALESTYPE_64K_SB)
	 	 {
	 		 /* Get bank2 start address depending on the package */
	 		 Bank2Addr = (SalesType == SALESTYPE_192KB_DB)?
	 				 BANK2_START_ADDRESS_192KB : BANK2_START_ADDRESS_128KB;
 
	 		 	 if (((SYSCFG->CFGR1 & SYSCFG_FBMODE_MASK) ==0))
	 		 	 { /* we are in bank1*/
	 		 		 /************************ Check Data value ************************/
	 		 		 /* If data value selected to remap Bank2 */
	 		 		 if (*(__IO uint8_t *)DATA_VALUE_SELECT == DATA_BANK2_SELECTED)
	 		 		 {
	 		 			 if (*(unsigned int*)Bank2Addr>0x20000000 && *(unsigned int*)Bank2Addr<=0x20005004 )
	 		 			 {
	 		 				 start_of_bootloader();
	 		 			 }
	 		 		 }
	 		 	 }
	 	 }
 
	 	 /* Configure the Vector Table location add offset address ------------------*/
#if defined (USER_VECT_TAB_ADDRESS)
  SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#endif /* USER_VECT_TAB_ADDRESS */
}

PPham.2
Associate

hello everyone.

Do you know about #define SALESTYPE_64K_SB 0x33003300

what is 0x33003300 ?

because in the my project also have 0x33003300 but i don't know it is what.

please help me.

thanks.