Project

General

Profile

Actions

Feature #1889

closed

Add USB Ethernet support

Added by Kurtis Hanna over 5 years ago. Updated over 4 years ago.

Status:
Resolved
Priority:
Low
Assignee:
-
Category:
Wi-Fi
Target version:
Start date:
09/01/2018
Due date:
% Done:

100%

Estimated time:
Resolution:
fixed
Device:
Grant:
Type of work:

Description

Currently Replicant devices can connect to the Internet via a USB connection to a computer that's connected to the Internet: https://redmine.replicant.us/projects/replicant/wiki/ReplicantUSBNetworking

However, Replicant devices can't connect to the Internet via a a USB Ethernet Adapter: https://redmine.replicant.us/boards/9/topics/8001

It seems as though the reason why Replicant doesn't currently work with USB Ethernet Adapters is due to the fact that upstream LineageOS disables kernel module support for security reasons. https://www.reddit.com/r/LineageOS/comments/5xrapo/ethernet_on_lineage/ https://redmine.replicant.us/boards/9/topics/8001?r=8031#message-8031

It seems like Android 6 does support this type of feature: https://www.youtube.com/watch?v=uisnj8Xufp0

I'm not sure if this is helpful, but I figured I'd add this link to LineageOS' source code as well: https://git.replicant.us/LineageOS-mirror/android_frameworks_opt_net_ethernet/log/?h=cm-13.0

Would it be a security issue to add this functionality to all Replicant devices by enabling kernel module support to get ethernet working, as the LineageOS dev suggested on the reddit post?

Replicant 6 currently supports 3 "Wi-Fi only" tablets. Without mobile data or the ability to use the internal Wi-Fi card with software freedom, users must choose between reverse tethering their Replicant device to a computer that is on the internet or buying an external USB Wi-Fi dongle and using RepWifi. It'd be great to offer another option.

Lastly, I couldn't find a Category for this issue that made sense. Please feel free to create an "Other" category in redmine or move this issue to a Category that makes more sense.


Files

IMG_20191010_164533.jpg (2.7 MB) IMG_20191010_164533.jpg ariel enter, 10/10/2019 10:58 PM
Screenshot_2019-10-10-15-11-36.png (133 KB) Screenshot_2019-10-10-15-11-36.png ariel enter, 10/10/2019 10:58 PM
IMG_20191015_150302.jpg (2.44 MB) IMG_20191015_150302.jpg ariel enter, 10/15/2019 09:12 PM

Related issues

Blocks Replicant - Issue #1960: Build release candidate image for 6.0 0004Closed10/09/2019

Actions
Actions #1

Updated by Denis 'GNUtoo' Carikli over 5 years ago

Hi,

As I understand the best way to solve this bug would be to simply compile in the kernel image, all USB Ethernet adapters drivers. This should be trivial to do.

It would be better to have them as modules (as it would use less RAM and would carry less risk of making the kernel image too big for the boot partition) but as far as I know we have no good enough module loading mechanism in Android 6.x to do that.

Actions #2

Updated by Kurtis Hanna about 5 years ago

I'd love to research this issue more. Does anyone have any links to articles or documentation or code about this? I would really like to be able to connect my phone to my ethernet cable if it is a somewhat trival thing to make happen in software.

Actions #3

Updated by Denis 'GNUtoo' Carikli about 5 years ago

The following might work:
  • Start to work on it for a device that you can easily test on
  • try to build an image and test it
  • go in your kernel source code and run:
    export ARCH=arm
    make xconfig # select the drivers you want to add, like the asix driver
    make savedefconfig
    

    Then copy the generated defconfig in the place of your kenrel default configuration

For the Galaxy S3 4G, in device/samsung/i9305/BoardConfig.mk we have:

# Kernel
TARGET_KERNEL_SOURCE := kernel/samsung/smdk4412
TARGET_KERNEL_CONFIG := lineageos_i9305_defconfig

You can then go in kernel/samsung/smdk4412 and you have arch/arm/configs/lineageos_i9305_defconfig
You can then run the following to change the kernel configuration:

export ARCH=arm
make lineageos_i9305_defconfig
make xconfig # select the drivers you want to add, like the asix driver
make savedefconfig
cp defconfig arch/arm/configs/lineageos_i9305_defconfig

However if you do that, the Android build system might complain that your kernel source tree is dirty, so you can remove the binaries changes with the following:

make clean
make mrproper
make distclean

This is because running "make xconfig" will compile the graphical utility that enables you to change the kernel configuration.

Alternatively you can just clone the kernel again outside of the Replicant tree and do that there, and copy the resulting defconfig in Replicant source tree.

Once it's cleaned you can re-launch a build as usual, sign the build and install it as usual.

While this takes more time and it not very convenient it's way safer than flashing the boot.img.

If you do still attempt to flash the boot.img make sure to double check that you are not flashing the kernel in the bootloader partition, otherwise your may break your device if you do that.

This mistake is not that far fetched: On some devices like the Galaxy SII, the PIT partition named BOOT is the bootloader, while on many other devices it's the boot.img

Actions #4

Updated by Denis 'GNUtoo' Carikli about 5 years ago

  • Target version changed from Replicant 6.0 0005 to Replicant 6.0 0004
Actions #5

Updated by Denis 'GNUtoo' Carikli almost 5 years ago

I've tested an adapter compatible with the asix driver with the Galaxy Nexus.

On my desktop, lsusb shows the following:

$ sudo lsusb -d 0b95:1720  -vvvv

Bus 001 Device 016: ID 0b95:1720 ASIX Electronics Corp. 10/100 Ethernet
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0b95 ASIX Electronics Corp.
  idProduct          0x1720 10/100 Ethernet
  bcdDevice            0.01
  iManufacturer           1 USB
  iProduct                2 USB2.0 10/100 Ethernet Adapter
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0027
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              300mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass         0 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              11
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

This shows that it should consume 300mA maximum.

The Galaxy Nexus should be able to provide 500mA on the USB port according to the kernel source code

However when I tried it, in dmesg we can see the following error:

asix 1-1:1.0: (unregistered net_device): Failed to enable software MII access

The interface also was not there in /sys/class/net

Actions #6

Updated by Denis 'GNUtoo' Carikli almost 5 years ago

On the Galaxy Nexus, after retrying after a power off and power on I got a "<->" icon in the top bar. This is the icon for ethernet. I can then update repositories with f-droid.

Actions #7

Updated by Denis 'GNUtoo' Carikli almost 5 years ago

I've sent patches to the mailing list for the Galaxy Nexus, that I could then reliability test. It didn't work the first time but it worked all the subsequent times reliabily.

I've patches for the Galaxy SII too, but I need to go buy a new battery as on the second hand ones I have just doing 'dmesg' in the terminal application makes the touchkey leds flicker. This is probably because it refresh the display and consume more power and that such old battery can't stand the current draw.

I've pushed the patches in the following repositories:

The ethernet/replicant-6.0-dev branch in my manifest can also be used to test the patches.

Actions #8

Updated by Denis 'GNUtoo' Carikli almost 5 years ago

  • Status changed from New to In Progress
Actions #9

Updated by Kurtis Hanna over 4 years ago

I believe that once we have support for the N7100, N51XX, and espresso10 devices we can close this ticket.

Actions #10

Updated by Joonas Kylmälä over 4 years ago

I suggest to skip this feature for the 0004 release.

Actions #11

Updated by Kurtis Hanna over 4 years ago

  • Blocks Issue #1960: Build release candidate image for 6.0 0004 added
Actions #12

Updated by Kurtis Hanna over 4 years ago

We need someone to test some Roms that GNUtoo built for the espresso devices in order to close this issue. The Roms can be downloaded here: https://replicant.cyberdimension.org/ethernet-test-0001/

The espressowifi Roms work on:
Galaxy Tab 2 7.0 Wi-Fi (P3110)
Galaxy Tab 2 10.1 Wi-Fi (P5110)

The espresso3g Roms work on:
Galaxy Tab 2 7.0 (P3100)
Galaxy Tab 2 10.1 (P5100)

If you need GNUtoo's GPG key to verify the images, you can find it here: https://redmine.replicant.us/projects/replicant/wiki/People#Denis-GNUtoo-Carikli

We mainly just want to know that the devices boot up, so this will be really easy to test.

Actions #13

Updated by Kurtis Hanna over 4 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 0 to 90
Actions #14

Updated by ariel enter over 4 years ago

I just test the ROM, and it boot and works correctly. My device seems to be GT-P3113 so I installed the espressowifi ROM and as I said it worked.

Can I keep using that version of the ROM? or should I get back to the regular Replicant ROM?

I might have a USB Ethernet around, should I test it? is there something special that I would have to do after connecting it? I'm guessing that only asix driver compatible devices will work?

I was very happy to help. Thank you for considering me C:

EDITH: Sorry, I let my self carry a way. You probably already know USB Ethernet works fine. I just got really excited to help. Once again thank you. I think I'll be going to libre planet this year. I'm from Mexico BTW.

Actions #15

Updated by ariel enter over 4 years ago

OK, my mistake. I used Tap 2 7.0 instead of the 10.1 one. Luckily I have both do you guys need me to test it on 10.1 too?

Actions #16

Updated by Kurtis Hanna over 4 years ago

Hello Ariel,

Thanks so much for providing this testing and feedback! You're welcome to keep using that Rom, but we will have an official testing version of Replicant 6.0 0004 ready in a few days that will include a number of fixes and updates that this Rom does not have. If you could test the 10.1 Rom as well on your device that'd be spectacular! Please feel free to test out the USB Ethernet adapter on both devices as well if you have one. Asix driver compatible devices are the most likely to work. You might need to restart the device to get the ethernet adapter to turn on. We might be at LibrePlanet this upcoming year as well. It'd be great to meet up!

Cordially,
Kurtis

Actions #17

Updated by ariel enter over 4 years ago

Sorry for the delay, I just tested on the Tap 2 10.1 and it works!!! It's also a espressowifi since it doesn't seem to have a ship socket. Any way I used espressowifi and it work.

Now time to look at the libre planet schedule and tickets. It will be my first and probably last time I'll ever go. I'm sure it will be a unforgettable life time experience C:

See you soon.

Actions #18

Updated by Kurtis Hanna over 4 years ago

Thanks for the update, Ariel! This is very helpful! Looking forward to seeing you at LibrePlanet!

Actions #19

Updated by Kurtis Hanna over 4 years ago

  • Status changed from Feedback to Resolved
  • % Done changed from 90 to 100
  • Resolution set to fixed

All of the ethernet patches have been pushed so I'm closing this ticket and marking it as fixed.

Actions

Also available in: Atom PDF