Page 2 of 2

Re: System dies after several days - system tick problem?

Posted: Wed Mar 18, 2015 2:19 pm
by Giovanni
I will look into instrumenting that code some more.

Giovanni

Re: System dies after several days - system tick problem?

Posted: Sat Mar 21, 2015 2:13 pm
by Erikk
Im also getting errors when working with Virtual Timers on a Stm32f4-discovery.
Im using the chibios 3.0 release inside the latest Chibistudio and compiling with -O2.


Setting timer Virtualtimer for the first time, inside a normal thread:

Code: Select all

  chSysLock();
  chVTDoSetI(&vt_can_broadcast, MS2ST(2000), can_vt_cb, NULL);
  chSysUnlock();



Callback:

Code: Select all

void can_vt_cb(void* arg){
  chSysLockFromISR();
  chBSemSignalI(&SemCanVt);
  chVTSetI(&vt_can_broadcast, MS2ST(2000), can_vt_cb, arg);
  chSysUnlockFromISR();
};




Always when running the chVTSetI inside the callback, it hangs with reason: 0x8002760 "stStartAlarm".

BUT, its works flawlessly when compiling with -O0 instead of -O2.

Any thoughts?

Re: System dies after several days - system tick problem?

Posted: Sat Mar 21, 2015 2:29 pm
by Giovanni
Interesting, I have to verify that scenario (setting a timer from a timer callback).

Giovanni

Re: System dies after several days - system tick problem?

Posted: Sat Mar 21, 2015 5:26 pm
by Erikk
After adding some more code to the program it hangs up even with -O0.

Only way to make it work is to make the thread sleep for a certain time instead of using a virtual timer to release a semaphore.

Re: System dies after several days - system tick problem?

Posted: Sat Mar 21, 2015 5:32 pm
by Giovanni
Don't worry, that error is a very specific error condition, should be easy to implement a fix.

Giovanni

Re: System dies after several days - system tick problem?

Posted: Mon Mar 23, 2015 11:05 am
by Giovanni
Hi,

I committed a tentative fix for this issue, could you test it?

Giovanni

Re: System dies after several days - system tick problem?

Posted: Mon Mar 23, 2015 8:08 pm
by Erikk
Works perfectly!
Thanks.

Re: System dies after several days - system tick problem?

Posted: Tue Mar 24, 2015 11:39 pm
by steved
Going backwards from my perspective, I'm afraid.

The code I started running on 14th March is still running - 10 days continuous operation (unless we had a power cut, which I would probably have noticed). This is using a delta of 2. It had some improvements over the code which originally triggered my post; these eliminated a couple of virtual timers (most of the time) and also increaased the minimum timeout to 2ms.

Since then I've made a small improvement in what I believe to be my longest ISR (character receive) although retriggering a virtual timer is probably the longest part of the execution time.

This evening I've run the latest Chibi repository contents and my latest code with deltas of 2, 3 and 4, and all fail. With delta=2 it took around an hour, while with larger deltas it was minutes or less.

I'll try and roll back my code to the version that's been running for a long time, in case I've unintentionally broken something. That'll be tomorrow evening.

Re: System dies after several days - system tick problem?

Posted: Wed Mar 25, 2015 9:20 am
by Giovanni
I think you should not seek solutions that minimize the problem, that would be hiding the real cause. If you could put together a small project that I could test it would be the best solution, try to maximize the effect instead.

Giovanni

Re: System dies after several days - system tick problem?

Posted: Wed Mar 25, 2015 12:51 pm
by rew
i.e. make sure that it works with delta=4 and THEN switch back to delta=2.