Skip to content
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

Wish: configure usb networking when cable is plugged #107

Closed
pavelmachek opened this issue Mar 29, 2018 · 20 comments
Closed

Wish: configure usb networking when cable is plugged #107

pavelmachek opened this issue Mar 29, 2018 · 20 comments

Comments

@pavelmachek
Copy link

I created simple script to do configure usb0 networking, but I still need to launch it manually. It would be nicer to configure it by default.

@dderby
Copy link
Member

dderby commented Mar 29, 2018

I'll pick this one up. I've already got something similar set up on the N950 (WIP) so it will be easy enough to add this to the N900 and Droid 4.

@freemangordon
Copy link

what about https://github.com/maemo-leste/libicd-network-usb?

@MerlijnWajer
Copy link
Member

In #39 I made a start with usb networking and mass storage using libgadget / gadgetfs. It is close to done, I just need to work on the gtk integration, and I was running into musb bugs at the time. I think they should be fixed now. So maybe libicd-network-usb can be used in combination with loading usbnet by default with gadgetfs.

@dderby
Copy link
Member

dderby commented Mar 29, 2018

I enabled the g_ether gadget in my kernel config and then set up usb0 in /etc/network/interfaces. If you've nearly got libicd-network-usb working with hildon-status-bar-usb, that would be better than my method so I'll leave it to you to finish off.

@MerlijnWajer
Copy link
Member

I think it would be useful to share what you have in /etc/network/interfaces for usb networking. It might take a few more days for me to get this ready.

@dderby
Copy link
Member

dderby commented Mar 29, 2018

Sure. This is what I add to /etc/network/interfaces:

allow-hotplug usb0
iface usb0 inet static
        address 192.168.2.15
        netmask 255.255.255.0
        gateway 192.168.2.14

Then on my PC I run:

# ifconfig usb0 up 192.168.2.14
# iptables -A POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE

I can put this in a pull request if you like.

@parazyd
Copy link
Member

parazyd commented Mar 31, 2018

@dderby If it's not going to break existing network functionality, then please make a patch :)

@dderby
Copy link
Member

dderby commented Apr 1, 2018

Will do. I tested it on the Droid 4 with the default kernel and usb0 didn't come up. I think it's probably the kernel config. I'll check the N900 too and submit a patch once it's all working.

@freemangordon
Copy link

@dderby - sorry, I don;t get it - which package are you going to patch?

@dderby
Copy link
Member

dderby commented Apr 1, 2018

@freemangordon, as this is a temporary fix (until @MerlijnWajer finishes off the other stuff) and we don't yet have the leste-devel package, I was just going to add this to the root overlay in https://github.com/parazyd/arm-sdk/ where we already have /etc/network/interface files pulled into the build for N900 and Droid 4.

@MerlijnWajer
Copy link
Member

MerlijnWajer commented Apr 2, 2018

So the way it will work in the future is like this:

What will need to be figured out is how to create the gadget by default.

For other types of debugging, just enable g_nokia as built in, then you will not need to create usb gadget. But it will also not be possible (afaict) to create other gadgets.

@ADIX7
Copy link

ADIX7 commented Aug 11, 2018

Will there be any option to configure gadgets manually? On PiZero people can create gadget as they wish like this: http://isticktoit.net/?p=1383

I usually create a script and run in rc.local

@MerlijnWajer
Copy link
Member

We could either have a mechanism to have various custom gadgets, or just allow a 'custom' gadget setting that allows people to run whatever script they want.

@ADIX7
Copy link

ADIX7 commented Aug 11, 2018

The custom gadget setting would be great. Users can have their own settings files, flags etc, eg. my config has several script files in several folder. It's also easier to backup and copy to other devices like a PiZero.
A connected and disconnect event would be nice too.

@MerlijnWajer
Copy link
Member

FYI I'm planning to fix this by having ke-recv just always/autoconfigure usbnet, and ignore mass storage for the alpha. Then we should have usbnet working decently.

Unless we want this way earlier in the boot process, this should be fine?

@MerlijnWajer
Copy link
Member

@pavelmachek - few questions, since I want to wrap this up for the alpha:

  1. Is it OK if the interface is brought down once cable is disconnected, or would this interfere with debugging?
  2. Shall I (for now) just always configure usb networking by default on plug, rather than just charge (fremantle default)

Alternatively I can just probe the usb networking module on boot in some script, but since I'm working on ke-recv anyway ... if the above two are fine, I will make it work with ke-recv.

@pavelmachek
Copy link
Author

pavelmachek commented Sep 16, 2018 via email

@MerlijnWajer
Copy link
Member

MerlijnWajer commented Sep 17, 2018

Once the following steps are done, this can be closed:

  1. Replace/fix/update ke-recv scripts with gadgetfs binaries
  2. Fix hildon-status-bar-usb status-checks (is mass-storage-in-use etc) with more sensible checks
  3. Package gadget(fs) binaries (gadget-clear, gadget-mass-internal, gadget-network)
  4. Clean up gadget code
  5. Make ke-recv enter gadget-network ('pcsuite') mode by default rather than 'charging only'.
  6. Ensure that configfs and usb_f_mass_storage (or similar) is probed in ke-recv init script
  7. Respect /etc/default/usbnetwork (like Fremantle does) (skipped for now)
  8. Fix ke-recv init script so that dsme doesn't decide to reboot whenever it starts
  9. Build ke-recv (and gadgets?) in jenkins
  10. Test in new image

Optional, but nice to do:

  1. Add support for droid4, lime2 and a33 tablet. Should just be a couple of defs: https://github.com/maemo-leste/ke-recv/blob/nextgen-usbhack/src/udev-helper.c#L71

EDIT: This was a note to self mostly

@MerlijnWajer
Copy link
Member

ke-recv is in the repo now (as well as hildon-status-bar-usb and hildon-usb-gadgets). I am still in the process of testing it a bit more, but I think apt install ke-recv should just work on the N900 at this point. It will set up static network without using it as gateway or doing any forwarding. I use it for ssh access only currently.

@MerlijnWajer
Copy link
Member

I will close this issue as it should work now, and make new issues for the open issues that are not particularly relevant for the alpha. LMK if just the static config and not as default gw was not what you wanted.

BTW: This should work before X is even started, so you can log in and do things while powervr is starting for a few minutes.

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

No branches or pull requests

6 participants