Hi,
I am trying to communicate two 1064 EVK via Ethernet Port. Firstly, I decided to use enet_txrx_transfer SDK example.
Two scenario exist:
First : When I use one board connected with my PC. Demo is running and packets are transferring between EVK and PC.
Second : When I run same SDK code on both EVK in case of one as ENET_SendFrame and other one as ENET_ReadFrame, ENET_SendFrame is transmitting data but ENET_ReceiveFrame is not able to get them. I checked ENET1 initialization config setting and they are not manipulated. They are original in SDK example. I also attached main files but shortly can be seen as below:
Sender : enet_txrx_transfer_1064EVK_A.c :
while (1)
{
if (g_testTxNum < ENET_TRANSMIT_DATA_NUM)
{
/* Send a multicast frame when the PHY is link up. */
if (kStatus_Success == PHY_GetLinkStatus(EXAMPLE_ENET, EXAMPLE_PHY, &link))
{
if (link)
{
g_testTxNum++;
txnumber++;
if (kStatus_Success == ENET_SendFrame(EXAMPLE_ENET, &g_handle, &g_frame[0], ENET_DATA_LENGTH))
{
PRINTF("The %d frame transmitted success!\r\n", txnumber);
}
else
{
PRINTF(" \r\nTransmit frame failed!\r\n");
}
}
}
SDK_DelayAtLeastUs(3000000,CLOCK_GetFreq(kCLOCK_CpuClk));
}
}
Receiver : enet_txrx_transfer_1064EVK_B.c :
while (1)
{
/* Get the Frame size */
status = ENET_GetRxFrameSize(&g_handle, &length);
/* Call ENET_ReadFrame when there is a received frame. */
if (length != 0)
{
/* Received valid frame. Deliver the rx buffer with the size equal to length. */
uint8_t *data = (uint8_t *)malloc(length);
status = ENET_ReadFrame(EXAMPLE_ENET, &g_handle, data, length);
if (status == kStatus_Success)
{
PRINTF(" A frame received. the length %d ", length);
PRINTF(" Dest Address %02x:%02x:%02x:%02x:%02x:%02x Src Address %02x:%02x:%02x:%02x:%02x:%02x \r\n",
data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9],
data[10], data[11]);
}
free(data);
}
else if (status == kStatus_ENET_RxFrameError)
{
/* Update the received buffer when error happened. */
/* Get the error information of the received g_frame. */
ENET_GetRxErrBeforeReadFrame(&g_handle, &eErrStatic);
/* update the receive buffer. */
ENET_ReadFrame(EXAMPLE_ENET, &g_handle, NULL, 0);
}
}
Could you please help me what is wrong?
Thanks and Regards.
Hi @Lukas_Frank ,
I highly suggest you check this code:
SDK_2_11_1_EVK-MIMXRT1064\boards\evkmimxrt1064\driver_examples\enet\txrx_ptp1588_transfer
It needs to use two EVK board connect together.
We also have the AN about it:
https://www.nxp.com/docs/en/nxp/application-notes/AN12149.pdf
https://www.nxp.com/webapp/Download?colCode=AN12149SW&location=null
Use the AN code, it contains the test code directly, one set to master, another set to slave.
Wish it helps you!
Best Regards,
Kerry
Hi Dear @kerryzhou ,
When I try to fill my frame I'm getting an HardFault error when I fill last 30 bytes of g_frame. I think there is a constraint in somewhere for last 30 byte for g_frame but I didn't catch what is wrong. I also check frame formats in RM but I just find for Pause Frame. What is the frame format that should I use? Could you please share frame details for me? Here is how to fullfill frame content defined below:
static void ENET_BuildPtpEventFrame(void)
{
//ENET_DATA_LENGTH defined as 1000 above
uint32_t count;
uint32_t length = ENET_DATA_LENGTH - 14;
uint8_t mGAddr[6] = {0x01, 0x00, 0x5e, 0x01, 0x01, 0x1};
/* Build for PTP event message frame. */
memcpy(&g_frame[0], &mGAddr[0], 6);
/* The six-byte source MAC address. */
memcpy(&g_frame[6], &g_macAddr[0], 6);
/* The type/length: if data length is used make sure it's smaller than 1500 */
g_frame[12] = 0x08U;
g_frame[13] = 0x00U;
g_frame[0x0EU] = 0x40;
/* Set the UDP PTP event port number. */
g_frame[0x24U] = (kENET_PtpEventPort >> & 0xFFU;
g_frame[0x25U] = kENET_PtpEventPort & 0xFFU;
/* Set the UDP protocol. */
g_frame[0x17U] = 0x11U;
/* Add ptp event message type: sync message. */
g_frame[0x2AU] = ENET_PTP_SYNC_MSG;
/* Add sequence id. */
g_frame[0x48U] = 0;
g_frame[0x48U + 1] = 0;
//for(count = 1; count<length-400; count++) //Hard Error Doesn't Rise
//....
//for(count = 1; count<length-100; count++) //Hard Error Doesn't Rise
//....
//for(count = 1; count<length-34; count++) //Hard Error Doesn't Rise
//for(count = 1; count<length-33; count++) //Hard Error Doesn't Rise
//for(count = 1; count<length-32; count++) //Hard Error Doesn't Rise
//for(count = 1; count<length-31; count++) //Hard Error Doesn't Rise
for(count = 1; count<length-30; count++) //Hard Error Rises
{
g_frame[count + (0x48U + 1)] = count % 0xFFU;
}
}
For example below figure showing some details for Pause Frame. I could not find frame details for Native Ethernet PTPv2 in RM section 41.3.3.1.2. Where can I find a reference for sending multicast frame like below figure?
Thanks and Regards.
Hi @Lukas_Frank
Can you debug the AN12149SW, then check the related frame? That code is working.
You just need to set one board as master, another as a slave.
Best Regards,
Kerry
Hi Dear @kerryzhou ,
It is important use pure ENET without lwip in my case. Could you help me please for this case? What does mean that 30 byte ? How can I set whole Ethernet frame bytes without hardfault error? I described my error above detaily.
Thanks and Regards.
Hi @Lukas_Frank ,
If you don't modify the last 30 bytes of g_frame, just the above data, then you don't meet the hard fault issues, right?
If yes, I think these 30 bytes may be used for the format.
You mentioned:Demo is running and packets are transferring between EVK and PC.
If you modify one EVK code and test with PC, do you still meet hardfault?
If not, you can check the related data in the Ethernet, and compare with the two EVK board data.
Best Regards,
Kerry
Hi Dear @kerryzhou ,
If you don't modify the last 30 bytes of g_frame, just the above data, then you don't meet the hard fault issues, right?
Answer 1 : You are right, I don't meet with hard fault when I don't set last 30 bytes. It is only working when the last 30 bytes are 0x00. But, I am trying to clear why. Will am I not be able to send 1500? Will I always able to 1470 bytes payload?
If you modify one EVK code and test with PC, do you still meet hardfault?
Answer 2 : Yes, I am still getting hardfault in EVK to PC example. So, I have no chance to compare.
If yes, I think these 30 bytes may be used for the format.
I believe that too. It is using by ethernet frame format. But, there is some confusion.
To make clear the status. I have following question:
Question : We have 46 to 1500 payload data in original ethernet frame. Why I am getting hard fault when I set following parameters for "length indexes" and "enet data length" parameters below. In below case, normally, I should be able to send 1500 bytes. But it is working only when I don't set last 30 byte. What is the standard of that differentiate from normal ethernet frame? Where can I exact info in the RM?
#define ENET_DATA_LENGTH (1500)
.
.
/* The type/length: if data length is used make sure it's smaller than 1500 */
g_frame[12] = 0xDCU;
g_frame[13] = 0x05U;
.
.
Thanks and Regards.
Hi @Lukas_Frank ,
Good question!
From your description, the last 30 bytes should related to the protocal.
I need to more checking.
Now, due to the COVID-19, I just have one MIMXRT1050-EVKB on my side, so, could you please share me the detail steps, which is based on the PC and the SDK code project to reproduce the issues?
I need to reproduce it at first, then I can also check with our internal expert and material.
When you use the PC, which tool you are use to testing, what about the cable, do you do some modifications? I mean this cable:
Make loopback network cable:
568B standard Unknowed standard
J1 orange+white green+white
J2 orange green
J3 green+white orange+white
J4 blue brown+white
J5 blue+white brown
J6 green orange
J7 brown+white blue
J8 brown blue+white
If to reproduce the issues with PC, whether the normal cable is OK? And what's the PC related software you are using?
Best Regards,
Kerry
Hi Dear @kerryzhou ,
Here are the details for reproducing results:
IDE Version | MCUXpresso v11.5.0_7232 |
SDK Example | evkmimxrt1064_enet_txrx_ptp1588_transfer |
Hardware | I have two 1064 evk connected with ethernet cable |
Terminal | I used MCUXpresso Serial Terminal to see outputs |
Cables |
|
I hope you safe and healthy.
Thanks and Regards.
Hi @Lukas_Frank ,
Thanks so much for your detailed information.
Do you work this issue for the company?
If yes, I highly recommend you use the company email to create the account and create the new question post, as that will have higher priority, and I can spend more time on the debugging.
Now, you are using the 3rd part email, gmail, it is the lowest level, we also have limit working time on this level.
So, if you can, please use the company email create the new question post, then @ me, then I can spend more time and do more checking internally, thanks a lot for your understanding.
Best Regards,
Kerry