This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with stack pointer when i use my bootloader

Hi!

I'm tring to make a bootloader to update my project firmware for a GD32E103 (cortex-M4).

Seems i can load the code for my main application without problem, after that when i reset the target and noting happens, after 2 day of reading some books and serching on the forum i just stay lock on the same problem.

This is my booting code:

if(REG32(0x0800FFF0) == 0x89ABCDEF)		//Set if after read last message from HEX file 
{ 
	//Disables SysTick timer and its related interrupt
	SysTick->CTRL = 0x00; 
	
	//Disable IRQ
	__disable_irq();
	for (i = 0; i < 8; i ++) // Disable IRQs
		{ NVIC->ICER[i] = 0xFFFFFFFF; }
	for (i = 0; i < 8; i ++) // Clear pending IRQs
		{ NVIC->ICPR[i] = 0xFFFFFFFF; }
	
	//Set the MSP
	__set_MSP(*((volatile uint32_t*) USER_APPLICATION_BASE_ADDRESS)); 
		
	__DMB(); //DMB instruction before relocating VTOR
	SCB->VTOR = 0x08002800;	//We relocate vector table to the sector 1
	__DSB(); //DSB instruction after relocating VTOR
	__ISB();
		
	//Jump to main firmware
	JumpAddress = *((volatile uint32_t*) (USER_APPLICATION_BASE_ADDRESS + 4));
	void (*reset_handler)(void) = (void*)JumpAddress;
	reset_handler(); //We start the execution from he Reset_Handler of the main firmware
	
	while(1)
		{;}//Never coming here
}

This is the configuration from my main programm(left) and bootloader (rigth) 

   

Parents
  • Updating.

    Seems the code posted on the top post works, i tried a blinking a led just coding on main function and that works.

    Now i think the problem is on the timers IRQ's, as you can see on the on the NVIC registers, they need to be attend.

    I will come back with more if i found the problem

Reply
  • Updating.

    Seems the code posted on the top post works, i tried a blinking a led just coding on main function and that works.

    Now i think the problem is on the timers IRQ's, as you can see on the on the NVIC registers, they need to be attend.

    I will come back with more if i found the problem

Children
No data