Skip to main content
Mgawa.1
Associate II
Oct 18, 2020 2:10 PM UTC
Solved

When jumping to application 1 or 2 from custom bootloader, interrupts are not working

I am using a custom bootloader in STM32F091RB controller (cortex M0) which has a system clock of 8MHz and my application STM32F091VC controller (cortex M0) has system clock of 48MHz. Will it affect my application peripheral's interrupt. As my interrupts are not working. I have also mapped vector table to SRAM and again remapped it to 0x00000000. Though its not working.

Below is from bootloader code.

#define SRAM_BASE_ADDR 0x20000000
#define CODE_SLOT_1_BASE_ADDR	 (uint32_t)0x08002100
#define CODE_SLOT_2_BASE_ADDR	 (uint32_t)0x08019000
 
void fnJumpToApp(void)
{
 uint8_t i;
		uint32_t *p = (uint32_t *)SRAM_BASE_ADDR; // Base of RAM (0xC0 carved out in scatter file)
		uint32_t *q = (uint32_t *)CODE_SLOT_1_BASE_ADDR; // Base of FLASH
 	__disable_irq();
		/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
		
		/* Copy the vector table from the Flash (mapped at the base of the application
		load address 0x08000000) to the base address of the SRAM at 0x20000000. */
		for(i=0; i<48; i++)
		*p++ = *q++;
 
		/* Enable the SYSCFG peripheral clock*/
		RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
		/* Remap SRAM at 0x00000000 */
		SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
		
		/* Set system control register SCR->VTOR */
		uliJumpAddress = *(uint32_t*) (CODE_SLOT_1_BASE_ADDR + 4);
 
		Jump_To_Application = (pFunction) uliJumpAddress;
		__set_MSP(*(uint32_t*) CODE_SLOT_1_BASE_ADDR);
		Jump_To_Application();
}

Below is from the application code.

void fnRemapVectorTable(void)
{
 
 uint8_t i;
		uint32_t *p = (uint32_t *)SRAM_BASE_ADDR; // Base of RAM (0xC0 carved out in scatter file)
		uint32_t *q = (uint32_t *)CODE_SLOT_1_BASE_ADDR; // Base of FLASH
 
		/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
 
		/* Copy the vector table from the Flash (mapped at the base of the application
		load address 0x08000000) to the base address of the SRAM at 0x20000000. */
		for(i=0; i<48; i++)
		*p++ = *q++;
						/* Enable the SYSCFG peripheral clock*/
				RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
				RCC_APB2PeriphClockCmd (RCC_APB2Periph_SYSCFG, ENABLE);
					/* Remap SRAM at 0x00000000 */
				SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
	
			__enable_irq();
} 
 

can anyone please help me out?

This topic has been closed for replies.
MM..1
MM..1Best answer
Super User
Oct 18, 2020 4:31 PM UTC

I mean your idea have some mistakes. As first why relocate in bootloader ? We use only jump to app and relocate in start app sequence.

example from 03X but i mean no dif with 09x

__IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));

void IAP_Config(void)

{

uint8_t i = 0;

// Relocate by software the vector table to the internal SRAM at 0x20000000

// Copy the vector table from the Flash (mapped at the base of the application

 // load address 0x0800x000) to the base address of the SRAM at 0x20000000

 for(i = 0; i < 48; i++) VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));

// Remap SRAM at 0x00000000

 SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);

}

too i dont uderstand why you copy vectors from ap1 but jump to ap2

and maybe your compiler make mis when try *p++ = *q++;

Plus when you relocate to ram you need reserve this ram in map.

5 replies

TDK
Oct 18, 2020 2:36 PM UTC

> I am using a custom bootloader in STM32F091RB controller (cortex M0) which has a system clock of 8MHz and my application STM32F091VC controller (cortex M0) has system clock of 48MHz.

You have a bootloader on a separate chip from your application? I would attach a debugger to the chip you're trying to debug and see what "not working" actually means. Ensure you're not in an interrupt context. Ensure interrupts are enabled.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Mgawa.1
Mgawa.1Author
Associate II
Oct 18, 2020 7:22 PM UTC

No. Actually my controller is STM32F091RB but ky bootloader project has device as STM32F091RB but my application project has device as STM32F091VC​. Will it cause to interrupt issue?

Tesla DeLorean
Guru
Oct 18, 2020 3:06 PM UTC

Lose the RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); in both cases. Use RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

To reset the unit you must enable then disable the internal reset node

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MM..1
MM..1Best answer
Super User
Oct 18, 2020 4:31 PM UTC

I mean your idea have some mistakes. As first why relocate in bootloader ? We use only jump to app and relocate in start app sequence.

example from 03X but i mean no dif with 09x

__IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));

void IAP_Config(void)

{

uint8_t i = 0;

// Relocate by software the vector table to the internal SRAM at 0x20000000

// Copy the vector table from the Flash (mapped at the base of the application

 // load address 0x0800x000) to the base address of the SRAM at 0x20000000

 for(i = 0; i < 48; i++) VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));

// Remap SRAM at 0x00000000

 SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);

}

too i dont uderstand why you copy vectors from ap1 but jump to ap2

and maybe your compiler make mis when try *p++ = *q++;

Plus when you relocate to ram you need reserve this ram in map.

MM..1
Super User
Oct 19, 2020 7:05 AM UTC

How IDE you use ? Keil , IAR, CubeIDE? I mean you dont setup RAM shift and app use RAM from address zero, then any variables overwrite your interrupt vector table values.