ECE497 Tips and Tricks

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.


 * Adafruit's BeagleBone site.
 * State of the Beagle 2011, learn about the Beagle's past, present and future.
 * BeagleBoard.org, the starting point for all thing Beagle.
 * Beagle Discussion Group, lot's of good information here, but you'll have to dig a bit. Subscribe and follow the discussion.
 * blogspot, see what is being said about the Beagle.
 * eLinux, this is where this page is being hosted. It's about embedded Linux in general, not just the BeagleBoard.
 * Free Electrons Beagle Board Training, some good labs about what makes embedded Linux run.
 * TI Embedded Speech Recognizer (TIesr) is a fixed-point recognizer written in C++ and C.
 * Google Summer of Code. BeagleBoard is an accepted organization.
 * Linux Kernel Map
 * Texas Instruments Embedded Processors Wiki

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.

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

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

ssh and X-windows
When using ssh between to 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$ opkg update beagle$ opkg 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: host$ vinagre or 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 was ask for you 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  I added the following to my   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  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

debugfs
debugfs looks like a handy way to look into the kernel. These notes are based on the example here.

beagle$ cd / beagle$ mkdir debugfs beagle$ mount -t debugfs none debugfs

Then explore...

bone$ cd debugfs; ls -F asoc/  gpio       mmc0/      pm_debug/   sched_features  vram bdi/   hid/       musb/      regdump     testmode        wakeup_sources clock/ memblock/  omap_mux/  regulator/  usb/

beagle$  cd debugfs; ls -F asoc/ clock/  hid/   omapdss/   sched_features  usb/ bdi/  gpio    mmc0/  pm_debug/  tracing/        vram

Tool chain work flows
Here is a link to a list of workflows for various tool chains.

On the Beagle
On the Beagle under Angstrom you use opkg to manage packages. Start with

beagle$ opkg update

This updated the local database with the current version information. Then

beagle$ opkg list > /tmp/list beagle$ less /tmp/list

will list all the available packages. You can also search here [1] to see what packages are available.

[1] www.angstrom-distribution.org/repo/

On the host
There are tree command that I use for managing packages.


 * dpkg
 * is used for listing what packages are installed.


 * synaptic
 * is a GUI-based package manager. I used it to discover new packages to install.


 * apt-get
 * is used to install and update packages.

For example, let's suppose you run make menuconfig and the error message says *** Install ncurses (ncurses-devel) and try again.

Let's see what's installed. host$ dpkg -l > /tmp/list host$ grep curses /tmp/list ii libncurses5      5.7+20090803-2ubuntu3  shared  libraries for terminal handling ii libncursesw5     5.7+20090803-2ubuntu3  shared libraries for terminal handling (wide ii  mtr-tiny         0.75-2build1           Full screen ncurses traceroute tool ii  ncurses-base     5.7+20090803-2ubuntu3  basic terminal type definitions ii  ncurses-bin      5.7+20090803-2ubuntu3  terminal-related programs and man pages

Hmmm... there's something related to ncurses installed, but the error says something about ncurses-devel. Let's fire up synaptic host$ synaptic & Enter ncurses-devel in the search field.

The green dot in the S column says the package is installed. libncurses5-dev isn't installed. Install it with: host$ sudo apt-get install libncurses5-dev

And now your make should work.

byobu - A Screen Manager
For years Unix has had  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 on your host with:

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

It's a bit harder on the Beagle. beagle$ opkg update beagle$ opkg install screen Go to here and download the latest version to your Beagle. beagle$ tar zxvf byobu_*.orig.tar.gz beagle$ cd byobu* and follow the instructions in INSTALL. I had to hack one file. beagle$ gedit /usr/local/lib/byobu/.constants.

Change the last two lines to:

export SED="sed" export READLINK="readlink"
 * 1) command -v gsed >/dev/null && export SED="gsed" || export SED="sed"
 * 2) command -v greadlink >/dev/null && export READLINK="greadlink" || export READLINK="readlink"

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.

Hmmm.... I had to reinstall and it doesn't seem to be working now.

Finding what opkg installed
Once you've run opkg, how do you know what's been installed? Take a look in /var/lib/opkg/info or /usr/lib/opkg/info. The files that end in .list contain a list of what's been installed.

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.

CSSE's Linux reference page
CSSE332, Operating Systems, has a nice page of Linux resources.

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, please copy and paste this rather lengthy command into a terminal:

host$ '''sudo cp /etc/apt/sources.list{,.old} && \ sudo sh -c '\ . /etc/lsb-release && echo " deb http://ftp.csse.rose-hulman.edu/ubuntu $DISTRIB_CODENAME main restricted universe multiverse deb http://ftp.csse.rose-hulman.edu/ubuntu $DISTRIB_CODENAME-updates main restricted universe multiverse deb http://ftp.csse.rose-hulman.edu/ubuntu $DISTRIB_CODENAME-security main restricted universe multiverse " > /etc/apt/sources.list' && sudo apt-get update

The text and further instructions are available here.

The script makes a backup of the updates file and replaces it with links to our mirror. The $DISTRIB_CODENAME is replaced by whatever distro you are running (eg. lucid, maverick, natty etc.). I wish I could take credit for it, but it was a joint effort with Mike McLeish :-)

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

Mounting the BeagleBone filesystem locally
Do you have a favorite text editor that you want to use to edit the code on the BeagleBone without having to copy the files back and forth? Then SSHFS is the solution for you.

First install SSHFS. On Ubuntu host$ sudo apt-get install sshfs on Arch Linux host$ sudo pacman -Sy sshfs on Fedora host$ sudo yum install sshfs

Then enable the kernel module called fuse host$ sudo modprobe fuse

Now make sure the following command results in the output below host$ systemctl list-units --all|grep fuse sys-module-fuse.device   loaded active   plugged       /sys/module/fuse If not, then run host$ sudo systemctl enable fuse

Finally, mount the filesystem on the BeagleBone to a folder on your host using host$ sshfs USERNAME@HOSTNAME_OR_IP:/BEAGLEBONE_PATH LOCAL_MOUNT_FOLDER SSH_OPTIONS I use (no SSH options) host$ cd /mnt host$ sudo mkdir BeagleBone host$ sudo chown $USER:$USER BeagleBone host$ chmod 777 BeagleBone host$ sshfs root@192.168.7.2:/ /mnt/BeagleBone host$ cd BeagleBone host$ ls

You will see the fines on your Bone.

This also works for mounting files on your host on your Bone.

More tips
GigaMegaBlog has some nice tips for the BeagleBone, many of which apply to the -xM.

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.

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

Setup stuff on github
If you've cloned the course github site ([EBC Exercise 05 Getting Exercise Support Materials]]) you will find set up things in exercises/setup. install.sh is a list of various things I to to a fresh SD card to 'move in'. For example, the bone will mount a filesystem on the host computer if it's connected via USB. You can turn this off and have the eithernet over USB run at boot time with:

cd /lib/systemd/system/basic.target.wants rm storage-gadget-init.service ln -s ../network-gadget-init.service.
 * 1) Turn off storage gadget, turn on network at boot time.

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:

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

host$ byobu /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 byobu for help.

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

Installing Ubuntu
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.

I followed the instructions from here and 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 SPEd image.

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.

Installing Always Innovating's Super Jumbo
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. Here's a video showing what it can do.

I've put a copy of the compressed image on my DFS site. Feal free to play with it. Here's a wiki that shows how to switch between OS's on the fly.

Resizing an SD card partition via the Beagle
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 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.

beagle$ 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 beagle$ cp ramdisk.gz /media/mmcblk0p1/ beagle$ shutdown -r now

I halted the board during reboot and did: 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

I allowed it to boot and did:

beagle$ umount /dev/mmcblk0p1 beagle$ umount /dev/mmcblk0p2 beagle$ 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. beagle$ umount /dev/mmcblk0p2 beagle$ 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. beagle$ shutdown -r now

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?

Sharing Laptop Internet Connection with BeagleBoard
Moved to EBC_Exercise_02_Internet_Connection_via_the_Host

Using u-boot to specify a MAC address at boot
The BeagleBoard has a problem where Linux will randomly select a MAC address at boot. In order to get around this, 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.


 * 1) Make sure your kernel compiles and boots.
 * 2) Grab the patch, and open it with gedit
 * 3) Open .../git/drivers/net/usb/smsc95xx.c
 * 4) 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.
 * 5) Go to 656-ish, and repeat for the other block of code.
 * 6) Save and re-compile.
 * 7) Install the new kernel as normal.
 * 8) Edit the kernel command line. There are two ways to do this:
 * 9) Edit the uBoot source and recompile
 * 10) Go to u-boot, and edit ../include/configs/omap3_beagle.h
 * 11) Change mmcargs, nandargs, and ramargs to include a parameter for "ethaddr=...", where ... is your MAC address.
 * 12) Save, close, recompile.
 * 13) Install the new u-boot as normal.
 * 14) Edit the boot.scr file
 * 15) See  Modifying Kernel Command Line Parameters
 * 16) Register your MAC Address via any method that works, and enjoy reduced-hassle internet access on your Beagle.
 * 17) Optionally, Update opkg.

Rename an External Storage Device
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 "Expansion Drive" and the space in there causes problems in some of the setup scripts. It is possible to add an entry in /etc/fstab that mounts the device with a certain name, but this is very cumbersome, for many reasons. Instead, I used this [1] very helpful guide to change the label on my external drive.

[1] help.ubuntu.com/community/RenameUSBDrive

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: network={ ssid="YourHomeNetworkName" psk="YourHomeNetworkPassword" }
 * 1) Home 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 before the first quotation mark.When finished editing save and exit this file. The information for the RHIT school network was found here:RHLUG
 * 1) School Network

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 beagle$ ifup wlan0
 * 1) it will report messages here and then
 * 1) 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

Development tips for bitbake and oe
Gumstix Development Tips appears to have some good ideas that can apply to the Beagle too.

Point to a given git snapshot
The original SD card image came from here. The file ec2buld.sh shows how the image was build. There are a couple of interesting things in this file.

Line 564 shows an additional git repository was used.

host$ cd sources/openembedded host$ git remote add myrepo git://gitorious.org/~Jadon/angstrom/jadon-openembedded.git host$ git remote update

Run this git command to get access to this repository. (It took about 2 minutes at 6:20am.) Line 21 shows the hash tag for the build.

ANGSTROM_REPO_ID=24805033b1205acc35f8b4d75cc42f8b9c2a1b38

If we pull from this tag we will have the same files as were used to generate the SD image. So do the following

host$ git checkout 24805033b1205acc35f8b4d75cc42f8b9c2a1b38

This takes about 10 seconds.

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 : 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.

Turning off gpe
The following worked last year, but doesn't seem to work now.

Running above will write on top of what Angstrom is doing. You can turn off the display manager by using: /etc/init.d/gpe-dm stop Replace  with   if you want to run it again.

Details of making your own MLO
Hardware Environment for a BeagleBoard XM with JTAG

Software Environment for a BeagleBoard XM with JTAG

This might make a good lab.

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