maemo-leste / bugtracker

Issue tracking repository
62 stars 3 forks source link

Wish: configure usb networking when cable is plugged #107

Closed pavelmachek closed 5 years ago

pavelmachek commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

MerlijnWajer commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

dderby commented 6 years ago

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 commented 6 years ago

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

dderby commented 6 years ago

@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 commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

Not sure. 1. I don't see how downing the interface would cause problems, so probably ok. 2. Yes, I guess doing usb net by default is ok.

Thanks!

MerlijnWajer commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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.