I have a problem with creating “FreeRTOS_socket”. I download FreeRTOS Source codes and I open project in the path below.
Here is my main method:
Project Successfully build. Also, FreeRTOS_IPInit() return 1 (pdTRUE). Then, I use simple TCP socket code in my main scope. I set my ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddres values correctly.
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
/* Create the socket. */
xSocket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP);
/* Check the socket was created successfully. */
if (xSocket != FREERTOS_INVALID_SOCKET)
xBindAddress.sin_port = FreeRTOS_htons(9999);
if (FreeRTOS_bind(xSocket, &xBindAddress, sizeof(&xBindAddress)) == 0)
/* The bind was successful. */
//Socket is not created.
//There was insufficient FreeRTOS heap memory available for the socket
// to be created.
Official TCP Socket creation code says heap memory is not available if it is going in else. Then I increased heap memory in FreeRTOSConfig.h but still is not creating socket.
I know I can use winsocket properly but I want to use FreeRTOS_Socket.
Could you please notify me about what is going wrong with my approach?
Thanks and Regards,
[edited for code formatting and moved to Libraries category]
When you step into the function to the point where memory is being allocated, and in particular where the memory allocation fails, what is the size of the memory being requested? If it is too large it might be configuration file problem.
Question Scope 1
Yes I waited for IP stack initialisation to complete and it returns 1 (pdTRUE). But, I realized that although it was successful, it did not print the correct value
Question Scope 1
Question Scope 2
Firstly, I am curious about is there any spesifical configuration after I download official FreeRTOS files and using Demos in Visual Studio. In project that I download (attached below) uses BufferAllocation_2.c and heap_4.c when I build the project. Should I do a spesifical configuration for including “mem-alloc-scheme” or “buf-alloc-scheme” in my project build process?
Here is my build process log:
------ Rebuild All started: Project: RTOSDemo, Configuration: Debug Win32 ------
cl : Command line warning D9035: option ‘Gm’ has been deprecated and will be removed in a future release
c:\users\AshinesPC\downloads\freertosv10.3.1_winsoc\freertosv10.3.1\freertosv10.3.1\freertos-plus\demo\freertos_plus_tcp_minimal_windows_simulator\main.c(171): warning C4996: ‘inet_addr’: Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\winsock2.h(1831): note: see declaration of ‘inet_addr’
c:\users\AshinesPC\downloads\freertosv10.3.1_winsoc\freertosv10.3.1\freertosv10.3.1\freertos-plus\demo\freertos_plus_tcp_minimal_windows_simulator\main.c(181): warning C4189: ‘a’: local variable is initialized but not referenced
event_groups.obj : warning LNK4075: ignoring ‘/EDITANDCONTINUE’ due to ‘/SAFESEH’ specification
The problem that I understand from the debug process is : There is not a failure in memory allocation. FreeRTOS_IPInit() complete succesfully and return “pdTRUE” but it is not setting xIPTaskInitialised = true because in the code line that linked below. xTaskCreate_of_FreeRTOS_IPInit() (Line 1014)
Task Creation success but it is not setting up “xIPTaskInitialised = pdTrue” so in the socket side build process exiting in #this_line demo shown in below. It originates from inner of specified line xIPIsNetworkTaskReady is returning pdFALSE
Firstly, I think that issue about heap memory and I did not focus to TaskScheduling part. But after your feedback, I gone into the issue of scheduling and I learned FreeRTOS concepts. Now issue is successfully solved. Grateful for your help.