[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] lwIP crash?!

From: Artem Pisarenko
Subject: Re: [lwip-users] lwIP crash?!
Date: Thu, 22 Nov 2012 10:42:43 +0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2

2. Make sure your sys arch protection implementation does
If it is the sys_arch_protect/unprotoect function you mean, then they end in a portDISABLE/ENABLE interrupt in my port
Yes. But also make sure you enabled SYS_LIGHTWEIGHT_PROT in lwipopts.h.

3. Make sure that numerical(!) value of interrupt priority is equal to or
*greater* than the configMAX_SYSCALL_INTERRUPT_PRIORITY setting in your
FreeRTOSConfig.h. Also be warned that configMAX_SYSCALL_INTERRUPT_PRIORITY
must not be set to 0. Use only priorities 1 and above.
This one I have some difficulties understand. My configMAX_SYSCALL_INTERRUPT_PRIORITY is set to 5 << (8 - configPRIO_BITS) Schould end up with the value of 40 The text in my FreeRTOSConfig.h state that: /* Priorities passed to NVIC_SetPriority() do not require shifting as the function does the shifting itself. Note these priorities need to be equal to or* lower *than configMAX_SYSCALL_INTERRUPT_PRIORITY - therefore the numeric value needs to be equal to or greater than 5 (on the Cortex-M3 the lower the numeric value the higher the interrupt priority). */ Isn't that the opposite of what you say??
Ethernet NVIC priority is set with NVIC_SetPriority with prio 9. 
NVIC_SetPriority does shift the value to 72 ? Is that the a problem?

Thanks to engineers of ARM you are not only one who experiences difficulties with this priorities mess.

Shortly. Let's call shifted priority value as "raw value". But next, by value we will mean "short value". (You must make conversion between them.)
configMAX_SYSCALL_INTERRUPT_PRIORITY must be defined as raw value.
NVIC_SetPriority() value must be short value.
Your ethernet priority value must be equal or greater than config max syscall. And it's ok as I see (9 >= 5).
See http://www.freertos.org/RTOS-Cortex-M3-M4.html for detailed explanation.

5. Make sure you defined configKERNEL_INTERRUPT_PRIORITY to 255 or (255 <<
It is set to 248 ( 31 << (8 - configPRIO_BITS) ) Changing it to 255 does not do the trick.
It's the same because 255 will loss left bits after shifting and resulting value ends up in 248. 255 is just universal value made to be independend of configPRIO_BITS.

Just to sort out the priorities I use the following:

The RTOS task calling the netconn_recv uses priority 6
lwIP Receive thread has 5
lwIP tx clean thread has 6
TCP ip task has 8
Information about tasks priorities is not enough. (Don't confuse with interrupt priorities ! They have different meaning !) It depends on how your tasks and ethernet driver work.

I can see that the netconn_recv is "stucked" for around 300 ms from time to
time. Even the server did send the packet.
Check your driver. Maybe it implemented very ugly such as, for example, it have thread (with some priority) which check for every input packet arrived every 100ms. And, even worse, receives only one packet before going to sleep again. The same for transmitting.

In summary, I think something wrong at system level (priorities, freertos config and usage, lwip config, lwip port...) which cause memory corruption.

Regards, Artem

reply via email to

[Prev in Thread] Current Thread [Next in Thread]