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.