cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Jumping to Bootloader from Application on STM32H747 with Riverdi Display and TouchGFX

Sasa1234
Associate III

Hello everyone,

I'm facing an issue with jumping from my application to the bootloader on an STM32H747 microcontroller. I'm using a 7-inch Riverdi display and have developed graphical interfaces using TouchGFX. My application, which I've built using only the M7 core (disabling the M4 core) and FreeRTOS for task management and graphics, has its main file structured as man1.c attached.I've also created a bootloader program with the following structure:  The bootloader works perfectly when the STM32H747xx_FLASH.ld file contains the following instruction:

Assolutamente! Ecco la traduzione del tuo post in inglese, adatta per un forum tecnico come quello di STM:

Subject: Trouble Jumping to Bootloader from Application on STM32H747 with Riverdi Display and TouchGFX

Hello everyone,

I'm facing an issue with jumping from my application to the bootloader on an STM32H747 microcontroller. I'm using a 7-inch Riverdi display and have developed graphical interfaces using TouchGFX. My application, which I've built using only the M7 core (disabling the M4 core) and FreeRTOS for task management and graphics, has its main file structured as follows:

I've also created a bootloader program with the following structure:

The bootloader works perfectly when the STM32H747xx_FLASH.ld file contains the following instruction:

MEMORY
{
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
/*FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K*/ /* Memory is divided. Actual start is 0x08000000 and actual length is 2048K */

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 250K

DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (xrw) : ORIGIN = 0xD0000000, LENGTH = 4M
SDRAM2 (xrw) : ORIGIN = 0xD0400000, LENGTH = 4M
}

 

However, when I try to jump to the bootloader from my application using a jump_to_bootloader() function, the jump to the bootloader fails. This is code snipet:

 

typedef void (*pFunction)(void);
 
 
#define BOOT_ADDR 0x080B50000
void jump_to_bootloader(void)
{
 
 
 
__disable_irq();  // Disabilita tutti gli interrupt
 
HAL_RCC_DeInit(); // Disabilita tutti i clock
HAL_DeInit();     // Deinizializza le periferiche
 
 
 
SCB_DisableICache();
SCB_DisableDCache();
 
// Disabilita SysTick timer
   // SysTick->CTRL = 0;
   // SysTick->LOAD = 0;
   // SysTick->VAL  = 0;
 
 
// Pulisci flag di reset
__HAL_RCC_CLEAR_RESET_FLAGS();
 
 
 
__set_MSP(*(__IO uint32_t*)BOOT_ADDRESS); // Imposta il nuovo Stack Pointer
 
 
SCB->VTOR = BOOT_ADDRESS;
 
// Puntatore alla funzione di reset dell'applicativo
uint32_t JumpAddr = *(__IO uint32_t*)(BOOT_ADDRESS+ 4);
pFunction Jump = (pFunction)JumpAddr;
 
__enable_irq(); // Riabilita gli interrupt prima del salto
// Esegui il salto
Jump(); // Salta all’applicazione
// Se il salto fallisce, reset
NVIC_SystemReset();
}

 

 I've made to the .ld files of both the application and the bootloader.

// Application .ld

/* Memories definition */
MEMORY
{
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
/*FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K*/ /* Memory is divided. Actual start is 0x08000000 and actual length is 2048K */

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 724K

DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
QUADSPI (r) : ORIGIN = 0x90000000, LENGTH = 64M
SDRAM (xrw) : ORIGIN = 0xD0000000, LENGTH = 4M
SDRAM2 (xrw) : ORIGIN = 0xD0400000, LENGTH = 4M
}

// Bootloader.ld

 

/* Memories definition */
MEMORY
{
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
/*FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K*/ /* Memory is divided. Actual start is 0x08000000 and actual length is 2048K */

FLASH (rx) : ORIGIN = 0x08B500000, LENGTH = 250K

DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
SDRAM (xrw) : ORIGIN = 0xD0000000, LENGTH = 4M
SDRAM2 (xrw) : ORIGIN = 0xD0400000, LENGTH = 4M
}

 

 

Could someone please advise on what modifications I need to make in both the application and the bootloader code to successfully jump to the bootloader? Is there something I'm missing in the process?How may I had to manage all peripherals?

Thank you in advance for your help!

 

 

 

21 REPLIES 21

In basic reply deinit isnt required, but for clean visual some steps as off backlight , stop refresh display is ok.

Some peripherals for example RTC isnt reset with NVIC reset , but i mean you dont use it.

Then simply create noinit variable marker and set it to right value before reset ...

Sasa1234
Associate III

Hi everyone!
After a lot of trial and error, I finally solved my STM32 dual-application setup issue. I created two projects:

  1. A bootloader, which starts at address 0x08000000

  2. An application, located at  0x08020000

they have these .ld files

Bootloader .ld (128KB at start of Flash):
MEMORY
{
  FLASH   (rx)   : ORIGIN = 0x08000000, LENGTH = 128K
  RAM_D1  (xrw)  : ORIGIN = 0x24000000, LENGTH = 512K
  DTCMRAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
  RAM_D2  (xrw)  : ORIGIN = 0x30000000, LENGTH = 288K
  RAM_D3  (xrw)  : ORIGIN = 0x38000000, LENGTH = 64K
  ITCMRAM (xrw)  : ORIGIN = 0x00000000, LENGTH = 64K
}

  and .ld file for the second project.

MEMORY
{
  FLASH    (rx)   : ORIGIN = 0x08020000, LENGTH = 896K
  RAM_D1   (xrw)  : ORIGIN = 0x24000000, LENGTH = 512K
  DTCMRAM  (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
  RAM_D2   (xrw)  : ORIGIN = 0x30000000, LENGTH = 288K
  RAM_D3   (xrw)  : ORIGIN = 0x38000000, LENGTH = 64K
  ITCMRAM  (xrw)  : ORIGIN = 0x00000000, LENGTH = 64K
  QUADSPI  (r)    : ORIGIN = 0x90000000, LENGTH = 64M
  SDRAM    (xrw)  : ORIGIN = 0xD0000000, LENGTH = 4M
  SDRAM2   (xrw)  : ORIGIN = 0xD0400000, LENGTH = 4M
}

 In the main.c file of bootloader I use this function

typedef void (*pFunction)(void);

static void JumpToApplication(void)
{
    __disable_irq();          // Disable all interrupts
    HAL_RCC_DeInit();         // Reset clock configuration
    HAL_DeInit();             // Deinit peripherals
    SysTick->CTRL = 0;        // Disable SysTick if running

    __set_MSP(*(__IO uint32_t*)0x08020000); // Set new MSP from app vector table
    SCB->VTOR = 0x08020000;                 // Point VTOR to new app

    uint32_t JumpAddr = *(__IO uint32_t*)(0x08020000 + 4); // Reset_Handler address
    pFunction Jump = (pFunction)JumpAddr;

    __enable_irq();           // Re-enable interrupts if needed

    Jump();                   // Execute the jump

    NVIC_SystemReset();       // If jump fails, reset
}

  

Everything now works perfectly. The bootloader initializes, then jumps to the second application at 0x0802000 without issues.

Big thanks to everyone who offered support and tips during this process — your help made it happen!