hi i am using code warrior 10.6 (mqx 4.0) TWRk60d100m(MkV512VMD10)
i found difficulties in my project about RAM . now when i take some new global Varible , my ethernet TASK(TCP Socket) is not working, RTCS Socket not created ??
then i show in map File hardly 60k RAM use and my task stack is around 20k , so total 80k Ram use out of 128k
so why my ethernet Task RTCS Socket create not working??
plese any one help me ???
Hi Hiren,
can you please explain with more details the environment?
- How many tasks you have
- Which task owns the variable
- What kind of socket is this? A TCP socket you open on your own or a socket that a service of the RTCS is trying to open.
- How is this variable related with the socket Task
For instance I can say that you may set the number of sockets that RTCS will use by setting the variables below just before calling RTCS_create(). If the rproblem is that you are running out of sockets this may solve the problem.
_RTCS_socket_part_init = 4;
_RTCS_socket_part_grow = 2;
_RTCS_socket_part_max = 20;
I wonder if you problem is related to the following problem.
Best regards,
Carlos
In my development,I have 15 number of TASK, one is Ethernet_task that comm. with single PC (PC is Server- TWRk60d100m is client). i already set RTCS Setting as you suggest before calling RTCS_create() . Up to some extend of RAM memory, This work fine ,but when i take new variable,other task work Fine except Ethernet , below some limit of RAM consume all is well..why this happened???
my Code of Ethernet_Task As....
......
..
_RTCSPCB_init = 4;
_RTCSPCB_grow = 2;
_RTCSPCB_max = 20;//4
_RTCS_msgpool_init = 4;
_RTCS_msgpool_grow = 2;
_RTCS_msgpool_max = 20;
_RTCS_socket_part_init = 4;
_RTCS_socket_part_grow = 2;
_RTCS_socket_part_max = 20;//4
RTCS_create();
ip_data.ip = IPADDR(192,168,1,202);
ip_data.mask = IPADDR(255,255,255,0);
ip_data.gateway = 0;
ENET_get_mac_address(BSP_DEFAULT_ENET_DEVICE, ip_data.ip,mac_address);
ipcfg_init_device(BSP_DEFAULT_ENET_DEVICE, mac_address);
error = ipcfg_bind_staticip(BSP_DEFAULT_ENET_DEVICE, &ip_data);
// set remote host(TCPServer) socket address
server_socket_addr.sin_family = AF_INET;
server_socket_addr.sin_port = 80;
server_socket_addr.sin_addr.s_addr = IPADDR(172, 168, 1, 200);
.....
....
// loop to establish connection
do
{
socket_handle = socket(PF_INET, SOCK_STREAM, 0); //Socket Create
if (socket_handle == RTCS_SOCKET_ERROR)
printf("\n[TCPClient]: Failed to create socket.");
error = connect(socket_handle, &server_socket_addr, sizeof(server_socket_addr)); //Connet Socket with Server
if (error != RTCS_OK) //if any Error in Connecting Socket then Shutdown Socket
{
if (error == RTCSERR_TCP_TIMED_OUT)
printf("\n[TCPClient]: Connection timeout.");
else if (error == RTCSERR_TCP_CONN_RESET)
printf("\n[TCPClient]: Connection reset by peer.");
shutdown(socket_handle, FLAG_ABORT_CONNECTION);
printf("\n[TCPClient]: Retry to connect TCPServer 5 seconds later...");
_time_delay(200);
break;
}
} while (error != RTCS_OK);
....
.....
//after connection establish
recv(socket_handle, RxBuffer, sizeof(RxBuffer), 0)
..........
is RAM Size I have is over ???
or some Other problem??
also i print Socket error code 0x612 ( buffer space not available) so i expect RAM is problem??
please help me???
Hi Hiren,
You can check if task is running out stack by checking 'Stack Usage' tool in menu MQX when you are debugging (debug session must be paused). Here you can check if you require to increase the task stack.
You may also increase or reduce the buffer size by using setsockopt() function with options OPT_TBSIZE and OPT_RBSIZE. You can find documentation in MQX_RTCS_User_Guide.pdf which is located in C:\Freescale\Freescale_MQX_4_2\doc\rtcs
If the porblem persists please attach some images of the 'Task Summary', 'Socket Sumamry' and 'Stack Usage' tools before the problem and after the problem? You can find this option in menus MQX and RTCS when you are debugging.
Please also attach .map file and indicate the following
- Which is the global variable that is causing the problem
- What change in this variable causes the problem.
Error is returned in
socket_handle = socket(PF_INET, SOCK_STREAM, 0); //Socket Create
right?
Regards,
Carlos
hi carlos
i noticed by debug session that stack is enough in both the case.
For expansion i need to take global variable for other task not in
ethernet_Task,and my Ethernet_Task is stuck.
then i print RAM Peak usage =_mem_get_highwater() - 0x1FFF0000; it reach
near to 128k;
so what it mean , my RAM is over ?? what should i do to go ahead ??
how to know ,how much RAM uses by kernel ?
and what to do to optimize RAM usage by kernel??
in my .map file
Bss + data RAM is 51k
and RAM Peak usage =128K , i am not understand about the Rest 128k-51k=77k
RAM , please elaborate about this 77k RAM??
please help me out
regards ,
Hiren Tailor
On 12 February 2016 at 23:36, Carlos_Musich <admin@community.freescale.com>
Hi Hiren,
Please consider following points.
1) Your last question is duplicated in the following post RAM Memory Utilization
Here you can find the explanation from isaacavila about the space that the application use and the space that kernel sue. Consider that the heap and the tasks stack is not part of .data neither .bss.
2) Consider using setsockopt() function with options OPT_TBSIZE and OPT_RBSIZE. You can find documentation in MQX_RTCS_User_Guide.pdf which is located in C:\Freescale\Freescale_MQX_4_2\doc\rtcs
3) Besides Task Aware Debugger tool you can use Performace Tool provided by MQX. You can find related documentation in MQX_PerfTool_Getting_Started.pdf located in MQX installation path C:\Freescale\Freescale_MQX_4_2\doc\tools\cw
4) Please note that _mem_get_highwater() returns the highest pointer used in the memory pool. But memory pool is taken from the heap. This does not mean that all the RAM in lower locations outside the heap is used.
Regards,
Carlos