ECE497 Tips and Tricks

Some useful tips and tricks for Linux and the Beagleboard.

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 to X-windows systems try

host$ ssh -CY root@beagle 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.

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

host $ ssh-keygen host $ cd ~/.ssh host $ sftp Beagle put id_rsa.pub exit host $ ssh Beagle 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. beagle $ mkdir ~/.ssh beagle $ cd ~/.ssh beagle $ mv ../id_rsa.pub. beagle $ cp id_rsa.pub authorized_keys beagle $ exit 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. host $ ssh Beagle 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.
 * On your host computer run
 * On your Beagle run
 * Back on the host computer:

Here is move information on ssh authorization.

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:/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@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: cd ~ mkdir MyDocs mkdir dfs-home mkdir afs-home Now you can mount your files by using: cd ~ mount dfs-home cd dfs-home ls You should now see your dfs files. You can unmount using: cd ~ sudo umount dfs-home

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

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.

Sharing Laptop Internet Connection with BeagleBoard
Two options: One uses Ubuntu's GUI network connections manager, the other requires modifying things yourself.

Option 1 - Using Ubuntu Network Connections GUI
 * 1) In Ubuntu, go to System -> Preferences -> Network Connections
 * 2) 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.)
 * 3) Click the 'IPv4 Settings' tab and change 'Method' to 'Shared to other computers'
 * 4) Click apply
 * 5) Restart Ubuntu
 * 6) Connect the BeagleBoard to the laptop with the crossover Ethernet cable
 * 7) 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

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.

A number of steps were taken from the Ubuntu Community Documentation.

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: sudo ifconfig eth0 192.168.1.13 If you don't want to configure this after every boot, add an entry to /etc/network/interfaces with the following: auto eth0 address 192.168.1.13 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255

On the host machine, configure the IP tables to use NAT translation for routing packets: sudo iptables -A FORWARD -o wlan0 -i eth0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -A POSTROUTING -t nat -j MASQUERADE To avoid having to setup the IP tables after every boot, save the IP tables sudo iptables-save | sudo tee /etc/iptables.sav And add the following command to /etc/rc.local (or other appropriate file for your distribution) to be run at boot iptables-restore < /etc/iptables.sav

IP forwarding needs to be enabled: sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" To make sure this is set after rebooting, add these lines to /etc/sysctl.conf: net.ipv4.conf.default.forwarding=1 net.ipv4.conf.all.forwarding=1

Install the DHCP server software sudo apt-get install dhcp3-server And edit the configuration file /etc/dhcp3/dhcpd.conf (comment out any already existing lines other than "ddns-update-style none;") 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";
 * 1) Added for DHCP with BeagleBoard

subnet 192.168.1.0 netmask 255.255.255.0 { 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 } You may need to edit /etc/default/dhcp3-server to specify the interface for the DHCP server INTERFACES="eth0" Then restart the DHCP server service sudo service dhcp3-server restart

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

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

Once the Beagle does have an IP address, try ping -c 3 -W 10 www.google.com 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
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) Go to u-boot, and edit ../include/configs/omap3_beagle.h
 * 9) Change mmcargs, nandargs, and ramargs to include a parameter for "ethaddr=...", where ... is your MAC address.
 * 10) Save, close, recompile.
 * 11) Install the new u-boot as normal.
 * 12) Register your MAC Address via any method that works, and enjoy reduced-hassle internet access on your Beagle.
 * 13) Optionally, Update opkg.

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

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

(For some reason, it is not letting me make a link out of that. It doesn't like the http:// at the beginning of it.)