OK, Flat is Better

OK, flat and messy is better for databases.  If the data exists already get it in a database first and then add structure that you need later.

Don’t waste time on what you never need.

Beaglebone ECAP PWM Input: Part 2 Setting Up the Kernel

Wow, setting up Angstrom’s openembedded/bitbake environment is hard.  First off, DO NOT USE WIRELESS.  There is something with my wireless router that causes some of the getline stuff to fail.  This cost me hours.  Also, this seems to take a lot of space so don’t put it on a VM disk.

OK …

Step 1, git the environment (git the pun?):


cd ~;mkdir oe;cd oe
git clone git://github.com/Angstrom-distribution/setup-scripts.git

Step 2, make the systemd-image


cd ~/oe/setup-scripts
MACHINE=beaglebone ./oebb.sh config beaglebone
MACHINE=beaglebone ./oebb.sh update
MACHINE=beaglebone ./oebb.sh bitbake systemd-image

Wait a good long while for the fetching, compiling, and all that to complete.

Step 3, load the systemd-image onto your card
Now you need to get a micro-SD card to put your new system image on. Don’t use the one that came with your beaglebone — this will just cause you stress if something goes wrong. First you have to format the card with a boot and root partition. I used this script:


wget http://www.angstrom-distribution.org/demo/beaglebone/mkcard.txt
mv mkcard.txt mkcard.sh;chmod +x mkcard.sh

Now, guess what? Some volume manager thing is going to start messing with you. (Things were a lot easier back in the day before logical volume management when a disk was a disk). When mkcard.sh run kpartx, the lvm stuff grabs your new partition on the sd card and won’t let you play with it. Anyway, do this as root:


# plug the card into your USB reader
dmesg # note the new device -- make sure it is your card and not your harddisk
# assume here the new drive is sdg
./mkcard.sh /dev/sdg
dmsetup ls
dmsetup remove sdg2  # if you see sdg2 in the dmsetup ls
dmsetup remove sdg1 # if you see sdg1 in the dmsetup ls
vi mkcard.sh # comment out the kpartx
   #if [ -x `which kpartx` ]; then
   #       kpartx -a ${DRIVE}
   #fi
./mkcard.sh 
./mkcard.sh /dev/sdg

Great, now you have a card all setup. Now …


mkdir /mnt/boot
mkdir /mnt/Angstrom
mount /dev/sdg1 /mnt/boot
mount /dev/sdg2 /mnt/Angstrom
cd ~username/oe/setup-scripts/build/\
tmp-angstrom_v2012_05-eglibc/deploy/images/beaglebone
cp MLO /mnt/boot
cp u-boot.img /mnt/boot
cp uImage-beaglebone.bin /mnt/boot/uImage
tar -xjv -C /mnt/Angstrom/ -f systemd-image-beaglebone.tar.bz2
umount /mnt/boot
umount /mnt/Angstrom

Ok, go boot your card and make sure your beaglebone is working. sshd is enabled so you just have to figure out the IP address of it and then ssh to it and do the opkg thing. I use the i2c bus stuff and gdb to look at my user space programs that puke:


ssh root@192.168.1.113
# password is just return

opkg update
opkg install i2c-tools i2c-tools-dev
opkg install gdb
opkg install gcc gcc-symlinks
opkg install cpp cpp-symlinks
opkg install libtool libtool-symlinks
opkg install g++ g++-symlinks
opkg install binutils-dev vim binutils-symlinks
opkg install libstdc++-dev
opkg install make

Step 2, build the environment:
Back on your non-wireless development machine. Time to setup the kernel build environment.


cd ~/oe/setup-scripts
MACHINE=beaglebone ./oebb.sh configure beaglebone
MACHINE=beaglebone ./oebb.sh update
MACHINE=beaglebone ./oebb.sh -c compile virtual/kernel
MACHINE=beaglebone ./oebb.sh i2c-tools
cd ~
# create softlink of big nasty directory to ~/bbl 
ln -s ~/oe/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-ti33x-psp-3.2.23-r14h+gitr720e07b4c1f687b61b147b31c698cb6816d72f01/git bbl

Step 3, write the env setup script
You want to do normal makefile stuff as you are making changes to the kernel area. To setup the environment save this script to a file bb_env_setup.


#!/bin/bash

echo "Running bitbake environment dump"
cd ~/oe/setup-scripts
MACHINE=beaglebone ./oebb.sh bitbake -e > bb_env_dump.txt

echo "Starting to set environment variables"
eval `grep "^export PKG_CONFIG_PATH=" bb_env_dump.txt`
eval `grep "^export PKG_CONFIG_SYSROOT_DIR=" bb_env_dump.txt`
eval `grep "^TARGET_SYS=" bb_env_dump.txt`
export TARGET_SYS
CROSS_COMPILE=${TARGET_SYS}-
export CROSS_COMPILE


eval `grep "^STAGING_DATADIR=" bb_env_dump.txt`
export STAGING_DATADIR


eval `grep "^export TARGET_CFLAGS=" bb_env_dump.txt`
eval `grep "^export TARGET_LDFLAGS=" bb_env_dump.txt`
eval `grep "^export PATH=" bb_env_dump.txt`

Step 4, build the kernel
Ok, run the environment setup script


. ./env_bb_setup

Now to build do:


cd ~/bbl
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage
# note that you can build specific files from the bbl directory with
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- drivers/pwm/pwm.o

This takes a while the first time. After that, it will only pick up your changes.

MAKE SURE YOU BACKUP YOUR CHANGES OUTSIDE OF THIS DIRECTORY STRUCTURE. It is very easy to mess this structure up if you need to rebuild the systemd-image.

Step 5, replace the kernel on your card and go
This is straight forward. Plug your card into your USB reader.


dmesg  # assume the card is sdg
mount /dev/sdg1 /mnt/boot
mount /dev/sdg1 /mnt/Angstrom
cd ~username/bbl/arch/arm/boot
cp uImage /mnt/boot/uImage  # say 'y' to overwrite
cp uImage /mnt/Angstrom/boot/uImage-3.2.23  # or whatever the version is, say 'y' to overwrite
umount /mnt/boot
umount /mnt/Angstrom

Pull the card and place in beaglebone and boot

Step 6 repeat 4 and 5 with your changes
Go into your kernel areas and start making changes. For me, the best thing to do would be to just add a:


printk(KERN_EMERG "filename: i am here\n")

to the driver probe function to make sure changes I make appear when I run dmesg after boot.


ssh root@192.168.1.113

dmesg | grep "i am here"  # you should see your log

Don’t do what I did and write a bunch of code only to learn that you weren’t properly copying over the uImage. This cost me more hours to my life.

Step 7 see a future post
I will start documenting the changes I am making to the drivers/pwm/ area of the linux kernel to bring in the pwm capture function.

Evil at 2.67 GHz

I am threatening the computer. “Do what I want or I will hurt you.” The computer is grinding its hard disk back. Its got 2 cores, each running evil at 2.67 GHz.

My computer runs a SIP client. One day when I was cursing the computer, the computer decided (on purpose?) to auto answer the phone. D’s little friend’s voice trembled as she said “uh, Mr. Erg?”

We are in the Terminator times.

Using Consolehelper to enable PPTP login

I use fedora core 10 on a linux server that I assign a static IP to.  I also log into my work using PPTP on this same computer.  While Network Manager seems to handle the static IP, I could not get it to bring up the PPTP session.  I finally gave up and decided to configure the PPTP session manual.

I wrote 2 scripts: goWork and stopWork (note that Work is capitalized).  I wanted to run this when I pressed an icon on the gnome tool bar but these scripts need to run as root.  After some research, I found that I wanted to use /usr/bin/consolehelper.

To enable this I did the following (note there is a punch line at the end):

  1. Put goWork and stopWork in /usr/sbin.
  2. chmod 755 /usr/sbin/goWork and chmod 755 /usr/sbin/stopWork
  3. Added files named goWork and stopWork in /etc/security/console.apps
  4. Added files named goWork and stopWork in /etc/pam.d/
  5. Added links in /usr/bin pointing to consolehelper
  6. Added application-launchers on the gnome panel to goWork and stopWork

The problem is it didn’t work at all.  There are a bunch of options in the /etc/security/console.apps and /etc/pam.d files so I got to spend hours trying different things out.  Finally, I found something on the web stating that pam.d or consolehelper didn’t work with files with capital letters!  I changed everything to gowork and stopwork and it all worked fine.  Evidentally this is a long term problem (link) from 2005.  Guess this explains why all the Fedora management utilities are named in lower case.

Fedora Core 8 using ‘alternatives’ to install Sun’s jdk

I have some old-ish java software that I needed to get going on Fedora Core 8. The icedtea java stuff never seems to work for me. I usually pull down the java sdk from Sun and then manually change all the things in the path, mozilla directories and my environment variables until I can get java to work. I decide this time to invest some time trying to figure out the right way to do it.
First I installed java (1.6 sdk), Sun now puts their stuff in /usr/java. There is a /usr/java/default link to a latest directory which links to the version I installed.


[root@h ~]# ls -l /usr/java
total 16
lrwxrwxrwx 1 root root   16 2008-08-07 13:18 default -> /usr/java/latest
drwxr-xr-x 9 root root 4096 2008-08-07 13:18 jdk1.6.0_07
lrwxrwxrwx 1 root root   21 2008-08-07 13:18 latest -> /usr/java/jdk1.6.0_07

FC8 has a utility called alternatives. This utility controls the links to standard utilities so that your machine can have different packages of these utilities and you can select which package you use. For example, java (the run time VM):

lrwxrwxrwx 1 root root 22 2008-08-01 09:44 /usr/bin/java -> /etc/alternatives/java
lrwxrwxrwx 1 root root 26 2008-08-18 16:30 /etc/alternatives/java -> /usr/java/default/bin/java

The alternatives utility set this link up. Alternatives has a concept of a master links and slave links. Master links have a name (e.g. java). The master’s slave links follow the master link. When you select a different link with alternatives, it changes the master link and the slave links.

To see the different options for a master link, you can run ‘alternatives –display <name>’. For example:


]# alternatives --display java
java - status is manual.
 link currently points to /usr/java/default/bin/java
/usr/lib/jvm/jre-1.5.0-gcj/bin/java - priority 1500
 slave keytool: /usr/lib/jvm/jre-1.5.0-gcj/bin/keytool
 slave rmiregistry: /usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry
 slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
 slave jre: /usr/lib/jvm/jre-1.5.0-gcj
/usr/java/default/bin/java - priority 2000
 slave keytool: /usr/java/jdk1.6.0_07/bin/keytool
 slave rmiregistry: /usr/java/jdk1.6.0_07/bin/rmiregistry
 slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
 slave jre: /usr/java/default/jre
Current `best' version is /usr/java/default/bin/java.

The output here says that the java link is set manually. (Automatic would set it best on the priority). The link currently points to /usr/java/default/bin/java. You can also see the slave links that go along with it.

To change the link, you can run ‘alternatives –config java’.


]# alternatives --display java
java - status is manual.
 link currently points to /usr/java/default/bin/java
/usr/lib/jvm/jre-1.5.0-gcj/bin/java - priority 1500
 slave keytool: /usr/lib/jvm/jre-1.5.0-gcj/bin/keytool
 slave rmiregistry: /usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry
 slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
 slave jre: /usr/lib/jvm/jre-1.5.0-gcj
/usr/java/default/bin/java - priority 2000
 slave keytool: /usr/java/jdk1.6.0_07/bin/keytool
 slave rmiregistry: /usr/java/jdk1.6.0_07/bin/rmiregistry
 slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
 slave jre: /usr/java/default/jre
Current `best' version is /usr/java/default/bin/java.
[root@fstats ~]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*+ 2           /usr/java/default/bin/java

Enter to keep the current selection[+], or type selection number:

Then you just pick the number you want. The problem now is how do you have Sun’s java as an alternative? After playing around for a bit, here’s the script that worked for me:


#!/bin/bash

alternatives --verbose --install /usr/bin/java java /usr/java/default/bin/java 2000 \
  --slave /usr/lib/jvm/jre jre /usr/java/default/jre \
  --slave /usr/lib/jvm-exports/jre jre_exports /usr/lib/jvm-exports/jre-1.5.0-gcj \
  --slave /usr/bin/keytool keytool /usr/java/jdk1.6.0_07/bin/keytool \
  --slave /usr/bin/rmiregistry rmiregistry /usr/java/jdk1.6.0_07/bin/rmiregistry

alternatives --verbose --install /usr/bin/javac javac /usr/java/default/bin/javac \
2000  --slave /usr/lib/jvm/java java_sdk /usr/java/default \
  --slave /usr/lib/jvm-exports/java java_sdk_exports /usr/lib/jvm-exports/java-1.5.0-gcj \
  --slave /usr/bin/javadoc javadoc /usr/java/default/bin/javadoc \
  --slave /usr/bin/javah javah /usr/java/default/bin/javah \
  --slave /usr/bin/jar jar /usr/java/default/bin/jar \
  --slave /usr/bin/jarsigner jarsigner /usr/java/default/bin/jarsigner \
  --slave /usr/bin/appletviewer appletviewer /usr/java/default/bin/appletviewer \
  --slave /usr/bin/rmic rmic /usr/java/default/bin/rmic

There is stuff out on the web that kind of explains this but I had trouble with a few things. Here is the man entry for the config command:


alternatives [options] --install link name path priority [--slave link name path]... [--initscript service]

The link is the link on your path (e.g. /usr/bin/java) not the link in the /etc/alternatives directory. The name is the master link name (e.g. java). The path is where you new stuff is (e.g. /usr/java/default/bin/java). The slave links have names too.

Terrific, how do you find out what all nasty slave links and names should be in your ‘alternatives –config’ command line? You can look at ‘alternatives –display’ output but it doesn’t tell you install link (e.g. /usr/bin/java). I don’t know why this is — you should be able to use the tool to display everything you need to install an alternative.

Anyway, here’s the punch line. You can goto the /var/lib/alternatives directory and there is a file in there for every master link. For example, here is my /var/lib/alternatives/java:


auto
/usr/bin/java
keytool
/usr/bin/keytool
orbd
/usr/bin/orbd
pack200
/usr/bin/pack200
policytool
/usr/bin/policytool
rmid
/usr/bin/rmid
rmiregistry
/usr/bin/rmiregistry
servertool
/usr/bin/servertool
tnameserv
/usr/bin/tnameserv
unpack200
/usr/bin/unpack200
jre_exports
/usr/lib/jvm-exports/jre
jre
/usr/lib/jvm/jre
java.1.gz
/usr/share/man/man1/java.1.gz
keytool.1.gz
/usr/share/man/man1/keytool.1.gz
...

Note that there are a bunch of entries that aren’t listed by ‘alternatives –config’ or ‘alternatives –display’.  I ignored those when I wrote my ‘alternatives –install’ script.

I am sure that there are things that I did wrong here but it seems to work and allows me to switch back and forth between Icedtea and Sun’s java.

Creative Webcam on Fedora Core 8

Spent a lot of time this morning trying to get a Creative Webcam on Fedora Core 8 (FC8). My goal was to get streaming working from the webcam. Man, this was a pain and its still not really working. Here is what I did.

I plugged the webcam in. It didn’t just work — nothing popped up on my desktop. Dang.


[root@bigbird ~]# lsusb
...
Bus 005 Device 002: ID 041e:4034 Creative Technology, Ltd
...

Then I dorked around on the net and starting yum-ming everything that I could find related to webcam.

The one that seemed to work is here. I kinda half followed the directions. The atrpms was already in my /etc/yum.repos.d/atrpms.repo file. I just enabled the stable by setting enabled=1 (it was 0). I then did the following.


yum install gspcav1
yum install uvc
yum install camE
yum install camstream

I rebooted and camE worked.

I then tried to figure out streaming. Man, what a confusing mess. I pulled up vlc. When you open the device in vlc (video0), at the bottom of the page is a box for streaming. Select that box and then click on settings. Select “play locally” and “HTTP”. For the encapsulation method select “Ogg”. For the transcoding options, select “Video Codec” and then mp4v in the drop down. Under Miscellaneous check “Select all elementary streams” and set the time to live to 8. Then press OK.

To view this stream with mplayer, try the following:


mplayer http://localhost:1234

The ogg encapsulation is the only encap that seemed to let mplayer find the fps. I could not figure out how to find the fps on the other methods.

Note that I believe that you will need to fix the firewall (iptables) and probably something in SE Linux to get this stream off your linux box. Here’s a link that might help.

30 years of Computer Security Research Swept under the Rug

I was in a meeting discussing minimal security for a home network application. The question on the table was whether the family users need or want separate identities when interacting with network devices.

Thinking about it, it seems like taking the computer security model (e.g. you log onto to your work station) and apply it to generic devices that are on the network seems silly. For example, do you log into the refrigerator or the toilet if it happens to be networked (a.k.a. living in Hong Kong)? This seems stupid but these devices monitor the user’s health. How can they do that without the current user being identified?

From 30 years of computer security research and even more of non-computer security work, identity is required for security. But I think this identity is really only a tag for a set of privileges and does not necessarily need to be a single individual. I do think that for security of large group of people you need to identify each person (or more accurately each login should be given to only one person) but I believe for most families this is not necessary in general and in general identity is more a feature enabler (i.e. your toilet tracking your individual hydration and telling you to drink more water) than a set of privileges. The set privileges (e.g. watching a rated R movie) can be accessed by people who prove they are in the adult group by knowing the adult password.

To that end here is patent that seems to use the remote control to identify the TV viewer: link

Computer from 1989

Here’s a scan of the specs of a computer that I bought in 1989. At this time, I was a Junior Electrical Engineering major at A&M. We had VAX accounts at school that we used to run SPICE models and email. In the few CS classes that I took, we had UNIX accounts. The 386SX was used for remote access via A&M’s dial-up (terminal), word processing, and Quatro-Pro for some lab results.

386SX Spec Sheet

Look at how much it cost me!!!!

A few years later, I bought a 486DX-33 computer. I was still at A&M but working on a Master of Science degree. I used it and turbo C++ and gcc based compiler on DOS to run simulations of Speech CODECs and packet loss recovery techniques. I also ran Latex on it to write my thesis.