ecc2 kernel in arduino
Moderator: paolo.gai
ecc2 kernel in arduino
Hello
I have a program running on an Arduino Nano and I a get different result using a FP kernel or using an ECC2 kernel. I don't understand why the behaviour is different. Could someone take a look and tell me what might be the issue?
Here is my test program with comments:
// I activate only Task1 at startup
setup(void){
ActivateTask(Task1);
}
// Task1 has priority 2 configured in the OIL .Task1 the high priority one in my example.
TASK(Task1) {
ActivateTask(Task2);
do_some_fast_led_blinking();
};
// Task2 has priority 1 which is lower than Task1.
TASK(Task2) {
do_some_slow_led_blinking();
};
When I run with FP kernel I get some fast led blinking first and some slow led blinking afterwards. When I run with ECC2 kernel I get only the fast blinking. Why?
I have a program running on an Arduino Nano and I a get different result using a FP kernel or using an ECC2 kernel. I don't understand why the behaviour is different. Could someone take a look and tell me what might be the issue?
Here is my test program with comments:
// I activate only Task1 at startup
setup(void){
ActivateTask(Task1);
}
// Task1 has priority 2 configured in the OIL .Task1 the high priority one in my example.
TASK(Task1) {
ActivateTask(Task2);
do_some_fast_led_blinking();
};
// Task2 has priority 1 which is lower than Task1.
TASK(Task2) {
do_some_slow_led_blinking();
};
When I run with FP kernel I get some fast led blinking first and some slow led blinking afterwards. When I run with ECC2 kernel I get only the fast blinking. Why?
Re: ecc2 kernel in arduino
mhhh... strange behavior.
Uestions:
- are these tasks activated by an interrupt?
- FP counts pending activations using a counter, whereas ECC2 uses the declared value in the OIL file. What are the parameters in the OIL file?
Lost activations could be in general the cause. I was just looking at the SVN code; in the original FP, if you are using alarms, maybe has a missing wraparound check on pending activation increment that could create an issue after longtime if you are using an alarm to periodically activate Task1.
Ciao,
PJ
Uestions:
- are these tasks activated by an interrupt?
- FP counts pending activations using a counter, whereas ECC2 uses the declared value in the OIL file. What are the parameters in the OIL file?
Lost activations could be in general the cause. I was just looking at the SVN code; in the original FP, if you are using alarms, maybe has a missing wraparound check on pending activation increment that could create an issue after longtime if you are using an alarm to periodically activate Task1.
Ciao,
PJ
Re: ecc2 kernel in arduino
Hello Rilius,
you shouldn't get any blinking at all, if all the checks were in place...
ECC2 is an OSEK Kernel and needs the call to StartOS to enable scheduling.
The problem is that StartOS, by requirement, do not return, unless you specify ERIKA's custom policy EE_OPT = "__OO_STARTOS_OLD__"; .
if you do that you can add the StartOS call at the beginning of setup
you shouldn't get any blinking at all, if all the checks were in place...
ECC2 is an OSEK Kernel and needs the call to StartOS to enable scheduling.
The problem is that StartOS, by requirement, do not return, unless you specify ERIKA's custom policy EE_OPT = "__OO_STARTOS_OLD__"; .
if you do that you can add the StartOS call at the beginning of setup
Code: Select all
// I activate only Task1 at startup
setup(void){
StartOS(OSDEFAULTAPPMODE);
ActivateTask(Task1);
}
Re: ecc2 kernel in arduino
Thanks for the answers. I added the StartOS() funcion and I still have the same behaviour: Task2 does not run when I use the ECC2 kernel.
These are my files which are the "Blink Demo" sample program for Arduino with some modifications.
These are my files which are the "Blink Demo" sample program for Arduino with some modifications.
Code: Select all
// conf.oil
CPU mySystem {
OS myOs {
EE_OPT = "DEBUG";
CPU_DATA = AVR8 {
APP_SRC = "code.cpp";
APP_SRC = "task.c";
MULTI_STACK = TRUE; /* FALSE */
};
MCU_DATA = MEGA {
MODEL = MEGA_328p;
};
EE_OPT = "__ARDUINO_SDK__";
/* EE_OPT = "__ARDUINO_SDK_CC__"; */
/* EE_OPT = "__ARDUINO_SDK_CC_1_6_8__"; */
EE_OPT = "__ARDUINO_SDK_ORG__";
EE_OPT = "__ARDUINO_SDK_ORG_1_7_9__";
EE_OPT = "__ARDUINO_UNO_328__";
/* EE_OPT = "__ARDUINO_NANO_328__"; */
/* Used to build separate libarduino.a */
EE_OPT = "__ADD_LIBS__";
LIB = ENABLE {
NAME = "ARDUINO_SDK";
};
KERNEL_TYPE = ECC2; /* FP */
EE_OPT = "__OO_STARTOS_OLD__";
};
TASK Task1 {
PRIORITY = 2;
STACK = PRIVATE {
SYS_SIZE = 128;
};
SCHEDULE = FULL;
ACTIVATION = 3;
};
TASK Task2 {
PRIORITY = 1;
STACK = PRIVATE {
SYS_SIZE = 128;
};
SCHEDULE = FULL;
ACTIVATION = 3;
};
};
Code: Select all
// @file: code.cpp
#include "ee.h"
#include "Arduino.h"
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
void loop(void){
}
void setup(void){
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
StartOS(OSDEFAULTAPPMODE);
ActivateTask(Task1);
}
int main(void){
EE_mcu_init();
init();
#if defined(USBCON)
//USBDevice.attach();
#endif
setup();
//for (;;) {
// loop();
// if (serialEventRun) serialEventRun();
//}
return 0;
}
Code: Select all
// @file: task.c
#include "ee.h"
#include "Arduino.h"
extern int led;
void do_some_fast_led_blinks(){
int i;
for(i = 0; i < 8; i++){
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(300);
}
}
void do_some_slow_led_blinks(){
int i;
for(i = 0; i < 5; i++){
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
}
TASK(Task1) {
ActivateTask(Task2);
do_some_fast_led_blinks();
};
TASK(Task2) {
do_some_slow_led_blinks();
}
Re: ecc2 kernel in arduino
Hi,
128 bytes of private stack seems to be at limit, try 256 or 512; or, even better since you don't use blocking primitives, use STACK=SHARED; .
Errico Guidieri.
128 bytes of private stack seems to be at limit, try 256 or 512; or, even better since you don't use blocking primitives, use STACK=SHARED; .
Errico Guidieri.
Re: ecc2 kernel in arduino
Hi Errico,
When I use the kernel ECC2 with STACK=SHARED then both tasks get activated but when I use the kernel with ECC2 with STACK=128 or 256 or 512 then Task2 does not run.
I want separate stacks to use SetEvent and WaitEvent.
I am thinking maybe the Arduino Nano is not the right hardware to do some Erika testing.
Thanks
Robert
When I use the kernel ECC2 with STACK=SHARED then both tasks get activated but when I use the kernel with ECC2 with STACK=128 or 256 or 512 then Task2 does not run.
I want separate stacks to use SetEvent and WaitEvent.
I am thinking maybe the Arduino Nano is not the right hardware to do some Erika testing.
Thanks
Robert
Re: ecc2 kernel in arduino
Hi Robert,
Arduino Nano is supported by Erika Enterprise, but you have to enable the right EE_OPT in the OIL file:
EE_OPT = "__ARDUINO_NANO_328__";
If the problem persists, we try to reproduce that as soon as possible.
BR,
Giuseppe.
Arduino Nano is supported by Erika Enterprise, but you have to enable the right EE_OPT in the OIL file:
EE_OPT = "__ARDUINO_NANO_328__";
If the problem persists, we try to reproduce that as soon as possible.
BR,
Giuseppe.
Re: ecc2 kernel in arduino
Hi Robert,
thank you for bug report: effectively we found a "stack initialization" bug in multi-stack environment.
The bug was fixed from Revision 3380: please update your repository.
We tested the application you posted on this thread on an Arduino Uno board and all tasks now seem to run.
BR,
Giuseppe.
thank you for bug report: effectively we found a "stack initialization" bug in multi-stack environment.
The bug was fixed from Revision 3380: please update your repository.
We tested the application you posted on this thread on an Arduino Uno board and all tasks now seem to run.
BR,
Giuseppe.
Re: ecc2 kernel in arduino
Hi Robert,
The nightly build plugins now contains the patched version. Please update your installation using the nightly builds, redo a test, and please report if you find any other issue.
Thanks for the bug report!
Regards,
Paolo
The nightly build plugins now contains the patched version. Please update your installation using the nightly builds, redo a test, and please report if you find any other issue.
Thanks for the bug report!
Regards,
Paolo
Re: ecc2 kernel in arduino
I tested again with revision r3380 and it worked.
Thanks.
Robert
Thanks.
Robert