Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » About FreeRTOS (when FreeRTOS release? )
About FreeRTOS [message #1805596] Thu, 18 April 2019 12:07 Go to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Firstly I congratulation for you delevloped 4diac, open source runtime and plc programming ide.

I use STM32F746 discovery kit which includes ethernet. Also I did run freeRTOS and lwip on STM32F76 board.

I try to compile 4diac for freertos+lwip until now I did not success. Some errors like this:

"[100%] Linking CXX executable forte"
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
CMakeFiles/forte.dir/arch/freeRTOS/main.cpp.obj: In function `forte_malloc(unsigned int)':
main.cpp:(.text._Z12forte_mallocj[_Z12forte_mallocj]+0xa): undefined reference to `pvPortMalloc'

undefined reference to `vTaskDelete'
undefined reference to `xTaskCreate'
.... etc.

I want to ask you officially support freeRTOS? can I compile forte for freertos+lwip (for stm32) or freeRTOS upcoming?



Re: About FreeRTOS [message #1805612 is a reply to message #1805596] Thu, 18 April 2019 18:28 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 #1805643 is a reply to message #1805612] Fri, 19 April 2019 12:41 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi Professor,

thanks for reply. If I success to compile 4diac for stm32f7 I want to share with you, my illustrations.

I have little experince for cmake how to compile thats why I dont know how to define platform specific symbols.
I had earlier compiled freertos project for stm32f746 which includes "libSTM32F7xx_FreeRTOS.a" , "libSTM32F7xx_HAL_Driver.a".

This project's CMakelists.txt

# Load the the extern library
add_library (STM32F7xx_HAL_Driver STATIC IMPORTED)
set_property (TARGET STM32F7xx_HAL_Driver PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/Drivers/Build/lib/libSTM32F7xx_HAL_Driver.a)

# Load the the extern freertos library
add_library (STM32F7xx_FreeRTOS STATIC IMPORTED)
set_property (TARGET STM32F7xx_FreeRTOS PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/FreeRTOS/Build/lib/libSTM32F7xx_FreeRTOS.a)

In summary, how can I define FORTE_FreeRTOSLwIP_LIB? Which extension need to be this file?(".a" , "lib" ) I tried "libSTM32F7xx_FreeRTOS.a" but any results.

Thanks.

Re: About FreeRTOS [message #1805659 is a reply to message #1805643] Fri, 19 April 2019 17:49 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 #1805795 is a reply to message #1805659] Wed, 24 April 2019 08:35 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
Hi,

I compiled forte for freeRTOS susscessfully. The easiest way I found was to compile forte as a library. Usually you have a project in some IDE for your board, where you have all the files for compiling a normal freeRTOS application.

The important thing is to select "FreeRTOSLwIP" as FORTE_ARCHITECTURE, add all the folders with headers files from your project to the variable FORTE_FreeRTOSLwIP_INCLUDES (separated by semicolon) and keep FORTE_BUILD_STATIC_LIBRARY true and FORTE_BUILD_EXECUTABLE false.
Re: About FreeRTOS [message #1805848 is a reply to message #1805795] Thu, 25 April 2019 11:48 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Thanks Jose Maria,

I compiled successfully "libforte-static.a". Now I am trying this library to add my project

add_library (forte-static STATIC IMPORTED)
set_property (TARGET forte-static PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/forte-incubation_1.10.1/src/libforte-static.a)

target_link_libraries (${CMAKE_PROJECT_NAME}.elf STM32F7xx_HAL_Driver STM32F7xx_FreeRTOS forte-static)


Although I set this flag (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_HAL_DRIVER -D STM32F746xx -DFORTE_LITTLE_ENDIAN -DFORTE_USE_REAL_DATATYPE" ) there is something wrong:


/forte_lreal.h:38:25: error: 'setTDFLOAT' was not declared in this scope
setTDFLOAT(paValue);

Thanks..

Re: About FreeRTOS [message #1805857 is a reply to message #1805848] Thu, 25 April 2019 15:50 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 #1805951 is a reply to message #1805857] Mon, 29 April 2019 10:52 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi,

I compiled forte as a library "libforte-static.a" for use in my project. When "nm" command for I see which functions compile in static library ("nm libforte-static.a > nm.txt")
nm.txt that includes:

forte_sync.cpp.obj:
00000010 N $d
00000000 t $t
00000000 t $t
00000001 T _ZN19CFreeRTOSSyncObjectC1Ev
00000001 T _ZN19CFreeRTOSSyncObjectC2Ev
00000001 T _ZN19CFreeRTOSSyncObjectD1Ev
00000001 T _ZN19CFreeRTOSSyncObjectD2Ev
U vQueueDelete
U xQueueCreateMutex


That functions which about freertos undefined, didnt compile. Whatever I did, I couldnt compile freertos functions in forte.

In my project's cmake add_library(..libforte-static.a) I saw this error:

C:/Users/ARGE3/Desktop/F7Cmake/Forte/Build/src/libforte-static.a(forte_sem.cpp.obj): In function `forte::arch::CFreeRTOSSemaphore::CFreeRTOSSemaphore(unsigned int)':
C:/Users/ARGE3/Desktop/F7Cmake/Forte/src/arch/freeRTOS/forte_sem.cpp:21: undefined reference to `xQueueGenericCreate'


Because of this functions which about freertos, in libforte-static.a not defined.

So I couldnt include freertos files in forte cmake yet.
As though, forte not include my "libSTM32F7xx_FreeRTOS.a".
How can I do this?

Thanks for helping.
Re: About FreeRTOS [message #1805971 is a reply to message #1805951] Mon, 29 April 2019 14:17 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
l compiled freertos files in forte any c files (I couldnt include lib file)
forte_add_sourcefile_c(FreeRTOS/Source/croutine.c)
forte_add_sourcefile_c(FreeRTOS/Source/event_groups.c)
now successfully, created libforte-static.a file and this library is used in my project. I created a hex file for STM32 but not work normally.
now i am working on lwip, try to include forte library for use my project.
Re: About FreeRTOS [message #1805976 is a reply to message #1805971] Mon, 29 April 2019 14:41 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
I didn't understand quite well your current issue but the following functions:
vQueueDelete
xQueueCreateMutex
xQueueGenericCreate

should be in your freeRTOS code. Actually forte uses for example xSemaphoreCreateBinary and similar, which are part of the official API.

The easiest way to compile forte for freeRTOS is not to include the freeRTOs libraries, and then add libforte-static.a library to your project.
Re: About FreeRTOS [message #1806012 is a reply to message #1805976] Tue, 30 April 2019 13:18 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi,

I included libforte-static.a in my project and successfully compiled. But there is a problem with forte task (vForteTask) if this task compile in my project, any task not working.
If I dont compile forte task lwip(ethernet) is working.
Do you have any suggestion ?

Thanks
Re: About FreeRTOS [message #1806014 is a reply to message #1806012] Tue, 30 April 2019 13:36 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
I'm not sure how you implement your forte task, but the easiest way of doing it is to include "forte_Init.h" (which is in the src/arch/freeRTOS folder) and then the code should look something like this:

static void forte_thread(void *arg)
{
	forteGlobalInitialize();
	TForteInstance forteInstance = 0;
	int resultForte = forteStartInstanceGeneric(0, 0, &forteInstance);
	if(FORTE_OK == resultForte){
		forteJoinInstance(forteInstance);
	}else{
		PRINTF("Error %d: Couldn't start forte\n", resultForte);
	}
	forteGlobalDeinitialize();
	vTaskDelete(NULL);
}
Re: About FreeRTOS [message #1806016 is a reply to message #1806014] Tue, 30 April 2019 13:55 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
I implemented this task (which is in the src/arch/freeRTOS/main.cpp)
void vForteTask( void* pvParameters ){
  ( void ) pvParameters;

  RMT_DEV *poDev = new RMT_DEV;

  poDev->setMGR_ID("192.168.100.101:61499");
  poDev->startDevice();
  DEVLOG_INFO("FORTE is up and running\n");
  poDev->MGR.joinResourceThread();
  DEVLOG_INFO("FORTE finished\n");
  delete poDev;
  Test++;
  vTaskDelete(NULL);
}
Re: About FreeRTOS [message #1806017 is a reply to message #1806016] Tue, 30 April 2019 14:06 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Dear Jose Maria,

I guess you run forte on STM32F1xx am I right? Is forte running on Stm32 clearly?

Thanks

Re: About FreeRTOS [message #1806054 is a reply to message #1806017] Wed, 01 May 2019 17:12 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
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 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
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 #1814369 is a reply to message #1806014] Tue, 10 September 2019 09:53 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
I use the code I posted before, after LwIP was initialized. I didn't try yet passing arguments, but you shouldn't need to do anything there, because 61499 is already the default port and the IP is not taken in account when opening the connection. Forte just uses the localhost to connect.

Do you get any error when not passing any parameter?


Jose Maria Jesus Cabral Lassalle wrote on Tue, 30 April 2019 13:36
I'm not sure how you implement your forte task, but the easiest way of doing it is to include "forte_Init.h" (which is in the src/arch/freeRTOS folder) and then the code should look something like this:

static void forte_thread(void *arg)
{
	forteGlobalInitialize();
	TForteInstance forteInstance = 0;
	int resultForte = forteStartInstanceGeneric(0, 0, &forteInstance);
	if(FORTE_OK == resultForte){
		forteJoinInstance(forteInstance);
	}else{
		PRINTF("Error %d: Couldn't start forte\n", resultForte);
	}
	forteGlobalDeinitialize();
	vTaskDelete(NULL);
}

Re: About FreeRTOS [message #1814414 is a reply to message #1814369] Wed, 11 September 2019 07:59 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
"Do you get any error when not passing any parameter?"
Unfortunately I couldnt run forte task clearly, but I found what is the problem.
The problem is my heap. I did try many times try to change my tasks heap size.

1) I have 320K SRAM but if I define configTOTAL_HEAP_SIZE bigger 48500 bytes lwip dont run clearly (I didint unterstand why, I am reseraching)
2) FreeRTOS allows only configTOTAL_HEAP_SIZE / 4 memory for tasks = I have 12125 bytes heap for tasks
3) Lwip uses 2.1Kbytes (and 128bytes for init taks) -> total 2,25 Kbytes
4) remaining heap size = 12125 - 2250 = 9875 bytes if I allocated 9875 bytes for forte task malloc failed(vApplicationMallocFailedHook).
RMT_DEV *device = new RMT_DEV; this object bigger 9875 bytes.

Finally I need to find, how can I configTOTAL_HEAP_SIZE bigger size.
Re: About FreeRTOS [message #1814498 is a reply to message #1814414] Thu, 12 September 2019 09:11 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi Jose Maria Jesus Cabral Lassalle,
I configured my heap but stil dont work forte task. If lwip init and init any task led task etc. everything works fine but if I compile any forte functions lwip dont works fine.
Although I tried many times, many methods, couldt succes yet.

Can you send your Stm32 project to me for examine ?
email: cytopal@gmail.com
Re: About FreeRTOS [message #1814564 is a reply to message #1814498] Fri, 13 September 2019 09:54 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
Hi,

unfortunately I cannot share my stm32 project. But the fact that you cannot make your heap bigger I think is really strange. Make sure that your 320KRam are properly configured. It looks like the problem is in the configuration of your micro and unfortunately I cannot help that much.

Regards,

Jose Cabral
Re: About FreeRTOS [message #1814688 is a reply to message #1814564] Mon, 16 September 2019 12:01 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
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 #1814692 is a reply to message #1814688] Mon, 16 September 2019 13:24 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
Is your freeRTOS scheduler running? You must not call the forteJoinInstance from main.
Re: About FreeRTOS [message #1814694 is a reply to message #1806014] Mon, 16 September 2019 15:34 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
If I call forteJoinInstance in main freeRTOS scheduler not running.

Jose Maria Jesus Cabral Lassalle wrote on Tue, 30 April 2019 13:36
I'm not sure how you implement your forte task, but the easiest way of doing it is to include "forte_Init.h" (which is in the src/arch/freeRTOS folder) and then the code should look something like this:

static void forte_thread(void *arg)
{
	forteGlobalInitialize();
	TForteInstance forteInstance = 0;
	int resultForte = forteStartInstanceGeneric(0, 0, &forteInstance);
	if(FORTE_OK == resultForte){
		forteJoinInstance(forteInstance);
	}else{
		PRINTF("Error %d: Couldn't start forte\n", resultForte);
	}
	forteGlobalDeinitialize();
	vTaskDelete(NULL);
}

I called forteJoinInstance in main because Jose Cabral as said.

And if I use this codes in Forte task
  RMT_DEV *poDev = new RMT_DEV;

  poDev->setMGR_ID("localhost:61499");
  poDev->startDevice();
  DEVLOG_INFO("FORTE is up and running\n");
  poDev->MGR.joinResourceThread();
  DEVLOG_INFO("FORTE finished\n");
  delete poDev;
  vTaskDelete(NULL);


in this line RMT_DEV *poDev = new RMT_DEV; (Although I have more than 100Kb ram) I watch on debug hardfault.

Re: About FreeRTOS [message #1814700 is a reply to message #1814694] Mon, 16 September 2019 18:24 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Alois Zoitl wrote on Mon, 16 September 2019 13:24
Is 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
	CThread::join();
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 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
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 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
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 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Jose Maria Jesus Cabral Lassalle wrote on Tue, 17 September 2019 11:53
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);
}





I tried as you said but still doesnt work.

forteJoinInstance(GESforteInstance); -> doesnt success.
Re: About FreeRTOS [message #1814751 is a reply to message #1814750] Tue, 17 September 2019 12:22 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
hat happens if you remove the join. and turn the other loop into a busy loop. maybe with a sleep to not use all cpu resources.
Re: About FreeRTOS [message #1814756 is a reply to message #1814751] Tue, 17 September 2019 13:08 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
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 #1814796 is a reply to message #1814756] Wed, 18 September 2019 13:08 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi,
I debugged more,

in threadbase.tpp

void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::join(){
  if(nullHandle != mThreadHandle){
    mJoinSem.waitIndefinitely();                      // from here 
    mJoinSem.inc(); //allow many joins
  }
}


forte_sem.cpp
    void CFreeRTOSSemaphore::waitIndefinitely(){
      if(mSemaphore != NULL){
        xSemaphoreTake(mSemaphore, portMAX_DELAY);                                         // from here
      }
    }


queue.c

     BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ){
             .....
             .....
             else
			{
				/* There was no timeout and the semaphore count was not 0, so
				attempt to take the semaphore again. */
				prvUnlockQueue( pxQueue );
				( void ) xTaskResumeAll();                                                                                    // in here all tasks resume and system crash (hardfault)
			}


Do you have any ideas, what's the reason?

Thanks for make time for me.
Re: About FreeRTOS [message #1814944 is a reply to message #1814796] Mon, 23 September 2019 09:33 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
I'm not sure what the problem could be. I saw that you tried my code wich kills the vIPTask, but then you have again an infinite for loop.

Can you ping when you use the code that kills vIPTask and without forte?

Also, try initializing GESforteInstance to zero:

TForteInstance GESforteInstance = 0;
Re: About FreeRTOS [message #1815011 is a reply to message #1814944] Tue, 24 September 2019 08:08 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi Jose,

Finally, I think(guess) forte is running. If I kill(vTaskDelete) vIPTask, the system is crash (hardfault, I dont know why).
I dont kill vIPTask, forte task is running now.
I tried that TForteInstance GESforteInstance = 0; is the same TForteInstance GESforteInstance; anything changed.

Now I have a new problem, I cant deploy any 4diac application to my board.
The problem is : Major download error Problem: Create Resource Instance "xxx" failed.
Added screenshots.
Re: About FreeRTOS [message #1815022 is a reply to message #1815011] Tue, 24 September 2019 10:19 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
What 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?
Re: About FreeRTOS [message #1815050 is a reply to message #1815022] Tue, 24 September 2019 18:36 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
The response to the query commend shown in the deployment console looks a bit suspicious to me. What 4diac FORTE version are you using.
Re: About FreeRTOS [message #1815063 is a reply to message #1815022] Wed, 25 September 2019 05:57 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Jose Maria Jesus Cabral Lassalle wrote on Tue, 24 September 2019 10:19
What 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 #1815064 is a reply to message #1815050] Wed, 25 September 2019 06:06 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Alois Zoitl wrote on Tue, 24 September 2019 18:36
The response to the query commend shown in the deployment console looks a bit suspicious to me. What 4diac FORTE version are you using.


I am using "forte-incubation_1.10.3" and ide version is 1.10.3.
Also I copiled forte as a static library and include my stm32cubemx freertos+lwip project. I am using Atollic compiler which supports gcc(eclipse based).

My compiler settings
C/C++ Build / Settings / Tool Setting
C++ Compiler / Miscellaneous

-ffunction-sections -fdata-sections -fstack-usage -Wall -DLWIP_TIMEVAL_PRIVATE=0 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops -ffast-math -ftree-vectorize -DNOLOG -DFORTE_LITTLE_ENDIAN -DDEV_MGR -DFORTE_SUPPORT_ARRAYS -DFORTE_SUPPORT_BOOT_FILE -DFORTE_SUPPORT_CUSTOM_SERIALIZABLE_DATATYPES -DFORTE_SUPPORT_QUERY_CMD -DFORTE_MODIFY_SOURCES_ON_MISSING_GENERATED_INCLUDES -DFORTE_LINKED_STRINGDICT -DFORTE_COM_RAW -DFORTE_SUPPORT_MONITORING -DFORTE_COM_LOCAL -DFORTE_COM_FBDK -DFORTE_UNICODE_SUPPORT -DFORTE_USE_64BIT_DATATYPES -DFORTE_USE_REAL_DATATYPE -DFORTE_USE_LREAL_DATATYPE -DFORTE_USE_TEST_CONFIG_IN_FORTE -DFORTE_USE_WSTRING_DATATYPE -D__USE_W32_SOCKETS

C++ Linker / Miscellaneous flags as the same.
Re: About FreeRTOS [message #1815066 is a reply to message #1815064] Wed, 25 September 2019 06:24 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 #1815079 is a reply to message #1815066] Wed, 25 September 2019 09:44 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
oh, right! I have something related to that.

I call a function called:

__libc_init_array();

actually, this was already in my project, and it looks like this:

#if defined (__cplusplus)
//
// Call C++ library initialisation
//
__libc_init_array();
#endif
// __libc_init_array(); //Jose
// Reenable interrupts
__asm volatile ("cpsie i");

#if defined (__REDLIB__)
// Call the Redlib library, which in turn calls main()
__main();
#else
main();
#endif

but for some reason it wasn't working properly, so I added the call again in the main function before all the board configurations:
*/
int main(void)
{
__libc_init_array();

...
... // some init codes
Re: About FreeRTOS [message #1815085 is a reply to message #1815079] Wed, 25 September 2019 11:09 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
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 #1815142 is a reply to message #1815086] Thu, 26 September 2019 06:43 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi,
/* Call the clock system initialization function.*/
  bl  SystemInit   
/* Call static constructors */
    bl __libc_init_array                                                                   // here in startup
/* Call the application's entry point.*/
  bl  main
  bx  lr    
.size  Reset_Handler, .-Reset_Handler


That function(__libc_init_array) already calls by startup, before from main function.

CForteArchitecture::initialize() this method already calls by forteGlobalInitialize() in forte task.
Re: About FreeRTOS [message #1815143 is a reply to message #1815142] Thu, 26 September 2019 07:05 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 907
Registered: January 2014
Senior Member
does then your linker ld script accomodate the static ctor section.
Re: About FreeRTOS [message #1815145 is a reply to message #1815143] Thu, 26 September 2019 07:53 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
My linker file includes
.preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  } >FLASH
  .init_array :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
  } >FLASH
  .fini_array :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array*))
    PROVIDE_HIDDEN (__fini_array_end = .);
  } >FLASH


Actually I am not sure these accomodate the static ctor section.
I dont know what is the meaning "PROVIDE_HIDDEN"
Re: About FreeRTOS [message #1815221 is a reply to message #1815145] Fri, 27 September 2019 12:47 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
I'm running out of ideas. May I ask what board and IDE are you using? are you able to share the code of your project?
Re: About FreeRTOS [message #1816491 is a reply to message #1815221] Wed, 30 October 2019 06:25 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi Jose,

I sent email which includes my project.

Thanks
Best Regards.
Re: About FreeRTOS [message #1816511 is a reply to message #1816491] Wed, 30 October 2019 10:49 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
Sorry I didn't get anything
Re: About FreeRTOS [message #1816517 is a reply to message #1816511] Wed, 30 October 2019 11:35 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
cabral@fortiss.org
your email address, is that right?
Re: About FreeRTOS [message #1816522 is a reply to message #1816517] Wed, 30 October 2019 12:50 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 160
Registered: February 2016
Senior Member
yes, but I didn't get anything, there's nothing even in the junk folder. Try sending it again, or maybe it was blocked by some server because of the type of file. I had issues sending zip file. You could upload to dropbox or something and then just send me the public link to it
Re: About FreeRTOS [message #1816523 is a reply to message #1816522] Wed, 30 October 2019 13:06 Go to previous messageGo to next message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
I sent google drive link via email.

Thanks for helping
Re: About FreeRTOS [message #1816655 is a reply to message #1816523] Mon, 04 November 2019 08:50 Go to previous message
cyt tpl is currently offline cyt tplFriend
Messages: 31
Registered: April 2019
Member
Hi,

I prepared a document which includes my works until now.
NOTE: My project can successfully compile, but not work clearly.

https://drive.google.com/open?id=1X3if3ky8yjo1uzXI9TLxpt0C9cmJvnTa
Previous Topic:Integrating into FreeRTOS
Next Topic:Building forte with opc_ua
Goto Forum:
  


Current Time: Fri Nov 15 15:14:31 GMT 2019

Powered by FUDForum. Page generated in 0.04314 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top