Changed IP stack and added FreeRTOS. The system works a few seconds and then gets stuck.
Custom IP stack working fine with CoOS.
uIP working fine with CoOS.