FreeRTOS+ATmega128+uIP

nobody wrote on Friday, October 07, 2005:

Did anybody implement (try to implement) this?
I can run uIP+ATmega128 without FreeRTOS, it works OK, but I tried to run uIP (without modification) with FreeRTOS and failed. At the first glance it looks like some global variables get corrupted:
uIP uses {volatile unsigned short uip_len} global var and uip_len can be modified unpredictably (i.e. I initialize it to zero and immediately printf to the usart debug port, and the value is not zero).
Things became better when I used {static volatile unsigned short uip_len} - no unpredictable changes (although still no result), but in the IAR example included with FreeRTOS no static modificator used for this variable (although it uses modified uIP - with interrupts and semaphores).
I would like to use the original (polling version of uIP with timer0), what would be the start point to get it working?

Thanks for any suggestions,
Alexander.

nobody wrote on Friday, October 07, 2005:

Do you have the uIP statck running in the same task as the application that uses uIP?

For example, the ARM uIP demo implements a WEB server.  The uIP and HTTP components are both in the same task.  The uIP stack uses the uIP variables (uip_len, etc.) to send and receive.  The HTTP components use the uip variables to read from and write to the uIP buffers.  If they are in the same task then you are guaranteed that they wont both try and access the variables at the same time.  If they are not in the same task then some mutual exclusion of the variables will have to be implemented.

nobody wrote on Friday, October 07, 2005:

Really fast reply…
Yes, they are in the same task (I use AVRGCC by the way)

Alexander.

nobody wrote on Friday, October 07, 2005:

Could it be a stack problem?  The function call nesting depth means the uIP task will require a good bit more stack.

There is not RAM available.  How big is the uIP buffer being user?

nobody wrote on Friday, October 07, 2005:

That should not be stack - I tried with different sizes (150-1000 byte).
UIP_BUFSIZE was 100-1500.

the RAM available on MCU is 4K

nobody wrote on Friday, October 07, 2005:

Got it!
Playing around uip’s UIP_BUFSIZE (512byte) and  FreeRTOSConfig.h parameters (configTOTAL_HEAP_SIZE=1500, configMINIMAL_STACK_SIZE=128byte, stack size in xTaskCreate() = 150). Looks like it was a problem with stack/heap size indeed, silly me!

Thanks,
Alexander.

nobody wrote on Monday, October 10, 2005:

What is the difference between uIP stack and lwIP stack?

rtel wrote on Monday, October 10, 2005:

See table 1 in:
http://www.sics.se/~adam/mobisys2003.pdf
for (slightly out of date) information.