I have problem with sam7x with udp

dumarjo wrote on Friday, March 16, 2007:


I have modified the web demo sample to use udp protocol I have 2 task that wait on queues. I have also 1 udp connection. I use also the usb to emulate a joystick.

up to now i been able to do all i want. the usb part is working, the udp also.

BUT, some time, the os hangs. I don’t know exactly why it hangs. I can run my software for 5 10 minutes, and he hangs. I have used the debugger to know where the program is, and he is loked up in this function :

unsigned portLONG ulEMACInputLength( void )

in this part of the function:

    /* Walk through the descriptors until we find the last buffer for this
    frame.  The last buffer will give us the length of the entire frame. */
    while( ( xRxDescriptors[ ulIndex ].addr & AT91C_OWNERSHIP_BIT ) && !ulLength )
        ulLength = xRxDescriptors[ ulIndex ].U_Status.status & emacRX_LENGTH_FRAME;

        /* Increment to the next buffer, wrapping if necessary. */
        if( ulIndex >= NB_RX_BUFFERS )
            ulIndex = 0;

I never get out from there. I would like to know if somebody have already had this issue.

btw i have test my software with lwip 1.1.0 and also with 1.2.0 and same thing happen.



embeddedc wrote on Friday, March 16, 2007:

The descriptors are automatically filled by the processor DMA.  Something is getting corrupt in the RAM utilized by the DMA.

A fix would be to include some code to ensure that you don’t loop more than once, and if you find yourself doing this resetting the descriptors to their default state.  This would prevent your code hanging, but does not fix the cause of the problem, only the symptom.  It would be better to find what is causes the corruption in the first place.  Most likely thing would be a stack overflow (before anybody else says it).

dumarjo wrote on Monday, March 19, 2007:

This is what i though.

When this happen, i don’t received interrupt from the mac anymore.

Right now i use only 1 udp connection but i use it in 2 task. I will try to protect the connection with semaphore to see what happen.


dumarjo wrote on Wednesday, March 21, 2007:

Ok i have found the problem

Protected the connection between both task is correcting some part of the problem.

The second is since we don’t use the tcp at all, after the refresh of the arp table, the computeur cannot communicate with the arm7 because in the lwip sample from freertos, the broadcast bit is not set. So iu have change to accept the broadcast and now everything is working well.

I have also remove the caf bit to receive only the data that match our mac addr.

So thank-you for your help on that one.