Skip to content

Add ethernet support to eval-pqmon #2550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

romandariana
Copy link
Contributor

@romandariana romandariana commented Apr 11, 2025

Pull Request Description

This PR adds support for the W5500 Ethernet controller chip, providing standard Ethernet connectivity for no-os projects. The implementation includes:

  • Core W5500 driver with SPI interface and socket management
  • Network interface adapter to integrate with the no-os network_interface API
  • IIO subsystem support for W5500-based network communications
  • Integration with the eval-pqmon project, adding a new "ethernet" build option

PR Type

  • New feature (change that adds new functionality)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

Copy link
Contributor

@buha buha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a builds.json

i see this project doesn't have one, but i would add it at this stage to ensure we don't break this project or the w5500 networking infrastructure

@buha
Copy link
Contributor

buha commented Apr 14, 2025

and make sure to review the #ifdefs you added, they seem to break some existing projects that use networking

@romandariana
Copy link
Contributor Author

romandariana commented Apr 14, 2025

I pushed a v2 with some fixes for now:

v1 -> v2

  • use /** instead of /*! doxygen syntax in header files
  • moved errno.h and string.h in the .c file, same for delay.h and alloc.h
  • instead of using network_interface.h, i refactored the driver to use driver specific structure for socket address to see if we get rid of some of the build errors this way. a low-level driver would better not depend on higher level network interface. the mapping between the two is done in w5500_network
  • updated the README.md file of the eval-pqmon project

Rename the "ethernet" build option to "ethernet_t1l" to clarify that
it refers specifically to the ADIN1100 T1L Ethernet PHY. This change
prepares for the future addition of WIZ850io (W5500-based) Ethernet
support as an alternative interface option.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Add low-level driver for the WIZnet W5500 Ethernet controller chip.
The driver provides SPI interface communication, socket management,
and TCP/UDP/MACRAW protocol implementations.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Add adapter layer to integrate the W5500 Ethernet controller with
the generic network_interface API. This enables the W5500 driver
to be used with no-os TCP/IP socket implementations.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Add W5500 Ethernet controller support to the IIO subsystem by extending
the network interface conditionals to include NO_OS_W5500_NETWORKING.
This allows applications to use W5500-based network connectivity for
IIO communication alongside existing UART and LWIP options.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Add support for standard Ethernet connectivity to the eval-pqmon project
using the W5500 Ethernet controller. This introduces a new "ethernet"
build option alongside the existing USB, serial, and ethernet_t1l options.
Configure necessary hardware parameters, SPI interface, and network stack
integration for the WIZ850io module.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
@romandariana
Copy link
Contributor Author

v2 -> v3

  • add #ifdef NO_OS_W5500_NETWORKING to w5500_network files to avoid getting it built in random projects

@buha
Copy link
Contributor

buha commented Apr 16, 2025

ok, i'm dropping the requirement to add builds.json at this point, that's a separate discussion because any build of this project requires pqlib and i am not sure we have the infrastructure now, that can be a separate pr

Comment on lines +556 to +567
ret = w5500_socket_open(net_dev->mac_dev, new_physical_id, W5500_Sn_MR_TCP, 2);
if (ret)
return ret;

ret = w5500_socket_bind(net_dev->mac_dev, new_physical_id,
server_socket->local_port);
if (ret)
return ret;

ret = w5500_socket_listen(net_dev->mac_dev, new_physical_id);
if (ret)
return ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open, bind and listen should have been called for a server socket prior to accept(). Why is it necessary to add this sequence here?

Comment on lines +569 to +576
new_socket = &net_dev->sockets[new_physical_id];
new_socket->sock_id = sock_id;
new_socket->local_port = server_socket->local_port;
new_socket->in_use = 1;
new_socket->role = W5500_ROLE_SERVER;

server_socket->sock_id = net_dev->next_virtual_id++;
server_socket->role = W5500_ROLE_CLIENT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain what is happening here? Are we changing the socket associated with the server?

Copy link
Contributor Author

@romandariana romandariana Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, in the iio module where accept is called, it expects a new client socket to be created and the server socket keeps listening for new connections. But for W5500, the socket that is listening changes status and becomes a "client" socket. To bypass this, in the w5500 accept function I created a new socket that will be the server socket, thus the 3 function callings above, then I switch the virtual ids. Should I extract this switch in another static function to make things clearer?


socket = &net_dev->sockets[physical_id];

socket->role = (proto == PROTOCOL_TCP) ? W5500_ROLE_CLIENT : W5500_ROLE_UNUSED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can know if the socket will be used by a client or server at this point

struct w5500_dev *mac_dev;
struct w5500_network_dev *net_dev;

status = w5500_init(&mac_dev, &w5500_ip);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can move this part in the w5500_network_init() function in order to simplify the application code.

.gpio_reset = w5500_rst_gpio_ip,
.gpio_int = w5500_int_gpio_ip,
.mac_addr = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03},
.ip_addr = {192, 168, 1, 110},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to support DHCP besides the static IP assignment? Also, it would be nice if you could define a macro for the IP address and netmask (similarly to this approach: https://github.com/analogdevicesinc/no-OS/blob/main/projects/apard32690/Makefile#L13-L16 , however you can set it directly into the init param). I think that would provide a simple way of building the project with different ip addresses for the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants