cancel
Showing results for 
Search instead for 
Did you mean: 

IAP application with STM32CubeIDE/ STLink

Tu Nguyen Ngoc
Associate II

Hi everyone,

I'm following the LWIP_IAP application in STM32756G_EVAL 's Repository. The bootloader work fine, but I don't know how to config the application firmware to boot from a specify address flash.

Is this the right way to config flash memory of app firmware via .ld file like this

MEMORY
 
{
 
 RAM  (xrw)  : ORIGIN = 0x20000000,  LENGTH = 512K
 
 FLASH  (rx)  : ORIGIN = 0x8019000,  LENGTH = 924K
 
}

I spend 100Kb for bootloader.

One more question, could I use ST-Link Utility to program my application firmware. For testing purpose, in case my bootloader doesn't work correctly?

Thanks in advance

8 REPLIES 8

Need to also change address programmed into SCB->VTOR in SystemInit()

​

Yes, can write App via ST-LINK​

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

I think your user program start is not on a page boundary. This will give trouble. Either you erase the end of the bootlaoder or your can not erase the start of the user program!

Tu Nguyen Ngoc
Associate II

Thank both of you. I followed your instructions, but my app still failed to start.

Here is the code to jump into apps from bootloader

 if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
		/* Jump to user application */
		JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
		Jump_To_Application = (pFunction) JumpAddress;
		/* Initialize user application's Stack Pointer */
		__set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
		Jump_To_Application();
		/* do nothing */
		while(1);
}
 
#define USER_FLASH_FIRST_PAGE_ADDRESS 0x08020000

I changed my STM32F767VGTX_FLASH.ld file:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K
  FLASH    (rx)    : ORIGIN = 0x8020000,   LENGTH = 896K
}

Also set SCB->VTOR :

#define VECT_TAB_OFFSET  0x20000 
void SystemInit(void){
 ... 
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
 }

I don't know if I still missing something?

Thanks

0693W000000VC2uQAG.pngOne more strange thing:

The value store in address 0x8020000 is 0x20080000 which mean if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) will return false condition. That 's why my bootloader can't jump to my app.

Hi clive1,

Could you help me point out what I have done wrong. I followed all your instructions, but I still cannot jump to my app. I compiled the code in Keil C, it works well. Here is some clues:

0693W000000VC2uQAG.pngOne more strange thing:

The value store in address 0x8020000 is 0x20080000 which mean if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) will return false condition. That 's why my bootloader can't jump to my app.

Thank you.

Piranha
Chief II

Don't post the same content multiple times!

> The value store in address 0x8020000 is 0x20080000 which mean if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) will return false condition. That 's why my bootloader can't jump to my app.

So you already know where the problem is. Why don't you solve it? Have you answered to yourself what that code does?

Sorry, my bad. I tried to change mask value from 0x2FFE0000 to 0x2FF00000 , so I can jump from bootloader to app. But I don't think it is correct way.

BTW, If I compile the code in Keil C, I have different first 4 bytes in flash (0x20008098) which is satisfy bootloader requirement (0x20008098 & 0x2FFE0000 =0x20000000). Isn't it weird?

Thank you.

Piranha
Chief II

You still haven't answered the following questions:

  1. What is that first word in vector table? The answer is in PM0253.
  2. What are you trying to do with that value in your if condition?

By the way, as everything with ST's software, this booting approach is terrible anyway. Read my description of a much better and simpler approach here:

https://community.st.com/s/question/0D50X0000AFpTmUSQV/using-nvicsystemreset-in-bootloaderapplication-jumps