Tag OE

Bluetooth GPS on the mini2440 with GPSd

For a long time i've had a SiRF 3 bluetooth GPS which i've just connected to the mini2440 using a ludicrously cheap USB bluetooth adapter from DealExtreme. Including shipping it cost £1.38 delivered!! Here's what you get for your money:

image1

image2

The chip is a Conwise CW6626. Anyway, what matters most is that if you have bluetooth configured it works out of the box!

Connecting to the GPS is easy. First check the interface:

hciconfig -a

If it says down bring it up:

hciconfig hci0 up

After executing the above I got the following:

root@mini2440:~# hciconfig -a
hci0: Type: USB
BD Address: 00:15:83:15:A3:10 ACL MTU: 672:3 SCO MTU: 128:2
UP RUNNING
RX bytes:348 acl:0 sco:0 events:11 errors:0
TX bytes:38 acl:0 sco:0 commands:11 errors:0
Features: 0xff 0x3e 0x85 0x30 0x18 0x18 0x00 0x00
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy:
Link mode: SLAVE ACCEPT
Name: ''
Class: 0x000208
Service Classes: Unspecified
Device Class: Phone, Cordless
HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c
Manufacturer: Cambridge Silicon Radio (10)

Now turn your GPS on and do a scan:

root@mini2440:~# hcitool scan
Scanning ...
00:0D:B5:32:2C:02 BT-GPS-322C02

Now fill in /etc/bluetooth/rfcomm.conf with the details. Here's mine:

#
# RFCOMM configuration file.
#
rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device
device 00:0D:B5:32:2C:02;

# RFCOMM channel for the connection
channel 1;

# Description of the connection
comment "BT-GPS-322C02";
}

Next bind the device:

rfcomm bind rfcomm0

And check the device output using:

cat /dev/rfcomm0

Next i bitbaked gpsd, by simply typing:

bitbake gpsd

In my OE installation (see the various posts about setting this up).

Once this builds you can install the appropriate ipks. From memory I think i installed the following:

gpsd_2.39-r0.5_armv4t.ipk

gpsd-static_2.39-r0.5_armv4t.ipk

gpsd-gpsctl_2.39-r0.5_armv4t.ipk

gps-utils_2.39-r0.5_armv4t.ipk

libgps18_2.39-r0.5_armv4t.ipk

This pulled in a whole load of other packages. Next you can start gpsd by typing:

gpsd /dev/rfcomm0

And monitor the output using:

gpsmon

If all has gone well you should get a text output of the parsed NMEA data:

image3

Anyway..that's just the tip of the iceburg. If you want to learn more have a look at the gpsd website and the bluetooth page i have based this post on.

Bitbaking the kernel, Angstrom and qt4-embedded all at once

This is what i should have done to begin with! The instructions are very similar to previous ones except this time we clone the right git repository!

On a fresh copy of Fedora 11 I updated the system and installed the packages reccommended by OE:

su -c “yum install python m4 make wget curl ftp cvs subversion tar bzip2 gzip unzip
python-psyco perl texinfo texi2html diffstat openjade docbook-style-dsssl
docbook-style-xsl docbook-dtds docbook-utils sed bison bc glibc-devel glibc-static
gcc binutils pcre pcre-devel git quilt groff linuxdoc-tools patch linuxdoc-tools
gcc-c++ help2man perl-ExtUtils-MakeMaker”

I then made a folder called OE in my home directory and git cloned the mini2440 repo:

cd ~
mkdir OE
cd OE
git clone git://repo.or.cz/openembedded/mini2440.git openembedded

I then setup the source-me.txt similar to before:

gedit source-me.txt

I put the following in:

export OETREE="/home/doug/OE"

BBPATH=${OETREE}/:${OETREE}/openembedded/

echo Setting up dev env for Ångström

if [ -z ${ORG_PATH} ] ; then
ORG_PATH=${PATH}
export ORG_PATH
fi

if [ -z ${ORG_LD_LIBRARY_PATH} ] ; then
ORG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export ORG_LD_LIBRARY_PATH
fi

PATH=${OETREE}/openembedded/bitbake/bin:${ORG_PATH}

LD_LIBRARY_PATH=
export PATH LD_LIBRARY_PATH BBPATH
export LANG=C
export BB_ENV_EXTRAWHITE="MACHINE DISTRO OETREE ANGSTROM_MODE ANGSTROMLIBC LIBC"

su -c 'sysctl vm.mmap_min_addr=0'

echo "Altered environment for OE Development"

Now all you need to do is setup the local.conf. Simply edit the example and copy it to the right place:

cd openembedded
gedit mini2440_local_conf_example.conf

Read this file and edit as appropriate. I have attached mine as an example. Now copy it to the conf/local.conf

cp mini2440_local_conf_example.conf conf/local.conf

If you want qt4-embedded or any other package included in the build simply edit the recipe in:

openembedded/recipes/images/mini2440-image.bb

I added qt4-embedded:

#Angstrom bootstrap image

IMAGE_PREPROCESS_COMMAND = "create_etc_timestamp"

ANGSTROM_EXTRA_INSTALL ?= ""

DEPENDS = "task-base-extended
psplash-zap
esekeyd u-boot-utils tslib
i2c-tools i2c screen rsync nfs-utils
directfb gdbserver directfb mtd-utils
"

IMAGE_INSTALL = "task-base-extended
${ANGSTROM_EXTRA_INSTALL}
psplash-zap qt4-embedded
esekeyd u-boot-utils tslib-calibrate tslib-tests
i2c-tools i2c screen rsync nfs-utils-client
directfb gdbserver directfb mtd-utils
rsvg pango
"

export IMAGE_BASENAME = "mini2440-image"
IMAGE_LINGUAS = ""

inherit image

Then all you have to do is source the script from wherever you put it:

source source-me.txt

and run bitbake:

bitbake mini2440-image

from the ~/OE/openembedded/ directory..

If you get an error trying to build a package try cleaning it:

bitbake -c clean INSERTPACKAGENAME

Then try and build the image again. Maybe you won't have this problem. I guess it's either because the checksum parser failed to build or my hdd is dodgy. It only happened once on binutils but worked fine after cleaning it.

A few hours later if all goes well you should have images in:

~/OE/oetmp/deploy/glibc/images/mini2440/

Obviously that directory depends on what you setup in the local.conf.

Good luck!

Configuring Open Embedded to bake Angstrom images for the mini2440

Please Note: I noticed a few people were having trouble with the Angstrom build using Doug's article, so I thought I'd post the exact method I used (which seemed to work!) so others can retrace my steps with out confusing anyone by editing the previous article! If you have already successfully baked an Angstrom image please ignore this post!

First off I'd like to point out that this article is essentially an amalgamation of the Open Embedded Wiki (Getting Started) and Angstrom's 'Building Angstrom' articles but in context relating to the mini2440 Embedded PC. If you would like a more detailed and probably better written explanation please refer to these two articles.

Make sure you have the packages needed for Open Embedded(OE) by visiting here and looking under the section relating to your distro. Running fedora 11 I did:

su -c "yum install python m4 make wget curl ftp cvs subversion tar bzip2 gzip unzip
python-psyco perl texinfo texi2html diffstat openjade docbook-style-dsssl
docbook-style-xsl docbook-dtds docbook-utils sed bison bc glibc-devel glibc-static
gcc binutils pcre pcre-devel git quilt groff linuxdoc-tools patch linuxdoc-tools
gcc-c++ help2man perl-ExtUtils-MakeMaker"

Getting down to business...

Open up a terminal. Issue these commands:

su -
mkdir -p /stuff2/build/conf
chmod 777 -Rf /stuff2/
exit
cd /stuff2/

Download latest bitbake from here and extract the bitbake directory in the archive (eg. bitbake-1.8.16) to /stuff2/

A few more commands:

mv bitbake-1.8.16/ bitbake
git clone git://git.openembedded.org/openembedded
cp openembedded/conf/local.conf.sample build/conf/local.conf

Edit the config you have just copied using your favourite text editor.

gedit build/conf/local.conf

It is important that you read the config carefully so that you understand what everything does...

Next edit it to look something like this (which is just a slightly modified version of openembedded/contrib/angstrom/local.conf) :

Note: Do not copy and paste from this article due to formatting issues. You can download a pre-made local.conf here.Just extract to /stuff2/build/conf/ ...

MACHINE = "mini2440"

# Where to store sources
DL_DIR = "/stuff2/downloads"

INHERIT += " rm_work "

# Make sure you have these installed
ASSUME_PROVIDED += "gdk-pixbuf-csource-native imagemagick-native librsvg-native"

# Which files do we want to parse:
BBFILES := "/stuff2/openembedded/recipes/\*/\*.bb"
BBMASK = ""

# What kind of images do we want?
IMAGE_FSTYPES += " tar.bz2 "

# Set TMPDIR instead of defaulting it to $pwd/tmp
TMPDIR = "/stuff2/${DISTRO}-dev"

# Make use of SMP and fast disks
PARALLEL_MAKE = "-j2"
BB_NUMBER_THREADS = "2"

#tinderbox
#INHERIT += "oestats-client"
OESTATS_BUILDER = "myname"

DISTRO = "angstrom-2008.1"

Save and exit the editor. Download this script and move it to the directory /stuff2/ .

Check it is ok:

gedit /stuff2/source-me.txt

It should look something like this:

export OETREE="/stuff2"
export PATH=/stuff2/bitbake/bin:$PATH
BBPATH=${OETREE}/:${OETREE}/build/:${OETREE}/openembedded/
PKGDIR=${OETREE}/build/
DL_DIR=${OETREE}/downloads
echo Setting up dev env for Ångström

if [ -z ${ORG_PATH} ] ; then
ORG_PATH=${PATH}
export ORG_PATH
fi

if [ -z ${ORG_LD_LIBRARY_PATH} ] ; then
ORG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export ORG_LD_LIBRARY_PATH
fi

PATH=${OETREE}/openembedded/bitbake/bin:${ORG_PATH}

cd $PKGDIR

LD_LIBRARY_PATH=
export PATH LD_LIBRARY_PATH BBPATH
export LANG=C
export BB_ENV_EXTRAWHITE="MACHINE DISTRO OETREE ANGSTROM_MODE ANGSTROMLIBC LIBC"

echo "Altered environment for OE Development"

save, and start the script:

cd /stuff2/
source source-me.txt
cd ../openembedded

one last update:

git pull

Issue a few commands to fix build issues:

su
sysctl vm.mmap_min_addr=0
setenforce 0 (Fixes an SELINUX problem during building)
exit

issue build commands:

bitbake base-image ; bitbake console-image ; bitbake x11-image

Be prepared to saturate your internet connection, wait a long time and take up a lot of disk space! The result ends up in:

stuff2/angstrom-dev/deploy/glibc/images/mini2440

You should have the image(s) in .jffs2 for flashing and .tar.gz for mounting using NFS.

Building Angstrom

I've been meaning to put this up for a while. Providing nothing goes wrong the whole process is actually very easy! This is basically a rehash of the Angstrom webpage so you might prefer to follow that taking notes of the minor deviations below:

export OETREE="/home/doug/OE"
mkdir -p ${OETREE}

cd ${OETREE}
git clone git://git.openembedded.org/openembedded.git openembedded
cd openembedded
git checkout origin/stable/2009 -b stable/2009

To update the OE metadata simply:

cd ${OETREE}/openembedded
git pull

Now make the suggested script source-me.txt changing OETREE to suit your needs:

export OETREE="/home/doug/OE"

BBPATH=${OETREE}/:${OETREE}/build/:${OETREE}/openembedded/
PKGDIR=${OETREE}/build/
DL_DIR=${OETREE}/downloads
echo Setting up dev env for Ångström

if [ -z ${ORG_PATH} ] ; then
ORG_PATH=${PATH}
export ORG_PATH
fi

if [ -z ${ORG_LD_LIBRARY_PATH} ] ; then
ORG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export ORG_LD_LIBRARY_PATH
fi

PATH=${OETREE}/openembedded/bitbake/bin:${ORG_PATH}

cd $PKGDIR

LD_LIBRARY_PATH=
export PATH LD_LIBRARY_PATH BBPATH
export LANG=C
export BB_ENV_EXTRAWHITE="MACHINE DISTRO OETREE ANGSTROM_MODE ANGSTROMLIBC LIBC"

echo "Altered environment for OE Development"

I also had to set:

sudo sysctl vm.mmap_min_addr=0

Then setup local.conf:

mkdir -p ${OETREE}/build/conf
cp ${OETREE}/openembedded/contrib/angstrom/local.conf ${OETREE}/build/conf/

Now edit ${OETREE}/build/conf/local.conf and add this to the end:

MACHINE = "mini2440"

Now download the mini2440 config file from openembedded. Put this in:

${OETREE}/openembedded/conf/machine/

Now source the source-me.txt, go to the OE tree, check it's up to date

source source-me.txt
cd ${OETREE}/openembedded
git pull - -rebase

Now build the images, you can build all of them or just one. I used the base image for running Qt but i also built the gpe image which worked nicely if you need it.

bitbake base-image ; bitbake console-image ; bitbake x11-image ; bitbake gpe-image

Be prepared to saturate your internet connection, wait a long time and take up a lot of disk space!

The result ends up in:

${OETREE}/angstrom-dev/deploy/glibc/images/mini2440

You should have the image(s) in .jffs2 for flashing and .tar.gz for mounting using NFS.

Compiling the kernel with DS1621 support

After building the temperature sensing I2C circuit i posted about before i compiled a kernel for the mini2440 which supported the DS1621 temperature sensor. Thanks to the existing kernel support this was remarkably easy.

All i had to do was edit /mini2440_defconfig in .../kernel/mini2440/arch/arm/configs and change line 1039 to:

CONFIG_SENSORS_DS1621=y

I compiled the kernel using the script i posted here interrupting the process after the git clones to change the line above and then allowing it to continue. I then booted the mini2440 and the sensor module was immediately available under:

/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0048

In this directory you have the following:

root@mini2440:/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0048# ls
alarms name temp1_max uevent
driver power temp1_max_alarm
hwmon subsystem temp1_min
modalias temp1_input temp1_min_alarm

The output on the DS1621 is controlled by the temp1_min and temp1_max thresholds. By default it goes high when temp1_input < temp1_min. You can view the temperature by reading temp1_input and you can adjust temp1_min and temp1_max by echoing the required threshold to the file, for example:

root@mini2440:/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0048# cat temp1_input
26500
echo 27000 > temp1_min

In this configuration the DS1621 output is high and drives the base of my transistor which switches on an LED. As soon as i heat the sensor the temperature goes above temp1_min the LED turns off.

Although i have no purpose for this circuit it serves as a proof of concept for installing I2C devices on the mini2440.

Here's another pic with the power light on but the output off:

DSC_0052

SMD on veroboard was never meant to look nice!

Compiling the mini2440 kernel

Thanks to BusError there is a mini2440 kernel available here:

http://code.google.com/p/mini2440/

It took me a little while to get it to compile and i thought i'd post a guide to help anyone else having trouble. Compilation was done using Fedora 11. I used the livecd to install and added some packages afterwards. The main ones are those recommended for openembedded. The page to look at is here:

http://wiki.openembedded.net/index.php/OEandYourDistro

I used:

su -c "yum install python m4 make wget curl ftp cvs subversion tar bzip2 gzip unzip
python-psyco perl texinfo texi2html diffstat openjade docbook-style-dsssl
docbook-style-xsl docbook-dtds docbook-utils sed bison bc glibc-devel glibc-static
gcc binutils pcre pcre-devel git quilt groff linuxdoc-tools patch linuxdoc-tools
gcc gcc-c++ help2man perl-ExtUtils-MakeMaker"

At first the build generated various errors which were resolved by installing more packages. Unfortunately I do not remember which ones but i've attached a list of all packages i currently have installed in case you get stuck. In each case simply googling the error resulted in a post advising to install a particular package. After that everything worked!

The script i used to build the kernel was based very closely on the one modified by BusError. If i remember correctly I had to change a path near the end of the script. I've attached a copy of the exact same script which worked for reference.

You run the script by simply typing:

sudo sh mini2440-bootstrap-v2.sh

On my laptop using an Intel T7400 CPU this takes about 30-45 minutes depending on the download speeds.

If you use the default install path you should have u-boot.bin and uImage along with some other files in the directory:

/usr/src/mini2440/output

If you don't then something has gone wrong so go back and check the various error messages in the terminal and fix them!

You can then flash these files as per normal.

Downloads:

Fedora 11 Installed packages

Mini2440 build script