# PIC32MX lwIP + FreeRTOS port again

**URL:** <https://forums.freertos.org/t/pic32mx-lwip-freertos-port-again/4440>\
**Category:** Kernel\
**Created:** [November 26, 2008, 1:28pm UTC](https://forums.freertos.org/t/pic32mx-lwip-freertos-port-again/4440 "2008-11-26T13:28:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 26, 2008, 1:28pm UTC](https://forums.freertos.org/t/pic32mx-lwip-freertos-port-again/4440/1 "2008-11-26T13:28:33Z")

</div>

**[akhe](https://sourceforge.net/u/akhe/)** wrote on [Wednesday, November 26, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/c20a3083/#8c0e):

I received and send frames now which is a success. There is a problem though in the Tctcpip thread. It appears to be FreeRTOS related so I ask here. Quite complex to explain the problem byt here we go.

In the tcpip thread the code waits for a frame. This is done with

sys\_mbox\_fetch(mbox, (void \*)&msg);

which is defined in the sys\_arch.c&nbsp; When called I get an exception.

I have checked that the mbox has been initialized and can trace the fault to a list iteration in vListInsert (called in vTaskPlaceOnEventList)

for( pxIterator = ( xListItem \* ) &( pxList-\>xListEnd ); pxIterator-\>pxNext-\>xItemValue \<= xValueOfInsertion; pxIterator = pxIterator-\>pxNext )  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /\* There is nothing to do here, we are just iterating to the  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wanted insertion position. \*/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

As I can see the list pointers are messed up as this point giving the exception. I have not been able to figure out why yet.

Call stack is

- tcpip\_thread  
- sys\_mbox\_fetch  
- sys\_arch\_mbox\_fetch  
- xQueueGenericReceive  
- vTaskPlaceOnEventList

Any hints appreciated.

Cheers  
/Ake

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [November 26, 2008, 3:03pm UTC](https://forums.freertos.org/t/pic32mx-lwip-freertos-port-again/4440/2 "2008-11-26T15:03:44Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, November 26, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/c20a3083/#8c0e/5849):

Most likely cause of this is stack overflow - the lwIP threads can use quite a bit of stack, especially when using standard GCC C library functions such as sprintf() [you can use cut down versions that are more stack friendly on embedded systems].

Check the task that implements your lwIP functionality AND any task that is created using sys\_thread\_new() within sys\_arch.c.&nbsp; Put a break point in sys\_thread\_new() to ensure you catch each time it is called.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 26, 2008, 5:19pm UTC](https://forums.freertos.org/t/pic32mx-lwip-freertos-port-again/4440/3 "2008-11-26T17:19:11Z")

</div>

**[akhe](https://sourceforge.net/u/akhe/)** wrote on [Wednesday, November 26, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/c20a3083/#8c0e/e39f):

Hi Richard,

you are right of course.

Thanks a lot.

/Ake
