AnsweredAssumed Answered

STM32F072R8 Bootloader jumping with USART3

Question asked by Raj Patel on Aug 24, 2017
Latest reply on Aug 25, 2017 by Raj Patel

   I am trying to utilizes the "Flash Loader Demonstrator by STM" to download new firmware onto the STM32F072R8 chip and I will not be able to use the pin  BOOT0  on my board. The idea is to use the main program to jump to system bootloader and use USART3 to communicate with the Flash Loader.  

   My board has 4 UARTs that are connected to other sensor and devices. USART1 is used for a LTE device, UART2 is used for a GPS device,USART3 is used to connect to PC, and USART4 is used for a LORA device. To test the bootloader, I have a relay that is connected to a GPIO pin. Onces the GPIO pin goes high, the program goes to the jumping function. The program correctly jumps to the system memory but the Flash Loader gets no response to the target.  My main program does not initialize any of the Uarts. The only thing that I set up is the GPIO for the relay. 

Below is the code that I am using  for jumping. I am missing something in the jumping function. 

 

USART3 is connected to PB10 and PB11.  I have the RX and TX connected, correctly. 

 

typedef struct{
uint8_t MODE;
}sysState;

 

// Relay 2 - brown wire to Connector
void Configure_PC0(void) {

GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
NVIC_InitTypeDef NVIC_InitStruct;
/* Enable clock for GPIOC */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

/* Enable clock for SYSCFG */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStruct);

}

 

int main(void)
{
sysState gState;
gState.MODE = RUNMODE;
Timers_Init();
Led_Init();
Configure_PC0();


//Turn off the Led's Initially
Led_State(LED_OFF, LED1);
Led_State(LED_OFF, LED2);
Led_State(LED_OFF, LED3);

Led_PowerOn();
uint8_t ON_OFF;
for(;;)
{

ToggleHeartbeat();  // toggle LED1 
ON_OFF = GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_0);  //read relay


if(gState.MODE==BOOTMODE || ON_OFF== 1)
{ // pin pin is pressed
   Led_State(LED_ON, LED2);
   Led_State(LED_ON, LED3);
   // JUMP to internal system bootloader
      jumpBootloader(1);
}
}
}

 

void jumpBootloader(char i)

{
   void (*SysMemBootJump)(void);
* For STM32F072, system memory is on 0x1fffC800
*/
volatile uint32_t addr = 0x1fffC800;

RCC_DeInit();
// Step: Disable systick timer and reset it to default values
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;

__disable_irq();

SYSCFG->CFGR1 = 0x01;

SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));

__set_MSP(*(uint32_t *)addr);

SysMemBootJump();

 

/**
* Step: Connect USB<->UART converter to dedicated USART pins and test
* and test with bootloader works with STM32 Flash Loader Demonstrator software
*/


}

Outcomes