cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE how to set offset for program?

binhla
Associate II

I am making a DFU for stm32f4-discovery board.

My DFU is using a project generated by STM32CubeMX V1.0.

And It worked well with the program generated by the STM32CubeMX V1.0

But when I worked with a project generated by STM32CubeIDE, I cannot make the main program run.

I had made these steps:

First, in system_stm32f4xx.c

#define USER_VECT_TAB_ADDRESS
 
#if defined(USER_VECT_TAB_ADDRESS)
/*!< Uncomment the following line if you need to relocate your vector Table
     in Sram else user remap will be done in Flash. */
/* #define VECT_TAB_SRAM */
#if defined(VECT_TAB_SRAM)
#define VECT_TAB_BASE_ADDRESS   SRAM_BASE       /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#else
#define VECT_TAB_BASE_ADDRESS   FLASH_BASE      /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x8000     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#endif /* VECT_TAB_SRAM */
#endif /* USER_VECT_TAB_ADDRESS */

Seconds, in STM32F407VGTX_FLASH.ld

/* Memories definition */
MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  FLASH    (rx)    : ORIGIN = 0x8008000,   LENGTH = 992K
}

Third, in STM32F407VGTX_RAM.ld, I made the same change

/* Memories definition */
MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  FLASH    (rx)    : ORIGIN = 0x8008000,   LENGTH = 992K
}

1 ACCEPTED SOLUTION

Accepted Solutions
Semer CHERNI
ST Employee

Hello @binhla​ 

First let me thank you for posting.

I see that you are making your own bootloader.

For this purpose I recommend this ST tutorial on how to make a simple bootloader.

How to Create a Super Simple Bootloader, Part 1: Getting Started - YouTube

In case the tutorial helped you please tag this poste as Best Answer so it will be visible to other community members.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Semer CHERNI
ST Employee

Hello @binhla​ 

First let me thank you for posting.

I see that you are making your own bootloader.

For this purpose I recommend this ST tutorial on how to make a simple bootloader.

How to Create a Super Simple Bootloader, Part 1: Getting Started - YouTube

In case the tutorial helped you please tag this poste as Best Answer so it will be visible to other community members.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

binhla
Associate II

Thank you for your response.

I will check the tutorial and inform you soon.

Best regards.

Dears,

I have watched the series.

After watching part 4, I have my bootloader and main application generated by STM32CubeIDE.

But the stm32F407VGTx cannot run the main application and stuck on the bootloader.

With the same bootloader, It work with the Application that generated by STM32CubeIDE.

Can you send an example of the main application with VECT_TAB_OFFSET is 0x8000 for the stm32F407VGTx?

Best regards.

binhla
Associate II

Dear all.

Just a notice.

The function SystemClock_Config in the bootloader and the app must be the same.

Other wise, the bootloader may fail to jump into the app.

Best regards.