I am using an FRDM k64 Arduino, and developing a TCP/IP client on it. It works as follows. There is a circular queue that stores data. Periodically that queue gets data put in the queue from external sensors via an interrupt. During free time I check to see if there is data in the queue, if there is data, empty the queue and write the data to a server. To do this I use FreeRTOS plus the netconn API that comes with LWIP. I have 1 thread called TCPThread that creates a connection, and connects to my server. I then have an infinite while loop that checks the queue and runs netconnwrite if there is data (yes I handle looping back on the queue). After few hundred sucessful writes to the server (currently just a C# server on a PC that writes the data to a screen) my MCU crashes. I end up in the default ISR, which points to a bus fault.
If I lower the number of netconnwrite calls by increasing the minimum ammount of data in the queue before we bother to write to the server (for example need 100 bytes vs 1 byte to call netconnwrite) the ammount of time the MCU lasts between crashes goes up (havent checked exact number of calls, but my gut says it will be simmilar). Is there something I am missing here? It seems I am running out of memory and crashing, but because LWIP is an API I really don't have an easy way to malloc for it/shouldn't I not need to because all resources should be freed after a local function (netconn_write) is called?
Unfortunately we cannot support lwIP. Trying to support users on lwIP,
which is moderately involved third party code, was what lead us to
develop our own TCP/IP stack so we could better support TCP users.
Your system could be going wrong in any number of ways. In my
experience, the biggest source of problems in lwIP applications is
normally the driver, not the lwIP code at all.
You say "I end up in the default ISR, which points to a bus fault." If
it is the default ISR, how are you determining that it is a bus fault?