/**************** User Guide for running uClinux on Philips LPC22xx ******************/ I. The First Compile Guide If you decided to make up an uClinux development environment, this is the list that you have to grab on your linux pc : 1) uClinux distribution The easiest way to getting started with uClinux is to play with a copy of uClinux-dist from the uClinux.org site at: http://www.uclinux.org/pub/uClinux/dist/ Note that the kernel version in the distribution may not be the latest. In this time, we use the distribution is http://www.uclinux.org/pub/uClinux/dist/uClinux-dist-20040408.tar.gz If you have some strange trouble with compilation, even if you followed this guide, simply use this distribution for your testing, and update later. 2) the uClinux-2.6 Kernel You could find the latest uClinux/ARM kernel patch at: http://adam.kaist.ac.kr/~hschoe/ At the download section, the kernel package is: http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.5.tar.bz2 3) the Philips LPC22xx patch You could find the Philips LPC22xx patch for uClinux-2.6.5 from the maillist of uClinux.org. The mail title is "[PORT]uClinux and linux-2.6.5 patch for Philips LPC22xx platform". (For better maintenance, will move to a seperate webpage later.) 4) ARM-ELF toolchain Since the linux 2.6 kernel code uses some new features of newer binutils, you need a newer ARM-ELF toolchain for kernel compilation than the one of uclinux.org. You could find the latest toolchain at the same place with the kernel and patch download section above, and the direct url at current time is : http://adam.kaist.ac.kr/~hschoe/download/arm-elf-tools-20040427.sh That's all for your first compilation. (On this guide, the downloaded files are gathered on ~/incoming) II. Install tools and source code package step by step 1) Install the toolchain Be the root and execute the arm-elf-tools-20040427.sh like: [root@hyoklinux /]# /bin/sh ~/incoming/arm-elf-tools-20040427.sh You should see the list of files that is installed. The toolchain binaries for execution are installed to /usr/local/bin. So you need the directory to be included in your search path, usually it is default for common linux distribution like RedHat. 2) Untar the uClinux distribution On a directory which has enough free available space(about 2GB?), untar the uclinux distribution : [root@hyoklinux /]# tar -zxvf ~/incoming/uClinux-dist-20040408.tar.gz Let's look around what we have on the uClinux-dist directory: [root@hyoklinux /]# cd uClinux-dist/ [root@hyoklinux uClinux-dist]# ls -al total 104 drwxr-xr-x 15 1000 users 4096 Apr 8 09:27 . drwxr-xr-x 28 root root 4096 Apr 27 20:32 .. -rw-r--r-- 1 1000 users 18007 Apr 8 09:13 COPYING drwxr-xr-x 3 1000 users 4096 Apr 8 09:13 Documentation -rw-r--r-- 1 1000 users 9305 Apr 8 09:13 Makefile -rw-r--r-- 1 1000 users 4934 Apr 8 09:13 README -rw-r--r-- 1 1000 users 1743 Apr 8 09:13 SOURCE drwxr-xr-x 2 1000 users 4096 Apr 15 15:19 bin drwxr-xr-x 3 1000 users 4096 Apr 8 09:27 config <-- the configuration files for userland and etc. drwxr-xr-x 11 1000 users 4096 Apr 8 09:27 freeswan <-- IPsec implementation drwxr-xr-x 68 1000 users 4096 Apr 8 09:23 glibc <-- Yes, the GNU C library. drwxr-xr-x 18 1000 users 4096 Apr 8 09:28 lib <-- many libraries ported to uClinux include uC-libc. drwxr-xr-x 15 1000 users 4096 Apr 8 09:27 linux-2.0.x <-- uClinux 2.0.x kernel drwxr-xr-x 16 1000 users 4096 Apr 8 09:27 linux-2.4.x <-- uClinux 2.4.x kernel drwxr-xr-x 18 1000 users 4096 Apr 8 09:27 linux-2.6.x <-- uClinux 2.6.x kernel drwxr-xr-x 3 1000 users 4096 Apr 8 09:26 tools <-- utilities for romfs install and etc. drwxr-xr-x 17 1000 users 4096 Apr 8 09:27 uClibc <-- the uClibc, from uclibc.org. Differ to uC-libc. drwxr-xr-x 174 1000 users 4096 Apr 8 09:27 user <-- the ¡°userland¡±. The applications that is ported. drwxr-xr-x 44 1000 users 4096 Apr 8 09:27 vendors <-- the configuration files for each vendor/models. 3) Make a new linux-2.6.x kernel from the scratch The kernel version of linux-2.6.x directory in the 20040408 distribution is ¡°linux-2.6.2-uc0¡±. We need another kernel with newer kernel version for uClinux/ARM 2.6, here. [root@hyoklinux uClinux-dist]# tar -jxvf ~/incoming/linux-2.6.5.tar.bz2 III. Add Philips LPC22xx patch Now it's time to add Philips LPC22xx patch to the uClinux package. Untar the downloaded Philips LPC22xx patch package, [root@hyoklinux incoming]# tar -zxvf uClinux-philips-lpc22xx.tar.gz [root@hyoklinux incoming]# cd uClinux-philips-lpc22xx Enter into the src sub-directories, you can find several patch files: src/config.in src/linux-2.6.x linux-2.6.5-lpc22xx.patch.gz src/vendors/Philips.tar.gz Back to the uClinux-dist directory for further operation. 1) Add LPC22xx patch to linux-2.6.5 [root@hyoklinux uClinux-dist]# gzip -dc ~/incoming/uClinux-philips-lpc22xx/src/linux-2.6.5-lpc22xx.patch.gz | patch -p0 You should see the codes that patched in some directories that contains ¡°armnommu¡± string. You can use the directory name ¡°inux-2.6.5¡± for your uClinux 2.6 kernel directory without further operation. However, I recommend to use the kernel directory name to ¡°linux-2.6.x¡± because it is more convenient. So you don't need the linux-2.6.x directory which is included in the uClinux-dist. : [root@hyoklinux uClinux-dist]# rm -rf linux-2.6.x/ And we rename the newer patched kernel directory to ¡°linux-2.6.x¡±. [root@hyoklinux uClinux-dist]# mv linux-2.6.5 linux-2.6.x 2) Copy vendors/Philips/LPC22xx directory The directory is for the new vendor/product item. [root@hyoklinux uClinux-dist]# cd vendors [root@hyoklinux vendors]# tar -zxvf ~/incoming/uClinux-philips-lpc22xx/src/vendors/Philips.tar.gz 3) Replace uClinux-dist/config.in file Replace the uClinux-dist/config.in file with the one in the downloaded package. [root@hyoklinux uClinux-dist]# cp ~/incoming/uClinux-philips-lpc22xx/src/config.in ./ Now you are ready to config system and build images. IV. Config the system in the first time 1) Distribution configuration We need setup the configuration for kernel, file systems and user applications. [root@hyoklinux uClinux-dist]# make menuconfig At the first Main Menu, Select the ¡°Vendor/Product Selection¡±. And Select ¡°Philips¡± for the ¡°Vendor¡±, and ¡°LPC22xx¡± for the ¡°Philips Products¡±. You can go back to main menu with 'esc' key or ¡°Exit¡± button. At the Main Menu, Select the ¡°Kernel/Library/Defaults Selection¡±. And Select ¡°linux-2.6.x¡± for the ¡°Kernel Version¡±, and ¡°uClibc¡± for the ¡°Libc version¡±. And toggle the whole below menus : (linux-2.6.x) Kernel Version (uClibc) Libc Version [*] Default all settings (lose changes) (NEW) [*] Customize Kernel Settings (NEW) [*] Customize Vendor/User Settings (NEW) [*] Update Default Vendor Settings (NEW) You can go back to main menu with 'esc' key or ¡°Exit¡± button. With the first ¡°default all settings¡±, the configration files in the vendors directory is loaded. And with the second ¡°Customize kernel settings¡±, we can edit the kernel configration. The thrid ¡°Customize Vendor/User settings¡± is for configuration of applications and libraries configuration for making the romfs.img which will be the rootfs of the kernel. With the final ¡°Update Default Vendor settings¡±, your changes on the kernel and user application configuration will be saved on the vendors/product directory. In your developing or debugging stage, you can toggle the Kernel Settings and/or User Setttings only. You can go back to main menu with 'esc' key or ¡°Exit¡± button, and do again for save dialog. And save it! 2) Kernel configuration If you followed the steps in ¡°confirm the configuration files¡± above, your kernel should get configured. Let's have a rough look at some related configuration items: System Type---> ARM System Type---> [*] Philips LPC22xx [*] Set flash/sdram size and base addr (0x81000000) (S)DRAM Base Address (0x00400000) (S)DRAM Size (0x80000000) FLASH Base Address (0x00200000) FLASH Size LPC22xx options---> [ ]Default Big Endian (10000000) Oscillator Freqnecy (40000000) ARM Core Frequency [*] Remap Vectors to ram The SRAM/FLASH base address and size, the Oscillator Frequency(Fosc) should consistent with your board. The ARM Core Frequency(Fcclk) is your target CPU frequency. General Setup---> (root=/dev/ram0 initrd=0x81100000,800K console=ttyS0) Default kernel command string The initialil ramdisk base address and size can be changed according to your romfs.img size. Character devices---> Serial drivers---> [*] 8250/16550 and compatible serial support [*] Console on 8250/16550 and compatible serial port The UART of Philips LPC22xx is 16c550 compatible. So toggle these two items for serial and console input/output. File systems---> [*] Second extended fs support [*] ROM file system support The romfs acts as the root file system(necessary) which is read-only. While the ext2 is read-wirtable but it costs much memory space. You can determine to select ext2 or not according to your memory size and your application. 3) Application/library Configuration On this menu, you don't need fix anything for now. Look around the configurations and simply ¡°exit¡± and save. Only a kindly prompt that you can see an item: Miscellaneous Applications---> [*] hello which is a simple application that will print "Hello, Philips!" on the serial Terminal window. V. Build image 1) Make We are ready to make the whole bunch. Simply type: [root@hyoklinux uClinux-dist]# make For linux-2.4.x, you should do ¡°make dep¡± before ¡°make¡±. But linux-2.6.x don't need to. It will compile the whole kernel and uclibc, user applications, and make the romfs.img. 2) The results You should get the files in the image directory like: [root@hyoklinux uClinux-dist]# ls -al images total 3036 drwxr-xr-x 2 root root 4096 Apr 27 22:13 . drwxr-xr-x 17 1000 users 4096 Apr 27 22:13 .. -rw-r--r-- 1 root root 1540272 Apr 27 22:13 image.bin -rwxr-xr-x 1 root root 45912 Apr 27 22:13 linux.data -rwxr-xr-x 1 root root 704856 Apr 27 22:13 linux.text -rw-r--r-- 1 root root 789504 Apr 27 22:13 romfs.img [root@hyoklinux uClinux-dist]# ls -al linux-2.6.x/linux* -rwxr-xr-x 2 root root 499433 Apr 27 22:11 linux-2.6.x/linux -rwxr-xr-x 2 root root 15499433 Apr 27 22:11 linux-2.6.x/linux.bin If you got the same files, you've the whole kernel and rootfs image. The linux.bin is the kernel image while the large file "linux" includes the debuggging sysbols. The "romfs.img" is the file system image. "linux.bin" and "romfs.img" are the target images that will be programmed and run in the target board. VI. Load images In the downloaded Philips LPC22xx patch package, you can find a directory "bootloader" in which there are some reference files for a simple bootloader. Basically a bootloader implements functions: - Necessary system initialization - Load kernel and fs images to specific position: linux.bin-->0x81008000, romf.img-->0x81100000. The position is determined before your building stage. - Jump to kernel start and run Design your own bootloader by referring it or by porting some popular powerful bootloaders. e.g. U-Boot, blob, etc. You need manage to program the bootloader and the kernel/fs images to your board flash. VII. Running uClinux 1) If you have write the bootloader image that includes uClinux kernel and fs into the externl flash - Connect UART0 of the board with your PC - Open a Terminal on the PC and set its parameters as "9600 8n1n" - Power on the boad The bootloader will load kernel and fs images to SRAM and then run. 2) If you have ADS and MultiICE, you can download the kernel/fs images to board SRAM and run. In this way, you can run and debug the uClinux without writing images to Flash. - Copy linux.bin and romfs.img to a directory in Windows env. e.g. d:\ess\ - Open AXD->System Views->Command Line Interface->, then type "ob d:\ess\config.ini". The file contents of config.in is as: setmem 0xE002C000 0x80000005 32 setmem 0xE002C014 0x0F814924 32 setmem 0xFFE00000 0x2000AEEF 32 setmem 0xFFE00004 0x20007C67 32 setmem 0xFFE00008 0x1000FFEF 32 setmem 0xFFE0000c 0x0000FFEF 32 lb d:\ess\linux.bin 0x81008000 lb d:\ess\romfs.img 0x81200000 pc 0x81008000 r uClinux begin running, enjoy it... --------------------------------------------------------------------------------------------------------------------- Linux version 2.6.5-ucLPC (root@localhost.localdomain) (gcc version 2.95.3 2 0010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfir e/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #176 Tue Nov 16 09:19:46 CST 2004 CPU: Philips-LPC2294 [22940000] revision 0 (ARMvundefined/unknown) Machine: LPC2294, PHILIPS ELECTRONICS Co., Ltd. On node 0 totalpages: 2048 DMA zone: 0 pages, LIFO batch:1 Normal zone: 2048 pages, LIFO batch:1 HighMem zone: 0 pages, LIFO batch:1 Built 1 zonelists Kernel command line: root=/dev/ram0 initrd=0x81200000,1000K console=ttyS0 PID hash table entries: 64 (order 6: 512 bytes) Memory: 8MB = 8MB total Memory: 5896KB available (994K code, 133K data, 48K init) Calibrating delay loop... 3.57 BogoMIPS Dentry cache hash table entries: 1024 (order: 0, 4096 bytes) Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) checking if image is initramfs...it isn't (ungzip failed); looks like an ini trd Freeing initrd memory: 1000K POSIX conformance testing by UNIFIX Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled ttyS0 at MMIO 0x0 (irq = 6) is a 16550A ttyS1 at MMIO 0x0 (irq = 7) is a 16550A RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) RAMDISK: romfs filesystem found at block 0 RAMDISK: Loading 948 blocks [1 disk] into ram disk... done. VFS: Mounted root (romfs filesystem) readonly. Freeing init memory: 48K Shell invoked to run file: /etc/rc Command: hostname Philips-LPC2294 Command: /bin/expand /etc/ramfs.img /dev/ram1 Command: mount -t proc proc /proc Command: mount -t ext2 /dev/ram1 /var Command: mkdir /var/tmp Command: mkdir /var/log Command: mkdir /var/run Command: mkdir /var/lock Command: mkdir /var/empty Command: cat /etc/motd Welcome to ____ _ _ / __| ||_| _ _| | | | _ ____ _ _ _ _ | | | | | | || | _ \| | | |\ \/ / | |_| | |__| || | | | | |_| |/ \ | ___\____|_||_|_| |_|\____|\_/\_/ | | |_| Philips/LPC2294 support by For further information check: http://www.uclinux.org/ Command: ifconfig lo 127.0.0.1 Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo Command: dhcpcd & [13] Command: sh Sash command shell (version 1.1.1) /> Reading command line: Bad file descriptor pid 14: failed 256 Execution Finished, Exiting init: Booting to single user mode Sash command shell (version 1.1.1) />ls -la drwxr-xr-x 1 0 0 32 Jan 1 00:00 . drwxr-xr-x 1 0 0 32 Jan 1 00:00 .. drwxr-xr-x 1 0 0 32 Jan 1 00:00 bin drwxr-xr-x 1 0 0 32 Jan 1 00:00 dev drwxr-xr-x 1 0 0 32 Jan 1 00:00 etc drwxr-xr-x 1 0 0 32 Jan 1 00:00 home drwxr-xr-x 1 0 0 32 Jan 1 00:00 lib drwxr-xr-x 1 0 0 32 Jan 1 00:00 mnt dr-xr-xr-x 18 0 0 0 Jan 1 00:00 proc lrwxrwxrwx 1 0 0 4 Jan 1 00:00 sbin -> /bin lrwxrwxrwx 1 0 0 8 Jan 1 00:00 tmp -> /var/tmp drwxr-xr-x 1 0 0 32 Jan 1 00:00 usr drwxr-xr-x 7 0 0 1024 Jan 1 00:00 var /> ps PID PORT STAT SIZE SHARED %CPU COMMAND 1 S 163K 0K 7.3 /sbin/init 2 S 0K 0K 0.0 ksoftirqd/0 3 S 0K 0K 0.0 events/0 4 S 0K 0K 0.0 kblockd/0 5 S 0K 0K 0.0 pdflush 6 S 0K 0K 0.0 pdflush 8 S 0K 0K 0.0 aio/0 7 S 0K 0K 0.0 kswapd0 15 R 102K 0K 11.8 /bin/sh /> cat /proc/meminfo MemTotal: 6968 kB MemFree: 4648 kB Buffers: 1076 kB Cached: 400 kB SwapCached: 0 kB Active: 1160 kB Inactive: 300 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 6968 kB LowFree: 4648 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 0 kB Writeback: 0 kB Mapped: 0 kB Slab: 700 kB Committed_AS: 0 kB PageTables: 0 kB VmallocTotal: 4194303 kB VmallocUsed: 0 kB VmallocChunk: 4194303 kB />cd var /var>cd lucy /var/lucy>hello /******** Hello Philips! ********/ /******** Hello LPC22xx! ********/ /**** Welcome using uClinux for Philips LPC22xx! ****/