-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adding MACRAW mode support #33
Adding MACRAW mode support #33
Conversation
Could you provide an example usage? Not necessary runnable, but enough to grasp how to set it up... |
My specific use case is unfortunately closed-source currently, but the essence of these changes is as follows: The general pattern is to first implement your necessary trait on the impl smoltcp::phy::Device for w5500::RawDevice<SPI> {
// Implementation details
} Now that the trait is implemented, we can use the // During hardware setup, construct the RawDevice
let external_mac = W5500::UninitializedDevice::new(w5500::bus::FourWire::new(spi, cs))
.initialize_macraw(mac).unwrap();
// Pass the RawDevice to smoltcp, which then allows smoltcp to be used as in any other application
let interface = smoltcp::iface::InterfaceBuilder::new(external_mac, ...).finalize(); Once you have the smoltcp interface, you can use it however you'd like to make as many UDP/TCP sockets as you'd like. Smoltcp is a software-based network stack, so it's configurable for different operations and extendable (e.g. supports DHCP and maybe DNS in the future) |
You make it sound as if you plan further PRs? I'd love so see a mention somewhere (maybe in the Re |
Directly as written, yes. That's why I said (implementation details). In reality, there's some synchronization primitives (FIFOs, frame pools) etc. that are required. You can't implement
As I mentioned above, there's a fair amount more to implementing the smoltcp phy Device trait for just the RawDevice, as there's a lot of other resources that need to be managed. I'm trying to figure out where this code would best live, but I don't think any of it is actually specific to the W5500 - it works for any external PHY/MAC, so I don't think I planned on moving the code into this repo. |
Fine with me. Feel free to post follow ups anyway :) |
This PR adds in initial MACRAW operation mode support. This allows you to run a software-based network stack (e.g. smoltcp) on socket 0.
The current implementation does not support any type of hybrid model (e.g. TCP/UDP on sockets 1-7, raw on socket 0), but rather allocates the whole RX/TX buffers for socket 0 in raw mode and disables the other sockets.
Using this, raw ethernet frames can be read from and written to the W5500 MAC.
I have used this branch with Smoltcp to implement multiple MQTT clients over TCP to confirm operation.