A collection of Rust crates for low-level networking functionality.
So far:
-
cotton-netif
: enumerating available network interfaces and their IP addresses, including ongoing (asynchronous) comings and goings of network interfaces (e.g. on USB hotplug/unplug); so far, for Linux only.
-
cotton-scsi
: implementing SCSI direct-access storage device commands in terms of an abstract SCSI transport.
-
cotton-ssdp
: implementing SSDP, the Simple Service Discovery Protocol, a mechanism for discovering available resources (service) on a local network. Uses cotton-netif, in order to do the Right Thing on multi-homed hosts (but meaning that it is unlikely to work on Windows platforms).
-
cotton-unique
: creating deterministic but per-device unique identifiers such as MAC addresses.
-
cotton-usb-host
: a no-std, no-alloc asynchronous USB host stack, initially for RP2040.
-
cotton-usb-host-hid
: USB "Human Interface Device" (HID) keyboard & mouse support (i.e., supporting attaching USB keyboards & mice to a microcontroller, to allow keyboard & mouse input).
-
cotton-usb-host-msc
: USB mass-storage support for cotton-usb-host (i.e., supporting attaching USB mass-storage devices to a microcontroller, to give the microcontroller extra storage space).
-
cotton-w5500
: smoltcp driver for the Wiznet W5500 Ethernet controller in MACRAW mode, including interrupt-driven mode.
These crates are no_std-compatible, meaning that they can be used on
embedded systems. In fact, all pushes to my local (not Github)
continuous-integration server are automatically tested on both STM32
and RP2040 platforms. You can read about how that is set up on my
blog: Part
one,
Part two,
Part three.
These system-tests also serve as example code combining the Cotton crates with the wider ecosystem, including examples where the combining of the wider ecosystem components needed a little research in its own right even before involving Cotton, so perhaps that in itself will be useful to others:
-
stm32f746-nucleo-hello: basic test that an attached STM32F746-Nucleo development board is working correctly; no-alloc;
-
stm32f746-nucleo-dhcp-rtic: combining RTIC (1.x) + stm32-eth + smoltcp + cotton-unique (a.k.a. how not to have a hardcoded, made-up MAC address!); no-alloc;
-
stm32f746-nucleo-ssdp-rtic: combining RTIC + stm32-eth + smoltcp + cotton-unique + cotton-ssdp;
-
stm32f746-nucleo-dhcp-rtic2: combining RTIC 2 + stm32-eth + smoltcp + cotton-unique; no-alloc;
-
stm32f746-nucleo-ssdp-rtic2: combining RTIC 2 + stm32-eth + smoltcp + cotton-unique + cotton-ssdp;
-
stm32f746-nucleo-ssdp-embassy: combining Embassy + cotton-unique + cotton-ssdp; proof-of-concept, not very Embassy-idiomatic;
-
rp2040-usb-hid-boot-keyboard: combining RTIC 2 + cotton-usb-host + cotton-usb-host-hid;
-
rp2040-usb-msc: combining RTIC 2 + cotton-usb-host + cotton-usb-host-msc; WARNING this writes to the USB drive, don't use one with data on that you want to keep;
-
rp2040-usb-otge100: combining RTIC 2 + cotton-usb-host;
-
rp2040-w5500-hello: basic test that an attached W5500-Pico-EVB development board (or anything that equivalently wires together an RP2040 and a W5500) is working correctly; no-alloc;
-
rp2040-w5500-dhcp-rtic: combining rp2040-hal + RTIC + w5500-hl + w5500-dhcp + cotton-unique; no-alloc;
-
rp2040-w5500macraw-dhcp-rtic: combining rp2040-hal + RTIC + w5500 (MACRAW mode with interrupts) + smoltcp + cotton-unique (note that's a different W5500 crate); no-alloc;
-
rp2040-w5500macraw-ssdp-rtic: combining rp2040-hal + RTIC + w5500 (MACRAW mode with interrupts) + smoltcp + cotton-unique + cotton-ssdp;
My long-term goals for this project as a whole:
-
provide useful, solid, well-tested components to folks needing Rust crates for networking, including UPnP and embedded devices
-
develop skills in Rust coding, including the packaging, distributing, and publicising of it, after a career spent with C++
Cotton's MSRV is now 1.85, new enough to include the MSRV-aware dependency resolver. This means that future MSRV updates will be minor version bumps only, not major version bumps, because they will not break downstream builds.
The final releases which still built with pre-MSRV-aware versions (1.80) were cotton-netif 0.2, cotton-scsi 0.2, cotton-ssdp 0.2, cotton-unique&nbps;0.3, cotton-usb-host 0.2, cotton-usb-host-hid 0.1, cotton-usb-msc 0.2, and cotton-w5500 0.2.
Everything is licensed under Creative Commons CC0, qv.