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.

Mini2440 cable kit and soldering LGA14!

The very kind people at www.andahammer.com were generous enough to send me a mini2440 cable kit! This will be much easier than chopping up 2.5″ IDE connectors! The kit has all the connections you could ever need and will certainly make things much easier!

DSCF1279-1-1

After getting the DS1621 thermometer working on the I2C bus i now on plan on connecting something more complicated and very small! They probably won’t recommend it in the data sheet but you can solder LGA14 using a normal iron and some enamelled wire. My first attempt is below. Unfortunately i started with much thicker wire which subsequently pulled a pad off but the thinner 0.15mm stuff is fairly easy. Checking the connections with a multimeter revealed no short circuits.

DSCF1281-1-1

The plan is try this again with the same device (without breaking it!) and then solder it to some veroboard to which i’ll connect one of my new cables 🙂

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 &gt; 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!

Booting using NFS and TFTP (updated)

Rather than slowly wearing out your NAND flash you can boot the mini2440 over a network by loading the kernel using TFTP and the OS from an NFS share. This also makes it much faster to test changes. Using Fedora 11 you can use YUM to install tftp, tftp-server and nfs-utils.

yum install tftp tftp-server nfs-utils

I created a folder /home/doug/mini2440/root_fs and added the following line to /etc/exports to allow r/w access from 192.168.1.*:

/home/doug/mini2440/root_fs 192.168.1.1/24(rw,sync,no_root_squash)

..and extracted the Angstrom file system as root to /home/doug/mini2440/root_fs

You’ll need to edit /etc/xinetd.d/tftp to setup TFTP. Mine is posted below for reference, you at least need to set disable = no.

# default: off
# description: The tftp server serves files using the trivial file transfer
#    protocol.  The tftp protocol is often used to boot diskless
#    workstations, download configuration files to network-aware printers,
#    and to start the installation process for some operating systems.
service tftp
{
disable    = no
socket_type        = dgram
protocol        = udp
wait            = yes
user            = root
server            = /usr/sbin/in.tftpd
server_args        = -s /home/doug/mini2440/kernel
per_source        = 11
cps            = 100 2
flags            = IPv4
}

I then started the services :

/etc/init.d/nfs start

/sbin/service xinetd start

To automate these i think you can do:

chkconfig tftp on

chkconfig xinetd on

chkconfig nfs on

Next i edited the uboot environment. Use the command setenv to modify or add entries and savenev when you’re finished. I ended up with the following:

MINI2440 # printenv
bootdelay=3
baudrate=115200
ethaddr=08:08:11:18:12:27
usbtty=cdc_acm
mtdparts=mtdparts=mini2440-nand:256k@0(u-boot),128k(env),5m(kernel),-(root)
mini2440=mini2440=0tb
bootargs_base=console=ttySAC0,115200 noinitrd
bootargs_init=init=/sbin/init
root_nand=root=/dev/mtdblock3 rootfstype=jffs2
root_mmc=root=/dev/mmcblk0p2 rootdelay=2
root_nfs=/mnt/nfs
set_root_nfs=setenv root_nfs root=/dev/nfs rw nfsroot=${serverip}:${root_nfs}
ifconfig_static=run setenv ifconfig ip=${ipaddr}:${serverip}::${netmask}:mini2440:eth0
ifconfig_dhcp=run setenv ifconfig ip=dhcp
ifconfig=ip=dhcp
set_bootargs_mmc=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_mmc}
set_bootargs_nand=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nand}
set_bootargs_nfs=run set_root_nfs; setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nfs} ${ifconfig}
mtdids=nand0=mini2440-nand
bootargs=console=ttySAC0,115200 noinitrd init=/sbin/init mini2440=0tb ip=192.168.1.85 root=/dev/nfs rw nfsroot=192.168.1.10:/home/doug/mini2440/root_fs
bootfile="uImage"
filesize=1E9088
fileaddr=32000000
gatewayip=192.168.1.100
netmask=255.255.255.0
ipaddr=192.168.1.85
serverip=192.168.1.10
bootcmd=tftp;bootm 32000000
partition=nand0,0
mtddevnum=0
mtddevname=u-boot

Note when you setenv you have to omit the = sign. Obviously you’ll want to change some of this to suit your network setup. Here my laptop is 192.168.1.10 and 192.168.1.100 is my pfsense box which is assigning 192.168.1.85 to the mini2440 by DHCP.

When you boot the system uboot will download the kernel over TFTP and then mount the NFS share.

If you have DHCP on your network Angstrom should automatically get an IP. You can skip the rest in this case!

If you want a static address you can change /etc/network/interfaces. I simply changed dhcp to static for eth0:

iface eth0 inet static

And after this the system booted up fine. Lastly i have a note which says I deleted the symlink /etc/resolve.conf and replaced it with:

domain local
search local
nameserver 192.168.1.100

Be warned that the the entire of above needs to be compliant with your firewall and selinux, it won’t work otherwise!

I found the following Links helpful:

TFTP

NFS

U-boot NFS / TFTP boot

Cross compiling Qt-embedded 4.5.3

Cross compiling Qt was actually very easy. I used the same machine described in the mini2440 kernel post.  If you have a vanilla install of Fedora 11  it’s more than likely you’ll get some errors due to missing packages so check the list i posted if you can’t figure out which ones you need. This is what i did:

  1. Download the Qt source from Trolltech
  2. Untar the archive somewhere, i simply used the desktop
  3. Edit the file mkspecs/qws/linux-arm-g++/qmake.conf according to your toolchain. I have attached mine here as an example. I used the toolchain from OpenEmbedded.
  4. Now run the following commands within the Qt directory:
  • ./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/local/Qt -qt-mouse-tslib -little-endian
  • gmake -j 2 (or however many CPUs you have)
  • sudo gmake install

The resulting ~74MB  will be located in /usr/local/Qt. At first i ran the library from an SD card using a system wide link but later i used NFS.

I ran the library using BusError’s mini2440 kernel and an Angstrom base image I cross compiled using OpenEmbedded apriori. In my next post i’ll describe how to compile Angstrom Linux for this purpose which also provides the toolchain i used here. Finally when i get access to my mini2440 i’ll explain how to use the examples and setup the touch screen which was a little fiddly.

Big thanks to Cor for his post on building Qt which i’ve relied on heavily here.

Controlling the mini2440 system LEDs and the EEPROM

This is pretty trivial but i thought i’d post it just incase. Using the mini2440 kernel by BusError the system LEDs are registered under /sys/devices/platform/s3c24xxled.X, where X is the LED number. LEDs 1-4 are located on the system board and LED 5 is the backlight. To control the devices you can do the following:

cd /sys/devices/platform/s3c24xx_led.5/leds/backlight

echo 0 > brightness #turns the backlight off

echo 255 > brightness #turns the backlight on

You can also choose from one of the available triggers, for example..

root@mini2440:/sys/devices/platform/s3c24xx_led.5/leds/backlight# cat trigger
none nand-disk mmc0 timer heartbeat [backlight] gpio default-on
root@mini2440:/sys/devices/platform/s3c24xx_led.5/leds/backlight# echo heartbeat > trigger

Will make your backlight flash on and off like crazy!

Unfortunately there is no PWM control to manage the brightness. This would have been really nice.

The EEPROM can be controlled in a similar way. You can access it in:

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

Data can be written by using the following command:

echo whatever you want > eeprom

The just do the following to read the memory:

cat eeprom

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

Probing the mini2440 I2C bus

I’m fairly new to electronics and i’ve certainly never used I2C before so I built a simple circuit based on a DS1621 I2C thermometer as a test. I got this for a couple of pounds from the seller ‘crodnet’ on ebay.

I found an old 2.5″ laptop drive connector which wasn’t large enough to fit on CON5 so i chopped it up and put it on the camera interface. I wired up the SDA and SCL lines along with 3.3V and GND to the veroboard. I also soldered a couple of LEDs, one for the power light and the other wired up through a transistor with the base connected to the thermostat output on the DS1621. This pin can be programmed to go high at a particular temperature.

I then plugged it in and powered up the mini2440. Running i2cdetect showed a new device at 0x48. The other devices are the onboard EEPROM. Looking at the datasheet for the DS1621 the temperature can be read from the location 0xAA. I was able to observe the temperature in hex through i2cget. Converting the output 0x0016 to decimal gives 22.0 degrees. The sensor is pretty neat, it responds almost immediately to the presence of your finger.

Below are the I2C commands i used. I installed i2c tools using opkg.

root@mini2440:~# i2cdetect -l
i2c-0    i2c           s3c2410-i2c                         I2C adapter

root@mini2440:~# i2cdetect s3c2410-i2c
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: UU UU UU UU -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

root@mini2440:~# watch --interval=1  i2cget -y s3c2410-i2c 0x48 0xAA w

Every 1.0s: i2cget -y s3c2410-i2c 0x48 0xAA w      Tue Sep 15 23:31:25 2009
0x0016

Below is a picture of the device..it looks like a right mess but it works great!

DSC_0032

The next stage is compile the driver from the lmsensors package…