cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 UART1 bootloader fails after TouchGFX init

Gabriel T
Senior

Hi,

MCU : STM32H743ZI

TouchGFX : 4.18.1

After I execute HAL::initialize(), my jump doesn't work anymore, I do get in the bootloader but the USART1 bootload doesn't ACK my requests. If I jump before HAL::initialize it does work. I tried to look at the register modified during HAL::initialize but I found nothing relevant and I do not have access to the code.

In TouchGFX code "TouchGFXGeneratedHAL.cpp" :

void TouchGFXGeneratedHAL::initialize()
{
    // BOOTLOAD jump working ok here
    HAL::initialize();
    // BOOTLOAD jump fails here

My jump code :

void Bootloader_Jump(void)
{
  uint32_t i=0;
  void (*SysMemBootJump)(void);
  volatile uint32_t BootAddr = 0x1FF09800;
  MODIFY_REG(RCC->D2CCIP2R, RCC_D2CCIP2R_USART16SEL, (uint32_t)(0U));
  __disable_irq();
  SysTick->CTRL = 0;
  HAL_RCC_DeInit();
  for (i=0;i<5;i++)
  {
  NVIC->ICER[i]=0xFFFFFFFF;
  NVIC->ICPR[i]=0xFFFFFFFF;
  }
  __enable_irq();
 
  /* Set up the jump to booloader address + 4 */
  SysMemBootJump = (void (*)(void)) (*((uint32_t *) ((BootAddr + 4))));
 
  /* Set the main stack pointer to the bootloader stack */
  __set_MSP(*(uint32_t *)BootAddr);
 
  /* Call the function to jump to bootloader location */
  SysMemBootJump();
 
  while (1)
  {
  /* Code should never reach this loop */
  }
}

Any ideas to make it work ?

4 REPLIES 4
Gabriel T
Senior

The issue also appears with USB bootload, before "HAL::initialize();" I get the correct "DFU in FS Mode". After "HAL::initialize();" I get unrecognized USB device

MM..1
Chief II

And what? Jump from app isnt official start. And

  __disable_irq();
  SysTick->CTRL = 0;
  HAL_RCC_DeInit();
  for (i=0;i<5;i++)
  {
  NVIC->ICER[i]=0xFFFFFFFF;
  NVIC->ICPR[i]=0xFFFFFFFF;
  }
  __enable_irq();

isnt perfect way to handle runned peripherals to valid state.

Use watchdog reset and jump to boot on main start.

Gabriel T
Senior

Thanks for your reply, I'm not sure I got what you tried to say. We want to perform this kind of bootloader jump https://community.st.com/s/article/STM32H7-bootloader-jump-from-application

 int main(void)
{
  /* USER CODE BEGIN 1 */
  if(__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)) __HAL_RCC_CLEAR_RESET_FLAGS();
  if(__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) {__HAL_RCC_CLEAR_RESET_FLAGS();Bootloader_Jump();}