cancel
Showing results for 
Search instead for 
Did you mean: 

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

Mgawa.1
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

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.

View solution in original post

5 REPLIES 5
TDK
Guru

> 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".

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
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief II

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.

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?

MM..1
Chief II

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.