cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f767zi nucelo ethernet hardware setup : Can we use our laptop as a router for testing?

Anare.1
Associate III

Hello  everyone,

It is a quite basic question, I have this stm32767zi nucleo board with a LAN driver and rj45 connector, and I intend to test the basic ping/web server examples.So for now, I do not have a router with me, so I was wondering, if I could use my laptop as a router itself , if it is connected to the WiFi and connect my board to laptop using an Ethernet cable.

1 ACCEPTED SOLUTION

Accepted Solutions
LCE
Principal

I'm not sure if I understand correctly...

If you just ask: can I connect Nucleo to laptop via ethernet jack and check the Nucleo's webserver?

Then the answer is: yes!
I recently did that while travelling on a train

But you either need some PC app to run it as a DHCP server, or you have to give the Nucleo a static IP address, with most parts matching that of your PC's.
subnet mask and gateway must be identical, IP4 address itself has to match the first 3 (or 2?) bytes.

Example:

 

 

laptop's address (find out via cmd / ipconfig)
IP4 address:    169.254.111.7
SubNet:         255.255.0.0
GateWay:        169.254.111.1

then your Nucleo's address should be set to:
IP4 address:    169.254.111.x
SubNet:         255.255.0.0
GateWay:        169.254.111.1

with x any 8 bit value except the laptop's (7 here)

 

 

I just tested that (but with a USB-ethernet bridge adapter with a Microchip LAN9512), it's working here.

Edit:
It will probably 169.254.x.y

wikipedia says:

169.254.0.0/16169.254.0.0–169.254.255.25565536SubnetUsed for link-local addresses[10] between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server.

View solution in original post

10 REPLIES 10
TDK
Guru

You can't plug in the board and expect the board to show up as a device on the network via your laptop.

You can communicate directly with the laptop via an ethernet cable, but setup is a bit of a mess.

A WiFi to ethernet adapter can provide the setup you want.

If you feel a post has answered your question, please click "Accept as Solution".
Anare.1
Associate III

Thank you for the response and time, But is it possible to run a web server using fixed.static ip addresses?

TDK
Guru

Possible, yes, but not very practical to run a web server from a microcontroller due to the low onboard memory and relatively slow processing speed. A raspberry Pi or similar would be much better suited and much easier to put together.

If you feel a post has answered your question, please click "Accept as Solution".
Anare.1
Associate III

Thank you again, I do understand the code constraints on this design of writing a web server in a uC.So all I have to do is run the webserver/html page on raspberry pi and communicate to the IP of raspberry pi using the wifi to ethernet adapter from my board(IP of the uC board). Please feel to correct me, if I am wrong.

LCE
Principal

I'm not sure if I understand correctly...

If you just ask: can I connect Nucleo to laptop via ethernet jack and check the Nucleo's webserver?

Then the answer is: yes!
I recently did that while travelling on a train

But you either need some PC app to run it as a DHCP server, or you have to give the Nucleo a static IP address, with most parts matching that of your PC's.
subnet mask and gateway must be identical, IP4 address itself has to match the first 3 (or 2?) bytes.

Example:

 

 

laptop's address (find out via cmd / ipconfig)
IP4 address:    169.254.111.7
SubNet:         255.255.0.0
GateWay:        169.254.111.1

then your Nucleo's address should be set to:
IP4 address:    169.254.111.x
SubNet:         255.255.0.0
GateWay:        169.254.111.1

with x any 8 bit value except the laptop's (7 here)

 

 

I just tested that (but with a USB-ethernet bridge adapter with a Microchip LAN9512), it's working here.

Edit:
It will probably 169.254.x.y

wikipedia says:

169.254.0.0/16169.254.0.0–169.254.255.25565536SubnetUsed for link-local addresses[10] between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server.

Possible, yes, but not very practical to run a web server from a microcontroller due to the low onboard memory and relatively slow processing speed.


You shouldn't always assume the author is trying to make a server for YouTube. There are countless examples for which the resources on STM32 MCUs are not only sufficient, but plentiful. I am serving a non-trivial web-page with HTML, CSS, JavaScript, AJAX and the related services on MCU side running as a charm and it takes just a few tens of KB of FLASH memory. I am running it on F7, but it could run even on F1 with 128 KB of FLASH.

@LCE , in addition to static configuration link-local addresses can also be assigned by AutoIP.

 

But is it possible to run a web server using fixed.static ip addresses?

The web server doesn't care who assigned the IP address.

I do not have a router with me

As LCE already said, there is no need for a router and there is no even need for a switch.

The real problem is this:

https://community.st.com/t5/embedded-software-mcus/how-to-make-ethernet-and-lwip-working-on-stm32/td-p/261456

Thank you so much for the detailed response and references.I  really appreciate the insights.

Anare.1
Associate III

Thank you for your time and efforts to answer my queries, I really appreciate it.

LCE
Principal

Actually try what @Piranha told us about, it's called AutoIP in lwIP, activated by the #define LWIP_AUTOIP 1 in opt.h.

I didn't know about that, I'm still an ethernet beginner, but included AutoIP last week.
It's working great!
So now my application starts with DHCP, when that times out it starts AutoIP, if that fails it uses a static IP.

Thanks @Piranha !