Peewee Linux - DiskOnChip Using DiskOnChip with Redhat 7.2, 2.4 Kernels and Open Source MTD Drivers Mark Meade, mark@lakeshoremicro.com v0.01, 23 January 2002 1. Introduction This document describes how to use Peewee Linux to configure a bootable 8MB DiskOnChip (DOC), using the open-source Memory Technology Devices (MTD) drivers available in the 2.4 kernels. Once these MTD Drivers are installed and configured properly, all of the various Peewee Linux configuration options may be used, including creating ext2 file systems on the DOC. For development, I have a 8MB DiskOnChip Millennium (MD-2800-D08), with the M- Sys DIP Evaluation Board. This EVB is an ISA card, available direct from Tri-M Systems (http://www.tri-m.com/pricing/msystems.pdf). 2. Verify TrueFFS Driver Version The latest revision (as of Jan 2002) of the M-Systems DOC firmware is version 5.0. This newest version is currently incompatible with the open source MTD drivers. The previous version (4.2) seems to work fine. Using the TrueFFS DOS utilities available from M-Systems (DOC-DOSver4.2.zip, http://www.m-sys.com), verify that the DOC is recognized, and that the firmware version is 4.2: dinfo If the DOC is recognized, the device address will be printed, as well as additional information about the drive size and software version. If the version is not 4.2, run the DFORMAT utility: dformat /win:D000 /s:doc42.exb The above example assumes the DOC was found at D000:0000. 3. Install Redhat 7.2 If you are starting completely from scratch, install Redhat 7.2, with the "Development" and "Kernel" options. The examples later in this document assume that GRUB is used as the bootloader (the default for RH7.2). 4. Compile new Kernel with DOC Support Because the Redhat 7.2 kernel does not support the DOC, you'll first need to build a custom kernel on your development system to include the MTD drivers. This kernel will allow you to access the DOC device similar to any another block device, such as a floppy or hard disk drive. Redhat 7.2 is shipped with kernel version 2.4.7. Download the latest version (2.4.17 as of this writing) from ftp.kernel.org or mirrors. The file used is this example was linux-2.4.17.tar.bz2. 4.1 Build new kernel Copy linux-2.4.17.tar.bz2 to the /usr/src directory. Prepare to build the kernel: cd /usr/src mkdir linux-2.4.17 ln –s linux-2.4.17 linux bunzip2 linux-2.4.17.tar.bz2 tar xvf linux-2.4.17.tar cd linux make xconfig (or make menuconfig) If desired, start with the options from one of the Redhat config files located in /usr/src/linux-2.4/configs. I used kernel-2.4.7-athlon.config. Enable the following MTD options, as part of the kernel (y): MTD Support, Debugging, FTL, NTFL, NTFL write support M-Sys DOC 2000/Millenium. Save and exit. Now, from /usr/src/linux: make dep make bzImage make modules make modules_install depmod –a 4.2 Add new kernel to boot menu Copy the new kernel image file to the /boot directory: cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.doc If you're using Grub, simply add another entry to /boot/grub/grub.conf, for instance: title Redhat Linux (2.4.17) DOC root (hd0,0) kernel /bzImage.doc ro root=/dev/hda1 5. Boot new Kernel with MTD Support Reboot, and choose the new kernel with DOC support. When the kernel is booting, there should be a message that a DOC has been found. To make sure, type: dmesg | more You should see something like this: DiskOnChip Millennium found at address 0xD0000. Flash Chip found: Manufacturer ID: 98, Chip ID: E6 There should also be a mtd entry in /proc: cat /proc/mtd dev: size erasesize name mtd 000800000 00002000 "DiskOnChip Millennium" 6. Download MTD Utilities Download the latest MTD stuff from ftp.uk.linux.org/pub/people/dwmw2/mtd/cvs. There should be files called mtd-snapshot-2002xxxx.tar.bz2; grab the latest one, it should have everything you'll need. bunzip2 mtd-snapshot-20020117.tar.bz2 tar xvf mtd-snapshot-20020117.tar Create the entries for the mtd and nftl devices in the /dev directory. The easiest way to do this is: cd mtd/util ./MAKEDEV Make a new directory in the /mnt directory, and attempt to mount the DOC. If the DOC was formatted as detailed in step #2, there should be one FAT12 (DOS) partition on the device: sfdisk –l /dev/nftla (displays partition information) mkdir /mnt/doc mount /dev/nftla1 /mnt/doc df (should show DOC free space) umount /mnt/doc 7. Install Peewee Linux Download Peewee Linux, version 0.61.0. Assuming you have burnt the ISO image onto a CD: mount /dev/cdrom cd /mnt/cdrom ./cd_install Select the binary or source option, and all the necessary files will be copied to the hard drive. Now, try to run Peewee for the first time: cd /root/Embedded_Build ./pwlconfig Unless ncurses was installed initially, you'll probably get the infamous (…) problem. If this occurs, mount Redhat 7.2 CD #2, and go to the /Redhat/RPMS directory (most likely /mnt/cdrom/Redhat/RPMS). rpm –-install ncurses4-5.0-4.i386.rpm Back to /root/Embedded_Build again, now try ./pwlconfig. 8.Create New Project Using the "minimal" project as a starting point, create a new project called "doc- test". The "Manage Projects" menu option may be used to copy the "minimal" project to a new project. Under "Configure Target Hardware", change the following options: Target: Compressed ramdisk on ext2 partition Ide flash target (or HD) configuration parameters: Target Device: /dev/nftla Boot Device on Target System: /dev/nftla Exit Peewee, saving the new project. 9. Install MTD-patched LILO Save the LILO included with Peewee Linux; you'll need to update it with a patched version that supports the DOC: cd bin cp lilo lilo.orig Install the patched LILO for DiskOnChip 2000: cd ~/mtd/patches tar xzvf lilo-mtd.tar.gz cp lilo-mtd ../../Embedded_Build/bin/lilo 10. Create Peewee Custom Files 10.1 Create MTD Device Entries In this section, you'll create the /dev entries needed to access the DOC device itself after booting. If your root file system is on a ramdisk, you may never have any need to do this, but these entries are necessary if your target is configured as a "read- write root on a single partition". cd ~ mkdir custom cd custom mkdir dev mknod nftla b 93 0 mknod nftla1 b 93 1 mknod nftla2 b 93 2 mknod nftla3 b 93 3 mknod nftla4 b 93 4 mknod nftla5 b 93 5 mknod nftla6 b 93 6 mknod nftla7 b 93 7 mknod nftla8 b 93 8 mknod nftla9 b 93 9 10.2 Copy MTD kernel Copy the MTD-aware kernel to your custom directory. This allows Peewee Linux to use your new kernel, rather than the default 2.2.17 kernel. cd .. mkdir boot cd boot cp /boot/bzImage.doc bzImage cd ../../Embedded_Build 11. Create bootable DOC Run Peewee Linux again, and select the "Configure Project File System" option. Select ""Configure Custom files", and then "Reload custom files from source". Make sure both "boot" and "dev" are selected. In the main Peewee Linux menu, choose the "Extract File System for Project" option. After this is executed, check the output to verify that the custom files were copied correctly. Now select the "Load File System onto Target /dev/nftla" option. If the target build script doesn't succeed, check to make sure that /mnt/doc was not mounted prior to running pwlconfig. 12. Reboot Exit Peewee Linux, and reboot the PC. Enter the BIOS setup, and change the boot device to the DiskOnChip. On most PC's, setting the first boot device to "SCSI" should work. At this point, there should be a LILO prompt, hit enter or just wait for the timeout. The new kernel that was built in step #4 should be booting. After logging in (root, password = redhat), run "uname –a" to make sure. In this example, the target was configured as a compressed ramdisk on a ext2 partition -- the root file system will be mounted on /dev/ram0. To mount the DiskOnChip device, simply use "mount /dev/nftla1 /mnt/flash". 13. Conclusion If the default Redhat configuration options were used, the kernel built in step #4 is probably very large. Once the DOC has been successfully booted, removing all unneeded options will drastically reduce the size of the kernel. Peewee Linux may be used to create bootable DOC targets of any configuration: uncompressed or compressed ramdisks, ext2 or FAT partitions, or even a read-write root on a single partition. As a reminder, Peewee Linux is based on libraries from Redhat 6.2. If custom applications are added, they must be either developed under Redhat 6.2, or statically linked with any required libraries. APPENDIX: Configuring Telnet Access Assuming that a network card (eth0) is up and running, the following instructions are one method for setting up telnet access with a 2.4 kernel: 1. Add the following directories and files to the ~/custom directory: * Create the /dev directory (if needed) * Create the /dev/pts directory * In the dev directory, create the ptmx entry with "mknod ptmx c 5 2" 2. Make sure the kernel is configured with the "Unix98 PTY support" and "/dev/pts file system for Unix98 PTYs" options enabled. 3. In the Peewee Linux project file system, select Network->netkit-telnet. Also select all the packages under Network_Base. This method uses "inetd" to allow telnet access. 4. Also make sure that the "touch" utility is included. This is selected under System_Utilities->fileutils->/usr/bin/touch. This program is used by the shell scripts used to configure inetd (/etc/rcS.d/10network and 50inetd). 5. If the /etc/securetty file is selected in the project file system, the entries for the unix98 PTYs should be added. Copy the securetty file to the ~/custom directory, and add the following entries: pts/0 pts/1 pts/2 ... pts/8 6. A new entry is needed in the /etc/fstab file. Because this file is generated automatically by Peewee Linux, it's easiest to just create a file called rc.modules in ~/custom/etc: echo "none /dev/pts devpts gid=5,mode=620 0 0" >>/etc/fstab mount -a REFERENCES: Using DiskOnChip with Linux Kernel 2.4: http://www.gctglobal.com/DownLoad/DiskOnChip/diskonchip.html The Linux MTD, JFFS HOWTO: http://www.embeddedlinuxworks.com/articles/mtd-jffs-HOWTO.txt in ~/custom/etc: echo "none /dev/pts devpts gid=5,mode=620 0 0" >>/etc/fstab mount -a REFERENCES: Using DiskOnChip with Linux Kernel 2.4: http://www.gctglobal.com/DownLoad/DiskOnChip/diskonchip.html The Linux MTD, JFFS HOWTO: http://www.embeddedlinuxworks.com/articles/mtd-jffs-HOWTO.txt