Friday, July 9, 2010

Embedded Linux for Intel IXP425 using Avila Gateworks Board

Avila Gateworks GW2348-4


Intel IXP425 was a network processor, I'm using Avila Gateworks GW2348-4 at my company during the development of first version of wimax project at the year of 2006. This is my first project using embedded linux. Main tools used were buildroot with kernel 2.4 patched by timesys along with its toolchain. It's not a free ones so not many explanation available at that time. These day I had success recreated a free source code using kernel 2.6 with some modifitacation that i took from avila BSP and I manage to add atheros wifi device driver support for the kernel and madwifi application at the buildroot.


Features
♦ Intel® XScale® IXP425 533MHz Processor
♦ 64Mbytes SDRAM
♦ 16Mbytes Flash
♦ Four Type III Mini-PCI Sockets
♦ Two 10/100 Base-TX Ethernet Ports
♦ Compact Flash Socket
♦ Two RS-232 Serial Ports
♦ General Purpose Digital I/O
♦ 1Kbyte Serial EEPROM
♦ Battery Powered Real Time Clock
♦ Voltage and Temperature Monitor
♦ Thermally Activated Fan Controller
♦ Watchdog Timer
♦ User LED and Push Button Reset
♦ Optional High-speed USB Host Controller
♦ Passive Power Over Ethernet
♦ Reverse Voltage and Transient Protection
♦ 9-48VDC Input Voltage Range
♦ 18W available for Mini-PCI Sockets
♦ 5W Typical Operating Power
♦ -40°C to 85°C Operating Temperature
♦ Software Support for Linux and VxWorks


Main advantages in creating embedded linux for this board were the network driver and encryption support that currently not supported by linux kernel due to license problem. You need to download the network source code from intel site and patched it to kernel source code. I've been download it and try it over and over again but always ended in version conflict with other source code. Here i'm succesfully injecting Ixp4xx npe driver version 2.4 from intel site itself and arranged it for easy compilation for you with step by step compilation. Some script are taken from gateworks bsp site, and also from its structure that I studied, then I managed to arrange these. This also a documentation for me and helping you who had the same problem as me try-in to make this board useable with free source code.

Host Environment

For the host linux i'm using opensuse 11, with kernel development option checked during installation. You will need the texinfo downgrade using yast from installed one (ver 4.11) to texinfo version 4.5. Mine using fedora texinfo 4.5 rpm and it work well. For other host environment you should check the texinfo version.

Besides those files, you still need internet connection to download the rest of the needed files. Buildroot will create the image of root files system and the toolchain produced will be used to compile the kernel.

Geting Needed Files


You may download all files that I upload it on mediafire on the Gateworks GW4328-4 projects.

Buildroot that I'm using originaly were buildroot-2009.02 and kernel-2.6.21.5, note that's the processor used pointed to intel strong arm IXP4xx. You may download modified ones below:
buildroot-2009.02+madwifi-0945
linux-2.6.21.5+madwifi-atheros-098
Extract both files using command line as shown below, note that you must run as non root user during all compilation process to avoid system damage.

#> tar -xzvf buildroot-2009.02-madwifi0945.tgz
#> bunzip2 linux-2.6.21.5-ixp400v24-madwifiath098.tar.bz2
#> tar -xvf linux-2.6.21.5-ixp400v24-madwifiath098.tar


Or you may download the original buildroot-2009.02 and linux-2.6.21.5, download files madwifilinux2621, it consist two folders, one is buildroot folder, second is linux-2.6.21.x folder. Copy all files on the directory of extracted buildroot and linux kernel, replace original ones.

#> tar -xzvf buildroot-2009.02.tgz
#> bunzip2 linux-2.6.21.5.tar.bz2
#> tar -xvf linux-2.6.21.5.tar
#>
tar -xzvf madwifilinux2621x.tgz

#>cp -vrf madwifilinux2621x/linux-2.6.21.x/* linux-2.6.21.5/.
#>cp -vrf madwifilinux2621x/buildroot/* buildroot-2009.02/.

If you not planing not to add madwifi linux just download this files ixp400lib24linux2621x, extract it then copy recrusively all files to original linux kernel source, overwrite the old ones. For the buildroot you may keep using the original one.

#> bunzip2 linux-2.6.21.5.tar.bz2
#> tar -xvf linux-2.6.21.5.tar

#> tar -xzvf ixp400lib24linux2621x.tgz
#> cp -vrf ixp400lib24linux2621x/* linux-2.6.21.5/.

Now we had all files needed. We can start building linux for the board now.

Buildroot Modified Description:

  • Adding package/madwifi-tools/* and dl/madwifi-tools.tgz
  • Edit target/generic/target_skeleton/inittab adding quote at tty1 and tty2 respawn, preventing for keep calling it, and open quote at ttyS0 to enable serial console.
  • Adding files at target/generic/target_skeleton/init.d/S10loadixp400 to load ixp npe module. Manually we need to use command line below to activate the ehernet device.
mknod /dev/ixpNpe c 241
insmod /lib/modules/2.6.21.5/kernel/drivers/net/ixp400_eth.ko

  • Adding files at target/generic/target_skeleton/init.d/S50httpd to start httpd service
  • Adding files at target/generic/target_skeleton/init.d/S60telnetd to start telnetd service
You may open those changes I've mad to evaluate them and changes if as you need.

Configuring Buildroot

Go to buildroot directory, on my patched version you can find broot.config and busybox.config, they were backup configuration files for Intel IXP425.

#> cd buildroot-2009.02

The configuration that I'm use were backuped at the broot.config files. You may load it from buildroot menu config or simply copy broot.config to .config, then run make menuconfig.


#>cp broot.config .config
#>make menuconfig




Check wheteher the target were arm and processor were xscale. Exit and save then start building buildroot by typing "make".

#>make

buildroot will start executing the script and downloading all needed files. You must connect to internet. Main component version that used are described below:

buildroot-2009.02.tar.gz
linux-2.6.21.5.tar.bz2
gcc-4.2.4.tar.bz2
binutils-2.17.tar.bz2
uClibc-0.9.29.tar.bz2
busybox-1.13.2.tar.bz2

The version combination were proven to successfully build, you may change another combination of version and see the result for yourself. Below a quick setting resume of buildroot config:

Targer Architecture -> armeb
Target Architecture Variant -> xscale
Build option
-> Show packages that are deprecated or obsolete
Toolchain
-> Kernel Headers -> Linux 2.6.21.5 kernel headers
-> uClibc C library Version -> uClibc 0.9.29
-> Binutils Version -> binutils 2.17
-> GCC compiler Version -> gcc 4.2.4
Package Selection for the target
-> BusyBox Version -> BusyBox 1.13.x
-> BusyBox configuration file to use -> busybox.config
-> Hardware handling / blockdevices and filesystem maintenance -> mtd/jffs2 utilities
Target filesystem options -> jffs2 root filesystem


After a little while, buildroot will finish compiling. The binary image will be palced below binary/uclibc/.. directory, toolchain will be palced below staging_dir/usr/bin/.. directory. This toolchain will be used to compile the linux kernel image. The root file system produced are not ready to deploy, we still need to inject the kernel modules to /lib/modules directory at the produced file system.

Configuring Linux Kernel Source

Extract the modified linux kernel, inside folder some modification had been made and tools needed were are ready provided. You can find ComArmMake & InstallModules script for fast process.

ComArmMake script shown below:

export PATH=$PATH:../buildroot-2009.02/build_armeb/staging_dir/usr/bin
make $1 $2 $3 ARCH=arm CROSS_COMPILE=armeb-linux-

The Path to the toolchain exported to linux path environment, it will enable the kernel script to get the toolchain with the prefix armeb-linux- as the cross compiler for the target. Change to be made if you place the buildroot folder and linux folder not in the same directory, adjust it to yours.

The installModules Script shown below:

export PATH=$PATH:../buildroot-2009.02/build_armeb/staging_dir/usr/bin
make modules_install ARCH=arm CROSS_COMPILE=armeb-linux- INSTALL_MOD_PATH=../buildroot-2009.02/project_build_armeb/uclibc/root
make modules_install ARCH=arm CROSS_COMPILE=armeb-linux- INSTALL_MOD_PATH=../buildroot-2009.02/target/generic/target_skeleton

Same as the above about the path of the toolchain (gcc) along with make modules_install command pointed to the target skeleton and project files system. This script will install the modules needed by kernel to the source of file system. Changes to your directory if kernel and buildroot not in the same directory.

Kernel Modified Description:

Changes I've made in kernel source were at drivers/ directory. They are modified Makefile to include ixp400 ethernet driver and net/wireless/madwifi driver for atheros wifi card. The other changes are at the files include/asm-arm/mach-types.h, I change the type of Avila Machines Value to 0xF5, its number that read by the kernel during boot time at the avila board.
You may evaluate all changes by compared to the original ones. Best you download my linux kernel source version, hope it will work well and easy to compile, because I had bad experience more than one time failed to compile and deploy the kernel image to the avila board.

The kernel configuration files were backuped to the kernel.config files. Copy it to .config then type in ./ComArmMake menuconfig.

#>cd linux-2.6.21.5
#>cp kernel.config .config
#>./ComArmMake menuconfig

Kernel configuration resumes as follow:

System type
-> ARM System Type -> IXP4xx based

-> Intel IXP4xx Implementation Options -> Avila

-> Build big-endian
kernel
Boot options

-> kernel command line -> console=ttyS0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mem=64M@0x00000000
Device Drivers
-> Network device support -> Ethernet (10 or 100Mbit) -> Intel IXP400 Ethernet Device support (checked as Modules)

-> Wireless LAN (non-hamradio) -> Atheros 802.11(a/b/g) PCI/Cardbus support

File systems -> Miscellaneous filesystems -> Journalling Flash File System v2 (JFFS2) support

Below some captured image of kernel setting.




Exit and save configuration, the script will arrange itself. Do the following command:

#>./ComArmMake dep
#>./ComArmMake modules
#>./ComArmMake zImage

or you might called all at once

#>./ComArmMake dep modules zImage

The kernel script will start compiling, and will resulting modules in driver directory, and kernel image at arch/arm/boot/zImage. This kernel image are now ready to deploy to the board, but the file system need to change in order to install needed modules by kernel. Type in my script to install modules.

#>./InstallModules

Check at the buildroot-2009.02/target/generic/target_skeleton/lib folders, check whether the modules/ directory were exist, this show that the modules succesfuly installed on the source filesystem.
Then you need to recompile the buildroot to make new file system. For sure, we need to remove old image at the binary/ directory, then start building it again.

#>cd ../buildroot-2009.02
#> rm -vrf binary/
#>make


Now we had two files, first one is buildroot-2009.02/binary/uclibc/rfs.armeb.jffs2 and linux-2.6.21.5/arch/arm/boot/zImage. Both need to be deployed to the board via a TFTP server that the redboot on the board can get it via ethernet cable. Assume that our board already had redboot installed, if not, you will need to get a jtag downloader and redboot image from avila and flash it to the board with a working version of redboot.

Setting Up TFTP Server

The TFTP server at opensuse 11.0 were configured via YAST, for other host you had to read it's own manual on how to activating the TFTP server.

#>su
#>yast


Turn off firewall
Security and Users -> Firewall-> Disable Firewall Automatic Starting


Enable TFTP service
Netwoek Service -> TFTP Server -> Enable TFTP Server
it will create /tftpboot directory if not exist.


Copy zImage and rootfs.armeb.jffs2 to /tftpboot directory

#> cp buildroot-2009.02/binary/uclibc/rfs.armeb.jffs2 /tftpboot/.
#> cp
linux-2.6.21.5/arch/arm/boot/zImage /tftpboot/.


Both files are now placed in tftpboot directory with tftp server running. Now we can get those files from gateworks board via ethernet using tftp protocol.

Deploying Image to Gateworks Board

Prepare the board firmly, connect to power supply, plug ethernet cross cable if you connect the ehernet directly to computer or a normal ehernet cable via an ethernet hub/switch running host linux, also plug the serial cable to other computer running hyperterminal. You may use the linux host to run minicom as serial terminal. But here I need to capture the process for you so I run everything remotely using a laptop running windows with a linux host computer running remotely via putty using ssh terminal.


Set the serial configuration at hyperterminal to baudrate 115200, 8 data bit, no parity and 1 stop bit.



Power the board, then press ctrl+c to enter redboot menu.


Now initialize flash content type in command lines below:


RedBoot> fis init
RedBoot> fis create -b 0x00080000 -l 0x00400000 -f 0x50080000 -e 0x00080000 -r 0x00080000 -n zImage
RedBoot> fis create -b 0x00080000 -l 0x00B60000 -f 0x50480000 -e 0x00080000 -r 0x00080000 -n rootfs
RedBoot> fis lis
Name FLASH addr Mem addr Length Entry point
RedBoot 0x50000000 0x50000000 0x00080000 0x00000000
zImage 0x50080000 0x00080000 0x00400000 0x00080000
rootfs 0x50480000 0x00080000 0x00B60000 0x00080000
FIS directory 0x50FE0000 0x50FE0000 0x0001F000 0x00000000
RedBoot config 0x50FFF000 0x50FFF000 0x00001000 0x00000000


Erase any flash content start at 0x50080000 with length 0x00400000(zImage) + 0x00B60000(rootfs) = 0xf60000

RedBoot> fis erase -f 0x50080000 -l 0xf60000
... Erase from 0x50080000-0x50fe0000: ..............................................................
.............................................................

We create image name zImage to hold the kernel and rootfs to hold the file system. You may change the size of each as you need, please learn the redboot command and flash allocation before you change it. Starting base address of allocation flash address must be set after the redboot area and before the redboot configuration. The space length of image must fit the image itself.

Set the ip address which the gateworks board and the host linux pc are in the same subnet. Mine setting are PC are 192.168.0.20 for my host, and my board set to 192.168.0.23. You must change them to fit yours setting.

RedBoot> ip_address -l 192.168.0.30/24 -h 192.168.0.20
IP: 192.168.0.30/255.255.255.0, Gateway: 192.168.0.1
Default server: 192.168.0.20

To test the connection, you can ping the board from linux host pc.
Load the image via tftp server, count the image size then write it to the flash.


Flashing Zimage

Load zImage from tftp server to memory of the gateworks board using command line below:

RedBoot> load -r -v -b 0x80000 zImage
Using default protocol (TFTP)
Raw file loaded 0x00080000-0x0024f8d7, assumed entry at 0x00080000


To write it ti flash space that we had prepared at the fis create we must calculate the loaded zImage size, from the loading process we got the zImage size by subtracting length of loaded files to its base address location, they were: 0x23ffff - 0x80000 = 0x1cf8d7.

RedBoot> fis write -f 0x50080000 -l 0x1cf8d7 -b 0x80000
* CAUTION * about to program FLASH
at 0x50080000..0x5025ffff from 0x00080000 - continue (y/n)? y
... Erase from 0x50080000-0x50260000: ...............
... Program from 0x00080000-0x00260000 at 0x50080000: ...............


Flashing rootfs

Load rootfs.armeb.jffs2 from tftp server to memory of the gateworks board using command line below:

RedBoot> load -r -v -b 0x80000 rootfs.armeb.jffs2
Using default protocol (TFTP)
Raw file loaded 0x00080000-0x002bffff, assumed entry at 0x00080000


Calculate the rootfs.armeb.jffs2 size: 0x2bffff - 0x80000 = 0x23FFFF
Write it to flash.

RedBoot> fis write -f 0x50480000 -l 0x23FFFF -b 0x80000
* CAUTION * about to program FLASH
at 0x50480000..0x506bffff from 0x00080000 - continue (y/n)? y
... Erase from 0x50480000-0x506c0000: ..................
... Program from 0x00080000-0x002c0000 at 0x50480000: ..................


Now we need to configure redboot script to load the linux kernel and seting up parameter needed by system.


RedBoot> fconfig
Run script at boot: true
Boot script:
..
Enter script, terminate with empty line
>> fis load zImage
>> exec -c "console=ttyS0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mem=64M
@0x00000000"
>>
Boot script timeout (100ms resolution): 25
Use BOOTP for network configuration: false
Gateway IP address: 192.168.0.1
Local IP address: 192.168.0.30
Local IP address mask: 255.255.0.0
Default server IP address: 192.168.0.20
Console baud rate: 115200
GDB connection port: 9000
Force console for special debug messages: false
Network debug at boot time: false
Default network device: npe_eth0
Update RedBoot non-volatile configuration - continue (y/n)? y
... Unlock from 0x50fe0000-0x51000000: .
... Erase from 0x50fe0000-0x51000000: .
... Program from 0x03fe0000-0x04000000 at 0x50fe0000: .
... Lock from 0x50fe0000-0x51000000: .

Now reset the board by typin reset command or push the reset button or plug/unplug the power cord.

RedBoot>reset



Here's captured text of the result:

+No devices on IDE controller 0

Trying NPE-B...success. Using NPE-B with PHY 0.
Ethernet eth0: MAC address 00:d0:12:07:70:71
IP: 192.168.0.30/255.255.0.0, Gateway: 192.168.0.1
Default server: 192.168.0.20

RedBoot(tm) bootstrap and debug environment [ROM]
Gateworks certified release, version 2.02 - built 05:22:19, Mar 3 2006

Platform: Gateworks Avila GW234X (IXP42X 533MHz) BE
Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
Copyright (C) 2004, 2005 Gateworks Corporation

RAM: 0x00000000-0x04000000, [0x000298b0-0x03fc1000] available
FLASH: 0x50000000 - 0x51000000, 128 blocks of 0x00020000 bytes each.
== Executing boot script in 2.500 seconds - enter ^C to abort
RedBoot> fis load zImage
RedBoot> exec -c "console=ttyS0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mem=64M @0x00000000"
Using base address 0x00080000 and length 0x00400000
Uncompressing Linux..................................................................................................................................... done, booting the kernel.
Linux version 2.6.21.5 (huntu2@linux-h53q) (gcc version 4.2.4) #4 PREEMPT Fri Jul 23 07:12:13 WIT 2010
CPU: XScale-IXP42x Family [690541c1] revision 1 (ARMv5TE), cr=000039ff
Machine: Gateworks Avila Network Platform
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT undefined 5 cache
CPU0: I cache: 32768 bytes, associativity 32, 32 byte lines, 32 sets
CPU0: D cache: 32768 bytes, associativity 32, 32 byte lines, 32 sets
Built 1 zonelists. Total pages: 16256
Kernel command line: console=ttyS0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mem=64M @0x00000000
PID hash table entries: 256 (order: 8, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60196KB available (3900K code, 642K data, 132K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
IXP4xx: Using 16MiB expansion bus window size
PCI: IXP4xx is host
PCI: IXP4xx Using direct access for memory space
PCI: bus0: Fast back to back transfers enabled
NET: Registered protocol family 8
NET: Registered protocol family 20
NET: Registered protocol family 2
Time: OSTS clocksource has been installed.
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NetWinder Floating Point Emulator V0.97 (double precision)
NTFS driver 2.1.28 [Flags: R/O].
JFFS2 version 2.2. (NAND) (C) 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
IXP4xx Watchdog Timer: heartbeat 60 sec
Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xc8000000 (irq = 15) is a XScale
serial8250.0: ttyS1 at MMIO 0xc8001000 (irq = 13) is a XScale
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
loop: loaded (max 8 devices)
ath_rate_amrr: 0.1 (svn r2456)
ath_rate_minstrel: 1.2 (svn r2456)
Minstrel automatic rate control algorithm.
Look around rate set to 10%
EWMA rolloff level set to 75%
Max Segment size in the mrr set to 6000 us
ath_rate_onoe: 1.0 (svn r2456)
ath_rate_sample: 1.2 (svn r2456)
ath_pci: 0.9.4.5 (svn r2456)
ath_hal: 0.9.30.13 (AR5210, AR5211, AR5212, AR5416, RF5111, RF5112, RF2413, RF5413, RF2133, REGOPS_FUNC)
wlan: 0.8.4.2 (svn r2456)
wlan: mac acl policy registered
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
IXP4XX-Flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
cfi_cmdset_0001: Erase suspend on write enabled
Searching for RedBoot partition table in IXP4XX-Flash.0 at offset 0xfe0000
5 RedBoot partitions found on MTD device IXP4XX-Flash.0
Creating 5 MTD partitions on "IXP4XX-Flash.0":
0x00000000-0x00080000 : "RedBoot"
0x00080000-0x00480000 : "zImage"
0x00480000-0x00fe0000 : "rootfs"
0x00fe0000-0x00fff000 : "FIS directory"
0x00fff000-0x01000000 : "RedBoot config"
block2mtd: version $Revision: 1.30 $
i2c /dev entries driver
TCP cubic registered
NET: Registered protocol family 1
XScale DSP coprocessor detected.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 132K
loading intel ixp driver module
mknod: /dev/ixNpe: File exists
ixp400_eth: Initializing IXP400 NPE Ethernet driver software v. 1.7
ixp400_eth: CPU clock speed (approx) = 532 MHz
ixp400_eth: Found PHY 0 at address 0
ixp400_eth: Found PHY 1 at address 1
ixp400_eth: eth0 is using NPEB and the PHY at address 0
ixp400_eth: eth1 is using NPEC and the PHY at address 1
ixp400_eth: Use default MAC address 00:d0:12:07:70:71 for port 0
ixp400_eth: Use default MAC address 00:d0:12:17:70:71 for port 1
Initializing random number generator... done.
Starting network...
ip: RTNETLINK answers: File exists
httpd: chdir(/var/www/): No such file or directory
ixp400_eth:
ixp400_eth: eth0 PHY:0 link up->down <3>ixp400_eth:
ixp400_eth: eth1 PHY:1 link up->down

HuntuzCool IXP425 Development System
uclibc login:


Default login are "root" with no password.
Congratulation, you have run your linux on Gateworks board succesfully.
The source I modified were far from perfect, you still develop your own modification to fit your need. I hope this can help you on your project using this board. Feel free to ask and please leave a comment below.

-----------------------------
huntu2 100724
-----------------------------

No comments:

Post a Comment