Installing ELDK

Download the image and mount it with:

mkdir ~/images
cd ~/images
wget ftp://ftp.denx.de/pub/eldk/4.1/ppc-linux-x86/iso/ppc-2007-01-19.iso
mkdir /mnt/image
mount ~/images/ppc-2007-01-19.iso /mnt/image -o loop=/dev/loop3

Install ELDK

cd /mnt/image/
./install -d /usr/local/eldk ppc_6xx

Create the devices:

cd /usr/local/eldk/ppc_6xx/dev
/mnt/image/ELDK_MAKEDEV

Fix the permissions:

cd /usr/local/eldk
/mnt/image/ELDK_FIXOWNER

Set environment in ~/.zshrc:

#export CROSS_COMPILE=ppc_6xx- # have problem with compile for AMD64
export PATH=$PATH:/usr/local/eldk/usr/bin:/usr/local/eldk/bin

Create the console device with:

mknod /usr/local/eldk/ppc_6xx/dev/console c 5 1

Install U-Boot

To get u-boot:

cd /usr/local/eldk/usr/src/
git clone git://www.denx.de/git/u-boot.git u-boot

Load image from RAM

At this testphase we boot u-boot from RAM so we can test if everything is ok before burn it into flash.

cd /usr/local/eldk/usr/src/u-boot
(change in Makefile line 391 the address 0xFF000000 to 0x00020000)
make Lite5200_LOWBOOT_config
make
cp u-boot.srec /tftpboot/MPC5200

Now set the jumper on your board to boot from high.

dBUG> set client 192.168.0.101
dBUG> set server 192.168.0.151
dBUG> set netmask 255.255.255.0
dBUG> dn -s MPC5200/u-boot.srec
dBUG> go 20100

u-boot should appear now on your icecube. The next step is now to write u-boot to flash.

Write u-boot to FLASH

Set bootmode to high boot in the icecube board.

cd /usr/local/eldk/usr/src/u-boot
make distclean
make Lite5200_LOWBOOT_config
(with address 0xFF000000)
make
cp u-boot.bin /tftproot/MPC5200/u-boot-lowboot.bin 

dBUG> set mac 00:01:AF:52:01:13
dBUG> set client 192.168.0.101 (IP-address of icecube)
dBUG> set server 192.168.0.151 (IP-address of the workstation)
dBUG> set netmask 255.255.255.0
dBUG> dn -i -o 0x100000 MPC5200/u-boot-lowboot.bin
dBUG> fe 0xFF000000 0xff050000
dBUG> fp 0xff000000 0xff040000 0x100000
dBUG> store (you can save the config in flash for boot-high)

Power off the board to set boot to low boot.

====== > setenv bootcmd
====== > setenv bootdelay
====== > setenv netdev
====== > setenv nfsargs
====== > setenv ramargs
====== > setenv addip
====== > setenv flash_nfs
====== > setenv flash_self
====== > setenv net_nfs
====== > setenv rootpath
====== > setenv bootfile
====== > setenv ntpserverip 192.168.0.251
====== > setenv bootcmd sntp\\; tftp 200000\\; bootm 200000
====== > setenv preboot echo\\;echo Autostarting. Press any key to abort..\\;echo
====== > setenv serverip 192.168.0.151
====== > setenv ipaddr 192.168.0.101
====== > setenv netmask 255.255.255.0
====== > setenv ethaddr 00:01:AF:52:01:13
====== > setenv bootdelay 5
====== > setenv hostname icecube
====== > setenv nfsroot root=/dev/nfs rw nfsroot=$(serverip):/usr/local/eldk/ppc_6xx
====== > setenv ip ip=$(ipaddr):$(serverip):$(serverip):$(netmask):$(hostname)::off
====== > setenv flashroot root=/dev/mtdblock2 rw
====== > setenv rootfs $(nfsroot)
====== > setenv bootfile MPC5200/uImage
====== > setenv bootargs $(rootfs) $(ip) console=ttyPSC0
====== > saveenv

Prepare NFS Server

Edit the file /etc/exports:

/usr/local/eldk/ppc_6xx 192.168.0.101(rw,sync,no_root_squash)

Restart the NFS server with:

/etc/init.d/nfs restart

Prepare TFTP Server

mkdir /tftpboot
mkdir /tftpboot/MPC5200
chown nobody:nobody /tftpboot
emerge net-ftp/atftp

Add the line to /etc/conf.d/local.start

/usr/sbin/in.tftpd -v --daemon /tftpboot

Building Linux-kernel 2.6

Getting the kernel:

git clone http://gitbits.246tNt.com/gitbits/linux-2.6-mpc52xx.git linux-2.6-mpc52xx
cd linux-2.6-mpc52xx
git pull http://gitbits.246tNt.com/gitbits/linux-2.6-mpc52xx.git ide:mpc52xx_ide
git pull http://gitbits.246tNt.com/gitbits/linux-2.6-mpc52xx.git bestcomm:mpc52xx_bestcomm
cd ..
ln -s linux-2.6-mpc52xx linux

or use the denx archive: (not working yet)

git checkout -b private2.6.18 v2.6.18

You can found the kernel configuration config-mpc52xx.bz2 .
Compile the kernel:

cd linux-2.6-mpc52xx
export CROSS_COMPILE=ppc_6xx-
make ARCH=ppc lite5200_defconfig
make ARCH=ppc menuconfig
make ARCH=ppc EXTRAVERSION=-mpc52xx CROSS_COMPILE=ppc-linux- uImage

Install the kernel for booting via TFTP:

cp arch/ppc/boot/images/uImage /tftpboot/MPC5200

Install the kernel for booting from FLASH:

mkimage -n 'Linux PPC MPC5200 2.6' -A ppc -O linux -T kernel -C gzip -a 00000000 -e 00000000 \
        -d arch/ppc/boot/images/vmlinux.gz /tftpboot/MPC5200/vmlinux.img

http://www.246tnt.com/mpc52xx/

You can change the installation pathes with the variable:

INSTALL_PATH=/path/to/kernl
INSTALL_MOD_PATH=/path/to/modules

Building and installing the modules:

make ARCH=ppc EXTRAVERSION=-mpc52xx CROSS_COMPILE=ppc-linux- modules
make ARCH=ppc EXTRAVERSION=-mpc52xx CROSS_COMPILE=ppc-linux- INSTALL_MOD_PATH=/usr/local/eldk/ppc_6xx modules_install

Boot kernel with U-BOOT

To load kernel from tftp:

====== > tftp
====== > bootm

To write kernel to flash:

====== > tftpboot 100000 MPC5200/vmlinux.img
====== > erase FF100000 FF1FFFFF
====== > cp.b 100000 FF100000 $(filesize)
====== > bootm FF100000

To save the bootvaribles in flash:

====== > setenv bootcmd bootm FF100000
====== > saveenv
====== > reset

setenv bootargs root=/dev/ram0 console=ttyPSC0 rw panic=1

Boot kernel from flash: (need to test)

Here's an example assuming you have a kernel image at address
$loadaddr and the dtb at $ftaddr

dtc -b0 -Idts -Odtb -V16 lite5200.dts > lite5200.dtb

download lite5200.dtb to the system

====== > bootm $loadaddr - $fdtaddr

Add the -f flag to dtc to ignore the missing /chosen node error

Use the "-O dtb" flag to output a fdt blob

Oh, and like Kumar said, you need the -V 0x10 flag to generate the
correct blob version.
Oh, and, -V 0x10 is the default now with a current
top-of-git DTC too.  :-)

Installing busybox

Download busybox: http://www.busybox.net/

Writing kernel modules for 2.6

Create a directory:

cd /usr/local/eldk/ppc_6xx/usr/src
mkdir kernel_mini_mod
cd kernel_mini_mod

Create a file minimod.c:

#include <linux/version.h>
#include <linux/module.h>

MODULE_LICENSE("GPL");

int init_module(void)
{
   return 0;
}

void cleanup_module(void)
{
   return;
}

Create a Makefile:

ARCH		:=	ppc
CROSS_COMPILE	:=	ppc_6xx-
INSTALL		:=	install -c

INSTALL_DATA	:=	$(INSTALL) -m 644
KERNELVERSION	:=	2.6.16-mpc52xx-gc92bc8e3
#EXTRA_CFLAG	:=	-g
ELDK_DIR	:=	/usr/local/eldk
KDIR		:=	$(ELDK_DIR)/ppc_6xx/lib/modules/$(KERNELVERSION)/build
INSTALLDIR	:=	$(ELDK_DIR)/ppc_6xx/lib/modules/$(KERNELVERSION)/kernel/drivers

ifneq ($(KERNELRELEASE),)

obj-m	:=	minimod.o

else

PWD		:=	$(shell pwd)

all:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)

clean:
	rm -f *.o *.ko *.mod.o *.mod.c .*.{cmd,flags}
	rm -rf config.status config.log autom4te*.cache .tmp_version

install: all
	mkdir -p $(INSTALLDIR)
	$(INSTALL_DATA) minimod.ko $(INSTALLDIR)/minimod.ko
	depmod -b $(ELDK_DIR)/ppc_6xx/ $(KERNELVERSION)
endif

Now you can compile the module with make and install it with make install.

http://www.linux-magazin.de/Artikel/ausgabe/2003/08/088_kerntechnik/kerntechnik.html

Xenomai

http://yopesblog.blogspot.com/2006/10/how-to-run-ubuntu-and-xenomai-on.html

I2C

Check if the module i2c_mpc and i2c_dev loads successfully. I can see the following with dmesg:

i2c_adapter i2c-0: adapter [[MPC|adapter]] registered
i2c_adapter i2c-1: adapter [[MPC|adapter]] registered
i2c /dev entries driver
i2c-core: driver [[dev_driver]] registered
i2c-dev: adapter [[MPC|adapter]] registered as minor 0
i2c-dev: adapter [[MPC|adapter]] registered as minor 1

the command

cat /proc/devices

says that i2c use the major number 89. i2c-dev says it uses the minor number 0 and 1 so we create the devices in /dev:

mknod i2c-0 c 89 0
mknod i2c-1 c 89 1

To autoload modules in ELDK create file /etc/rc.modules on the NFS mount with:

modprobe i2c_mpc
modprobe i2c_dev

and make it executable with:

chmod +x rc.modules

Creating a Flash Disk

On Thu, 2007-08-23 at 06:36 -0700, Mirek23 wrote:

Could someone advice me how to configure Linux kernel to make use of the Flash (with above mentioned partitions and JFFS2.

The Denx U-boot and Linux Guide (DULG) will tell you how to configure the kernel for MTD devices and will give some good general information: http://www.denx.de/wiki/view/DULG/FlashFilesystemsMTD

I do not know however which specific options to enable for MTD/JFFS2 since it has many sub options.

The following post has some relevant information for your setup: http://osdir.com/ml/linux.uclinux.devel/2005-12/msg00130.html

I do not know also where to place: -the partition information (which I have mentioned above)

The partition information probably should go in a file that you create for your board located at “drivers/mtd/maps/<your_file>.c”

-the start (0xFF800000) and end (0xFFBFFFFF) physical location of my Flash memory.

I think this information just needs to be defined in your board’s .h file in u-boot. I don’t think you need to specify this in any linux config files.