<<

Embedded System Setting up Development Environment

„ Tool chain installation

„ GCC tool chain includes gcc compiler,assembler, linker, and other related utilities.

„ (root@host)#rpm –ivh armtools-2.95.3- 5..rpm „ Add /usr/local/gnu-2.95.3/bin to the searching path.

„ (root@host)# export PATH=/usr/local/gnu- 2.95.3/bin:$PATH Setting up Development Environment

„ Installing uClibc

„ (root@host)#rpm –ivh uClibc-0.9.5- 1.i386.rpm

„ The uClibc will be installed in /usr/local/uClibc-0.9.5 Building

„ BusyBox: The Swiss Army Knife of Embedded

„ Official site: http://busybox.net

„ Install the BusyBox

„ Configure the function of busybox

„ Modify Makefile

„ make Configure the function of busybox

Config.h // This file defines the feature set to be compiled into busybox. // When you turn things off here, they won’t be compiled in at all. // //// This file is parsed by sed. You MUST use single line comments. // i.e., //#define BB_BLAH // // BusyBox Applications //#define BB_ADJTIMEX //#define BB_AR #define BB_ASH … # If you are running a , you may want to set this # to something more interesting, like “-linux-“. CROSS = arm-elf- CC = $(CROSS)gcc … CROSS_CFLAGS+= -nostdinc –I$(LIBCDIR)/include –I$(GCCINCDIR) #Add below LIBCDIR=/usr/local/uClibc-0.9.5/linux-2.0.x GCCINCDIR=/usr/local/gnu-2.95.3/lib/gcc-lib/arm-elf/2.95/include Modify Makefile

# If you are running a cross compiler, you may want to set this # to something more interesting, like “powerpc-linux-“. CROSS = arm-elf- CC = $(CROSS)gcc … CROSS_CFLAGS+= -nostdinc –I$(LIBCDIR)/include – I$(GCCINCDIR) #Add below LIBCDIR=/usr/local/uClibc-0.9.5/linux-2.0.x GCCINCDIR=/usr/local/gnu-2.95.3/lib/gcc-lib/arm-elf/2.95 „ How to use busybox

„ first

„ # ln -s busybox /bin/utilyname

„ # utilyname

„ Second

„ busybox utilyname Building uClinux O.S

„ Build kernel

„ Get kernel source code - kernel- 2.0.38.tar.bz2

„ http://www.kernel.org/pub/linux/kernel

„ ftp://linux.csie.nctu.edu.tw/kernel

„ Patch

„ root@host:~/linux/ #patch –p1 < patch-uClinux- arm-2.0.38.gz

„ http://www.uclinux.org/pub/uClinux/ Building uClinux O.S

„ Use netstart-patch

„ root@host:~/linux/ # zcat ../uClinux- NETStart-2.0.x.patch.gz | patch –p1

„ Set kernel configure

„ make (make xconfig)

„ make dep && make clean

„ make linux.bin Building an image

„ Build ramdisk:

„ root@host:~/# dd if=/dev/zero of=/tmp/initrd1024 bs=1k count=1024

„ Format :

„ root@host:~/# mkfs.minix /tmp/initrd-1024

„ Mount :

„ mount -o loop –t minix /tmp/initrd-1024 /mnt/initrd Building an initial ramdisk image

„ add/delete files into this directory

„ bin/

„ dev/

„ proc/

„ lib/

„ etc/

„ mnt/

„ usr/

„ sbin->bin/ Building an initial ramdisk image

„ umount

„ umount /mnt/initrd

„ dd if=/tmp/initrd1024 bs=1k count=1024 | gzip -9 /tmp/initrds.gz Download O.S to NET-Start! board Download O.S to NET-Start! board Download O.S to NET-Start! board Download O.S to NET-Start! board Download O.S to NET-Start! board

„ System power up, the switch 2 of SW2 is set at the OFF position, the bootstrap loader will boot into the built-in .

„ Commands of bootstrap loader „ HELP – Help „ UNIT - Set access unit „ DUMP - Memory dump „ COPY - Memory copy „ FILL - Fill memory „ POKE - Poke memory „ PEEK - Peek memory „ TX - Send XMODEM file „ RX - Receive XMODEM file „ GO - Execute binary „ INFO - Print system information Download O.S to NET-Start! board

„RUN>Help Download O.S to NET-Start! board

„ download linux.bin to NET-Start! board

„ RUN> rx 0x10000

„ RUN> copy 0x10000 0xb0000 0x1810000

„ download initrds.gz to NET-Start! board

„ RUN> rx 0x10000

„ RUN> copy 0x10000 0x70000 0x18c0000 Developing Application Program

„ Step1. Build the binary code

„ root@host:~/ # arm-elf-gcc - hello.c

„ root@host:~/# arm-elf-ld -L/usr/local/gnu- 2.95.3/lib/gcc-lib/arm-elf/2.95.3 -L/root/uClibc/lib - L/usr/local/gnu/arm-elf/lib -elf2flt -o hello /root/uClibc/lib/crt0.o /usr/local/gnu-2.95.3/lib/gcc- lib/arm-elf/2.95.3/crtbegin.o hello.o /usr/local/gnu-2.95.3/lib/gcc-lib/arm- elf/2.95.3/crtend.o -lc -lgcc -lc 2 Developing Application Program

„ Step2. download the program.

„ Step3. Execute the program

„ # chmod +x hello

„ # ./hello Reference

„ http://netcity3.web.hinet.net/UserData/st one369/comp/linux_one_disk.htm