Hello,
I'm trying to setup an UDP connection to broadcast data on the network but data are not sent and I get a RTCSERR_PCB_ALLOC error. I'm using MQX 4.1.1 on a MPC5668G.
Here is my initialisation of the comm stack:
IPCFG_IP_ADDRESS_DATA stIPConfig;
uint32_t u32Error;
_enet_address au8Address;
_RTCSPCB_init = 10; /* maximum RTCSPCBs available */
_RTCSPCB_grow = 2; /* maximum RTCSPCBs available */
_RTCSPCB_max = 20; /* maximum RTCSPCBs available */
/* Initialize Ethernet */
u32Error = RTCS_create();
if(RTCS_OK != u32Error)
{
_task_block();
}
ENET_get_mac_address((uint32_t)0, ENET_IPADDR, au8Address);
/* Initialize ENET device */
u32Error = ipcfg_init_device ((uint32_t)0, au8Address);
if(RTCS_OK != u32Error)
{
_task_block();
}
stIPConfig.ip = ENET_IPADDR; //#define ENET_IPADDR IPADDR(169,254,1,4)
stIPConfig.mask = ENET_IPMASK; //#define ENET_IPMASK IPADDR(255,255,0,0)
stIPConfig.gateway = 0;
u32Error = ipcfg_bind_staticip ((uint32_t)0, &stIPConfig);
if(RTCS_OK != u32Error)
{
_task_block();
}
And here is the code of my task that send the data:
void EthTask100msCycle(uint32_t u32Parameter)
{
TIME_STRUCT stTimePtr;
uint32_t u32TstCntr = 0U;
uint32_t u32Socket;
uint32_t u32Error;
sockaddr_in stAddress;
uint8_t au8TstBuffer[8];
/* Initialize periodic timers to make task cyclic */
_time_get_elapsed(&stTimePtr);
stTimePtr.MILLISECONDS += TASK_KU32_ETH_100MS_START_OFFSET;
(void)_timer_start_periodic_at(TimerCallbackFct, _task_get_td(MQX_NULL_TASK_ID), TIMER_ELAPSED_TIME_MODE, &stTimePtr, TASK_KU32_100MS_CYCLE);
u32Socket = socket(AF_INET, SOCK_DGRAM, 0);
if(RTCS_SOCKET_ERROR == u32Socket)
{
_task_block();
}
stAddress.sin_family = AF_INET;
stAddress.sin_port = 11001;
stAddress.sin_addr.s_addr = INADDR_BROADCAST;
u32Error = bind(u32Socket, (const sockaddr *)&stAddress, sizeof(stAddress));
if (RTCS_OK != u32Error)
{
_task_block();
}
while(1)
{
_task_block();
u32TstCntr++;
au8TstBuffer[0] = 'T';
au8TstBuffer[1] = e';
au8TstBuffer[2] = 's';
au8TstBuffer[3] = 't';
au8TstBuffer[4] = GET_DWORD_HIGH_BYTE(u32TstCntr);
au8TstBuffer[5] = GET_DWORD_MID_HIGH_BYTE(u32TstCntr);
au8TstBuffer[6] = GET_DWORD_MID_LOW_BYTE(u32TstCntr);
au8TstBuffer[7] = GET_DWORD_LOW_BYTE(u32TstCntr);
u32Error = sendto(u32Socket, au8TstBuffer, 8, RTCS_MSG_NOLOOP, (sockaddr *)&stAddress, sizeof(stAddress));
u32Error = RTCS_geterror(u32Socket); //Here error is 0x1310
}
}
When I step through the code, I can see that function _partition_alloc_internal (at line 136) returns PARTITION_OUT_OF_BLOCKS. At one point, the last condition condition fails :
Line 136:
if ((partpool_ptr->PARTITION_TYPE == PARTITION_DYNAMIC) && partpool_ptr->GROW_BLOCKS
&& ((partpool_ptr->MAXIMUM_BLOCKS == 0) || (partpool_ptr->TOTAL_BLOCKS
< partpool_ptr->MAXIMUM_BLOCKS)))
{ (...) }
1. What am I doing?
2. Can someone explain to me what is a PCB (Packet Control Block) and they get freed?
Thanks for your help
Hugo
解決済! 解決策の投稿を見る。
Hello Daniel,
Thanks for the answers. I cannot use MQX 4.2 as it does not support MPC5668G anymore and I don't feel confortable merging the modification into my MQX install because I don't know MQX well enough.
Thanks for the documentation, however it only explain how to configure the communication stack with the global variables but it doesn't explain what are PCBs, how they work and how they are freed.
However, I managed to fix my problem. There is a RESET pin on the Ethernet PHY chip which I was not setting up... Once I've set it high, it started working.
Hi Hugo:
Please check the following document for some RTCS configuration parameters
MQX RTCS Memory Configuration Parameters Introduction
From your description, it seems your system is running out of memory. Maybe it is a memory issue, it can't allocate memory from memory pool.
We fixed a memory leak issue in MQX 4.2, I strongly suggest you use the latest MQX 4.2, with the latest patch MQX 4.2.0.2, it is more stable than MQX 4.1.1
Regards
Daniel
I found your issue is happened with UDP , the memory leak we fixed is on TCP. Maybe it is not the cause for your issue.
Anyway, you can check the MQX 4.2 change log file.
C:\Freescale\Freescale_MQX_4_2\rtcs\rtcs_changelog.txt
You can change the RTCS parameters according to the document to see whether it helps.
Regards
Daniel
Hello Daniel,
Thanks for the answers. I cannot use MQX 4.2 as it does not support MPC5668G anymore and I don't feel confortable merging the modification into my MQX install because I don't know MQX well enough.
Thanks for the documentation, however it only explain how to configure the communication stack with the global variables but it doesn't explain what are PCBs, how they work and how they are freed.
However, I managed to fix my problem. There is a RESET pin on the Ethernet PHY chip which I was not setting up... Once I've set it high, it started working.
Great to hear that it works now.
Thank you for your suggestions, I will improve this document when I have time.
Regars
Daniel