Git Product home page Git Product logo

ipoverusb's Introduction

IP over USB Build Status

This repository contains the STM32 embedded firmware demonstration of a virtual network with a single lwIP server (DNS, DHCP, HTTP) presented on the USB network adapter interface. It's meant to be a starting point for IP over USB applications (using CDC-NCM protocol) and a low-cost IP stack development platform.

There are two possible supported software configurations:

  1. A bare-metal implementation using the lwIP native API.
  2. An RTOS implementation using FreeRTOS and the lwIP netconn API.

How to use

  1. Build and flash the image on an STM32F4DISCOVERY or a 32L476GDISCOVERY (easily portable to other STM32 targets)
  2. Connect to PC via USB
  3. Fix any driver issues, see below
  4. Go to http://www.lwip.home

Features

  • Using NCM implementation of USBDevice (double-buffered, efficient, simple API)
  • lwIP 2.1.0 with additional dummy DHCP server for out of the box operation
  • DNS server implementation allows domain name based access
  • Reprogramming via USB supported by DFU interface (DFU standard implementation to reboot to ROM)
  • FreeRTOS variant allows the choice of any lwIP APIs to be used by the application

ipoverusb's People

Contributors

benedekkupper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ipoverusb's Issues

Build IDE

could you tell me which IDE you use to Build?

Detection of disconnection

We are developing a USB device which, among other interfaces, provides ethernet via NCM with the help of your great library. It works beautifully.
However, we are running into a problem where the host sometimes decides to disconnect our device. We tested with other ethernet devices as well and saw the same disconnection behavior, so our device is not at fault (or at least shares this problem with others).
We are looking for a way (possibly a callback) to detect when the host disconnects from us. Unfortunately we cannot simply check VBUS as this pin is not handled by our main processor directly. Is there any way to ask how long ago the last transaction took place? We learned that not all transactions raise interrupts, so simply resetting a timer in the isr (as I ignorantly tried) won't do.
Any help is greatly appreciated.

IPoverUSB doesn't work with Linux or Mac

On Linux ethernet usb0 device shows up, but DHCP fails to get an answer.
Similarly on Mac - device shows up, but DHCP fails to get an IP address.

Below are included relevant logs from a Fedora 32 Linux box (the pcap has .log extension since github doesn't want to allow .pcap).

This is a FreeRTOS build of IPoverUSB.

diff --git a/Makefile b/Makefile
index 4a27072..aecde89 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ XPD_DIR = STM32_XPD
USBD_DIR = USBDevice
LWIPDIR = lwIP/src
CONTRIBDIR = lwip-contrib
-OS_DIR =
+OS_DIR = FreeRTOS/FreeRTOS/Source

##++---- Included files ----++##
include $(LWIPDIR)/Filelists.mk

This is using a:
https://www.amazon.com/gp/product/B00CW9AKDY/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
[STM32F4DISCOVERY] ST STM32 STM32F4 STM32F407 MCU Discovery Evaluation Development Board kit embedded ST-LINK/V2 debugger @xyg

Best guess is Linux/Mac and the IPoverUSB device are not agreeing on USB URB (possibly MBIM) framing and thus frames don't flow successfully in either direction.

[ 0.000000] Linux version 5.8.9-200.fc32.x86_64 ([email protected]) (gcc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1), GNU ld version 2.34-4.fc32) #1 SMP Mon Sep 14 18:28:45 UTC 2020
...
[316478.147751] cdc_ncm 1-6:1.1 enp0s20f0u6i1: unregister 'cdc_ncm' usb-0000:00:14.0-6, CDC NCM
[316484.539176] usb 1-6: new full-speed USB device number 7 using xhci_hcd
[316484.666861] usb 1-6: New USB device found, idVendor=0483, idProduct=ffff, bcdDevice= 1.00
[316484.666873] usb 1-6: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[316484.666881] usb 1-6: Product: IP over USB Demonstrator
[316484.666886] usb 1-6: Manufacturer: STMicroelectronics
[316484.666891] usb 1-6: SerialNumber: 19004100
[316484.690225] cdc_ncm 1-6:1.1: MAC-Address: 00:80:e1:00:00:00
[316484.690671] cdc_ncm 1-6:1.1 usb0: register 'cdc_ncm' at usb-0000:00:14.0-6, CDC NCM, 00:80:e1:00:00:00
[316484.708297] cdc_ncm 1-6:1.1 enp0s20f0u6i1: renamed from usb0
[316552.462093] device enp0s20f0u6i1 entered promiscuous mode
[316552.463409] cdc_ncm 1-6:1.1 enp0s20f0u6i1: 10 mbit/s downlink 10 mbit/s uplink
[316552.479401] cdc_ncm 1-6:1.1 enp0s20f0u6i1: network connection: connected
[316552.479457] IPv6: ADDRCONF(NETDEV_CHANGE): enp0s20f0u6i1: link becomes ready
[316619.602751] device enp0s20f0u6i1 left promiscuous mode

ip link set enp0s20f0u6i1 up; tcpdump -s 10000 -w dump.pcap -i enp0s20f0u6i1

tcpdump -r dump.pcap

reading from file dump.pcap, link-type EN10MB (Ethernet)
dropped privs to tcpdump
17:07:47.493508 ARP, Request who-has 192.168.0.1 tell 192.168.0.1, length 28
17:07:47.495812 IP6 :: > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
17:07:47.606866 IP6 :: > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
17:07:48.438819 IP6 :: > ff02::1:ff00:0: ICMP6, neighbor solicitation, who has zeus.lan, length 32
17:07:49.462910 IP6 zeus.lan > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
17:07:49.462926 IP6 zeus.lan > ff02::2: ICMP6, router solicitation, length 16
17:07:49.958865 IP6 zeus.lan > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
17:07:53.110865 IP6 zeus.lan > ff02::2: ICMP6, router solicitation, length 16
17:08:00.726869 IP6 zeus.lan > ff02::2: ICMP6, router solicitation, length 16
17:08:15.574873 IP6 zeus.lan > ff02::2: ICMP6, router solicitation, length 16
17:08:21.490129 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:80:e1:00:00:00 (oui Unknown), length 300
17:08:27.113025 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:80:e1:00:00:00 (oui Unknown), length 300
17:08:38.358633 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:80:e1:00:00:00 (oui Unknown), length 300
17:08:46.294864 IP6 zeus.lan > ff02::2: ICMP6, router solicitation, length 16

dhclient -4 -d -v enp0s20f0u6i1

Internet Systems Consortium DHCP Client 4.4.2b1
Copyright 2004-2019 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp0s20f0u6i1/00:80:e1:00:00:00
Sending on LPF/enp0s20f0u6i1/00:80:e1:00:00:00
Sending on Socket/fallback
DHCPDISCOVER on enp0s20f0u6i1 to 255.255.255.255 port 67 interval 6 (xid=0xbb3dfe7c)
DHCPDISCOVER on enp0s20f0u6i1 to 255.255.255.255 port 67 interval 11 (xid=0xbb3dfe7c)
DHCPDISCOVER on enp0s20f0u6i1 to 255.255.255.255 port 67 interval 18 (xid=0xbb3dfe7c)
^C
dmesg.txt
dump.pcap.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.