Build ARM Linux on cdb89712 This page is based on Roland Seuhs Page at URL http://roland.seuhs.com/en/index.php/Development/LiMa/CDB89712 Written by Laurent MASSON for IRTS 22 April 2002 note : All operations bellow were tested as root. Step 1 : Needed files : You need some files to build a linux on cdb89712. You can use other version than used in this document if you check they could run with cdb89712. file version URL binutils 2.11.2 http://www.gnu.org/order/ftp.html gcc 3.0.4 http://www.gnu.org/order/ftp.html shoehorn 3.4 http://www.bluemug.com/~miket/arm/arm.html hermit 1.3 http://www.bluemug.com/~miket/arm/arm.html linux Kernel 2.4.6 http://www.kernel.org/pub/linux/kernel/ Seuhs patches and files : http://roland.seuhs.com/patches/arm -patch for the Linux kernel -.config file for Linux - hermit-patch - shoehorn-patch - example tarball of /etc configuration thttpd 2.20c http://www.acme.com/software/thttpd Step 2 : Configurations : Edit your ~/.bashrc and add : export ARM_ROOT="path where you are going to install software" ex : export ARM_ROOT=/mnt/d2/arm89712 PATH=$ARM_ROOT/bin:$PATH type in all xterm windows or console : . ~/.bashrc Verify that it's work : echo $ARM_ROOT -> ex : response : /mnt/d2/arm89712 Step 3 : directory structure : make you root directory : mkdir $ARM_ROOT copy all sources files (gz...) into directory $ARM_ROOT/dl (create it if don't exist). gz files are in sub-directory 'gz', and cvs directories are in 'cvs' sub-directory (easy) ex: cp -r /mnt/d3/dowloader_arm/dl . Step 4 : Extract sources mkdir $ARM_ROOT/src Choose the best version of files cvs or gz. For tar.gz "tar" typing cd $ARM_ROOT/src for i in ../dl/*.tar.gz; do tar xzvf ../dl/$i; done or "cp -r" for cvs... you will see this sub-directories : binutils-2.12 gcc-2.95.3 linux (2.4.6) uClibc (20011221) busybox-0.60.2 tinylogin-1.01 thttpd-2.20c hermit-1.3 shoehorn-3.4 make symbolic link (easier for next steps if you don't have same version) : ln -s binutils-2.12 binutils ln -s gcc-2.95.3 gcc ln -s busybox-0.60.2 busybox ln -s tinylogin-1.01 tinylogin ln -s thttpd-2.20c thttpd ln -s hermit-1.3 hermit ln -s shoehorn-3.4 shoehorn cd $ARM_ROOT cp dl/gz/diversSeuhs/Linux.config ./src/linux/.config Step 5 : Build Binutils cd $ARM_ROOT/src/binutils ./configure --prefix=$ARM_ROOT --target=arm-linux make make install Step 6 : Build Kernels Headers cd $ARM_ROOT/src Apply patchs : zcat ../dl/gz/patch/patch-2.4.6-rmk1.gz | patch -p0 cat ../dl/gz/patch/patch-linux | patch -p0 cd linux cp ../../dl/gz/diversSeuhs/Linux.config .config Select your configuration : make menuconfig Choose exit and save configuration make dep mkdir $ARM_ROOT/arm-linux/include for f in asm asm-arm linux; do cp -ar include/$f $ARM_ROOT/arm-linux/include; done Step 7 : Compile gcc cd $ARM_ROOT/src/gcc vi gcc/config/arm/t-linux Modify this line from : TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC to TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix_h Run configure : ./configure --prefix=$ARM_ROOT --target=arm-linux --with-headers=$ARM_ROOT/arm-linux/include --enable-languages=c --disable-threads From here don't worry if only a part of gcc could be build (lack of headers fils) Type : make -i make install -i You can find now a CROSS compiler from host to arm-target into directory : $ARM_ROOT/arm-linux/bin/gcc ls $ARM_ROOT/arm-linux/bin/gcc -> response : .../arm-linux/bin/gcc Step 8 : Build ulibc cd $ARM_ROOT/src/uClibc cp extra/Configs/Config.arm Config Edit Makefile and replace all "cp -a" by "cp -af" vi Makefile Edit Config and modify the following lines to look like this: vi Config CROSS=arm-linux- KERNEL_SOURCE=$(ARM_ROOT)/src/linux PREFIX = "" DEVEL_PREFIX = $(ARM_ROOT)/$(TARGET_ARCH)-linux-uclibc (Warning : write this line before first use of DEVEL_PREFIX) TARGET_PREFIX = $(ARM_ROOT)/ramdisk/target make make install Step 9 : Compile the Linux kernel cd $ARM_ROOT/src/linux make clean rm -f include/asm-arm/constants.h make r Step 10 : Compile shoehorn cd $ARM_ROOT/src Apply patch : cat ../dl/gz/patch/patch-shoehorn | patch -p0 cd shoehorn make mkdir $ARM_ROOT/lib/shoehorn make INSTALLPREFIX=$ARM_ROOT install (as root) Step 11 : Compile hermit cd $ARM_ROOT/src Apply patch : cat ../dl/gz/patch/patch-hermit | patch -p0 cd hermit make PROFILE=cdb89712-boot mkdir $ARM_ROOT/lib/hermit make PROFILE=cdb89712-boot INSTALLPREFIX=$ARM_ROOT install (as root) make scrub make PROFILE=cdb89712 make PROFILE=cdb89712 INSTALLPREFIX=$ARM_ROOT install (as root) Step 12 : Compile busybox cd $ARM_ROOT/src/busybox Edit Config.h if you want to enable some networking stuff : vi Config.h Edit 'Makefile' and modify the following lines : vi Makefile CROSS = arm-linux- CC=$(ARM_ROOT)/arm-linux-uclibc/bin/gcc DOSTATIC = true make clean make ./install.sh $ARM_ROOT/ramdisk/target (as root) Step 13 : Build tinylogin cd $ARM_ROOT/src/tinylogin Edit Config.h if you want to enable/disable some stuff vi Config.h Edit Makefile to modify the following lines : vi Makefile CROSS = arm-linux- CC = $(ARM_ROOT)/arm-linux-uclibc/bin/gcc USE_SYSTEM_SHADOW=false DOSTATIC = true make ./install.sh $ARM_ROOT/ramdisk/target Step 14 : Build thttpd cd $ARM_ROOT/src/thttpd CC=$ARM_ROOT/arm-linux-uclibc/bin/gcc ./configure --target=arm-linux --prefix=/usr Edit Makefile vi Makefile Add '--static' to LDFLAGS : LDFLAGS = --static Go to line 125, you can see the following lines : installsubdirs: for i in $(SUBDIRS) ; do ( \ cd $$i ; \ pwd ; \ $(MAKE) $(MFLAGS) \ WEBDIR=$(WEBDIR) \ CGIBINDIR=$(CGIBINDIR) \ MANDIR=$(MANDIR) \ WEBGROUP=$(WEBGROUP) \ install \ ) ; done Edit this lines to obtain : installsubdirs: for i in $(SUBDIRS) ; do ( \ cd $$i ; \ pwd ; \ $(MAKE) $(MFLAGS) \ BINDIR=$(DESTDIR)$(BINDIR) \ WEBDIR=$(DESTDIR)$(WEBDIR) \ CGIBINDIR=$(DESTDIR)$(CGIBINDIR) \ MANDIR=$(DESTDIR)$(MANDIR) \ WEBGROUP=$(WEBGROUP) \ install \ ) ; done Edit libhttpd.c : vi libhttpd.c Add this line #include for your file look likes : #include "config.h" #include "version.h" #include #include #include #include #include #include (Warning : it's a read only file, use ":wq!" command) Go into 'extras' directory, and add $(STATICFLAG) as below : makeweb: makeweb.o $(CC) $(LDFLAGS) $(STATICFLAG) makeweb.o -o makeweb $(LIBS) $(NETLIBS) make mkdir $ARM_ROOT/ramdisk/target/usr/man/ mkdir $ARM_ROOT/ramdisk/target/usr/man/man1 mkdir $ARM_ROOT/ramdisk/target/usr/man/man8 mkdir $ARM_ROOT/ramdisk/target/usr/www mkdir $ARM_ROOT/ramdisk/target/usr/www/cgi-bin DESTDIR=$ARM_ROOT/ramdisk/target make install (Note : if your the group 'www' is not available on your system, you may get an error. Use 'groupadd' shell command to solve this : groupadd www ) Step 15 : Create ramdisk structure cd $ARM_ROOT/ramdisk/target mkdir dev cd dev mknod watchdog c 10 130 mknod zero c 1 5 mknod full c 1 7 mknod kmem c 1 2 mknod mem c 1 1 mknod null c 1 3 mknod rtc c 10 135 mknod mtd0 c 90 0 mknod mtd1 c 90 1 mknod mtd2 c 90 2 mknod mtd3 c 90 3 mknod mtdblock0 b 31 0 mknod mtdblock1 b 31 1 mknod mtdblock2 b 31 2 mknod mtdblock3 b 31 3 chmod 600 mtd* mknod cuam0 c 205 16 mknod cuam1 c 205 17 mknod ttyp0 c 3 0 mknod ttyp1 c 3 1 mknod ttyp2 c 3 2 mknod ttyp3 c 3 3 mknod ttyp4 c 3 4 mknod ttyp5 c 3 5 mknod ttyp6 c 3 6 mknod ttyp7 c 3 7 mknod ttyp8 c 3 8 mknod ttyp9 c 3 9 mknod ttyAM0 c 204 16 mknod ttyAM1 c 204 17 ln -s ttyAM0 ttyS0 ln -s ttyAM1 ttyS1 mknod tty c 5 0 mknod console c 5 1 mknod ptyp0 c 2 0 mknod ptyp1 c 2 1 mknod ptyp2 c 2 2 mknod ptyp3 c 2 3 mknod ptyp4 c 2 4 mknod ptyp5 c 2 5 mknod ptyp6 c 2 6 mknod ptyp7 c 2 7 mknod ptyp8 c 2 8 mknod ptyp9 c 2 9 mknod ram0 b 1 0 mknod ram1 b 1 1 mknod ram2 b 1 2 mknod ram3 b 1 3 chmod 660 ram* Now add your config files and directory structure cd $ARM_ROOT/ramdisk/target (as root) Extract "etc" directory : tar -xvzf /mnt/d2/arm89712/dl/gz/diversSeuhs/etc.tar.gz In 'etc' directory : cd etc You can add 'shadow' file : touch shadow You may edit 'inittab' and comment some lines, for examples : ::sysinit:/etc/rc #::respawn:/sbin/syslogd -n #::respawn:/sbin/klogd -n ::respawn:/sbin/getty -L ttyAM0 115200 vt100 #::respawn:-/bin/sh #::respawn:/sbin/getty -L ttyAM1 38400 vt100 You may also edit ' rc', and add this line at the beginning : #!/bin/sh then make it executable chmod u+x rc You can also chage 'name' and 'someone.com' by your host and domaine name for the target. Last but not least, you can edit 'passwd' and remove root password : root::0:0:Superuser:/:/bin/sh Complete your directory structure : mkdir tmp chmod 1777 tmp mkdir var var/log var/run touch var/run/utmp touch var/log/messages mkdir proc Step 17 : Ramdisk utils : cd $ARM_ROOT/ramdisk Create mnt directory : mkdir mnt Extract utils : tar -xvzf ../dl/gz/ramdisk/buildram.tar.gz This will create 4 shell scripts : mkRam : rm -rf ramdisk.img Ramdisk.gz dd if=/dev/zero of=ramdisk.img bs=1024 count=2048 mke2fs -N 500 ramdisk.img -F mount -o loop ramdisk.img mnt (cd target; tar cf - *) | (cd mnt; tar xvf -) umount mnt echo "Compressing Ramdisk..." cat ramdisk.img | gzip -9 -c > Ramdisk.gz mkKern : cd $ARM_ROOT/src/linux rm Image.gz rm vmlinux echo echo "Building Kernel Image..." make r echo "Kernel done." dwnload : echo "Wake the board up and press [ENTER]" read echo "Downloading Kernel..." hermit download -i ../src/linux/Image.gz -a 0x100000 echo "Downloading Ramdisk" hermit download -i Ramdisk.gz -a 0x200000 echo echo "Type : b" hermit terminal mkAll : mkKern mkRam dwnload Step 17 : Program hermit onto target board flash : Power down target board, install JP31, Power up board, then run : shoehorn --edb7211 --terminal --boot --loader=$ARM_ROOT/lib/shoehorn/loader.bin --kernel=$ARM_ROOT/lib/hermit/loader-cdb89712-boot.bin --initrd=/dev/null --port /dev/ttyS1 (if board is connected to serial line 1 on PC, otherwise, use ttyS0) Then read instruction : push onboard reset, then push wakup button. You will see hermit prompt : hermit> Type ? You will se hermit help Hit Ctrl-C to abort program. Burn flash : hermit download --input-file=$ARM_ROOT/lib/hermit/loader-cdb89712.bin --region=flash-1 --force-locked Power down target board, remove JP31, Power up board. Your board is ready to receive your Linux OS. After modifications on ramdisk do : Build ramdisk : Run mkRam : mkRam After modifications on kernel do : Rebuid Kernel : mkKern To download Kernel image and ramdisk onto target board, run : dwload Push Wakeup button, then press ENTER on host Wait during Kernel and ramdisk image are downloaded... At hermit prompt, type 'b' to boot Linux... it's good time to do prayer... Note : You can add this to your path to use uClibc : $ARM_ROOT/arm-linux-uclibc/usr/bin