[ECOS] ecos + lwip

Simon Kallweit simon.kallweit@intefo.ch
Wed Sep 2 15:32:00 GMT 2009

Mandeep Sandhu wrote:
> On Wed, Sep 2, 2009 at 11:45 AM, Mandeep
> Sandhu<mandeepsandhu.chd@gmail.com> wrote:
>>> You need to wait for cyg_lwip_sequential_init() to return before creating
>>> user threads.
>> That should be happening since I'm calling cyg_lwip_sequential_init() before
>> even creating my own thread!
>> <snip>
>> cyg_lwip_sequential_init();
>> cyg_lwip_thread_new( "My thread", m_main, (void *)"My thread",
>> my_stack, 0x1000, 5 );
>> ...
>> ...
>> <snip>
>> I'll enable more debugs to see where it's getting stuck.
> Hi Simon,
> I think I've partially fixed the issue. While going through the default config
> I noticed that the TCPIP thread's default priority is set to 8. Which was lower
> than my threads prio - 5.
> After changing it to 2, it's able to find the interface (et0) with all
> the right settings.

Well, that does not really make sense. cyg_lwip_sequential_init() will 
not return until the lwip stack is initialized, and initializing 
ethernet device drivers is part of that. This *must* work even when the 
TCPIP thread has lower priority, as long as you start your application 
thread *after* the execution of cyg_lwip_sequential_init(). By starting 
*after* I mean that you also have to make sure that 
cyg_lwip_sequential_init() and starting your applications thread is done 
in the same thread!

I hope I didn't miss the obvious here, but that's how it should work.

> Now another problem has cropped up! :) Sorry.
> My app's actually a DHCP server. So it receives DHCP packets with
> as the src IP. However, the stack is dropping them with the following message:
> ip_input: iphdr->dest 0xffffffff netif->ip_addr 0x101010b (0xffffff,
> 0x1010b, 0xff000000)
> ip_input: packet accepted on interface et
> ip_input: packet source is not valid.
> I've enabled the following in my config:
> * Support broadcast filter
> * Receive support
> Is anything else needed?

May I ask you to forward this question to the lwip mailing list, I have 
no experience on that subject myself.

> Just one more thing:
> While tracing the path from  cyg_lwip_sequential_init() to see what
> all happens, I saw that
> we end up calling lwip_init() twice!
> Once in cyg_lwip_sequential_init() and then again in tcpip_init().
> Why do we do it twice? The only function called between these 2 calls is
> cyg_semaphore_init().
> I think we can remove one of these. Or am I missing something?

Well, that's a bug. Thanks for spotting. I wrapped a new release you can 
download from:



Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list