cancel
Showing results for 
Search instead for 
Did you mean: 

Code getting stuck after changing FLASH start address in linker file.

DDosi
Associate II

Hello,

I am working with the stm32f413VGT (100 pin) controller on a custom hardware.

The project I am working on will be start by the bootloader. The bootloader is flashed at address 0x8000000.

My project should start from FLASH address 0x08040000 and I have changed the address in the linker file.

0693W00000Y9oW6QAJ.pngThe project worked fine with the default FLASH address 0x08000000 (without the bootloader), but it did not work after changes in linker file.

I have tried debugging the problem and the code is getting struck on HAL_delay() function. If I remove the delay then it is getting stuck on the first printf() function it reached.

Do I need to do something else to change the start address?

6 REPLIES 6
Rim LANDOLSI
ST Employee

Hello DDosi,

Thank you for reporting your issue !

In order to reproduce your issue, could you please provide your project to further analyze the problem.

Thanks,

Rim

Bob S
Principal

Did you also change the VTOR register to point to the applications vector table at 0x08040000? If not, all interrupts from the application will jump to the bootloader's ISR functions.

Make sure the setting of SCB->VTOR in SystemInit() points at the address of your vector table as built.

I would suggest using linker symbols directly rather than the defines ST chooses to use.

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

Thanks for the reply.

Yes, I didn't do any changes with SCB->VTOR.

I have made the changes in the system_stm32f4xx.c file (changed the SCB->VTOR to 0x08040000) and now the program runs as expected if flashed directly from the IDE.

But is still not able to boot from the bootloader.

the bootloader is downloading the .bin file and writing it to the flash from address 0x08040000.

And using the below code to start the application ->

/* User typedef */
typedef void (*pFunction)(void);
 
void BL_JumpToApplication(void)
{
	uint32_t  JumpAddress = *(__IO uint32_t*)(APPLICATION_ADDRESS + 4);
	pFunction Jump        = (pFunction)JumpAddress;
 
	HAL_RCC_DeInit();
	HAL_DeInit();
 
	SysTick->CTRL = 0;
	SysTick->LOAD = 0;
	SysTick->VAL  = 0;
 
	__set_MSP(*(__IO uint32_t*)APPLICATION_ADDRESS);
	Jump();
}

APPLICATION ADDRESS = (uint32_t) 0x08040000

I have another .bin file that works well with this bootloader.

Am I still missing something?

Again, thank you for your help. ��

Bob S
Principal

Open the dissassembly window in your debugger and single step through that function and the Jump() call. What happens? Does it go through the startup code for the application? If you just "let it run" then pause the debugger, where is the PC (you'll need the MAP file and possibly assembly listing for your application).

Rim LANDOLSI
ST Employee

Hello DDosi,

I have tried two methods to create bootloader project flashed at address(0x8000000), one of these methods uses BL_JumpToApplication function that you are using. It works fine with my application which started at the address (0x08040000).

Could you please provide the application main code that is getting stuck on HAL_delay() function to further analyze the problem.