|
Re: About FreeRTOS [message #1805612 is a reply to message #1805596] |
Thu, 18 April 2019 18:28 |
|
Hi,
thanks you.
Yes we support freeRTOS. From a quick look it seams that you didn't configure the freeRTOS lib (i.e., Cmake option FORTE_FreeRTOSLwIP_LIB). There these platform specific symbols should be defined.
Alois
|
|
|
|
Re: About FreeRTOS [message #1805659 is a reply to message #1805643] |
Fri, 19 April 2019 17:49 |
|
Hi,
maybe you then need more then one lib. In CMake Gui you can find, when selecting the advanced option, CMAKE_EXE_LINKER_FLAGS. There you can specify any option specific for you platform so in your case you could give "-lSTM32F7xx_FreeRTOS -lSTM32F7xx_HAL_Driver", where "-l stands for lowercase L". The font in this forum is not very good.
Furthermore you may need more compiler flags. This depends you your toolchain and your platform. you can yuse the CMake options for CXX_flags, Cpp flags to give this to our toolchain. We can unfortunately do this in a generic way. The best is that you take your example applications as reference.
Also please note that everytime when you make changes to your Cmake config you need to run configure and generate bevore you can run make again.
I hope this helps you to get this quickly runnig.
Cheers,
Alois
|
|
|
|
|
Re: About FreeRTOS [message #1805857 is a reply to message #1805848] |
Thu, 25 April 2019 15:50 |
|
Hi,
normally the FORTE_USE_REAL_DATATYPE FORTE_USE_LREAL_DATATYPE and FORTE_USE_64BIT_DATATYPE should be active per default. Are you explicitly setting some of them to off. TDFLOAT is required by the LREAL datatype.
I hope this helps,
Alois
|
|
|
|
|
|
|
|
|
|
Re: About FreeRTOS [message #1806054 is a reply to message #1806017] |
Wed, 01 May 2019 17:12 |
|
How much RAM have you available on your system. lwIP needs already quite a lot. This can be a problem with 4diac FORTE. Also on some systems I experienced that the tasks created by FORTE need a bit more stack size. Not sure what Jose's experience is here. Also 4diac FORTE will on startup create at least one socket. So lwIP needs to be up and running.
These are some of my experiences when working on very small embedded systems with 4diac FORTE. I hope they help.
|
|
|
Re: About FreeRTOS [message #1806206 is a reply to message #1806054] |
Mon, 06 May 2019 08:47 |
Jose Maria Jesus Cabral Lassalle Messages: 199 Registered: February 2016 |
Senior Member |
|
|
Yes, I got running cleary in a Stm32 and also in a NXP .
As Alois said, you should start your LwIP first. After I check that the LwIP didn't fail, I start my forte task:
if(sys_thread_new("forte_thread", forte_thread, NULL, 2000, 4) == NULL)
LWIP_ASSERT("forte_thread(): Task creation failed.", 0);
the 2000 is the stack size. I'm not sure about it, but I think the stack later multiplies by 4 somewhere. Anyhow, I'd recommend to add:
void vApplicationMallocFailedHook(){
for(;;){
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ){
for(;;){
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
put a breakpoint in both vTaskDelay, and in FreeRTOSConfig.h file make sure you have:
#define configCHECK_FOR_STACK_OVERFLOW 1
#define configUSE_MALLOC_FAILED_HOOK 1
This will allow you to check if there's a problem with your memory size. If the breakpoints above are reached, your memory is too small
|
|
|
Re: About FreeRTOS [message #1814253 is a reply to message #1806206] |
Fri, 06 September 2019 11:27 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
Hi Jose Maria Jesus Cabral Lassalle,
After for a long time I returned back to try to compile 4diac forte for STM32F746.
I compiled forte as a static library and add to my lwip freertos project.
As you said, I debugged and watched my memory (heap) with vApplicationMallocFailedHook function. I saw my memory which I allocated heap is not enough. When forte define object (RMT_DEV *device = new RMT_DEV;) the microcontroller(STM32F7) make malloc failed.
I incrased my allocated heap there are no problems in there.
But now I have a problem with healthy connection. If forte task deactive my lwip task works fine. But I activate forte task (sys_thread_new) ip doesnt works clearly. I send ping but no response.
void vForteThread(void * argument){
char flag[] = "-c";
char address[16] = "10.0.0.252";
char port[6];
sprintf(port, "%u", 61499);
strcat(address, port);
char* arguments[] = {flag, address};
forteGlobalInitialize();
TForteInstance GESforteInstance;
// int resultForte = forteStartInstanceGeneric(0,0, &GESforteInstance);
int resultForte = forteStartInstanceGeneric(2,arguments, &GESforteInstance);
if(FORTE_OK == resultForte){
forteJoinInstance(GESforteInstance);
}else{
Count++;
}
forteGlobalDeinitialize();
vTaskDelete(NULL);
}
void vIPTask(void const* argument){
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, GPIO_PIN_SET);
MX_LWIP_Init();
osDelay(500);
sys_thread_new("forte_th", vForteThread, NULL, 10240, 4);
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, GPIO_PIN_RESET);
for(;;){
osThreadTerminate(NULL);
}
}
I didnt find where am I wrong? How is your forte task?
Thanks
[Updated on: Fri, 06 September 2019 12:21] Report message to a moderator
|
|
|
|
|
|
|
Re: About FreeRTOS [message #1814688 is a reply to message #1814564] |
Mon, 16 September 2019 12:01 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
Hi,
After some process I am sure my Ram properly configured. Lwip task and forte task allocated heap, there is no fail.
Now there is a problem (I hope it is the last :) )
if(FORTE_OK == resultForte){
forteJoinInstance(GESforteInstance); // problem is here
}else{
Count++;
}
when run the forteJoinInstance() function there is no response the ping.
I watched in debug until CFDSelectHandler::run function which in fdselecthand.cpp
void CFDSelectHandler::run(void){
...
...
...
if(scmInvalidFileDescriptor != nHighestFDID){
retval = select(static_cast<int>(nHighestFDID + 1), &anFDSet, NULL, NULL, &tv); // no response in there
if(!isAlive()){
//the thread has been closed in the meantime do not process any messages anymore
return;
}
select function is not running. can there be a compiler flag error?
[Updated on: Mon, 16 September 2019 12:37] Report message to a moderator
|
|
|
|
|
Re: About FreeRTOS [message #1814700 is a reply to message #1814694] |
Mon, 16 September 2019 18:24 |
|
As you can see in Jose's code sample the method is called forte_thread. The intention of this code is to create an own task for starting up 4diac FORTE. This may be a bit of an overhead therefore doing it seperatly has its advantages.
The intention of the forteJoinInstance(forteInstance); is to wait until 4diac FORTE ends its execution. If you are intilializing 4diac FORTE from main before the scheduler is started then join makes no sense as you don't want to wait at this point. Instead you would invoke the scheduler here. So if you instead of joingin run the scheduler I would expect that pinging should work again.
|
|
|
Re: About FreeRTOS [message #1814721 is a reply to message #1814692] |
Tue, 17 September 2019 06:34 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
Alois Zoitl wrote on Mon, 16 September 2019 13:24Is your freeRTOS scheduler running? You must not call the forteJoinInstance from main.
Sorry Professor, I misunderstood this reply.
Let me explain that everything from beginning.
First of all into main function I created a task for lwip init.
int main(void){
... // some init codes
...
osThreadDef(ipTask, vIPTask, osPriorityNormal, 0, IPTASK_HEAPSIZE);
ipTaskHandle = osThreadCreate(osThread(ipTask), NULL);
osKernelStart()
}
in vIPTask I check the lwip send ping, works fine
if ping works fine create and run forte task
void vIPTask(void const* argument){
MX_LWIP_Init();
for(;;){
if(HAL_GPIO_ReadPin(GPIOI,GPIO_PIN_11) && forteFlag == false){ // if click the button
if(sys_thread_new("forte", vForteTask, NULL, FORTETASK_HEAPSIZE, 1) == NULL){ // start the forte thread
LWIP_ASSERT("vForteTask(): Task creation failed.", 0);
}
forteFlag = true;
}
}
Forte task codes as Jose Cabral said
void vForteTask( void * argument ){
( void ) argument;
forteGlobalInitialize();
TForteInstance GESforteInstance;
int resultForte = forteStartInstanceGeneric(0,0, &GESforteInstance);
if(FORTE_OK == resultForte){
forteJoinInstance(GESforteInstance); // problem is here
}else{
Count++;
}
forteGlobalDeinitialize();
vTaskDelete(NULL);
}
I watched in debug the codes when run forteJoinInstance(system crash) there is no response anything.
In debug, jump into the function(forteJoinInstance) it goes to
forte_Init.cpp
poDev->MGR.joinResourceThread(); then goes to
RMT_RES.cpp
getResourceEventExecution()->joinEventChainExecutionThread(); then goes to
ecet.h
then goes to
threadbase.tpp
if (0 != paThread) {
paThread->setAlive(true);
paThread->run(); //from this line then goes to
fdselecthand.cpp
void CFDSelectHandler::run(void){
....
retval = select(static_cast<int>(nHighestFDID + 1), &anFDSet, NULL, NULL, &tv); then goes to
sockets.c
lwip_select(....){
....
waitres = sys_arch_sem_wait(SELECT_SEM_PTR(select_cb.sem), msectimeout); // debug waits this line
}
after this line select mechanism waits semaphoretake and system not response anything
[Updated on: Tue, 17 September 2019 07:27] Report message to a moderator
|
|
|
Re: About FreeRTOS [message #1814732 is a reply to message #1814721] |
Tue, 17 September 2019 08:34 |
|
thanks for the clarification. From what you explain I think the crash is coming from somewhere else. select should block and wait until a message is arrived or in our case a timeout is happening. I also experienced on eCOS (similar to freeRTOS) that deguggin on this level is quite hard. As you say your system is crashing how can you observe that. Do you have any backtrace. Could it be a watchdog? Do you have timed semphores enabled in freeRTOS, what heap and what scheduler have you selected in your freeRTOS config.
@Jose: Am I missing something?
|
|
|
Re: About FreeRTOS [message #1814743 is a reply to message #1805596] |
Tue, 17 September 2019 10:44 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
I compiled forte as a static library and included my STM32 freertos lwip project.
Here is my project details.
Memory map, linker file, FreeRTOSConfig.h
#define IPTASK_HEAPSIZE 128
#define FORTETASK_HEAPSIZE 20000
[Updated on: Tue, 17 September 2019 11:52] Report message to a moderator
|
|
|
Re: About FreeRTOS [message #1814749 is a reply to message #1814732] |
Tue, 17 September 2019 11:53 |
Jose Maria Jesus Cabral Lassalle Messages: 199 Registered: February 2016 |
Senior Member |
|
|
Hi,
from CThread::join(); it shouldn't go to
if (0 != paThread) {
paThread->setAlive(true);
paThread->run(); //from this line
but I think this is just a misreading of the debugging stack.
The only thing I can imagine is causing problem is the fact that you leave your task vIPTask alive in an infinite loop without sleep.
I have a very similar configuration, where in a task I initialize the IP stack, start Forte thread, but then the first task is killed. So, maybe you could try the following
void vIPTask(void const* argument){
MX_LWIP_Init();
while(forteFlag == false){
if(HAL_GPIO_ReadPin(GPIOI,GPIO_PIN_11) ){ // if click the button
if(sys_thread_new("forte", vForteTask, NULL, FORTETASK_HEAPSIZE, 1) == NULL){ // start the forte thread
LWIP_ASSERT("vForteTask(): Task creation failed.", 0);
}
forteFlag = true;
}
}
vTaskDelete(NULL);
}
|
|
|
Re: About FreeRTOS [message #1814750 is a reply to message #1814749] |
Tue, 17 September 2019 12:20 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
Jose Maria Jesus Cabral Lassalle wrote on Tue, 17 September 2019 11:53Hi,
from CThread::join(); it shouldn't go to
if (0 != paThread) {
paThread->setAlive(true);
paThread->run(); //from this line
but I think this is just a misreading of the debugging stack.
The only thing I can imagine is causing problem is the fact that you leave your task vIPTask alive in an infinite loop without sleep.
I have a very similar configuration, where in a task I initialize the IP stack, start Forte thread, but then the first task is killed. So, maybe you could try the following
void vIPTask(void const* argument){
MX_LWIP_Init();
while(forteFlag == false){
if(HAL_GPIO_ReadPin(GPIOI,GPIO_PIN_11) ){ // if click the button
if(sys_thread_new("forte", vForteTask, NULL, FORTETASK_HEAPSIZE, 1) == NULL){ // start the forte thread
LWIP_ASSERT("vForteTask(): Task creation failed.", 0);
}
forteFlag = true;
}
}
vTaskDelete(NULL);
}
I tried as you said but still doesnt work.
forteJoinInstance(GESforteInstance); -> doesnt success.
|
|
|
|
Re: About FreeRTOS [message #1814756 is a reply to message #1814751] |
Tue, 17 September 2019 13:08 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
void vForteTask( void * argument ){
( void ) argument;
forteGlobalInitialize();
TForteInstance GESforteInstance;
int resultForte = forteStartInstanceGeneric(0,0, &GESforteInstance);
// if(FORTE_OK == resultForte){
// forteJoinInstance(GESforteInstance);
// }else{
// Count++;
// }
forteGlobalDeinitialize();
vTaskDelete(NULL);
}
void vIPTask(void const* argument){
MX_LWIP_Init();
// while(forteFlag == false){
for(;;){
if(HAL_GPIO_ReadPin(GPIOI,GPIO_PIN_11) && forteFlag == false){
if(sys_thread_new("forte", vForteTask, NULL, FORTETASK_HEAPSIZE, 1) == NULL){
LWIP_ASSERT("vForteTask(): Task creation failed.", 0);
}
forteFlag=true;
}
}
// vTaskDelete(NULL);
}
If the codes is configured in this way, pinging is alive.
|
|
|
|
|
|
|
|
Re: About FreeRTOS [message #1815063 is a reply to message #1815022] |
Wed, 25 September 2019 05:57 |
cyt tpl Messages: 31 Registered: April 2019 |
Member |
|
|
Jose Maria Jesus Cabral Lassalle wrote on Tue, 24 September 2019 10:19What did you change so forte could run? are you sure forte is running?
One question: is the FORTE_COM_ETH enabled when you compile forte?
I\''m not sure what the problem could be. I attached my FreeRTOSConfig.h file so you can compare with yours. Check the variables related to the priorities, this might be cause some problems
It's also strange that it crashes when you kill the vIPtask. Can you send the file where your main function is and the vIPTask is created?
1) Actually I am not sure after which changes forte run but in my opinion forte runs because I am watching in debug forte task runs. The forte task is processing in void CFDSelectHandler::run(void) (in fdselecthand.cpp) function. By the way the forte task in void CFDSelectHandler::run(void)
if((0 != FD_ISSET(sockDes, &anFDSet)) && (0 != callee)){
doesnt pass anytime. Maybe I missed something about sockets(flags etc.).
2) Yes FORTE_COM_ETH enabled to compile forte
3) Truely strange that it crashes when you kill the vIPtask. But I configured again according to your FreeRTOSConfig.h, there is no crash after vIPTask delete. Thanks for that.
My main function which includes the init vIPTask
int main(void){
... // some init codes
...
osThreadDef(ipTask, vIPTask, osPriorityNormal, 0, IPTASK_HEAPSIZE);
ipTaskHandle = osThreadCreate(osThread(ipTask), NULL);
osKernelStart()
}
|
|
|
|
Re: About FreeRTOS [message #1815066 is a reply to message #1815064] |
Wed, 25 September 2019 06:24 |
|
I think I know the issue. When you are building 4diac FORTE as library a special method is created (unfortunately I forgot its name). This method has been called by your code. Otherwise the linker optimizes all your types away. This would explain your strange Querry types response.
@Jose: do you rember the name of the function?
|
|
|
|
Re: About FreeRTOS [message #1815085 is a reply to message #1815079] |
Wed, 25 September 2019 11:09 |
|
ah yes this is one of the two things that need to be done. In order that that is working corrctly you also need a ctors section in your linker file. Normally you get this when you enable C++ support. As background in the ctor sectin the constructors of any static instances are called. We need that to initialize the type library.
But there is also the initFORTE method that need to be called from main. Jose hid this in the CForteArchitecture::initialize() method.
|
|
|
Re: About FreeRTOS [message #1815086 is a reply to message #1815079] |
Wed, 25 September 2019 11:14 |
|
ah yes this is one of the two things that need to be done. In order that that is working corrctly you also need a ctors section in your linker file. Normally you get this when you enable C++ support. As background in the ctor sectin the constructors of any static instances are called. We need that to initialize the type library.
But there is also the initFORTE method that need to be called from main. Jose hid this in the CForteArchitecture::initialize() method.
|
|
|
|
|
|
|
|
|
|
|
|
|