Skip to main content
Tu Nguyen Ngoc
Associate III
March 31, 2020
Question

IAP application with STM32CubeIDE/ STLink

  • March 31, 2020
  • 5 replies
  • 1913 views

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

This topic has been closed for replies.

5 replies

Tesla DeLorean
Guru
March 31, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Tu Nguyen Ngoc
Associate III
April 27, 2020

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.

Uwe Bonnes
Chief
March 31, 2020

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 III
April 1, 2020

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

Tu Nguyen Ngoc
Associate III
April 2, 2020

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.

Piranha
Principal III
April 27, 2020

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?

Tu Nguyen Ngoc
Associate III
April 28, 2020

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
Principal III
April 28, 2020

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