Page 3 of 6

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 8:01 am
by franek.bmw
The application firstly configure gpio and then configure NVIC like this:

Code: Select all

static void NVICConfig(void)
{
   NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x10000);

   NVIC_InitTypeDef  NVIC_InitStructure;
   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3);

   /* CAN */
   NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);

   NVIC_InitStructure.NVIC_IRQChannel = USB_HP_CAN1_TX_IRQn;
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);

   /* Timer 2 */
   NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);

   /* Timer 3 */
   NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);
}


Should I configure NVIC earlier? If yes, in what way?

When I make separate handler for each vector in bootloader, after jump it goes to handler for HardFaultVector.

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 8:27 am
by Giovanni
In general you need to perform those initializations before re-enabling interrupts.

Giovanni

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 8:28 am
by franek.bmw
Sure, I make this before enabling any interrups.

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 12:12 pm
by franek.bmw
I change my app to work with no bootloader. Only change flash addres in linker script and offset for nvic vectors, all work good. So I think the app is good. Is chibios enabling some other interrupts except which I enabled in user code?

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 12:18 pm
by Giovanni
The HAL enables the driver interrupts. You need to stop all drivers before jumping to the application.

The ST driver also enables a system tick timer that has to be manually stopped, there is no stop function currently.

Giovanni

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 12:25 pm
by franek.bmw
But by the way it sould cause problems in jump to chibios app to, am I right?

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 1:25 pm
by Giovanni
If you jump into a ChibiOS application then it is not a problem for sure because ChibiOS reinitializes everything.

You custom code, I cannot know but it should be responsibility of the bootloader to undo all initializations before starting the user code.

Giovanni

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 8:08 pm
by franek.bmw
I call stop function for all driver i've started (call start function). I also manually stop SysTick like this: SysTick->CTRL = 0; . But when I have define in mcuconf or chconf that I want to use some peripherals, then before jump I should disable it?

Re: STM32f103VET6 Bootloader jump problem.

Posted: Tue Jun 09, 2015 8:14 pm
by Giovanni
If you do xxxStart() then you need to do xxxStop().

Giovanni

Re: STM32f103VET6 Bootloader jump problem.

Posted: Wed Jun 10, 2015 9:58 am
by franek.bmw
I've debug my program, when bootloader jump it goes to HardFault. CFSR register point to IMPRECISERR. I found information that IMPRECISERR in most often is caused by a write to an invalid address. I don't know what to do with this error ;/