cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072R8 Bootloader jumping with USART3

Raj Patel
Associate II
Posted on August 24, 2017 at 17:18

   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

*/

}

#uart3 #boot0 #stm32f072 #bootloader
8 REPLIES 8
Posted on August 24, 2017 at 19:18

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

Not really the method I've demonstrated/advocated. Try stepping and debugging it. Try doing the mapping and then jumping via the 0x00000000 address not 0x1FFFC800, or at least confirm you can see the ROM at zero.

You disable the interrupts on the processor, where do you expect them to be enabled?

The System Loader expects all the non USART3_RX pins to be quiet, it is looking for signals. Consider writing your own loader.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Ran Kai
Associate II
Posted on August 24, 2017 at 20:51

I am having the same problem with my target getting no response on any usart at all.  Even the boot0 pin doesn't work for me.  My hardware setup with usart and terminal is working fine so no problem with communication.  

I tried sending 0x7F hex using terminal with pin boot0=1 and get no response.  Do you have atleast that working on any other ports Raj?

Posted on August 25, 2017 at 15:48

I have not tried putting the boot0 pin high, yet. I will try the bootloading on the  stm32fo discovery board to keep things simple. I am going to try each UART connection UART1, UART2, UART3 and see what  results. 

Raj Patel
Associate II
Posted on August 25, 2017 at 18:39

I got the bootloader to work  USART 1. I disconnected the debugger , I was able to program with the demo programer

Posted on August 25, 2017 at 17:02

Before going off the deep end, the pins/USARTs supported by the System Loader on the STM32F07xx are

USART1 PA9/PA10

USART2 PA14/PA15 - Likely to conflict with SWD debugger

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 25, 2017 at 17:50

I will give USART 1.

Posted on August 26, 2017 at 01:33

On one of the posts someone mentioned they were able to succeed after kept trying a few times.  You can try that on usart 3 and see if that works.  

Posted on August 26, 2017 at 01:35

Think we pretty much established that USART3 isn't supported in any configuration.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..