STM32f103VET6 Bootloader jump problem.

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

franek.bmw
Posts: 57
Joined: Thu Mar 13, 2014 11:15 am
Has thanked: 2 times

Re: STM32f103VET6 Bootloader jump problem.

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32f103VET6 Bootloader jump problem.

Post by Giovanni »

In general you need to perform those initializations before re-enabling interrupts.

Giovanni
franek.bmw
Posts: 57
Joined: Thu Mar 13, 2014 11:15 am
Has thanked: 2 times

Re: STM32f103VET6 Bootloader jump problem.

Post by franek.bmw »

Sure, I make this before enabling any interrups.
franek.bmw
Posts: 57
Joined: Thu Mar 13, 2014 11:15 am
Has thanked: 2 times

Re: STM32f103VET6 Bootloader jump problem.

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32f103VET6 Bootloader jump problem.

Post 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
franek.bmw
Posts: 57
Joined: Thu Mar 13, 2014 11:15 am
Has thanked: 2 times

Re: STM32f103VET6 Bootloader jump problem.

Post by franek.bmw »

But by the way it sould cause problems in jump to chibios app to, am I right?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32f103VET6 Bootloader jump problem.

Post 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
franek.bmw
Posts: 57
Joined: Thu Mar 13, 2014 11:15 am
Has thanked: 2 times

Re: STM32f103VET6 Bootloader jump problem.

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32f103VET6 Bootloader jump problem.

Post by Giovanni »

If you do xxxStart() then you need to do xxxStop().

Giovanni
franek.bmw
Posts: 57
Joined: Thu Mar 13, 2014 11:15 am
Has thanked: 2 times

Re: STM32f103VET6 Bootloader jump problem.

Post 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 ;/
Post Reply