210 likes | 342 Views
Explore solutions for creating embedded Linux systems tailored for client hardware, leveraging Intel PIII/PIV processors and Mini-ITX motherboards. This guide covers critical design issues, custom kernel development, and the selection of suitable Linux distributions such as Debian. Learn how to manage package installations, optimize storage, and build a minimalistic yet powerful desktop environment using GNOME2. Automate the build and deployment process, configure boot systems, and ensure space-efficient, customizable solutions for embedded applications.
E N D
Shanker Balan Exocore Consulting Bangalore http://shankerbalan.com/ Design Issues and Solutions for Embedded Linux Systems
Client Hardware • Intel PIII/PIV Processor • Mini-ITX Motherboard (VIA/Intel Chipset) • 256MB SDRAM • 128MB / 256MB DiskOnChip Storage Module • AC97 Compatible Sound Chipset • Conexant Soft Modem • CDROM / DVD Drive • USB Pen Drive
Feature Request • Fully integrated and customisable desktop environment • Java Runtime Environment • Browser, Messenger and Word Processor • Media Player • File Manager with “SMB” Browsing Support • XDMCP and RDP Support
The Big Plan • Choose a distribution • Find a suitable Compression method (cramfs, cloop) • “rootfs” on ramdisk • Build custom kernel and write bootup scripts • Create a “core” distribution and build around it
Debian: The Distribution Of Choice • Mix of “testing” And “unstable” • “Testing” for base packages (libs and tools) • “Unstable” for user applications (GNOME) • Advantages • Powerful package management tools (dpkg, apt-get) • Low cruft and minimalistic approach to package creation • Customisable - “dpkg –reconfigure”, “/etc/alternatives” etc • Exhaustive package collection (8000+)
Building the “core” • Do 2 Debian installs on seperate partitions on the target hardware • Regular install for a “build” environment with compiler • Base only install for “core” • Under “build” • “mount /mnt/core” && “chroot /mnt/core /bin/sh” • “apt-get update” && “apt-get install foo” • Configure GRUB to boot “build” and “core” • Boot into “core” for testing
Building Custom Kernel • Target platform is x86, not much effort needed • From “build”, “cd /usr/src/linux/” • “make menuconfig”. Note: “ext2” and “iso9660” should not be modules • Use “make-kpkg” to build kernel package and extra modules (if any) • Build “cloop” as module • Install new kernel in “core” and “build” • “dpkg -i custom_kernel.deb” • Boot into new kernel and test
Image Compression • Compress “core” to < size of flash device • Cramfs has file size limitation. Use “cloop” • “apt-get install cloop-utils” • “cd /mnt/core” • “mkisofs -R -l -V "Debian” -hide-rr-moved -v -exclude-list mkisofs.exclude . | create_compressed_fs - 65536 > ../CORE • Test compressed image • “insmod cloop file=/mnt/CORE” • “mount -r /dev/cloop /mnt/cloop”
Space Saved is Space Earned • mkisofs.exclude • /var/, /home, man pages, doc, unused wallpapers, themes etc • Use “localepurge” to remove superfluous locale data • Keep only “misc” and TrueType font packages
Make Flash Device Bootable • Appears as a regular IDE drive • “mke2fs -m0 /dev/hdc1” • “mount /dev/hdc1 /mnt/flash” • “mkdir /mnt/flash/boot” • “cp /vmlinuz /mnt/flash/boot/” • Install boot record using GRUB/LILO • Configure splash screen for eye candy
The Ramdisk • Ramdisk provides • Provides a “/” like environment • R/W /home area, /tmp and /var • /linuxrc init script for setting up a suitable environment • Mounts “cloop” image • Create symlinks to /cloop for all binaries (/etc, /bin, /sbin/, /usr etc) • Run “init” • Transfer control to compressed Debian
Creating The Ramdisk • “dd if=/dev/zero of=ramdisk bs=1k count=2880 • “mke2fs -m0 -Fq -b 1024 -N 8192 ramdisk” • “mkdir /mnt/ramdisk” • “mount -o loop,rw ramdisk /mnt/ramdisk” • Copy static “sh” and linuxrc script, cloop module etc • “umount /mnt/ramdisk” • “gzip -9 ramdisk”
Things to put into the Ramdisk • /dev entries, /static/{sh,init} (BusyBox), /modules/cloop.o • /linuxrc • Set $PATH /static • Mount “proc” and “devpts” • Mount -t ext2 -r /dev/hdc1 /mnt/flash • Insmod cloop and mount compressed “CORE” /compressed • Copy the library cache ld.so.cache and set symlinks to /compressed
/linuxrc • Set PATH to "/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:." && “hash -r” • Clean Up! “rm -rf /modules /static” • Create a nMB “tmpfs” RamDisk • mount -t tmpfs -o "size=10000k" ramdisk /ramdisk • Point /home, /var etc to /ramdisk • “exit 0” to start “init” • Init now follows /etc/inittab
RamDisk Gotchas • Use small block size and high inode count when formatting • Certain services wont work with symlinked /etc/*. Use “cp” for those. • Bigger ramdisk == less free RAM
Automate! Automate! Automate! • Create “Makefile” targets • “make kernel” • “make ramdisk” • “make boot” • “make compressed” ...
The Desktop Experience • Desktop Environment • GNOME2/Gtk2 or KDE3/Qt3? • We chose GNOME2 • Clean desktop interface • Usual eye candy • Most of the apps (Gaim, Abiword) uses Gtk • I am biased towards Gtk applications • Gconf2 based framework makes setting user defaults very easy
USB HotPlug Support • “apt-get install hotplug” • Add “Disk Mounter” applet to GNOME2 Panel • Clicking on the applet would mount the drive as “vfat” and open the file manager • User uses the USB drive for permenant storage
The Final Product • Original Size 500MB • Compressed Size: 90MB • Kernel 2.4.22 Xfree86 4.3.0 • GNOME 2.4.1 Gaim 0.71 • Mozilla 1.5 Abiword 2.0.0 • Rdesktop • “core” is now feature frozen
What Next? • Value Add • “core” + Java • “core” + OpenOffice • “core” + Insert Application Here • “cp -r /mnt/core /mnt/core+java” • “chroot /mnt/core+java /bin/sh” • “apt-get install jre && exit” • “make compressed” • TaDa!
Resources • http://www.debian.org Thank you!