Priority order violation - Asserion fails

Discussions and support about ChibiOS/RT, the free embedded RTOS.
fotis
Posts: 17
Joined: Mon Apr 04, 2016 7:04 pm
Has thanked: 1 time

Re: Priority order violation - Asserion fails

Postby fotis » Thu Jul 05, 2018 7:13 pm

steved wrote:Assuming that's lwIp you're running, I have a vague recollection of a similar problem. In my case it was down to insufficient stack allocation for one of the tasks; a networking-related one IIRC.
(The Chibi plugin for Eclipse will show you stack usage)

Note that you can actually use the debugger to see the states of variables at any point in the execution stack, just by highlighting the relevant level - that can sometimes give clues.


I have checked the stack usage, and I am sure that is more than sufficient (several kb more than necessary). I have also checked my heap, the exceptions stack, the main system stack... everything. I was sure that this is a memory related issue, but as it seems my memory is OK.


Giovanni wrote:The problem could be originated in another place, are you using any I-class API (those whose name ends with an "I") from thread context?

Giovanni


I have triple checked the code, and there are no calls to I-class functions. At all, i.e. neither in exception nor in thread context.

fotis
Posts: 17
Joined: Mon Apr 04, 2016 7:04 pm
Has thanked: 1 time

Re: Priority order violation - Asserion fails

Postby fotis » Thu Jul 05, 2018 7:15 pm

Regarding the I-Class functions (and generally the correct API usage), shouldn't the checks catch this?

I think I have all checks enabled.

User avatar
Giovanni
Site Admin
Posts: 11025
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 354 times
Been thanked: 298 times
Contact:

Re: Priority order violation - Asserion fails

Postby Giovanni » Thu Jul 05, 2018 8:27 pm

The "state checker" does catch that kind of errors.

Do you have IRQs? are all IRQs into the valid priority range? priorities 0...2 are special and cannot call RTOS code from those.

Giovanni

fotis
Posts: 17
Joined: Mon Apr 04, 2016 7:04 pm
Has thanked: 1 time

Re: Priority order violation - Asserion fails

Postby fotis » Thu Jul 05, 2018 10:20 pm

Yes I do have interrupts.

My start-up code sets the priority for ALL interrupts to 5.
Then Chibios starts which sets:

Code: Select all

NVIC_SetPriorityGrouping(CORTEX_PRIGROUP_INIT);    //CORTEX_PRIGROUP_INIT = 2
NVIC_SetPriority(SVCall_IRQn, CORTEX_PRIORITY_SVCALL);    //CORTEX_PRIORITY_SVCALL = 1
NVIC_SetPriority(PendSV_IRQn, CORTEX_PRIORITY_PENDSV);    //CORTEX_PRIORITY_PENDSV = 2
NVIC_SetPriority(SysTick_IRQn, CORTEX_MAX_KERNEL_PRIORITY + 1);    //CORTEX_MAX_KERNEL_PRIORITY = 1, thus systick priority is 2.


I also have disabled CORTEX_SIMPLIFIED_PRIORITY.

fotis
Posts: 17
Joined: Mon Apr 04, 2016 7:04 pm
Has thanked: 1 time

Re: Priority order violation - Asserion fails

Postby fotis » Thu Jul 05, 2018 10:23 pm

I just realized that I make use of a specific I-class function. Within my SysTick handler.

Unlocking the system will cause a reschedule, so I don't think that this is the problem.

My handler:

Code: Select all

void SysTick_Handler()
{
   CH_IRQ_PROLOGUE();

   chSysLockFromISR();
   chSysTimerHandlerI();
   chSysUnlockFromISR();

   CH_IRQ_EPILOGUE();
}

User avatar
Giovanni
Site Admin
Posts: 11025
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 354 times
Been thanked: 298 times
Contact:

Re: Priority order violation - Asserion fails

Postby Giovanni » Fri Jul 06, 2018 7:50 am

Try to lower systick priority, right now it is equal to PendSV and that could be the problem.

Also inspect NVIC registers and verify that priorities are as you expect.

Giovanni

fotis
Posts: 17
Joined: Mon Apr 04, 2016 7:04 pm
Has thanked: 1 time

Re: Priority order violation - Asserion fails

Postby fotis » Sat Jul 14, 2018 1:30 pm

Unfortunatelly it seems that either the priority of SysTick is the issue.

I have set:
SVCall to 1
PendSV to 2
SysTick to 3
All other interrupts to 5

I just had one more occurrence of the problem.
Any other ideas on what to check?

User avatar
Giovanni
Site Admin
Posts: 11025
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 354 times
Been thanked: 298 times
Contact:

Re: Priority order violation - Asserion fails

Postby Giovanni » Sat Jul 14, 2018 2:26 pm

You need to check into NVIC registers:

1) Priorities.
2) How priority grouping is set. You need to not have groups or priorities that should be at different levels would be in the same group.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 1 guest