Difference between revisions of "ECE497 Tips and Tricks"

From eLinux.org
Jump to: navigation, search
m (Changed incorrect use of 'to' to correct use of 'two' - makes statement clearer)
(114 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:ECE497]]
+
[[Category:ECE497 |Tips]]
 +
[[Category:ECE597 |Tips]]
 +
{{YoderHead}}
  
 
Some useful tips and tricks for Linux and the Beagleboard.
 
Some useful tips and tricks for Linux and the Beagleboard.
  
== Quick Tips ==
+
== Interesting Links ==
 +
 
 +
Since we are working with the open source community, you need to know where the action is.  Here are some useful links to what's happening in the Beagle community.
 +
 
 +
* [http://lug.rose-hulman.edu/wiki/Main_Page Rose-Hulman Linux Users Group wiki]
 +
* [http://learn.adafruit.com/category/beaglebone Adafruit's BeagleBone] site.
 +
* [https://learn.sparkfun.com/tutorials/tags/beaglebone SparkFun's Beagle] tutorials.
 +
* [http://BeagleBoard.org BeagleBoard.org], the starting point for all thing Beagle.
 +
* [http://groups.google.com/group/beagleboard Beagle Discussion Group], lot's of good information here, but you'll have to dig a bit.  Subscribe and follow the discussion.
 +
* [http://beagleboard.org/blog blog], see what is being said about the Beagle.
 +
* [http://elinux.org/BeagleBoard eLinux], this is where this page is being hosted.  It's about embedded Linux in general, not just the BeagleBoard.
 +
* [http://free-electrons.com/docs/ Free Electrons], some good labs about what makes embedded Linux run.
 +
* [https://gforge.ti.com/gf/project/tiesr/ TI Embedded Speech Recognizer] (TIesr) is a fixed-point recognizer written in C++ and C.
 +
* [http://code.google.com/soc/ Google Summer of Code].  BeagleBoard is an accepted organization.
 +
* [http://www.makelinux.net/kernel_map Linux Kernel Map]
 +
* [http://processors.wiki.ti.com/index.php/Category:OMAP35x Texas Instruments Embedded Processors Wiki]
 +
 
 +
== Linux ==
 +
 
 +
[http://freeengineer.org/learnUNIXin10minutes.html Learn UNIX in 10 Minutes] is a quick overview of the most commonly used Linux commands.
 +
 
 +
[http://lifehacker.com/5935869/top-10-tools-that-are-better-in-the-command-line?utm_campaign=socialflow_lifehacker_twitter&utm_source=lifehacker_twitter&utm_medium=socialflow Top 10 Tools] is a nice summary of 10 of the most useful Linux commands.
 +
 
 +
=== Quick Tips ===
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 10: Line 35:
 
! Description
 
! Description
 
|-
 
|-
| gnome-open
+
|  
 +
host$ '''gnome-open'''
 
| Open a file or directory using the default program
 
| Open a file or directory using the default program
 
|-
 
|-
 
| Give the IP address a name
 
| Give the IP address a name
 
| Inside /etc/hosts add a line of the form <IP address> <alias> this will allow you to refer to the host by name.
 
| Inside /etc/hosts add a line of the form <IP address> <alias> this will allow you to refer to the host by name.
 +
|-
 +
|
 +
beagle$ '''ntpdate ntp.org'''
 +
beagle$ '''rm /etc/localtime'''
 +
beagle$ '''ln -s /usr/share/zoneinfo/America/New_York /etc/localtime'''
 +
 +
| This will go to a '''n'''etwork '''t'''ime '''p'''rotocol server and get the current time and set the Beagle to it and set the local time zone. [http://derekmolloy.ie/automatically-setting-the-beaglebone-black-time-using-ntp/]
 +
|-
 +
|
 +
beagle$ '''mount -t debugfs debugfs /sys/kernel/debug/'''
 +
beagle$ '''cd /sys/kernel/debug'''
 +
beagle$ '''ls'''
 +
| Kernel Debug Info
 
|}
 
|}
  
== bash ==
+
=== Connecting to RHIT wifi ===
 +
 
 +
There is a discussion in the [https://groups.google.com/forum/?fromgroups=#!topic/beaglebone/9PEUmcsLXLU Beagle Google Group] about getting wireless working with the bone.
 +
 
 +
Use these settings for connecting to the Rose-Hulman wireless network:
 +
 
 +
* '''SSID:''' RHIT-1X
 +
* '''Security:''' WPA & WPA2 Enterprise
 +
* Leave "anonymous identity" blank
 +
* '''CA Certificate''': (None)
 +
* '''PEAP version''': Version 0
 +
* '''Inner authentication''': MSCHAPv2
 +
* Use your Rose username and password
 +
 
 +
=== bash ===
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 34: Line 87:
 
|}
 
|}
  
== ssh ==
+
=== ssh ===
  
=== Suspending ssh ===
+
==== Suspending ssh ====
  
Most programs can be suspended by typing ^z (Ctrl-z).  If you have an '''ssh''' connection to another machine you can suspend it by entering ~^z.  You can resume the connection by entering ''fg''.
+
Most programs can be suspended by typing <code>^z</code> (Ctrl-z).  If you have an '''ssh''' connection to another machine you can suspend it by entering <code>~^z</code>.  You can resume the connection by entering ''fg''.
  
=== ssh and X-windows ===
+
==== ssh and X-windows ====
  
When using ssh between to X-windows systems try
+
When using ssh between two X-windows systems try
  
<pre>
+
host$ '''ssh -CX root@beagle'''
host$ ssh -CY root@beagle
+
 
</pre>
+
The -X set the DISPLAY variable on the remote machine so you can open windows from the beagle on your host machine.   
The -Y set the DISPLAY variable on the remote machine so you can open windows from the beagle on your host machine.   
 
  
 
The -C compressed the data over the link.  Good for slow connections.
 
The -C compressed the data over the link.  Good for slow connections.
  
=== Authorizing ssh ===
+
==== vnc ====
 +
 
 +
You can run a vnc server on the Beagle.  Install it with:
 +
beagle$ '''apt-get update'''
 +
beagle$ '''apt-get install x11vnc'''
 +
Install a password with
 +
beagle$ '''x11vnc -storepasswd'''
 +
Run it on the Beagle with
 +
beagle$ '''x11vnc -display :0 -ssl -usepw -forever -q &'''
 +
On your host, connect to it with:
 +
 
 +
'''Applications:Internet:Remote Desktop Viewer'''
 +
 
 +
==== Authorizing ssh ====
 +
 
 +
'''ssh''' and '''scp''' can be set up for automatic authorization so you don't have to enter your password when using these commands. Here's how to do it.
 +
First let's see what's already there:
 +
 
 +
* On your Beagle run
 +
 
 +
beagle$ '''ls ~/.ssh'''
  
'''ssh''' and '''sftp''' can be set up for automatic authorization so you don't have to enter your password when using these commands. Here's how to do it:
+
'''~/.ssh''' may not exist, if not, it will be created. If it's there, check the files in it.
  
 
* On your host computer run
 
* On your host computer run
<pre>
 
host $ ssh-keygen
 
host $ cd ~/.ssh
 
host $ sftp Beagle
 
put id_rsa.pub
 
exit
 
host $ ssh Beagle
 
</pre>
 
The first command creates an authorization key and places it in your .ssh directory.  Remember the pass phrase you enter here.  You'll use it below.  The next two commands copy that key to your Beagle.  The last command connects to your Beagle.
 
* On your Beagle run
 
<pre>
 
beagle $ mkdir ~/.ssh
 
beagle $ cd ~/.ssh
 
beagle $ mv ../id_rsa.pub .
 
beagle $ cp id_rsa.pub authorized_keys
 
beagle $ exit
 
</pre>
 
Here we create a '''.ssh''' directory and copy the public key into it.  The authorized_keys folder contains a list of all the machines that are authorized to connect to your Beagle without a password.
 
* Back on the host computer:
 
<pre>
 
host $ ssh Beagle
 
</pre>
 
This time you should see a window pop up.  Enter your pass phrase from above.  You should be logged into your Beagle.  Log out and log in again.  This time you should get access without having to enter your pass phrase.
 
  
[http://kimmo.suominen.com/docs/ssh/ Here] is move information on ssh authorization.
+
host$ '''ssh-copy-id root@beagle'''
 +
 
 +
It will ask for your beagle password and then copy the needed files to it.
 +
 
 +
* Back on the beagle to see what has changed:
 +
 
 +
host$ '''ssh -CX root@beagle'''
 +
beagle$ '''ls ~/.ssh'''
 +
 
 +
The ssh command shouldn't ask for a password.  What new files appeared?
 +
 
 +
==== ssh configuration ====
 +
 
 +
Here's a nice tip so you don't have to remember who to login as on the beagle. On your host, put the following in '''~/.ssh/config'''.
 +
 
 +
Host beagle
 +
    User root
 +
    UserKnownHostsFile /dev/null
 +
    StrictHostKeyChecking no
 +
 
 +
Before you had to
 +
host$ ssh -CX root@beagle
 +
 
 +
Now you can just
 +
host$ ssh -CX beagle
  
== Mounting dfs/afs ==
+
=== Mounting dfs/afs ===
  
 
You can set up your Linux box to directly mount your afs and dfs files.  The [http://lug.rose-hulman.edu/wiki/Main_Page Rose-Hulman Linux Users' Group] has a nice [http://lug.rose-hulman.edu/wiki/HOWTO_Use_sshfs_to_mount_AFS/DFS_home page] with the details .
 
You can set up your Linux box to directly mount your afs and dfs files.  The [http://lug.rose-hulman.edu/wiki/Main_Page Rose-Hulman Linux Users' Group] has a nice [http://lug.rose-hulman.edu/wiki/HOWTO_Use_sshfs_to_mount_AFS/DFS_home page] with the details .
Line 88: Line 161:
 
After installing <code>sshfs</code> I added the following to my <code>/etc/fstab</code> file:
 
After installing <code>sshfs</code> I added the following to my <code>/etc/fstab</code> file:
 
<pre>
 
<pre>
sshfs#username@dfs.Rose-hulman.edu:/MyDocs/username /home/username/MyDocs fuse user,noauto,uid=1000,gid=1000 0 0
+
sshfs#username@dfs.Rose-hulman.edu:/DFS/MyDocs/username /home/username/MyDocs fuse user,noauto,uid=1000,gid=1000 0 0
sshfs#username@dfs.rose-hulman.edu:/Users/Y/username /home/username/dfs-home fuse user,noauto,uid=1000,gid=1000 0 0
+
sshfs#username@dfs.rose-hulman.edu:/DFS/Users/Y/username /home/username/dfs-home fuse user,noauto,uid=1000,gid=1000 0 0
 
sshfs#username@afs.rose-hulman.edu: /home/username/afs-home fuse user,noauto,uid=1000,gid=1000 0 0
 
sshfs#username@afs.rose-hulman.edu: /home/username/afs-home fuse user,noauto,uid=1000,gid=1000 0 0
 
</pre>
 
</pre>
 
You'll have to replace <code>username</code> with your login name.  Then create the mount points:
 
You'll have to replace <code>username</code> with your login name.  Then create the mount points:
<pre>
+
 
cd ~
+
host$ '''cd ~'''
mkdir MyDocs
+
host$ '''mkdir MyDocs'''
mkdir dfs-home
+
host$ '''mkdir dfs-home'''
mkdir afs-home
+
host$ '''mkdir afs-home'''
</pre>
+
 
 
Now you can mount your files by using:
 
Now you can mount your files by using:
<pre>
+
 
cd ~
+
host$ '''cd ~'''
mount dfs-home
+
host$ '''mount dfs-home'''
cd dfs-home
+
host$ '''cd dfs-home'''
ls
+
host$ '''ls'''
</pre>
+
 
 
You should now see your dfs files.  You can unmount using:
 
You should now see your dfs files.  You can unmount using:
<pre>
 
cd ~
 
sudo umount dfs-home
 
</pre>
 
  
== Installing Ubuntu ==
+
host$ '''cd ~'''
 +
host$ '''sudo umount dfs-home'''
 +
 
 +
=== byobu - A Screen Manager ===
 +
 
 +
For years Unix has had <code>screen</code> which is a screen manager.  ''byobu'' is wrapper for screen that puts a nice face on it.  You can run byobu on your host computer and on the Beagle.  With byobu you can start a long running program (bitbake for example) in one terminal and detach from the terminal and the program will keeping running in the background.  Using byobu you can later attach to the program (possibly from another terminal) and see how the program is progressing.
 +
 
 +
Install byobu with:
 +
 
 +
host$ '''sudo apt-get update'''
 +
host$ '''sudo apt-get install byobu'''
 +
 
 +
Now you can run it.
 +
 
 +
beagle$ '''byobu'''
 +
 
 +
You'll see a command prompt.  You'll also see some status information on the bottom two lines.  Type Ctrl-A ? for help.  Type Ctrl-A Ctrl-D to detach from the session.  Running byobu again will reattach you to the session.  Try running byobu in two windows at the same time.  You should see the same session in both.
 +
 
 +
=== Backing up an SD card with dd ===
 +
 
 +
Here's the command I use to backup an SD card. I use '''System:Administration:Disk Utility''' to figure out the path to the card.  In this case it's ''/dev/sdc''
 +
 
 +
host$ '''sudo time dd if=''/dev/sdc'' of=FIE2011.img bs=4M count=1000'''
 +
host$ '''sudo chown yoder:yoder FIE2011.img'''
 +
host$ '''md5sum FIE2011.img > FIE2011.img.md5'''
 +
host$ '''bzip2 -k FIE2011.img'''
 +
 
 +
It takes about 5 minutes to dd a 4G card, 1.2 minutes for md5 and bzip2 takes about 23 minutes.
 +
 
 +
It looks like the 7z compression is becoming popular. Use it via
 +
host$ ''' 7za a FIE2011.img.7z IFE2011.img
 +
 
 +
It took 16 minutes. The file size is 454M compared to 628M.  Wow, faster and smaller.
 +
 
 +
=== Local Ubuntu Update Mirror ===
 +
 
 +
Darryl Mouck in CSSE has passed this on...
 +
 
 +
We host a local mirror for all ubuntu updates. This is from the current distro back to hardy; it hosts every distro that ubuntu currently supports.
 +
 
 +
In order to get your system to point to our mirror follow the directions [https://local.rose-hulman.edu/academicaffairs/csse/Wiki/Ubuntu/update.aspx here].
 +
 
 +
=== Using pico DLP with BBB ===
 +
 
 +
Put this in uEnv.txt to use the BBB with a pico DLP.
 +
optargs=video=HDMI-A-1:640x480@60
 +
 
 +
=== systemd journal taking too much time/space ===
 +
 
 +
If you are running out of space because of the systemd journal try [https://groups.google.com/forum/#!searchin/beagleboard/systemd-journal/beagleboard/1NguS-SK-G8/NGhAVlTerkkJ this Google Group Suggestion]
 +
 
 +
=== Getting the BeagleBone to work with unusual network managers ===
 +
 
 +
If you plugged in your BeagleBone, but you just can't get it to pop up a page at 192.168.7.2 (aka your browser says "could not connect" or "time out"), then the following steps should help.
 +
 
 +
 
 +
First run
 +
host$ ip a
 +
 
 +
This will list a bunch of network interfaces. You should see one that looks odd and long like
 +
enp0s29u1u5
 +
 
 +
That is the interface for the BeagleBone. Now, to get the BeagleBone to communicate with your host over USB serial, run
 +
host$ sudo dhcpcd enp0s29u1u5
 +
 
 +
If this is successful, you should see your interface in the output of the command below. Its state should be UP.
 +
host$ ifconfig
 +
 
 +
== Windows ==
 +
 
 +
Most of the work is done under Linux; however there are some handy Windows-based tools.
 +
 
 +
=== Serial Port ===
 +
 
 +
[http://www.vandyke.com/products/securecrt/ SecureCRT] is a good program that gives you both access to a serial port and is also an ssh client. Rose has a license for [http://www.rose-hulman.edu/tsc/software/documentation/applications/securecrt-secureFX/installation/ SecureCRT].
 +
 
 +
[http://www.tucows.com/preview/195282 Tera Term] also gives you access to the serial port and it's free.
 +
 
 +
=== Notepad++ ===
 +
 
 +
[http://notepad-plus-plus.org/ Notepad++] is a nice text editor for Windows.
  
I've installed 2 different versions of Ubuntu on my SD cards. Each of my SD cards is 4GB, and this is just large enough to hold the Ubuntu images.
+
==Mac OS X==
 +
===Mounting the BeagleBone filesystem locally===
  
I followed the instructions from [http://elinux.org/BeagleBoardUbuntu#Maverick_10.10 here] and [http://elinux.org/BeagleBoardUbuntu#Maverick_10.10_2 here].
 
  
The first link references a Ubuntu wiki which details how to install a netbook edition of Ubuntu on ARM/OMAP processor-based systems. It is not beagle-specific. This image runs a little slowly, but not much slower than the [http://elinux.org/ECE497_Lab01_Installing_Angstrom_on_Your_Beagle_%28precompiled%29#From_beagleboard-validation.s3.amazonaws.com SPEd image].
+
1. Download and install OSXFUSE and SSHFS from [http://osxfuse.github.io/ github official page] in the respective order.
  
The second link references instructions for installing another image. This image is very minimal, and doesn't have a gui. There are instructions for installing a gui, which I did, with good success. As far as I can tell, even with the gui, this is the fastest image so far.
+
2. In Terminal do
 +
host$ '''mkdir /Volumes/Beagle'''
 +
host$ '''sshfs root@beagleIPaddr:/ /Volumes/Beagle'''
  
== Installing Always Innovating's Super Jumbo ==
+
== Set up on the BeagleBoard ==
  
[http://www.alwaysinnovating.com/home/index.htm Always Innovating] works with branded products and services companies that are looking to deliver great touch devices as part of their offerings. They have published a free SD card image for the BeagleBoard that runs Angstrom, Android, Ubuntu, and ChromiumOS.  [http://www.alwaysinnovating.com/beagleboard/ Here's] a video showing what it can do.
+
=== Accessing the Beagle via the Serial Port ===
  
I've put a copy of the compressed image on my DFS siteFeal free to play with it.  [http://www.alwaysinnovating.com/wiki/index.php/Beagleboard Here's] a wiki that shows how to switch between OS's on the fly.
+
During boot up the Beagle logs various messages on the serial portYou can see these messages by:
  
== Resizing an SD card partition via the Beagle ==
+
* See what USB/tty devices are already attached to your host
 +
host$ '''ls /dev/ttyU*'''
 +
* Attach a serial to USB converter to your host computer and the Beagle's serial port.
 +
* See what new USB/tty devices appeared
 +
host$ '''ls /dev/ttyU*'''
 +
* On my host, '''/dev/ttyUSB1''' appeared. On the host computer run
  
The following is a slick way to boot the Beagle so it isn't using the SD, then repartition the SD card. It came from [http://groups.google.com/group/beagleboard/browse_thread/thread/3be77bc54feb08a6/b792e092e3c48989?lnk=gst&q=resize+partition#b792e092e3c48989]
+
  host$ '''screen /dev/ttyUSB''1'' 115200'''
+
where '''ttyUSB1''' is what appeared when you plugged in your converter.
Jason Kridner says ...
 
I got a related question from Mark about how to perform the partition
 
resizing, so I figured I'd address that here.  I don't believe you'd
 
be able to resize a mounted partition and that this operation would
 
require another file system to mount.  Because this image does not
 
have the ramdisk, I downloaded the one used being shipped with the xM
 
boards today [http://www.google.com/url?sa=D&q=http://beagleboard-validation.s3.amazonaws.com/deploy/201008201549/sd/ramdisk.gz].
 
<pre>
 
root@beagleboard:~# wget
 
http://www.google.com/url?sa=D&q=http://beagleboard-validation.s3.amazonaws.com/deploy/201008201549/sd/ramdisk.gz
 
Connecting to beagleboard-validation.s3.amazonaws.com (72.21.214.39:80)
 
ramdisk.gz          100% |*******************************| 19492k 00:00:00 ETA
 
root@beagleboard:~# cp ramdisk.gz /media/mmcblk0p1/
 
root@beagleboard:~# shutdown -r now
 
</pre>
 
I halted the board during reboot and did:
 
<pre>
 
OMAP3 beagleboard.org # mmc rescan 0
 
OMAP3 beagleboard.org # run loaduimage
 
Loading file "/boot/uImage" from mmc device 0:2 (xxa2)
 
3194256 bytes read
 
OMAP3 beagleboard.org # run loadramdisk
 
reading ramdisk.gz
 
19960110 bytes read
 
OMAP3 beagleboard.org # run ramboot
 
</pre>
 
I allowed it to boot and did:
 
<pre>
 
root@beagleboard:~# umount /dev/mmcblk0p1
 
root@beagleboard:~# umount /dev/mmcblk0p2
 
root@beagleboard:~# fdisk /dev/mmcblk0
 
Command (m for help): p
 
Disk /dev/mmcblk0: 3965 MB, 3965190144 bytes
 
255 heads, 63 sectors/track, 482 cylinders
 
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Sector size (logical/physical): 512 bytes / 512 bytes
 
Disk identifier: 0x00000000
 
        Device Boot      Start        End      Blocks  Id  System
 
/dev/mmcblk0p1  *          1         15      120456    c  W95 FAT32 (LBA)
 
/dev/mmcblk0p2              16        444    3445942+  83  Linux
 
Command (m for help): d
 
Partition number (1-4): 2
 
Command (m for help): n
 
Command action
 
  e  extended
 
  p  primary partition (1-4)
 
p
 
Partition number (1-4): 2
 
First cylinder (16-482, default 16):
 
Using default value 16
 
Last cylinder, +cylinders or +size{K,M,G} (16-482, default 482):
 
Using default value 482
 
Command (m for help): w
 
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
Syncing disks.
 
root@beagleboard:~# umount /dev/mmcblk0p2
 
root@beagleboard:~# resize2fs /dev/mmcblk0p2
 
resize2fs 1.41.9 (22-Aug-2009)
 
Resizing the filesystem on /dev/mmcblk0p2 to 937794 (4k) blocks.
 
The filesystem on /dev/mmcblk0p2 is now 937794 blocks long.
 
root@beagleboard:~# shutdown -r now
 
</pre>
 
I then waited for the reboot.  That was all there was to it.
 
Going the other way would require performing the resize operation
 
first and specifying the size.  
 
  
Anyone care to automate this and submit this to Angstrom?
+
You are now talking to your Beagle's serial port. Login quickly.  There appears to be a bug that makes garbage appear on your screen if you wait too long. Try
 +
beagle$ '''shutdown -r now'''
  
== Kernel Boot Problems ==
+
You will see the shutdown messages, followed by the U-boot messages.  After a 3 second (or so) delay you will see the kernel booting.
  
[http://processors.wiki.ti.com/index.php/Kernel_-_Common_Problems_Booting_Linux Here] is a link with some suggestions of what to do if your kernel isn't booting properly.
+
'''Tip 1''': Ctrl-a H will cause the data on the serial port to be logged.  See
 +
host$ '''man screen'''
 +
for help.
  
== Serial port garbage ==
+
'''Tip 2''': <F6> will disconnect from the session. You can reconnect later.
  
If you are having trouble with garbage on the console, this might help. Sometimes the serial port times out.  Most of the time it just generates some junk which can be cleared with CTRL-U or backspace.  However, if it happens at the login prompt then getty thinks the terminal is 7-bit with parity (rather than 8-bit raw).  If this happens and you continue to login the whole session appears to be scrambled - if you press CTRL-D you can login again provided you don't stop typing... :]
+
=== Setup a USB Wireless Device on Beagle ===
I have simply added the following two lines to root's <code>.profile</code>:
 
<pre>
 
stty -parenb -parodd cs8 -inpck -istrip
 
echo 0 > /sys/class/tty/ttyS2/device/sleep_timeout
 
</pre>
 
A better fix would probably be to just add the second line to a rc.d startup script somewhere.
 
  
This suggestion came from this [http://groups.google.com/group/beagleboard/browse_thread/thread/d23c15e3c9fcb8fc posting].
+
([http://embeddedgeeks.wordpress.com/2012/01/03/belkin-micro-wifi-usb-dongle-on-the-beagleboard/ Here] are instructions on setting up a Belkin USB dongle.)
  
==Sharing Laptop Internet Connection with BeagleBoard==
+
The device I used to setup a wireless connection on the Beagle Board was the Linksys Compact Wireless-G USB Network Adapter with SpeedBooster.
Two options: One uses Ubuntu's GUI network connections manager, the other requires modifying things yourself.
 
  
'''Option 1 - Using Ubuntu Network Connections GUI'''
+
I first opened the wpa_supplicant.conf file to setup my networks:
# In Ubuntu, go to System -> Preferences -> Network Connections
 
# On the 'Wired' tab, select 'Auto eth0' and click 'Edit' (Note: name may be other than 'eth0'. If nothing exists in this list, then make sure there is '''not''' an entry starting with 'auto eth0' in your /etc/network/interfaces file; such an entry prevents Network Manager from managing that interface.)
 
# Click the 'IPv4 Settings' tab and change 'Method' to 'Shared to other computers'
 
# Click apply
 
# Restart Ubuntu
 
# Connect the BeagleBoard to the laptop with the crossover Ethernet cable
 
# Boot the BeagleBoard - if Ubuntu was already running and the Ethernet cable was already plugged in, the BeagleBoard should automatically get assigned an IP address and you should be able to access the Internet on the BeagleBoard via the laptop's wireless connection
 
  
'''Option 2 - Modifying Things Yourself'''<br />
+
beagle$ '''cd /etc'''
This will setup a DHCP server on the host machine that will listen to the Ethernet port and assign an IP address to the BeagleBoard when it is connected with an Ethernet crossover cable. The host machine will then act as a router using NAT to send packets out the wifi interface.<br />
+
  beagle$ '''gedit wpa_supplicant.conf &'''
A number of steps were taken from the [https://help.ubuntu.com/community/Internet/ConnectionSharing Ubuntu Community Documentation].<br />
 
Notes:
 
* 'eth0' will refer to the internal interface (connected to the BeagleBoard) and 'wlan0' will refer to the external interface (connected to the Internet).  Your interface names may differ.
 
* A number of configuration files are changed.  It's a good idea to save a backup copy of these before modifying them.
 
  
On the host machine, configure eth0 for a static IP:
+
This file is filled with numerous examples of possible wireless configurations for you to basically fill in. After looking at the examples, I scrolled down to the bottom of the page and set up two networks: one for home and one for school. Here are examples of my setup networks:
<pre>sudo ifconfig eth0 192.168.1.13</pre>
 
If you don't want to configure this after every boot, add an entry to /etc/network/interfaces with the following:
 
 
<pre>
 
<pre>
auto eth0
+
#Home Network
    address 192.168.1.13
+
network={
    netmask 255.255.255.0
+
        ssid="YourHomeNetworkName"
    network 192.168.1.0
+
        psk="YourHomeNetworkPassword"
    broadcast 192.168.1.255
+
}
 +
 
 +
#School Network
 +
network={
 +
        ssid="RHIT-1X"
 +
        proto=WPA
 +
        key_mgmt=WPA-EAP
 +
        pairwise=CCMP
 +
        group=TKIP
 +
        eap=PEAP
 +
        phase1="peapver=0 peaplabel=0"
 +
        phase2="auth=MSCHAPV2"
 +
        scan_ssid=1
 +
        identity="YourSchoolUsername"
 +
        password="YourSchoolPassword"
 +
}
 
</pre>
 
</pre>
 +
For the network examples above,the quotation marks actually belong there but replace the Your.... areas with your corresponding information. No <space> before the first quotation mark.When finished editing save and exit this file.
 +
The information for the RHIT school network was found here:[http://lug.rose-hulman.edu/wiki/RHIT-1X RHLUG]
  
On the host machine, configure the IP tables to use NAT translation for routing packets:
+
Now you must specify that this is the file to use for the wireless device:
 +
 
 +
beagle$ '''cd network'''
 +
beagle$ '''gedit interfaces &'''
 +
 
 +
This file will display all of the different types of Internet connections you have setup.
 +
To use the wpa_supplicant.conf file, scroll down to around line 42 of the code and uncomment the configuration for wpasupplicant. After doing this make sure all of the above lines mentioning anything about wlan0 are commented out. Return back to where it says "iface wlan0 inet dhcp" that you uncommented around line 42.
 +
Add "auto wlan0" above this line, make sure the line "wpa-conf /etc/wpa_supplicant.conf" is uncommented below the iface line, and change the wpa-driver line below that line to wext. So after all of that the code in this file for the wireless device should be the following:
 
<pre>
 
<pre>
sudo iptables -A FORWARD -o wlan0 -i eth0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
+
auto wlan0
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
+
  iface wlan0 inet dhcp
sudo iptables -A POSTROUTING -t nat -j MASQUERADE
+
    wpa-conf /etc/wpa_supplicant.conf
 +
    wpa-driver wext
 
</pre>
 
</pre>
To avoid having to setup the IP tables after every boot, save the IP tables
+
NOTE: the auto wlan0 command in this file means that this device will load at boot time. You can take the time in here now to comment out any interfaces you don't use like auto usb0 to make these devices not load at boot time, which will increase the speed at which you boot up.
<pre>sudo iptables-save | sudo tee /etc/iptables.sav</pre>
+
Save and exit this file
And add the following command to /etc/rc.local (or other appropriate file for your distribution) to be run at boot
+
 
<pre>iptables-restore < /etc/iptables.sav</pre>
+
Once you have finished this you can either restart the Beagle Board or:
 +
 
 +
beagle$ '''cd'''
 +
beagle$ '''/etc/init.d/networking restart'''
  
IP forwarding needs to be enabled:
+
I've found that a lot of the time the interface doesn't receive an IP address when it boots up. If you run ifconfig in the terminal you should see your wireless device connected to a network. If it is connected but no IP address I do the following:
<pre>sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"</pre>
 
To make sure this is set after rebooting, add these lines to /etc/sysctl.conf:
 
<pre>
 
net.ipv4.conf.default.forwarding=1
 
net.ipv4.conf.all.forwarding=1
 
</pre>
 
  
Install the DHCP server software
+
beagle$ '''ifdown wlan0'''
<pre>sudo apt-get install dhcp3-server</pre>
+
# it will report messages here and then
And edit the configuration file /etc/dhcp3/dhcpd.conf (comment out any already existing lines other than "ddns-update-style none;")
+
beagle$ '''ifup wlan0'''
<pre>
+
# more messages and it should report connecting and having an IP address
#Added for DHCP with BeagleBoard
 
default-lease-time 600;
 
max-lease-time 7200;
 
option subnet-mask 255.255.255.0;
 
option broadcast-address 192.168.1.255;
 
option routers 192.168.1.13;    #<--This must match the IP address you statically set for eth0
 
option domain-name-servers 137.112.4.196,137.112.5.28,137.112.12.11;    #<--Rose-Hulman's DNS servers (according to my laptop, at least)
 
option domain-name "rose-hulman.edu";
 
  
subnet 192.168.1.0 netmask 255.255.255.0 {
+
This ifdown ifup method has worked every time for me so far but if anyone can find a way to prevent having to do this almost every time please feel free to edit this
range 192.168.1.14 192.168.1.14;  #<--You can specify a larger range; I used this to force my BeagleBoard to always have the same IP so I could add an entry for that IP in /etc/hosts
 
}
 
</pre>
 
You may need to edit /etc/default/dhcp3-server to specify the interface for the DHCP server
 
<pre>INTERFACES="eth0"</pre>
 
Then restart the DHCP server service
 
<pre>sudo service dhcp3-server restart</pre>
 
  
You may need to reboot your host machine, and it may be necessary to run the command above to restart the DHCP server every time you boot (I'm not sure if it starts appropriately at boot).
+
== Fixing Problems ==
  
Now connect the BeagleBoard to the host machine with a crossover Ethernet cable and boot the Beagle.  After booting, run 'ifconfig' to see if the Beagle was assigned an IP address.  If it does not have an IP address, try running the command 'dhclient usb0'.
+
=== Kernel Boot Problems ===
  
Once the Beagle does have an IP address, try
+
[http://processors.wiki.ti.com/index.php/Kernel_-_Common_Problems_Booting_Linux Here] is a link with some suggestions of what to do if your kernel isn't booting properly.
<pre>ping -c 3 -W 10 www.google.com</pre>
 
to test if the setup is working correctly.  If it complains about a bad name, the DNS servers are incorrect; try pinging a specific IP such as 8.8.8.8 to see if packets get through (though unless you want to rely on all IP addresses, you will need to get some DNS servers that work).
 
  
==Using u-boot to specify a MAC address at boot==
+
=== Serial port garbage ===
The BeagleBoard has a problem where Linux will randomly select a MAC address at boot. In order to get around this, [http://maxgalemin.blogspot.com/2010/11/patch-for-fixing-random-mac-address-on.html one blogger] provides a patch to enable a kernel command line parameter to set a MAC address. Below is one way to apply, your mileage may vary.
 
  
# Make sure your kernel compiles and boots.
+
If you are having trouble with garbage on the console, this might help. Sometimes the serial port times out.   Most of the time it just generates some junk which can be cleared with CTRL-U or backspace. However, if it happens at the login prompt then getty thinks the terminal is 7-bit with parity (rather than 8-bit raw). If this happens and you continue to login the whole session appears to be scrambled - if you press CTRL-D you can login again provided you don't stop typing... :]
# Grab the patch, and open it with gedit
+
I have simply added the following two lines to root's <code>.profile</code>:
# Open .../git/drivers/net/usb/smsc95xx.c
+
<pre>
# Go to line 64-ish, and look for a place to insert the first code with plus signs preceding each line. Remove the plus signs.
+
stty -parenb -parodd cs8 -inpck -istrip
# Go to 656-ish, and repeat for the other block of code.
+
echo 0 > /sys/class/tty/ttyS2/device/sleep_timeout
# Save and re-compile.
+
</pre>
# Install the new kernel as normal.
+
A better fix would probably be to just add the second line to a rc.d startup script somewhere.
# Go to u-boot, and edit ../include/configs/omap3_beagle.h
+
 
# Change mmcargs, nandargs, and ramargs to include a parameter for "ethaddr=...", where ... is your MAC address.
+
This suggestion came from this [http://groups.google.com/group/beagleboard/browse_thread/thread/d23c15e3c9fcb8fc posting].
# Save, close, recompile.
 
# Install the new u-boot as normal.
 
# Register your MAC Address via any method that works, and enjoy reduced-hassle internet access on your Beagle.
 
# Optionally, Update opkg.
 
  
== Tools chain work flows ==
+
== Getting help from a news group ==  
  
[http://www.angstrom-distribution.org/some-usefull-workflow-blogs Here] is a link to a list of workflows for various tool chains.
+
[http://groups.google.com/group/beagleboard/msg/db315d63de2a522a Here's] a nice tip on what to do before posting a question to a news group.
  
I ran out of space on my Linux (Ubuntu) partition, so I opted to do all my development on an external hard drive. This works just fine, except that the drive is labeled  and the space in there causes problems in some of the setup scripts. It is possible to add an entry inhat mounts the device with a certain name, but this is very cumbersome, for many reasons. Instead, I used to change the label on my external drive.
+
{{YoderFoot}}

Revision as of 18:42, 3 December 2016

thumb‎ Embedded Linux Class by Mark A. Yoder


Some useful tips and tricks for Linux and the Beagleboard.

Interesting Links

Since we are working with the open source community, you need to know where the action is. Here are some useful links to what's happening in the Beagle community.

Linux

Learn UNIX in 10 Minutes is a quick overview of the most commonly used Linux commands.

Top 10 Tools is a nice summary of 10 of the most useful Linux commands.

Quick Tips

Tip Description
host$ gnome-open
Open a file or directory using the default program
Give the IP address a name Inside /etc/hosts add a line of the form <IP address> <alias> this will allow you to refer to the host by name.
beagle$ ntpdate ntp.org
beagle$ rm /etc/localtime
beagle$ ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
This will go to a network time protocol server and get the current time and set the Beagle to it and set the local time zone. [1]
beagle$ mount -t debugfs debugfs /sys/kernel/debug/
beagle$ cd /sys/kernel/debug
beagle$ ls
Kernel Debug Info

Connecting to RHIT wifi

There is a discussion in the Beagle Google Group about getting wireless working with the bone.

Use these settings for connecting to the Rose-Hulman wireless network:

  • SSID: RHIT-1X
  • Security: WPA & WPA2 Enterprise
  • Leave "anonymous identity" blank
  • CA Certificate: (None)
  • PEAP version: Version 0
  • Inner authentication: MSCHAPv2
  • Use your Rose username and password

bash

Tip Description
Ctrl-r Reverse incremental search
Ctrl-g Abort command
Esc-. Insert last argument from last command

ssh

Suspending ssh

Most programs can be suspended by typing ^z (Ctrl-z). If you have an ssh connection to another machine you can suspend it by entering ~^z. You can resume the connection by entering fg.

ssh and X-windows

When using ssh between two X-windows systems try

host$ ssh -CX root@beagle

The -X set the DISPLAY variable on the remote machine so you can open windows from the beagle on your host machine.

The -C compressed the data over the link. Good for slow connections.

vnc

You can run a vnc server on the Beagle. Install it with:

beagle$ apt-get update
beagle$ apt-get install x11vnc

Install a password with

beagle$ x11vnc -storepasswd

Run it on the Beagle with

beagle$ x11vnc -display :0 -ssl -usepw -forever -q &

On your host, connect to it with:

Applications:Internet:Remote Desktop Viewer

Authorizing ssh

ssh and scp can be set up for automatic authorization so you don't have to enter your password when using these commands. Here's how to do it. First let's see what's already there:

  • On your Beagle run
beagle$ ls ~/.ssh

~/.ssh may not exist, if not, it will be created. If it's there, check the files in it.

  • On your host computer run
host$ ssh-copy-id root@beagle

It will ask for your beagle password and then copy the needed files to it.

  • Back on the beagle to see what has changed:
host$ ssh -CX root@beagle
beagle$ ls ~/.ssh

The ssh command shouldn't ask for a password. What new files appeared?

ssh configuration

Here's a nice tip so you don't have to remember who to login as on the beagle. On your host, put the following in ~/.ssh/config.

Host beagle
   User root
   UserKnownHostsFile /dev/null
   StrictHostKeyChecking no

Before you had to

host$ ssh -CX root@beagle

Now you can just

host$ ssh -CX beagle

Mounting dfs/afs

You can set up your Linux box to directly mount your afs and dfs files. The Rose-Hulman Linux Users' Group has a nice page with the details .

After installing sshfs I added the following to my /etc/fstab file:

sshfs#username@dfs.Rose-hulman.edu:/DFS/MyDocs/username /home/username/MyDocs fuse user,noauto,uid=1000,gid=1000 0 0
sshfs#username@dfs.rose-hulman.edu:/DFS/Users/Y/username /home/username/dfs-home fuse user,noauto,uid=1000,gid=1000 0 0
sshfs#username@afs.rose-hulman.edu: /home/username/afs-home fuse user,noauto,uid=1000,gid=1000 0 0

You'll have to replace username with your login name. Then create the mount points:

host$ cd ~
host$ mkdir MyDocs
host$ mkdir dfs-home
host$ mkdir afs-home

Now you can mount your files by using:

host$ cd ~
host$ mount dfs-home
host$ cd dfs-home
host$ ls

You should now see your dfs files. You can unmount using:

host$ cd ~
host$ sudo umount dfs-home

byobu - A Screen Manager

For years Unix has had screen which is a screen manager. byobu is wrapper for screen that puts a nice face on it. You can run byobu on your host computer and on the Beagle. With byobu you can start a long running program (bitbake for example) in one terminal and detach from the terminal and the program will keeping running in the background. Using byobu you can later attach to the program (possibly from another terminal) and see how the program is progressing.

Install byobu with:

host$ sudo apt-get update
host$ sudo apt-get install byobu

Now you can run it.

beagle$ byobu

You'll see a command prompt. You'll also see some status information on the bottom two lines. Type Ctrl-A ? for help. Type Ctrl-A Ctrl-D to detach from the session. Running byobu again will reattach you to the session. Try running byobu in two windows at the same time. You should see the same session in both.

Backing up an SD card with dd

Here's the command I use to backup an SD card. I use System:Administration:Disk Utility to figure out the path to the card. In this case it's /dev/sdc

host$ sudo time dd if=/dev/sdc of=FIE2011.img bs=4M count=1000
host$ sudo chown yoder:yoder FIE2011.img
host$ md5sum FIE2011.img > FIE2011.img.md5
host$ bzip2 -k FIE2011.img

It takes about 5 minutes to dd a 4G card, 1.2 minutes for md5 and bzip2 takes about 23 minutes.

It looks like the 7z compression is becoming popular. Use it via

host$  7za a FIE2011.img.7z IFE2011.img

It took 16 minutes. The file size is 454M compared to 628M. Wow, faster and smaller.

Local Ubuntu Update Mirror

Darryl Mouck in CSSE has passed this on...

We host a local mirror for all ubuntu updates. This is from the current distro back to hardy; it hosts every distro that ubuntu currently supports.

In order to get your system to point to our mirror follow the directions here.

Using pico DLP with BBB

Put this in uEnv.txt to use the BBB with a pico DLP.

optargs=video=HDMI-A-1:640x480@60

systemd journal taking too much time/space

If you are running out of space because of the systemd journal try this Google Group Suggestion

Getting the BeagleBone to work with unusual network managers

If you plugged in your BeagleBone, but you just can't get it to pop up a page at 192.168.7.2 (aka your browser says "could not connect" or "time out"), then the following steps should help.


First run

host$ ip a

This will list a bunch of network interfaces. You should see one that looks odd and long like

enp0s29u1u5

That is the interface for the BeagleBone. Now, to get the BeagleBone to communicate with your host over USB serial, run

host$ sudo dhcpcd enp0s29u1u5

If this is successful, you should see your interface in the output of the command below. Its state should be UP.

host$ ifconfig

Windows

Most of the work is done under Linux; however there are some handy Windows-based tools.

Serial Port

SecureCRT is a good program that gives you both access to a serial port and is also an ssh client. Rose has a license for SecureCRT.

Tera Term also gives you access to the serial port and it's free.

Notepad++

Notepad++ is a nice text editor for Windows.

Mac OS X

Mounting the BeagleBone filesystem locally

1. Download and install OSXFUSE and SSHFS from github official page in the respective order.

2. In Terminal do

host$ mkdir /Volumes/Beagle
host$ sshfs root@beagleIPaddr:/ /Volumes/Beagle

Set up on the BeagleBoard

Accessing the Beagle via the Serial Port

During boot up the Beagle logs various messages on the serial port. You can see these messages by:

  • See what USB/tty devices are already attached to your host
host$ ls /dev/ttyU*
  • Attach a serial to USB converter to your host computer and the Beagle's serial port.
  • See what new USB/tty devices appeared
host$ ls /dev/ttyU*
  • On my host, /dev/ttyUSB1 appeared. On the host computer run
host$ screen /dev/ttyUSB1 115200

where ttyUSB1 is what appeared when you plugged in your converter.

You are now talking to your Beagle's serial port. Login quickly. There appears to be a bug that makes garbage appear on your screen if you wait too long. Try

beagle$ shutdown -r now

You will see the shutdown messages, followed by the U-boot messages. After a 3 second (or so) delay you will see the kernel booting.

Tip 1: Ctrl-a H will cause the data on the serial port to be logged. See

host$ man screen

for help.

Tip 2: <F6> will disconnect from the session. You can reconnect later.

Setup a USB Wireless Device on Beagle

(Here are instructions on setting up a Belkin USB dongle.)

The device I used to setup a wireless connection on the Beagle Board was the Linksys Compact Wireless-G USB Network Adapter with SpeedBooster.

I first opened the wpa_supplicant.conf file to setup my networks:

beagle$ cd /etc
beagle$ gedit wpa_supplicant.conf &

This file is filled with numerous examples of possible wireless configurations for you to basically fill in. After looking at the examples, I scrolled down to the bottom of the page and set up two networks: one for home and one for school. Here are examples of my setup networks:

#Home Network
network={
        ssid="YourHomeNetworkName"
        psk="YourHomeNetworkPassword"
}

#School Network
network={
        ssid="RHIT-1X"
        proto=WPA
        key_mgmt=WPA-EAP
        pairwise=CCMP
        group=TKIP
        eap=PEAP
        phase1="peapver=0 peaplabel=0"
        phase2="auth=MSCHAPV2"
        scan_ssid=1
        identity="YourSchoolUsername"
        password="YourSchoolPassword"
}

For the network examples above,the quotation marks actually belong there but replace the Your.... areas with your corresponding information. No <space> before the first quotation mark.When finished editing save and exit this file. The information for the RHIT school network was found here:RHLUG

Now you must specify that this is the file to use for the wireless device:

beagle$ cd network
beagle$ gedit interfaces &

This file will display all of the different types of Internet connections you have setup. To use the wpa_supplicant.conf file, scroll down to around line 42 of the code and uncomment the configuration for wpasupplicant. After doing this make sure all of the above lines mentioning anything about wlan0 are commented out. Return back to where it says "iface wlan0 inet dhcp" that you uncommented around line 42. Add "auto wlan0" above this line, make sure the line "wpa-conf /etc/wpa_supplicant.conf" is uncommented below the iface line, and change the wpa-driver line below that line to wext. So after all of that the code in this file for the wireless device should be the following:

auto wlan0 
  iface wlan0 inet dhcp
     wpa-conf /etc/wpa_supplicant.conf
     wpa-driver wext

NOTE: the auto wlan0 command in this file means that this device will load at boot time. You can take the time in here now to comment out any interfaces you don't use like auto usb0 to make these devices not load at boot time, which will increase the speed at which you boot up. Save and exit this file

Once you have finished this you can either restart the Beagle Board or:

beagle$ cd
beagle$ /etc/init.d/networking restart

I've found that a lot of the time the interface doesn't receive an IP address when it boots up. If you run ifconfig in the terminal you should see your wireless device connected to a network. If it is connected but no IP address I do the following:

beagle$ ifdown wlan0
# it will report messages here and then
beagle$ ifup wlan0
# more messages and it should report connecting and having an IP address

This ifdown ifup method has worked every time for me so far but if anyone can find a way to prevent having to do this almost every time please feel free to edit this

Fixing Problems

Kernel Boot Problems

Here is a link with some suggestions of what to do if your kernel isn't booting properly.

Serial port garbage

If you are having trouble with garbage on the console, this might help. Sometimes the serial port times out. Most of the time it just generates some junk which can be cleared with CTRL-U or backspace. However, if it happens at the login prompt then getty thinks the terminal is 7-bit with parity (rather than 8-bit raw). If this happens and you continue to login the whole session appears to be scrambled - if you press CTRL-D you can login again provided you don't stop typing... :] I have simply added the following two lines to root's .profile:

stty -parenb -parodd cs8 -inpck -istrip 
echo 0 > /sys/class/tty/ttyS2/device/sleep_timeout

A better fix would probably be to just add the second line to a rc.d startup script somewhere.

This suggestion came from this posting.

Getting help from a news group

Here's a nice tip on what to do before posting a question to a news group.




thumb‎ Embedded Linux Class by Mark A. Yoder