XMC4500 read IP Address before Flash Ethernet initialization

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User17149
Level 2
Level 2
First solution authored
Hi,

Currently the IP Address of the ethernet interface is hardcoded in the lwip header files.

Is it possible to circumvent this during Dave_init() so that the IP address can be read from Flash or a register or SD Card?

Thank you in advance

Kuros
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

You could use the netif status callback.
In the callback you could before starting your network applications, do the following

#if LWIP_NETIF_STATUS_CALLBACK == 1
/* The status callback will be called anytime the interface is brought up and down.
For example, if you would like to log the IP address chosen by DHCP when it has got one,
and know when this address changes, then you can use the status callback hook.
The function being called is netif_status_callback */

void netif_status_cb(struct netif *netif)
{
#if LWIP_DHCP
if (dhcp_supplied_address(netif) > 0)
{
/* Initialize echo server */
shell_init();
}
#else
if (netif_is_up(netif))
{
#define IP_ADDR0_0 (192U)
#define IP_ADDR1_0 (168U)
#define IP_ADDR2_0 (0U)
#define IP_ADDR3_0 (11U)

/*IPv4 subnet mask*/
/*Static IPv4 address*/
#define NETMASK_ADDR0_0 (255U)
#define NETMASK_ADDR1_0 (255U)
#define NETMASK_ADDR2_0 (255U)
#define NETMASK_ADDR3_0 (0U)

/*IPv4 gateway address*/
/*Static IPv4 address*/
#define GW_ADDR0_0 (192U)
#define GW_ADDR1_0 (168U)
#define GW_ADDR2_0 (0U)
#define GW_ADDR3_0 (10U)

ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;

IP4_ADDR(&ipaddr, IP_ADDR0_0, IP_ADDR1_0, IP_ADDR2_0, IP_ADDR3_0);
IP4_ADDR(&netmask, NETMASK_ADDR0_0, NETMASK_ADDR1_0 , NETMASK_ADDR2_0, NETMASK_ADDR3_0);
IP4_ADDR(&gw, GW_ADDR0_0, GW_ADDR1_0, GW_ADDR2_0, GW_ADDR3_0);

netif_set_addr(ETH_LWIP_0.xnetif, &ipaddr, &netmask, &gw);
/* Initialize echo server */
shell_init();
}
#endif
}
#endif


Regards,
Jesus
0 Likes
User17149
Level 2
Level 2
First solution authored
Thank you... I came around to trying this, but unfortunately it did not work as the Filesystem object is not initializable at this time.... The SD card is not accessible at this point of the initialization
0 Likes