I've attached patch files to enable DHCP, AutoIP and IGMP via LWIP, in the hope this could be added to ChibiOS 2.4...
This allows the board to attempt to receive an address from a DHCP server, but fall back to a link-local address using AutoIP if no DHCP server is found. The IGMP support allows for subscribing to multicast messages, and so could be used for implementing a UDP discovery protocol like ZeroConf or upnp to allow finding the board after it gets an address.
The changes are pretty minimal, just calling additional init methods, then setting up some more "tmr" methods to be called regularly from the lwipthread. There is also a small change in cc.h to add a LWIP_RAND define. In order for this to compile, there are also changes to lwipopts.h to enable the various LWIP features.
The patches are against 2.4.3, one file for changes to ChibiOS, then another to change lwipopts.h in the P407-LWIP demo.
I'm not sure what the best way is to allow for configuration of the changes, in case they are not wanted - it seems like there could be additional settings in lwipthread_opts. Alternatively, the new code could be controlled by the existing defines like LWIP_DHCP, LWIP_AUTOIP and LWIP_IGMP.
There is one additional change that is needed for the IGMP support to work - the MAC needs to be configured to pass through multicast packets. The simplest way of doing this seems to be from code in the appropriate demo, adding:
Code: Select all
ETH->MACFFR = ETH_MACFFR_PAM;
This seems to work when called before the "netconn_join_leave_group" function that is required to join a group.
I've tried the IGMP support, and multicast packets are received - the DHCP and AutoIP also seem to work very well, the board will swap between networks repeatedly, moving from DHCP to AutoIP and back as appropriate.