Ethernet Beaglebone

85 views
Skip to first unread message

Marco

unread,
Feb 20, 2015, 12:25:31 PM2/20/15
to nerves-...@googlegroups.com
Hi
I wrote a simple echo server in Elixir, without adding external libraries, I compiled it with Nerves-sdk and I loaded it on sd card using mmccopy. When I try to connect to the server via telnet to BeagleBone, I can not find the host. The program works on BeagleBone (I verified that works by connecting the PC with the bbb via FTDI cable), but I can not be interfaced to it. Have you any suggestions? I have to use external libraries or is it just a matter of configuring the buildroot (i used nerves_bbb_defconfig)?

Thanks

Frank Hunleth

unread,
Feb 20, 2015, 1:01:12 PM2/20/15
to nerves-...@googlegroups.com
Hi Marco,
Have you brought up the Ethernet interface on the BeagleBone? Nerves
leaves the BeagleBone in a pretty barebones state by default. Maybe
try running this on the BeagleBone through the FTDI cable:

os:cmd("/sbin/ip link set eth0 up").
os:cmd("/sbin/ip addr add 192.168.1.40/24 dev eth0").
os:cmd("/sbin/ip route add default via 192.168.1.1").

(or translate to :os.cmd or System.cmd if you're running the Elixir shell)

If that fixes things, then I'd add those lines to your program. A
while ago, I started writing a library to make this a little easier. I
haven't been using it much lately, but it might be useful. See
https://github.com/fhunleth/net_basic.ex.

Frank

>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "nerves-project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nerves-projec...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Frank Hunleth
Troodon Software LLC
Embedded Software Development
http://troodon-software.com/

Marco

unread,
Feb 21, 2015, 1:03:12 PM2/21/15
to nerves-...@googlegroups.com
Hi frank

When I write in iex commands via ftdi

System.cmd ("/ sbin / ip link set eth0 up")
System.cmd ("/ sbin / ip addr add 192.168.1.40/24 dev eth0")
System.cmd ("/ sbin / ip route add default via 192.168.1.1")

I get this error

** (UndefinedFunctionError) undefined function: System.cmd / 1
     (elixir) System.cmd ("/ sbin / ip link set eth0 up")


Frank Hunleth

unread,
Feb 21, 2015, 1:23:44 PM2/21/15
to nerves-...@googlegroups.com
Hi Marco,

On Sat, Feb 21, 2015 at 1:03 PM, Marco <fantaca...@gmail.com> wrote:
> Hi frank
>
> When I write in iex commands via ftdi
>
> System.cmd ("/ sbin / ip link set eth0 up")
> System.cmd ("/ sbin / ip addr add 192.168.1.40/24 dev eth0")
> System.cmd ("/ sbin / ip route add default via 192.168.1.1")

System.cmd takes two or three arguments. See
http://elixir-lang.org/docs/stable/elixir/System.html#cmd/3. Try this:

System.cmd("/sbin/ip", ["link", "set", "eth0", "up"])
System.cmd("/sbin/ip", ["addr", "add", "192.168.1.40/24", "dev", "eth0"])
System.cmd("/sbin/ip", ["route", "add", "default", "via", "192.168.1.1"])

I didn't test this, so double check when you enter it in that I didn't
make a typo. I personally prefer Elixir System.cmd in my programs, but
I think that :os.cmd is simpler to use at the shell prompt. I.e.,
:os.cmd('/sbin/ip link set eth0 up')

Frank

>
> I get this error
>
> ** (UndefinedFunctionError) undefined function: System.cmd / 1
> (elixir) System.cmd ("/ sbin / ip link set eth0 up")
>

Marco

unread,
Feb 22, 2015, 5:00:09 AM2/22/15
to nerves-...@googlegroups.com
Hi frank

I tried with :os.cmd and I got different results both on BeagleBone either via telnet.

When I am writing on iex, I get this error

iex (demo @ nerves) 1>:os.cmd ('/sbin/ip link set eth0 up')
libphy: PHY 4a101000.mdio: 01 not found
net eth0: phy 4a101000.mdio: 01 not found on slave 1
[]

If I rewrite the command, the error no longer appears

iex (demo @ nerves) 2>:os.cmd ('/sbin/ip link set eth0 up')
[]
iex (demo @ nerves) 3>:os.cmd ('/sbin/ip addr add 192.168.1.40/24 dev eth0')
[]
iex (demo @ nerves) 4>:os.cmd ('/sbin/ip route add default via 192.168.1.254')
[]

When I write another terminal before you enter commands in shell iex

marco @ ubuntu: ~ $ telnet 192.168.1.40
Trying 192.168.1.40 ...
telnet: Unable to connect to remote host: No route to host

after the commands

marco @ ubuntu: ~ $ telnet 192.168.1.40
Trying 192.168.1.40 ...
telnet: Unable to connect to remote host: Connection refused

Frank Hunleth

unread,
Feb 22, 2015, 9:41:02 AM2/22/15
to nerves-...@googlegroups.com
On Sun, Feb 22, 2015 at 5:00 AM, Marco <fantaca...@gmail.com> wrote:
> Hi frank
>
> I tried with :os.cmd and I got different results both on BeagleBone either
> via telnet.
>
> When I am writing on iex, I get this error
>
> iex (demo @ nerves) 1>:os.cmd ('/sbin/ip link set eth0 up')
> libphy: PHY 4a101000.mdio: 01 not found
> net eth0: phy 4a101000.mdio: 01 not found on slave 1

The libphy and net eth0 messages come from the Linux kernel. You're
seeing them since kernel messages get printed on the serial port by
default. Those two messages are expected on the BBB. The AM3358 chip
on the BBB supports two Ethernet interfaces, but only one is hooked
up. The "00" ethernet interface was found, but the second one "01"
isn't.

> []
>
> If I rewrite the command, the error no longer appears

This is because the ethernet interface has been initialized by the
kernel. You shouldn't see the kernel messages again unless you reboot.

>
> iex (demo @ nerves) 2>:os.cmd ('/sbin/ip link set eth0 up')
> []
> iex (demo @ nerves) 3>:os.cmd ('/sbin/ip addr add 192.168.1.40/24 dev eth0')
> []
> iex (demo @ nerves) 4>:os.cmd ('/sbin/ip route add default via
> 192.168.1.254')
> []
>
> When I write another terminal before you enter commands in shell iex
>
> marco @ ubuntu: ~ $ telnet 192.168.1.40
> Trying 192.168.1.40 ...
> telnet: Unable to connect to remote host: No route to host
>
> after the commands
>
> marco @ ubuntu: ~ $ telnet 192.168.1.40
> Trying 192.168.1.40 ...
> telnet: Unable to connect to remote host: Connection refused

This is good. When the BBB's Ethernet interface was down, you should
get "No route to host" which is what you did. The "Connection refused"
is telling you that the BBB refused the TCP connection trying to
establish a telnet session. That means the Ethernet interface is up
and working, but since there's no telnet server running on the BBB, it
won't connect. Ping should work at this point too.

In a previous email, you said something about an echo server that you
wrote. You should be able to connect to that now if it's running.
Also, I'd recommend using the nc utility (netcat) for making TCP
connections. Telnet sends control characters and can make things
confusing. (See the DO/DONT, WILL/WONT part of RFC 854.)

Frank

Marco

unread,
Feb 22, 2015, 10:57:14 AM2/22/15
to nerves-...@googlegroups.com
Hi frank

I tried to connect with netcat and it works.
Thank you very much. :)

Reply all
Reply to author
Forward
0 new messages