Beaglebone

From 太極
Revision as of 20:55, 23 June 2019 by Brb (talk | contribs)
Jump to navigation Jump to search

Official website

Basic

BeagleboneCup.jpg Beaglebone-specs.png

elinux

Books

http://elinux.org/Beagleboard:BeagleBoneBlack#Books

Blog, Resource

The meaning of LEDs in BBB board

  1. USR0 is configured at boot to blink in a heartbeat pattern
  2. USR1 is configured at boot to light during microSD card accesses
  3. USR2 is configured at boot to light during CPU activity
  4. USR3 is configured at boot to light during eMMC accesses

BlackUSR.png

Derek Molloy

A series of Youtube videos to introduce Beaglebone. The source code of Video #9 can be downloaded from original website.

  • Video #1 introduction to beaglebone
  • Video #2 C/C++ Programming
  • Video #3 GPIO programming on ARM
  • Video #4 I2C
  • Video #5 USB Wifi & Build Kernel
  • Video #6 Stepper motor
  • Video #7 LCD touchscreen
  • Video #8 Qt Creator
  • Video #9 Example of Qt; shows an application using GPIO + Qt. Video at 1:55 shows how GPIO pins were used for both LCD and LEDs.
  • Video #10 OpenCV
  • Video #11 introduction to GPIO
  • Video #12 Streaming video
  • Video #13 Windows USB network
  • Video #14 JRE, Eclipse

Paul McWhorter

https://www.youtube.com/watch?v=UMEUo6Wm6u4&list=PLGs0VKk2DiYyThNvj6VyDFmOnQ8ncXk8b 17 Lessons.

Google Group

https://groups.google.com/forum/#!forum/beagleboard

Linux, u-boot, kernel and kernel module sources

Debian

Download from http://beagleboard.org/latest-images. Username: debian. Password: temppwd. This distribution contains graphical desktop environment.

  • the source code is hosted in github
  • to rebuild the image, follow the instruction at elinux.org
  • to install the unstable release, check out elinux.org

BbbDebian.png

The Debian version can be found by (version 7 has a codename wheezy)

debian@beaglebone:~$ cat /etc/debian_version 
7.4

microSD version

It is not necessary but if we want first erase the microSD card, we can issue the following. See this page and wiki page for more dd command examples.

sudo fdisk -l    # determine the device id
export DISK=/dev/mmcblk0
sudo dd if=/dev/zero of=${DISK} bs=1024 count=1024

It is enough to just run the following

xz -d bone-debian-7.4-2014-03-04-2gb.img.xz # Or use Nautilus(file manager) to extract 
sudo dd bs=1M if=bone-debian-7.4-2014-03-04-2gb.img of=/dev/sdc
sudo sync

Hold the 'boot' button close to microSD card and apply power in order to boot from micro SD.

Note that I can add the 'time' command to see how long it takes to run the 'dd' command.

$ time sudo dd bs=4M if=bone-debian-7.5-2014-05-14-2gb.img of=/dev/sdc
425+0 records in
425+0 records out
1782579200 bytes (1.8 GB) copied, 1694.59 s, 1.1 MB/s

real	28m14.624s
user	0m0.012s
sys	0m1.264s

Something interesting about the timing is if I run the dd command again using a different img file or bs parameter, the speed is fast. It only takes 1m50s instead of 30m.

The partition table from gparted looks like

MicroSD BBB.png

The contents of each partitions look like

brb@brb-P45T-A:~/Downloads$ ls /media/BEAGLE_BONE/
App              debug    dtbs         MLO         scripts    u-boot.img
autorun.inf      Docs     initrd.img   README.htm  SOC.sh     uEnv.txt
BASIC_START.htm  Drivers  LICENSE.txt  README.md   START.htm  zImage
brb@brb-P45T-A:~/Downloads$ ls /media/rootfs/
bin   dev  home  lost+found  mnt  proc  run   selinux  sys  usr
boot  etc  lib   media       opt  root  sbin  srv      tmp  var

emmc version

sudo dd bs=1M if=BBB-eMMC-flasher-debian-7.4-2014-03-04-2gb.img of=/dev/sdc
sudo sync

Doing more in LXDE

Launch a terminal in LXDE by the keyboard shortcut Ctrl+Alt+t

Check out this and this posts. In summary,

Add the following lines to the <keyboard> section,

<!-- Launch LXTerminal with Ctrl+Alt+t-->
    <keybind key="C-A-t">
      <action name="Execute">
        <command>lxterminal</command>
      </action>
    </keybind>

to ~/.config/openbox/lxde-rc.xml. Then reboot.

Problem: if I type ifconfig, it will show bash: ifconfig: command not found. However, if I click on the terminal icon on the desktop, there is no this problem:(

Virtual keyboard

On my small lcd screen (480x272), matchbox is better than florence.

matchbox

sudo apt-get install matchbox-keyboard

The matchbox keyboard can only be launched via command line matchbox-keyboard. It is not in Accessories nor Universal Access.

florence

sudo apt-get update
sudo apt-get install florence

The florence keyboard can be accessed by LXDE Menu -> Universal Access -> Florence Virtual Keyboard.

The keyboard can be resized, make a change of color, et al. See

Maximize the terminal screen all the time

Modify the file ~/.config/openbox/lxde-rc.xml by adding (in the block of <applications>)

  <application name="lxterminal"> 
    <maximized>true</maximized> 
  </application> 

Then reboot or ran openbox --reconfigure after making the change. It works.

Change/Shorten the prompt

When I use the hdmi cape, the screen is too small so it makes to change/shorten the default prompt. My preferred setting is to use

PS1='$ ' 

. But if I want to change the setting permanently, I modify ~/.bashrc file and change two lines about PS1 by removing @\h, @u, and \w characters.

[if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[\033[00m\]:\[\033[01;34m\]\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\$ '
fi

See this post.

Root terminal

  • To enable the root account, type sudo passwd root
  • To disable root access, type sudo passwd -l root

Ubuntu/Debian

  • Hold the S2 button & power on BBB. 1st and 3rd LEDs blink.

eMMC version (info was outdated now)

  1. wget the image
  2. Use sudo su instead su to have full root permission. Use xz command to write the image to microSD
  3. Insert microSD to BBB and holding the button (closest to microSD) while applying power on BBB
  4. To copy the image to eMMC, use wget again to get the image file. Use sudo su instead su to have full root permission. Then use xz command again to write the image to eMMC.
  5. Remove microSD and reboot BBB. If we keep microSD in BBB, it will boot from microSD. MicroSD has the advantage that we can extend the space while eMMC cannot.
  • Kernel is 3.8.
  • The image contains a miniminal Ubuntu system. It only takes 276 MB when I use df -h command to check. So it does not come with a full desktop.
  • Defautl username=ubuntu, password=ubuntu
  • http://robotic-controls.com/learn/beaglebone/beaglebone-black-ubuntu
  • If I try to install xubuntu-desktop, it requires 421MB data to download and 1.2GB space to install. So it is not feasible since the /dev/mmcblk0p2 partition has only 1.8GB space. Fortunately, the solution in here works well.
  • Unfortunately, I got an error when I issue 'startx'.
Fatal server error:
AddScreen/ScreenInit failed for driver 0

Please check the log file at "/var/log/Xorg.0.log" for additional informaiton.

After I reboot, things looks better. I can get a login GUI. However, the system is very slow and I can not see mouse on the desktop.

microSD version (with LXDE desktop environment)

PS. Even the emmc version contains LXDE environment. Download from http://beagleboard.org/latest-images

At the beginning, the "/" partition still has 1.4GB space (see table below). If we boot into microSD (using ssh [email protected]) and follow the instruction or this or (latest) elinux.org to expand the microSD file system, we can make use whole space in uSD. It involves two commands: one is fdisk (extend the partition) and the other is resize2fs (extend the file system).

debian@beaglebone:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           15G  1.3G   13G  10% /
udev             10M     0   10M   0% /dev
tmpfs           100M  616K   99M   1% /run
/dev/mmcblk0p2   15G  1.3G   13G  10% /
tmpfs           249M     0  249M   0% /dev/shm
tmpfs           249M     0  249M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/mmcblk0p1   96M   69M   27M  72% /boot/uboot
/dev/mmcblk1p2  1.7G  1.3G  345M  79% /media/rootfs
/dev/mmcblk1p1   96M   72M   25M  75% /media/boot

To find out the Debian version, use

cat /etc/debian_version

Console version

Following the instruction on robotic-controls.com, we can install the console version of Ubuntu on BBB. The image I download is Ubuntu 13.10 https://rcn-ee.net/deb/rootfs/saucy/ubuntu-13.10-console-armhf-2013-11-15.tar.xz.

This image has some features like 192.168.7.2 access automatically just like Angstrom distribution (I don't know how to get this to work on eMMC version of Ubuntu image). That means I can just connect to BBB without using ethernet under Ubuntu OS.

Installation script (uSD is mounted on /dev/sdc in my case)

wget https://rcn-ee.net/deb/rootfs/saucy/ubuntu-13.10-console-armhf-2013-11-15.tar.xz
tar xJf ubuntu-13.10-console-armhf-2013-11-15.tar.xz
cd ubuntu-13.10-console-armhf-2013-11-15
sudo ./setup_sdcard.sh --mmc /dev/sdc --uboot bone

The username/password is ubuntu/temppwd.

Below is what I get in HOST os

brb@brb-P45T-A:~/ubuntu-13.10-console-armhf-2013-11-15$ ifconfig
...
eth2      Link encap:Ethernet  HWaddr 90:59:af:63:df:45  
          inet addr:192.168.7.1  Bcast:192.168.7.3  Mask:255.255.255.252
          inet6 addr: fe80::9259:afff:fe63:df45/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1010 (1.0 KB)  TX bytes:11690 (11.6 KB)
...

and what I get inside BBB

ubuntu@arm:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 90:59:af:63:df:43  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:56 
...
usb0      Link encap:Ethernet  HWaddr c6:18:a5:e4:60:71  
          inet addr:192.168.7.2  Bcast:192.168.7.3  Mask:255.255.255.252
          inet6 addr: fe80::c418:a5ff:fee4:6071/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:178 errors:0 dropped:0 overruns:0 frame:0
          TX packets:100 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:22583 (22.5 KB)  TX bytes:20013 (20.0 KB)
ubuntu@arm:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2   15G  493M   14G   4% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            247M  4.0K  247M   1% /dev
tmpfs            50M  236K   50M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            248M     0  248M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/mmcblk0p1   64M   17M   47M  27% /boot/uboot

We can make the Ubuntu talk to internet by using the instruction given in Angstrom section (run sudo su first).

TTL/Serial (FTDI) cable connection

The screenshot below shows we can use a ttl serial cable to log into beaglebone in command line mode. The beaglebone is powered by a 5v usb. The tricky part is the J4 pin (RXD) in BBB should be connected to the TXD pin in ttl cable. Similarly, the J5 (TDX) pin in BBB should be connected to the RXD pin 8n ttl cable. The 3.3v p8n in ttl cable is not used at all.

This post from dave.cheney.net asks NOT to connect the 5V pin from TTL to BBB. The Serial port pin settings is given on elinux.org as linked from codechiefl.wordpress.com.

Check out the beaglebone black system manual (Section 7.5 Serial Header) about the serial debug ports from https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SRM.pdf.

   BBB        TTL
  ==========
   J1 GND    GND
   J4 (RXD)  TX
   J5 (TXD)   RX

Ftdi2ttlserialcable.jpg

Here is the log of the booting process (Debian OS).

See also the UDOO example.

Find out the IP address if we use internet sharing

If we are using ethernet on BBB, we can find out the IP adress by using the following way.

Download fing deb package from overlooksoft website. Install it by double clicking the file in file manager. Issue the following command to find out the IP of beaglebone black (shared computer). The IP of my 2nd ethernet adapter (eth1) is 10.42.0.1.

sudo fing -n 10.42.0.1/24

Wifi setup command line using iwconfig

  • A USB wifi adapter can be found
lsusb
  • If the USB wifi device is detected, we want to know if it can be found on ifconfig command. To show the wifi interface name, use
iwconfig

The wifi adapter can be wlan0 or wlan1.

  • Some of my adapters
    • TP-LINK shows it is Atheros AR9271 802.11n.
    • The EdiMax is EW-7811Un 802.11n.
    • Rosewill RNX-EasyN1 is RT2870/RT3070
  • Setting up WiFi with BeagleBone Black from adafruit. The important messages are
    • Use a usb-extension (even an unpowered hub)
    • modify /etc/network/interfaces file to uncomment wlan0 interface & enter correct sssid/password
    • sudo ifup wlan0
    • To make the wlan0 up at the boot time, I have to change the line auto wlan0 to allow-hotplug wlan0 like this post on Raspberry Pi. Note that I am using a HDMI cape on my BBB.

My /etc/network/interfaces' looks like

auto lo
iface lo inet loopback

allow-hotplug wlan0
  wpa-ssid "YOURSSID"
  wpa-psk "YOURPASSWORD

iface usb0 inet static
  address 192.168.7.2
  netmask 255.255.255.0
  network 192.168.7.0
  gateway 192.168.7.1
dmesg | grep rtl8192
ifconfig wlan0
sudo apt-get install wireless-tools
iwconfig
sudo nano /etc/network/interface
# Made appropriate change on /etc/network/interface
sudo ifup wlan0 // not needed if we have enable wlan0 at boot. 
                // sudo ifconfig wlan0 up
sudo iwlist wlan0 scanning
ping www.google.com

where the file /etc/network/interface should be like

auto wlan0
iface wlan0 inet dhcp
    wpa-ssid mynetworkname
    wpa-psk mysecretpassphrase

wifi setup with wicd-curses (TUI/text user interface)

If we don't know the ssid or the connection is done through 'I Agree' method in a webpage, the command line way is not useful. However, with wicd-curses program, we can still connect to a wireless network. This works when I tested it on my work place wifi network.

# Remove ethernet. Connect to BBB by ssh [email protected] using USB cable
lsusb
ifconfig -a
sudo apt-get update
sudo apt-get install wicd-curses
sudo wicd-curses
# Shift+P to add wlan0 to wireless network. Press F10 to save it. Press Shift+R to refresh.

Take a screenshot

Use the scrot program.

sudo apt-get install scrot
scrot -d 5 screenshot.png  # delay 5 seconds

apt source

On my Debian 7.5/wheezy (lsb_release -a), the /etc/apt/sources.list shows

deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb http://ftp.us/debian.org/debian/ wheezy-updates main contrib non-free
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb [arch=armhf] http://debian.beagleboard.org/packages wheezy-bbb main

Angstrom

# Umount the uSD card 
mount # find /dev/sdc1
sudo diskfutil unmount /dev/sdc1
ls *.xz

# Copy img file to microSD card. Took about 15-30 minutes.
# Method 1.
tar -xJf BBB-eMMC-flasher-2013.06.20.img.xz
sudo dd bs=1m if=~/Downloads/BBB-eMMC-flasher-2013.06.20.img of=/dev/sdc
sudo sync
# Method 2.
xz -cd BBB-eMMC-flasher-2013.06.20.img.xz > /dev/sdc

Remove the microSD card and insert it fully into BBB uSD card slot.

To flash the BBB: Hold down the 'user boot' button (closes to uSD card slot) and power on BBB until the 4 LED's light up for a few seconds. It will take 30-45 minutes to flash the image onto the eMMC. Once it's done, the 4 LED's will all stay lit up at the same time. You can then power down your BBB, remove uSD and power up BBB.

The username is root. There is not password. We can access it by ssh [email protected].

If we type ifconfig in Angstrom, we find the connection is through usb0 adapter.

root@beaglebone:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 90:59:AF:63:DF:43  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:56 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:760 (760.0 B)  TX bytes:760 (760.0 B)

usb0      Link encap:Ethernet  HWaddr 86:27:86:2D:45:5C  
          inet addr:192.168.7.2  Bcast:192.168.7.3  Mask:255.255.255.252
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2765 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5003 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:179578 (175.3 KiB)  TX bytes:7067277 (6.7 MiB)

eMMC version

It contains two partitions.

fat16  BEAGLE_Bone    70.57MB
ext4   eMMC-Flasher   3.33GB

One BEAGLE_Bone partition, it contains 4 files. <ID.txt>, <MLO>, <u-boot.img>, and <uEnv.txt>.

<ID.txt> shows the eMMC flasher date (such as 2013.09.04). <MLI> and <u-boot.img> are binary files. <uEnv.txt> has only one line.

On eMMC-Flasher partition, it contains a regular Linux system (/bin, /boot, ...) and one file <eeprom.dump>.

Web server

http://stackoverflow.com/questions/10818459/where-is-the-web-server-root-directory-on-angstrom-linux-beagleboard-beaglebo

Google coder

http://www.adafruit.com/blog/2013/09/17/run-google-coder-on-your-beaglebone-black/

VNC

opkg update
opkg install x11vnc

x11vnc -bg -o %HOME/.x11vnc.log.%VNCDISPLAY -auth /var/run/gdm/auth-for-gdm*/database -display :0  -forever

To start VNC server at bootup and shutdown, check out

Package download

http://www.gigamegablog.com/2012/01/29/beaglebone-linux-101-configuring-angstrom-linux/

opkg update
opkg install XXXX
opkg list | grep "gfortran"

However, at least for BBB case, I cannot find gfortran package so I cannot install R. See discussions below

The angstrom linux package browser is the place we can see if packages for BBB Cortex-A8. According to Wikipedia the Cortex-A8 has armv7a architecture. Cortex-A7 (eg pcDuino3) is a smaller, faster, and more power-efficient successor to the Cortex-A8.

On ubuntu, we can use ldconfig -v command to show the installed libraries and their versions. See here. If we like to manually add libraries to ubuntu/debian, we can check the tip here.

XBMC

Forget about XBMC on BeagleBone Black. It has many pros over PI except the GPU that XBMC is heavily realies on, even for the interface.

BBB does have any hardware codec acceleration.

See

beaglebone.local and Avahi/Bonjour/Zeroconf

Instead of typing an IP address, we can use [email protected] to access BBB running on Angstrom OS. The implementation is done by Avahi Daemon/Bonjour/ZeroConf/Multicast.

We can manually install avahi-daemon in ubuntu-armhf by

sudo apt-get update
sudo apt-get install avahi-daemon

After that, we should be able to ssh [email protected] instead of using IP. PS: not stable.

brb@brb-P45T-A:~$ ssh [email protected]
ssh: connect to host ubuntu-armhf.local port 22: Connection refused

The real IP address can be found by ping HOSTNAME.local (Updated: use ps -ef | grep avahi to find out the exact hostname used in .local domain because at least one of my Ubuntu machines does not use its hostname exactly)

For the Angstrom OS with beaglebone, I found the IP number is in 192.168.7.2 (same as in the Getting Start page) by using ping command.

brb@brb-P45T-A:/etc/init$ ping beaglebone.local
PING beaglebone.local (192.168.7.2) 56(84) bytes of data.
brb@brb-P45T-A:/etc/init$ ifconfig
(skip)
eth2      Link encap:Ethernet  HWaddr 90:59:af:63:df:45  
          inet addr:192.168.7.1  Bcast:192.168.7.3  Mask:255.255.255.252

The same method can be applied to Raspberry Pi or Ubuntu. In fact, avahi-daemon is installed by default. We can use ps -ef | grep avahi to check it.

Internet over Ethernet

Suppose the host machine has a USB ethernet adapter/cable. We can share the internet from the host to BBB.

The host's USB-ethernet adapter has an IP 10.42.0.1 and it is configured as shared instead of DHCP.

The BBB will have eth0: 10.42.0.50 and usb0: 192.168.7.2.

We can use ssh [email protected] to access it. The BBB will have internet access.

echo "nameserver 8.8.8.8" > /etc/resolv.conf

Network over USB

We can use a USB cable to connect to BBB from a Windows/Linux/Mac computer. This is a very unique feature in BBB. Not even Raspberry Pi has this feature.

See the next section to know how to use this feature to get an internet access for BBB so it does not need to plug in an ethernet cable or a WIFI adapter.

Internet over USB

On BBB, run

sudo su
/sbin/route add default gw 192.168.7.1
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
netstat -rn

Note it is convenient to save the first 2 lines in a script file (eg 'networkusb') and chmod +x it. Then when we want to use USB to connect to internet, we just use sudo su ~/networkusb.

It is perfectly fine to have multiple lines of nameserver. (IP Masquerade/Share the internet connection + IP forward)

The above procedure of setting gateway is temporary. We can also permanently change the gateway setting by editing /etc/network/interfaces file (https://help.ubuntu.com/12.04/serverguide/network-configuration.html)

auto lo
iface lo inet loopback
auto usb0
iface usb0 inet static
    address 192.168.7.2
    netmask 255.255.255.0
    network 192.168.7.0
    gateway 192.168.7.1

Then run

sudo service networking restart

On host, run (wlan0 is my host internet adapter, eth1 is the BBB USB connection on my host)

sudo iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
sudo iptables -t nat -L

NOTE:

  1. The ip-forward statement can be alternatively enabled by un-commenting a suitable line in /etc/sysctl.conf file (same method was used by Adafruit)
  2. We can save the first 2 lines in a script file (eg. 00-firewall) and put it in the /etc/network/if-up.d directory. Don't forget to run chmod 755 on this file. Any script in this directory will be executed as soon as your network interfaces come up. See the instruction from debian-administration.org.
  3. See also the method provided from Adafruit by just modifying /etc/network/interfaces file.

And the following is the output of running iptables -t nat -L before running the masquerade & ip forward.

$ sudo iptables -t nat -L
[sudo] password for brb: 
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination    

and the following is after I run the masquerade and ip forward:

$ sudo iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  anywhere             anywhere     

Now everything should be done. Now we can ping www.google.com in BBB to see if the connection works. This is tested on my home ubuntu host machine running 12.04 & 14.04. We can use the last command to show nat table on host machine; See here.

Angstrom

http://beaglebone.cameon.net/home/internet-over-usb

ArchLinux

This post on Archlinux discusses how to get the usb network adapter that is built into the mini-usb power connector working under Arch.

Ubuntu

How to share internet over USB on BBB? http://askubuntu.com/questions/380810/internet-over-usb-on-beaglebone-black

microHDMI to VGA cable

http://circuitco.com/support/index.php?title=BeagleBone_Black_Accessories

Question: How to create EDIT? My NEC monitor supports only 1024 x 768.

Beagleboneblack HDMI page from circuitco.com.

Remote desktop connection

From Linux

See Raspberry#Connection_to_Raspberry_Pi_with_tightvnc

# Server side
sudo apt-get install tightvncserver
tightvncserver     # set up the password, e.g. same password as the debian user
vncserver          # this step may not be necessary
vncserver –kill :1 # kill the current vncserver
vncserver -geometry 480x272   # Simulate using the 4D 4.3" LCD cape; see the screenshot below. 

# Client side
xtightvncviewer 10.42.0.50:1 
# or xtightvncviewer 192.168.7.2:1 if we use usb0 
# or xtightvncviewer beaglebone.local:1 if we use usb0

BBB vnc.png

To start tightvncserver automatically at start, follow the instruction at here to create a new script file under /etc/init.d/ directory and run update-rc.d on the new script.

debian@beaglebone:~$ sudo nano /etc/init.d/vncserver
[sudo] password for debian: 
debian@beaglebone:~$ sudo chmod +x /etc/init.d/vncserver 
debian@beaglebone:~$ sudo update-rc.d vncserver defaults
update-rc.d: using dependency based boot sequencing
update-rc.d: warning: default start runlevel arguments (2 3 4 5) do not match vncserver Default-Start values (S)
update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match vncserver Default-Stop values (0 6)
insserv: Script vncserver is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
debian@beaglebone:~$ sudo reboot

Despite the warning, it still works. It make a copy of this vncserver file below. Something we may want to change for different scenario is the USER and GEOMETRY parameters.

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     S
# Default-Stop:      0 6
### END INIT INFO

# PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="debian"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"

# Color depth (between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.
NAME="my-vnc-server"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac

exit 0

From Windows

MobaXterm. See this blog.

My Observation about angstrom distribution

When I use the image BBB-eMMC-flasher-2013.06.20.img to put it on the microSD card with win32DiskImager, I see (from plugging SD in Ubuntu) the microSD card has 2 partitions

eMMC-Flasher  -ext4
BEAGLE_BONE - vfat

where eMMC-Flasher contains an ubuntu data and BEAGLE_BONE contains only 4 files.

ID.txt - just one line
MLO - 98K binary
u-boot.img - 371K binary
uEnv.txt - just one line

Flashing is done by pressing the 'Boot' button while connecting the power. It took 1 hour in my case when I flashed BBB-eMMC-flasher-2013.06.20.img.

However, once the microSD is flashed to eMMC, the 'eMMC-Flasher' partition will be gone and 'BEAGLE_BONE' partition is changed to include 3 new folders- App, Docs and Drivers AND some new files - START.htm, autorun.inf, README.md.

Android OS

BBB vs Raspberry Pi

Beaglebone 101

Angstrom includes a web server running on BBB. The web address is http://192.168.7.2

I have created screenshots in Google drive http://goo.gl/o03iex

Fix date/time

See here. Run the following to change the country and time zone.

sudo dpkg-reconfigure tzdata

Then run

sudo ntpdate pool.ntp.org

For one time fix (for example, we want to avoid an error from running 'make'), we can use

sudo date -s "2 Apr 2014 19:00:00"

Increase sudo timeout

http://ubuntuforums.org/showthread.php?t=183418

sudo visudo
# Add the following line for 10 minutes. Use -1 for infinity.
# Modify USER_NAME for your own.
Defaults:USER_NAME timestamp_timeout=10

Run Graphical App on remote computer

Suppose we have a Qt app we want to launch from a local computer and show the GUI on BBB. We can

  1. Run xhost + as a user on BBB
  2. Run export DISPLAY=:0.0 then our own graphical application from the local computer.

To run xhost command at boot (The xhost command needs an active X server to run, it can run at the login screen e.g. when lightdm loads), we can follow the instruction here

Run Graphical App as root on local computer

This is related to the question: Make X11 program work in an ssh sudo session

One way that works is to run ssh -X [email protected] first (it seems not necessary to use ssh -Y option). Then

sudo XAUTHORITY=/home/debian/.Xauthority /home/debian/Downloads/servo/servo

Then my GUI app located in /home/debian/Downloads/servo/servo will be launched as root shown in my local machine.

If the GUI app is not run by root, we don't need to bother the xauthroity. We can just run the app.

Use microSD as ext storage

It is possible. See the idea in here.

Playing music using command line tools

Install ALSA libraries first (these may be installed already). ALSA stands for Advanced Linux Sound Architecture.

sudo apt-get install alsa-base alsa-utils
sudo apt-get install libasound2-dev
  1. Beaglebone Robotic Project: Chapter 3.
  2. http://www.binarytides.com/play-music-console-ubuntu/
  3. http://infinetix.com/project/distributed-audio-beagle-bone-black/
  4. http://andicelabs.com/2014/03/usb-audio-beaglebone/
  • mpg123 - Yes, there are keyboard shortcuts. Use '-C' argument. For example, use ":" for fast? forward.
sudo apt-get install mpg123
  • sox - using about 50% of CPU. no keyboard shortcut
sudo apt-get install sox libsox-fmt-all
  • vlc - using about 50% of CPU and has a complete keyboard shortcuts. For example, a/z for volume and left/right arrow for fast backward/forward (seek -/+ 1%). Space for pause and s for stop. -/+ key to slow down/accelerate the playing speed for video files. Shift+left arrow to a short backwards jump. See also the hotkey page (not exactly the same).
sudo apt-get install vlc-nox
vlc -I ncurses XXX.mp3

To use Syba USB audio adapter, we should switch audio output from HDMI to USB adapter. To do that, create a new file called <.asoundrc> with the content

pcm.!default sysdefault:Device

If check the speaker and microphone are not muted, use

alsamixer

Use the m key to unmute the microphone. Make sure your USB sound device is detected, type

aplay -l
# OR
cat /proc/asound/cards

Now it is time to test the USB audio adapter by using VLC.

Build R on BBB

I am using Ubuntu 13.04 image since angstrom linux missing many required packages.

Since the space is limited, instead of using 'sudo apt-get build-dep r-base', I manually install the essential packages: build-essential, gfortran, libreadline6-dev, libx11-dev, libxt-dev and openjdk-7-jre.

I am using R 3.0.1. (Update) R 3.1.0 works well too.

ubuntu@ubuntu-armhf:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2  1.8G  276M  1.4G  17% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
devtmpfs        248M  4.0K  248M   1% /dev
none             50M  220K   50M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            248M     0  248M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/mmcblk0p1 1004K  472K  532K  48% /boot/uboot

sudo apt-get update
sudo apt-get install build-essential gfortran libreadline6-dev libx11-dev libxt-dev
sudo apt-get install openjdk-7-jre    
// (optional) need it if we don't want to get an error message at the end of running 'make'
// This require 143MB space.

// The whole process (configure + make) takes at least 2 hours on BBB
./configure --enable-R-shlib
make
// make > ~/Rmake.txt 2>&1

There is still warnings with library/datasets
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695411
It seems this is false alarm.

ubuntu@ubuntu-armhf:~/R-3.0.1$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2  1.8G  1.1G  615M  64% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
devtmpfs        248M  4.0K  248M   1% /dev
none             50M  224K   50M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            248M     0  248M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/mmcblk0p1 1004K  472K  532K  48% /boot/uboot

The complete process of running ./configure and make are recorded in

Other configure options

http://cran.r-project.org/doc/manuals/R-admin.html#Configuration-on-a-Unix_002dalike

./configure --disable-byte-compiled-packages --enable-R-shlib

Performance Test

Problems

  • Sometimes the system does not respond. The desktop is freezed and ssh to log in does not work. I am current using Ubuntu image.

Benchmark (Raspberry Pi vs BBB vs Edison) using the sysbench utility