Skip to content

Update connecting-to-the-internet-via-usb.md #306

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 94 additions & 1 deletion docs/tutorials/connecting-to-the-internet-via-usb.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,99 @@ If you are using an older version, please upgrade.

{% include /util/screenshot.html source="/images/brickman/wired-status-online-connect-automatically-selected.png" %}


* {: tab="linux_command_line"}{% include /style/icon.html type="info" %}
These instructions were written using Debian look-alikes for those wanting to know what happens under the hood.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention the exact debian version that was used for the tutorial. We should also mention that is should work for most Linux distros that don't otherwise have a network manager program (or something like that).

The commands need to be executed by root.
{:class="alert alert-info"}

1. Booting with a standard ev3dev image, lsusb will show
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not clear if lsusb should be run on the EV3 or the host computer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should give some credit to the people interested in this subject: they would not expect to see the EV3 when lsusb would be run on the EV3. Moreover, before step 12 it is not possible to enter an OS command on the EV3. But I'll try to add this to the introduction, along with Debian version etc.


`Bus 002 Device 008: ID 0694:0005 Lego Group`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using code fence. e.g.

```
Bus 002 Device 008: ID 0694:0005 Lego Group
```


I'll be using the EV3 as a USB Gadget, as follows.

2. When you've copied the ev3dev's image to the SD-card, mount the second partition (EV3DEV_ROOTFS).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this? ev3dev already sets up a gadget driver by default. Does it not work for you?

If your card is /dev/sdc, then mount /dev/sdc2 on a free directory:

`mount /dev/sdc2 /mnt/sdc2`

3. Add the "g_cdc" module to /etc/modules (which currently contains only comments):

`echo "g_cdc" >> /mnt/sdc2/etc/modules`

Unmount /dev/sdc2, put the SD-card in the EV3 and start it up.

4. Connect the USB cable to your computer and its mini-B plug to the EV3 (slot marked "PC").

5. Verify that USB tethering is disabled: *"Wireless and Networks" > "Tethering*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer no quotes on *Wireless and Networks > Tethering*

If you insist on quotes, you are missing one at the end of Tethering.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be more clear that we are now using the EV3, not the host computer.


6. Set default Linux network settings: *"Wireless and Networks" > "All Network Connections" > "Wired" >
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, prefer no quotes here

"IPv4" > "Change" > "Load Linux Defaults"*. The EV3 should get address 10.42.0.3, gateway 10.42.0.1.

7. Verify if the EV3 is recognized by your Linux PC: `lsusb` should show

`Bus 001 Device 002: ID 0525:a4aa Netchip Technology, Inc. Linux-USB CDC Composite Gadge (Ethernet and ACM)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent 4 extra spaces instead of using single backtick

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #307, we'll be able to use code fences, so let's replace this with a fence and not remove the fences in other places. Fences are much more readable than indentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fences are much more readable than indentation.

I disagree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it really doesn't make a difference in normal text, in lists I find it very hard to identify code formatting when it's space-indented. I think that code fences make it much easier to quickly identify the code in an indented list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In lists, it is still indented 4 extra spaces from the list text, so it looks exactly the same as normal text to me.

And regardless of any opinions on which is "better", the rest of the website uses indents, so I would like to stay consistent with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, indented code is a pain to edit, especially in lists.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I've changed my mind (c.f. #308).

In this pull request though, I would like to have a blank line before the start of each code fence.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In lists, it is still indented 4 extra spaces from the list text, so it looks exactly the same as normal text to me.

It's extremely difficult to differentiate between sub-bullets, indented additional lines, and code blocks; they all are indented in the same way. Using indentation for code blocks is an unnatural use of whitespace, and as a result it conflicts with all the other uses of whitespace.

And regardless of any opinions on which is "better", the rest of the website uses indents, so I would like to stay consistent with that.

argumentum ad antiquitatem. "It has always been done this way" isn't a reason to continue doing it; switching to code fences is trivial and something that I would happily put in the work for now that we have that ability.

How so?

Because you must maintain the indentation. Every line must be prepended with four spaces, so not only do you need to add the spacing before every line, but you also need to mess with indentation when copy-pasting code. This is especially difficult in GitHub's online editor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it looks like GitHub has decided not to auto-load comments on review threads 😆 Sounds good.


(Bus and Device may differ).

8. Your system should load cdc_ether to manage the EV3: check with `lsmod | grep cdc`.
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent 4 extra spaces instead of using code fence

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line above ``` please

Module Size Used by
cdc_ether 16384 0
```

9. Check dmesg to find which device has been assigned to the EV3 network: `dmesg | grep cdc`

```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent 4 extra spaces instead of using code fence

cdc_ether 1-5:1.0 usb0: register 'cdc_ether' at usb-0000:00:02.1-5, CDC Ethernet Device, d6:6a:37:7e:16:07
usbcore: registered new interface driver cdc_ether
cdc_ether 1-5:1.0 enp0s2f1u5: renamed from usb0
cdc_ether 1-5:1.0 enp0s2f1u5: kevent 12 may have been dropped
The device is enp0s2f1u5 in this case.
```

10. Assign the gateway address to the EV3 network device:

`# ifconfig enp0s2f1u5 10.42.0.1 netmask 255.255.255.0 up`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent 4 extra spaces instead of using single backtick

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code fence


11. Verify if you can ping the EV3:


```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent 4 extra spaces instead of using code fence

# ping 10.42.0.3
PING 10.42.0.3 (10.42.0.3) 56(84) bytes of data.
64 bytes from 10.42.0.3: icmp_seq=1 ttl=64 time=0.812 ms
64 bytes from 10.42.0.3: icmp_seq=2 ttl=64 time=0.685 ms
64 bytes from 10.42.0.3: icmp_seq=3 ttl=64 time=0.670 ms
^C
```

12. You have now established a network connection and you can ssh to the
EV3. If you have an internet connection which you want to make
available to your EV3, there is more that needs to be done.

13. Allow your system to forward IP traffic (given eth0 carries your
internet connection):

`# echo 1 > /proc/sys/net/ipv4/ip_forward`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code fence


(to make this permanent, add "net.ipv4.ip_forward=1" to /etc/sysctl.conf)

```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

# iptables --append FORWARD --in-interface enp0s2f1u5 -j ACCEPT
# iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
```

14. Assign a name-server (eg. google-public-dns-a) to your EV3 (you need
to be logged in on your EV3 as root):

`# echo "nameserver 8.8.8.8" > /etc/resolv.conf`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use ConnMan on the EV3 for network management. It will write over any changes made manually to /etc/resolv.conf. Instead a step should be added after step 3 that explains how to set the DNS using Brickman.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some reading about connman (does it sound like con-man?), tried in vain to get it to do what I wanted, and disabled it. Now, ev3dev nicely configures the network the way I tell it to in /etc/network/interfaces and /etc/resolv.conf.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in my previous review, ev3dev uses ConnMan for network management. It will write over /etc/resolv.conf, so I don't thing manually editing it is a good idea. Instead, I think it would be better to set the nameserver using Bricman at the same time we are setting the manual configuration above.


15. Verify if you can ping that nameserver:

`# ping 8.8.8.8`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, as in my previous review, I mentioned that it is possible to see the connection status using Brickman. It would save the steps of having to log in to the EV3 in order to complete this tutorial.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In that case we can drop steps 1 to 15.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be a step where you press the Connect button for the network connection on the EV3? When you do this, it will say "Online" on the screen, which verifies that DNS resolution is working.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite right, after selection of the "Load Linux Defaults", but possibly because of the manual interventions, the state remains "Connected", even though I can "apt-get upgrade".

* {: tab="Windows"}{% include /style/icon.html type="info" %}
These instructions were written using Windows 10, but should work on Windows
7 and 8 as well.
Expand Down Expand Up @@ -247,4 +340,4 @@ If you are using an older version, please upgrade.

Now that you have a network connection, you should
[connect to your EV3 with SSH](/docs/tutorials/connecting-to-ev3dev-with-ssh)
if you haven't done so already.
if you haven't done so already.