cancel
Showing results for 
Search instead for 
Did you mean: 

ethernet (UDP and TFTP)

ronandouguet
Associate II
Posted on March 30, 2012 at 16:19

Hi everybody,

I want to

make

an Ethernet connection

between the stm32f4 discovery board and my computer. I use a DP83848 Ethernet Board (

http://www.wvshare.com/product/DP83848-Ethernet-Board.htm

) to the Ethernet Physical Layer. I implement the LwIP TCP/IP stack on my board. And for the moment

I try to send

UDP

data

to the computer

from the card

. I configure ethernet with the file stm32f4x7_eth_bsp.c. And when

I test

ping

between

my card and

the computer

it works

. I create an function to send UDP Data :

void
udp_send_data(
void
)
{
struct
udp_pcb *ptel_pcb;
char
msg[]=
''testing''
;
struct
pbuf *p;
struct
ip_addr ipaddr;
/* Mise à jour de l'adresse IP du dest */
IP4_ADDR(&ipaddr, IP_DEST_ADDR0, IP_DEST_ADDR1, IP_DEST_ADDR2, IP_DEST_ADDR3);
ptel_pcb = udp_new();
udp_bind(ptel_pcb, &ipaddr, 1235);
//udp_recv(ptel_pcb, udp_echo_recv, NULL);
p = pbuf_alloc(PBUF_TRANSPORT,
sizeof
(msg),PBUF_RAM);
memcpy
(p->payload, msg, 
sizeof
(msg));
udp_sendto(ptel_pcb, p, &ipaddr, 1234);
pbuf_free(p); 
//De-allocate packet buffer
}

And I use it in the main program :

int
main(
void
)
{
/*!< At this stage the microcontroller clock setting is already configured to 
168 MHz, this is done through SystemInit() function which is called from
startup file (startup_stm32f4xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f4xx.c file
*/
unsigned 
int
i;
/* configure ethernet */
ETH_BSP_Config();
/* Initilaize the LwIP stack */
LwIP_Init();
/* UDP echoserver */
udp_echoserver_init();
/* Infinite loop */
while
(1)
{ 
/* check if any packet received */
if
(ETH_CheckFrameReceived())
{
/* process received ethernet packet */
LwIP_Pkt_Handle();
}
/* handle periodic timers for LwIP */
LwIP_Periodic_Handle(LocalTime);
Delay(100);
udp_send_data();
} 
}

In this configuration this

data

are

sent in

UDP

but if remove the following code :

/* check if any packet received */
if
(ETH_CheckFrameReceived())
{
/* process received ethernet packet */
LwIP_Pkt_Handle();
}
/* handle periodic timers for LwIP */
LwIP_Periodic_Handle(LocalTime);

There aren't UDP Frame !!! So I don't understand UDP

protocol

:(

I look for

examples

of

simple

UDP connection

?
1 REPLY 1
ronandouguet
Associate II
Posted on April 03, 2012 at 15:10

Hi,

Now, I have new problem with a TFTP server.

I tested the TFTP server demo (LwIP TCP/IP stack demonstration) and I use tftpd32 tool (TFTP client must be installed on the remote PC).

I observe frames between PC and my board with Wireshark and there are only two dataframe which exchanged between two devices (Request from PC and One Data Packet from board).

I don't know if it is the program on the board or the software which doesn't work ?

Thanks for your help.