2022-02-05 03:08 AM
Hi, I am using STM32G070KB controller. I tried to implement bootloader configuration via firmware as mentioned in document AN2606 and AN3155. But still its not entering boot mode. And also I need clarification for the "Execute BL_USART_Loop for USARTx".Can you please share any reference code or document for this?
2022-02-05 03:59 AM
Maybe you need show what you do. Start system bootloader or write own?
2022-02-05 07:18 AM
AN2606/AN3155 are the reference docs.
BL_USART_Loop is explained within AN3155, see Figure 1.
How are you trying to enter boot mode? How do you know it's not there?
Need to ensure all other BL interfaces are idle except the one you're using.
2022-02-06 08:21 PM
RCC->IOPENR |= (1<<0); /* Enable Clock for GPIO port A (PA2-Tx,PA3-Rx) */
GPIOA->MODER&=~(1<<28); /* Enable GPIO function for BLE PA8 */
GPIOA->MODER&=~(1<<29); /* Enable GPIO function for BLE PA8 */
GPIOA->PUPDR|=(1<<28); /* Enable GPIO function for BLE PA8 */
GPIOA->PUPDR&=~(1<<29); /* Enable GPIO function for BLE PA8 */
SET_BIT(FLASH->OPTR, FLASH_OPTR_nBOOT1);
CLEAR_BIT(FLASH->OPTR, FLASH_OPTR_nBOOT_SEL);
((void (*)(void)) *((uint32_t*) 0x1fff0000+4))();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
RCC->IOPENR = 0x00000000;
RCC->AHBENR = 0x00000000;
RCC->APBENR1 = 0x00000000;
RCC->APBENR2 = 0x00000000;
RCC->PLLCFGR = 0x00000000;
RCC->CR = 0x00000000;
/* Clear Interrupt Enable Register & Interrupt Pending Register */
for (int i=0;i<5;i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}
I configured boot mode settings via firmware with power on reset.
Using the above settings, I tried to read the boot mode. But its not entered.
2022-02-07 05:49 AM
From where your code is? Bootloader in system memory can be started two ways.
Seems you try method 2 , but your code isnt right. try
/**
* Function to perform jump to system memory boot from user application
*
* Call function when you want to jump to system memory
*/
void JumpToBootloader(void) {
void (*SysMemBootJump)(void);
/**
* Step: Set system memory address.
*
* For other families, check AN2606 document table 110 with descriptions of memory addresses
*/
volatile uint32_t addr = 0x1FFF0000; //0x1FFF0000;
/**
* Step: Disable RCC, set it to default (after reset) settings
* Internal clock, no PLL, etc.
*/
#if defined(USE_HAL_DRIVER)
HAL_RCC_DeInit();
#endif /* defined(USE_HAL_DRIVER) */
#if defined(USE_STDPERIPH_DRIVER)
RCC_DeInit();
#endif /* defined(USE_STDPERIPH_DRIVER) */
/**
* Step: Disable systick timer and reset it to default values
*/
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
/**
* Step: Disable all interrupts
*/
__disable_irq();
/**
* Step: Remap system memory to address 0x0000 0000 in address space
* For each family registers may be different.
* Check reference manual for each family.
*
* For STM32F4xx, MEMRMP register in SYSCFG is used (bits[1:0])
* For STM32F0xx, CFGR1 register in SYSCFG is used (bits[1:0])
* For others, check family reference manual
*/
//Remap by hand... {
#if defined(STM32F4)
SYSCFG->MEMRMP = 0x01;
#endif
//#if defined(STM32F0)
SYSCFG->CFGR1 = 0x01;
//#endif
//} ...or if you use HAL drivers
//__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(); //Call HAL macro to do this for you
/**
* Step: Set jump memory location for system memory
* Use address with 4 bytes offset which specifies jump location where program starts
*/
SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));
/**
* Step: Set main stack pointer.
* This step must be done last otherwise local variables in this function
* don't have proper value since stack pointer is located on different position
*
* Set direct address location which specifies stack pointer in SRAM location
*/
__set_MSP(*(uint32_t *)addr);
/**
* Step: Actually call our function to jump to set location
* This will start system memory execution
*/
SysMemBootJump();
/**
* Step: Connect USB<->UART converter to dedicated USART pins and test
* and test with bootloader works with STM32 Flash Loader Demonstrator software
*/
}
For G maybe you need change memory remap part. And maybe try 0x1FFF6800 addr
2022-02-07 08:45 PM
I have already tried this code but its not working for STM32G0. Or else is there any hardware connection for this condition?
and also i have been using STM32 cube programmer. Is it ok to use?
2022-02-08 08:33 PM
Yeah that code is working fine. I forgot to disable UART.