Add networking stack from TinyUSB. #334

Open
luigifcruz wants to merge 2 commits from luigifcruz/patch-piccolosdr into develop
luigifcruz commented 2021-04-11 20:01:09 -05:00 (Migrated from github.com)

I'm not sure if this is a path the maintainers want to pursue. But I added a tinyusb_net target on CMakeLists to import the necessary headers and files to make it possible to use the Pico as a network device based on the RNDIS example from TinyUSB.

As of now, I use these patches to build my PiccoloSDR project without known problems.

I'm not sure if this is a path the maintainers want to pursue. But I added a `tinyusb_net` target on CMakeLists to import the necessary headers and files to make it possible to use the Pico as a network device based on the RNDIS [example](https://github.com/hathach/tinyusb/tree/master/examples/device/net_lwip_webserver) from TinyUSB. As of now, I use these patches to build my PiccoloSDR [project](https://github.com/luigifcruz/pico-stuff) without known problems.
kilograham (Migrated from github.com) requested changes 2021-05-31 12:15:07 -05:00
kilograham (Migrated from github.com) left a comment

might be useful; not sure why some things are on tinyusb_common, and some on tinyusb_host and none on tinyusb_net!

might be useful; not sure why some things are on tinyusb_common, and some on tinyusb_host and none on tinyusb_net!
luigifcruz commented 2023-01-24 23:56:42 -06:00 (Migrated from github.com)

Rebased to the latest branch. :)

Rebased to the latest branch. :)
kilograham (Migrated from github.com) requested changes 2023-02-09 15:51:48 -06:00
kilograham (Migrated from github.com) commented 2021-10-04 13:08:39 -05:00

presumably you meant tinyusb_net here

presumably you meant tinyusb_net here
peterharperuk commented 2023-03-15 15:23:58 -05:00 (Migrated from github.com)

I've been playing around with the rndis stuff in tiny usb. I can't really see the point of running a dhcp server on the device. What would you use this for?

It would be nicer if dhcp could somehow obtain an address for the pico and use that as a network to get access to the internet. But I can't really get network sharing to work reliably. It looks like it sort of works on Windows if you're lucky. I'm not sure I can get it to work at all on Ubuntu.

Unless this is easy to use, I can't really see this being worth it?

I've been playing around with the rndis stuff in tiny usb. I can't really see the point of running a dhcp server on the device. What would you use this for? It would be nicer if dhcp could somehow obtain an address for the pico and use that as a network to get access to the internet. But I can't really get network sharing to work reliably. It looks like it sort of works on Windows if you're lucky. I'm not sure I can get it to work at all on Ubuntu. Unless this is easy to use, I can't really see this being worth it?
luigifcruz commented 2023-03-15 15:45:08 -05:00 (Migrated from github.com)

I mean, this is not the easiest way to get data out of the Pico. But, unfortunately, it's the only way to do it with a decent speed without extra hardware. I can get a stable 5 Mbps running an iperf3 server on the Pico using the TinyUSB interface. This enables projects like my PiccoloSDR that require large amounts of data to be transferred to the computer. I also can think about a few projects that would require the bandwidth offered by this stack. For example, digital signal analyzer using the PIO, digital oscilloscope, high-sampling rate sensors, etc.

Regarding compatibility, the current version of the PiccoloSDR, which uses this PR, works very well with Linux and macOS (including Apple Silicon). You plug it in, an IP is automatically assigned, and you can access it with zero configuration. I never tested this on Windows, but looks like Microsoft added support to USB NCM on Windows 11. This theoretically solves support for Windows.

While developing PiccoloSDR, a major hurdle was patching the SDK to give me the right headers and binaries. The actual development of the network application was trivial. This PR comes at almost zero cost for those who don't use this feature while significantly facilitating the development process of network apps for those who need it.

I mean, this is not the easiest way to get data out of the Pico. But, unfortunately, it's the only way to do it with a decent speed without extra hardware. I can get a stable 5 Mbps running an `iperf3` server on the Pico using the TinyUSB interface. This enables projects like my [PiccoloSDR](https://hackaday.com/2021/03/16/the-raspberry-pi-pico-as-an-sdr-receiver/) that require large amounts of data to be transferred to the computer. I also can think about a few projects that would require the bandwidth offered by this stack. For example, digital signal analyzer using the PIO, digital oscilloscope, high-sampling rate sensors, etc. Regarding compatibility, the current version of the PiccoloSDR, which uses this PR, works very well with Linux and macOS (including Apple Silicon). You plug it in, an IP is automatically assigned, and you can access it with zero configuration. I never tested this on Windows, but looks like [Microsoft added support](https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/supported-usb-classes) to USB NCM on Windows 11. This theoretically solves support for Windows. While developing PiccoloSDR, a major hurdle was patching the SDK to give me the right headers and binaries. The actual development of the network application was trivial. This PR comes at almost zero cost for those who don't use this feature while significantly facilitating the development process of network apps for those who need it.
kilograham commented 2023-03-15 16:33:28 -05:00 (Migrated from github.com)

i'm just confused by the PR in general; why are existing libraries being modified; can you just not add a new "tinyusb_net library"?

i'm just confused by the PR in general; why are existing libraries being modified; can you just not add a new "tinyusb_net library"?
peterharperuk commented 2023-03-16 05:08:55 -05:00 (Migrated from github.com)

can you just not add a new "tinyusb_net library"?

I guess you could, but tiny usb already seems to pile everything into tinyusb_device_base? What's more confusing is that this doesn't live in the pico-sdk anymore.

We're missing networking/rndis_reports.c and the include folder lib/networking, which are easy enough to add to your own project.

I'm more interested in knowing if we can use this for real.

> can you just not add a new "tinyusb_net library"? I guess you could, but tiny usb already seems to pile everything into tinyusb_device_base? What's more confusing is that this doesn't live in the pico-sdk anymore. We're missing networking/rndis_reports.c and the include folder lib/networking, which are easy enough to add to your own project. I'm more interested in knowing if we can use this for real.
peterharperuk commented 2023-03-16 05:23:38 -05:00 (Migrated from github.com)

@luigifcruz Sorry, I missed your comment. So your use case is just to connect two computers and communicate with IP stacks. The IP address comes from the Pico - effectively a small private network.

@luigifcruz Sorry, I missed your comment. So your use case is just to connect two computers and communicate with IP stacks. The IP address comes from the Pico - effectively a small private network.
mordae commented 2023-03-18 06:46:31 -05:00 (Migrated from github.com)

I am trying to build a subsampling receiver, learning as I go, and to my surprise the excellent demo from luigifcruz wouldn't work with stock SDK. 😅

Now seriously, using UDP to stream data over USB is a decent idea and with DHCP server it works out-of-box. I believe that USB tethering on Android works like that as well. It saves you the hassle of configuring network interfaces manually or writing specific device drivers.

I can imagine using it like that in a classroom setting.

(Sorry for butting in just to +1.)

I am trying to build a subsampling receiver, learning as I go, and to my surprise the excellent demo from luigifcruz wouldn't work with stock SDK. :sweat_smile: Now seriously, using UDP to stream data over USB is a decent idea and with DHCP server it works out-of-box. I believe that USB tethering on Android works like that as well. It saves you the hassle of configuring network interfaces manually or writing specific device drivers. I can imagine using it like that in a classroom setting. (Sorry for butting in just to +1.)
peterharperuk commented 2023-03-23 09:52:13 -05:00 (Migrated from github.com)

@luigifcruz @mordae Did you test by connecting to Windows or a Linux PC? I still don't seem to get an IP address when connecting to Linux.

@luigifcruz @mordae Did you test by connecting to Windows or a Linux PC? I still don't seem to get an IP address when connecting to Linux.
peterharperuk commented 2023-03-23 09:57:52 -05:00 (Migrated from github.com)

@luigifcruz @mordae Did you test by connecting to Windows or a Linux PC? I still don't seem to get an IP address when connecting to Linux.

Ignore me - I had a static IP address assigned. It worked ok after I removed this.

> @luigifcruz @mordae Did you test by connecting to Windows or a Linux PC? I still don't seem to get an IP address when connecting to Linux. Ignore me - I had a static IP address assigned. It worked ok after I removed this.
This pull request has changes conflicting with the target branch.
  • src/rp2_common/tinyusb/CMakeLists.txt
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'luigifcruz/patch-piccolosdr:luigifcruz/patch-piccolosdr'
git switch 'luigifcruz/patch-piccolosdr'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'develop'
git merge --no-ff 'luigifcruz/patch-piccolosdr'
git switch 'luigifcruz/patch-piccolosdr'
git rebase 'develop'
git switch 'develop'
git merge --ff-only 'luigifcruz/patch-piccolosdr'
git switch 'luigifcruz/patch-piccolosdr'
git rebase 'develop'
git switch 'develop'
git merge --no-ff 'luigifcruz/patch-piccolosdr'
git switch 'develop'
git merge --squash 'luigifcruz/patch-piccolosdr'
git switch 'develop'
git merge --ff-only 'luigifcruz/patch-piccolosdr'
git switch 'develop'
git merge 'luigifcruz/patch-piccolosdr'
git push origin 'develop'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!334
No description provided.