cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 LwIP ?

antonius
Senior
Posted on July 11, 2015 at 13:22

Guys,

Where can I find the file that defining IP address on LwIP application ?

I generated from STM32CubeMx...

Thanks
10 REPLIES 10
antonius
Senior
Posted on July 11, 2015 at 15:22

Is it the right way to define IP address 0.0.5 ??
 void MX_LWIP_Init(void)
{
IP_ADDRESS[0] = 10;
IP_ADDRESS[1] = 000;
IP_ADDRESS[2] = 000;
IP_ADDRESS[3] = 5;
NETMASK_ADDRESS[0] = 255;
NETMASK_ADDRESS[1] = 255;
NETMASK_ADDRESS[2] = 255;
NETMASK_ADDRESS[3] = 000;
GATEWAY_ADDRESS[0] = 10;
GATEWAY_ADDRESS[1] = 000;
GATEWAY_ADDRESS[2] = 000;
GATEWAY_ADDRESS[3] = 1;
/* Initilialize the LwIP stack */
lwip_init();
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]); 
/* add the network interface */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
/* Registers the default network interface */
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called */
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}

stm32cube-t
Senior III
Posted on July 15, 2015 at 14:06

Yes. Use STM32Cube MX LwIP configuration window to specify the IP address (Disable DHCP to see the IP address field) and see the specified IP address in the generated file called ''lwip.c''.

Best regards

antonius
Senior
Posted on July 15, 2015 at 14:20

In which directory is it ? thanks

antonius
Senior
Posted on July 15, 2015 at 15:00

This is what I see on lwip.c.....I recompile it, but still can not get a proper IP address,

I use DP83848 as a PHY chip.... Any ideas to make it right ?

void MX_LWIP_Init(void)
{
IP_ADDRESS[0] = 10;
IP_ADDRESS[1] = 0;
IP_ADDRESS[2] = 0;
IP_ADDRESS[3] = 5;
NETMASK_ADDRESS[0] = 255;
NETMASK_ADDRESS[1] = 255;
NETMASK_ADDRESS[2] = 255;
NETMASK_ADDRESS[3] = 0;
GATEWAY_ADDRESS[0] = 10;
GATEWAY_ADDRESS[1] = 0;
GATEWAY_ADDRESS[2] = 0;
GATEWAY_ADDRESS[3] = 1;
/* Initilialize the LwIP stack */
lwip_init();
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]); 
/* add the network interface */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
/* Registers the default network interface */
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called */
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}

stm32cube-t
Senior III
Posted on July 17, 2015 at 18:04

Hello,

You need to make sure your computer and your board are on the same network (same address range) or you will need a routing table to route packets from one to the other.

You have configured your board IP address to be 10.0.0.5.

Configure your PC address to be 10.0.0.6 for example, and reuse the same gateway IP address 10.0.0.1.

antonius
Senior
Posted on July 18, 2015 at 01:27

So I must set my LAN network as static IP with 10.0.0.6 ? thanks

0690X000006032OQAQ.jpg

antonius
Senior
Posted on July 18, 2015 at 01:58

I have set it, but still can not ping to my STM32 board....I'm using RMII setting for ethernet...and DP83848 chip for PHY....do I need a clock from STM32 or can I use a clock from the module itself ? it has a crystal but there's a port for OSCIN..??

Thanks

0690X000006032TQAQ.jpg

stm32cube-t
Senior III
Posted on July 27, 2015 at 20:58

Hello,

Please find attached a working configuration for STM32 evaluation board (F429 MCU).

In your configuration, please check the following:

- Ethernet configuration in the pinout tab (MII full-duplex is used here)

- MAC address under Ethernet and IP address under LwIP in the configuration Tab.

- Clock configuration (shall match your board design).

STM32 evaalboard user manual indicates the following regarding Ethernet Phy:

A 25 MHz clock can be generated by PHY or provided by MCO from the STM32F429NIH6 by setting jumper JP6

Best regards.

________________

Attachments :

LwIP_example.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0vy&d=%2Fa%2F0X0000000bfo%2F_8.3AjKPpTomIRBVsLLA65rf8PKEqF.vAQyDdyELSCk&asPdf=false
antonius
Senior

Posted on August 07, 2015 at 23:49

Thanks for the example,

Is it possible for me using it on STM32F407 and 107 ?

I have 429 but the ethernet board is connected to 107 ..

Please find my 107 project STM32F107 attached,

and the ethernet board has 50Mhz clock, and RMII mode...

How do you reckon ? }

Here're the setting on STM32CubeMX for MAC and IP address, I think there's something wrong with it...?? I follow all the procedure and hardware connection carefully and still can't get, at least MAC address... 0690X00000602xtQAA.jpg 0690X000006033qQAA.jpg It works already, but I'm not using STM32CubeMX generated code, I'm not sure, the code generated from STM32CubeMX is reliable for STM32F.. 

________________________

  Attachments :

STM32F107VCT7.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0vx&d=%2Fa%2F0X0000000bfp%2FH1Av8ktu4pocBrtbt8WZGez5oO0iG_Auzk2U34nDsaM&asPdf=false