CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" >

4. Using M-Systems DiskOnChip 2000 TSOP as an additional storage drive in Linux

The following are the steps performed for this purpose.

4.1. Step 1: Patch the Kernel

Download a fresh copy of Kernel 2.4.18 from http://www.kernel.org/pub/linux/kernel/v2.4.

The kernel that is downloaded from the site does not have support for the M-Systems driver so we need to add this functionality. This is done by adding a patch to the kernel.

The steps to conduct patching are as follows:

  1. Untar the kernel source file and the M-systems TrueFFS Linux driver version 5.14. If the source code is in .tar.gz format, use

    tar -xvzf linux-2.4.18.tar.gz

    If the source code is in .tar.bz2 format, use

    bunzip2 linux-2.4.18.tar.bz2

    After using bunzip2, you will get a file named linux-2.4.18.tar. Untar it using the command

    tar -xvf linux-2.4.18.tar

    Unarchiving the driver is done using the command

    tar -xvzf linux_binary.5_1_4.tgz

    This results in the creation of two directories: linux and linux_binary.5_1_4.

  2. The TrueFFS Linux driver package contains three different folders:

    • Documentation: this contains a PDF document describing the various functions of TrueFFS.

    • dformat_5_1_4_37: this contains a utility dformat, which is used to update the firmware on the DiskOnChip (DOC) and to create low level partitions on the DOC.

    • doc-linux-5_1_4_20: this contains patches, initrd scripts and other utilities.

  3. Now apply the patch to the kernel. We will use the linux-2_4_7-patch file that is present in linux_binary.5_1_4/doc-linux-5_1_4_20/driver. The following commands are used for this purpose:

    cd linux_binary.5_1_4/doc-linux-5_1_4_20/driver

    patch -p1 -d /usr/src/linux < linux-2_4_7-patch

    This will create a directory named doc in the linux/drivers/block directory.

  4. The patch created the doc directory, but did not copy the source files of the M-Systems driver, which are necessary in order to build the driver, into this directory. So execute the following command:

    cp linux_binary.5_1_4/doc-linux-5_1_4_20/driver/doc/* /usr/src/linux/drivers/block/doc

WarningKernel version
 

The patch will fail for kernels other than 2.4.18 since the source files where the patch is to be applied may be somewhat different in different kernels. The patch has been provided specifically for kernel 2.4.18.

Before moving on to Step 2, do the following:

4.2. Step 2: Compile the Kernel

Complete the following tasks for compiling the kernel:

  1. cd linux

  2. make menuconfig

    Check for the following options:

    • In the "Block devices menu", select:

      • M-Systems driver as module i.e. (M)

      • Loopback device support as built-in i.e. (*)

      • RAM disk support as built-in i.e. (*)

      • Initial RAM disk (initrd) support as built .in i.e. (*)

    • In the "Processor type and features menu", select "Disable Symmetric Multiprocessor Support".

    • In the "filesystem menu", select:

      • Ext3 journaling file system support as built-in

      • DOS FAT fs support as built-ina

      • MSDOS fs support as built-inb

      • VFAT (Windows-95) fs support as built-inc

    NoteFile System Menu
     

    a,b,c options should be activated if you want to mount your MS Windows partition, else they can be left out. It is, however, generally recommended to use them.

    An excellent resource on kernel compilation is the Kernel Rebuild Guide.

    The configuration file, linux/.config should essentially contain the following lines (only a part of the config file has been given):

    
#
    # Loadable module support
    #
    CONFIG_MODULES=y
    CONFIG_MODVERSIONS=y
    CONFIG_KMOD=y
    
    #
    # Processor type and features
    #
    
    # CONFIG_SMP is not set
    
    
    #
    # Memory Technology Devices (MTD)
    #
    # CONFIG_MTD is not set
    
    #
    # Block devices
    #
    # CONFIG_BLK_DEV_FD is not set
    # CONFIG_BLK_DEV_XD is not set
    # CONFIG_PARIDE is not set
    # CONFIG_BLK_CPQ_DA is not set
    # CONFIG_BLK_CPQ_CISS_DA is not set
    # CONFIG_BLK_DEV_DAC960 is not set
    CONFIG_BLK_DEV_LOOP=y
    # CONFIG_BLK_DEV_NBD is not set
    CONFIG_BLK_DEV_RAM=y
    CONFIG_BLK_DEV_RAM_SIZE=4096
    CONFIG_BLK_DEV_INITRD=y
    CONFIG_BLK_DEV_MSYS_DOC=m
    
    #
    # File systems
    #
    # CONFIG_QUOTA is not set
    # CONFIG_AUTOFS_FS is not set
    # CONFIG_AUTOFS4_FS is not set
    CONFIG_EXT3_FS=y
    CONFIG_FAT_FS=y
    CONFIG_MSDOS_FS=y
    # CONFIG_UMSDOS_FS is not set
    CONFIG_VFAT_FS=y
    # CONFIG_EFS_FS is not set
    # CONFIG_JFFS_FS is not set
    # CONFIG_JFFS2_FS is not set
    # CONFIG_CRAMFS is not set
    CONFIG_TMPFS=y
    # CONFIG_RAMFS is not set
    CONFIG_ISO9660_FS=y
    # CONFIG_JOLIET is not set
    # CONFIG_HPFS_FS is not set
    CONFIG_PROC_FS=y
    # CONFIG_DEVFS_FS is not set
    # CONFIG_DEVFS_MOUNT is not set
    # CONFIG_DEVFS_DEBUG is not set
    CONFIG_DEVPTS_FS=y
    # CONFIG_QNX4FS_FS is not set
    # CONFIG_QNX4FS_RW is not set
    # CONFIG_ROMFS_FS is not set
    CONFIG_EXT2_FS=y
    
  3. make dep

  4. make bzImage

  5. make modules

  6. make modules_install

  7. Copy the newly created bzImage to the /bott directory and name it vmlinuz-2.4.18, using this command:

    cp /arch/i386/boot/bzImage /boot/vmlinuz-2.4.18

Check for lib/modules/2.4.18/kernel/drivers/block/doc.o. This is the M-Systems driver that we need to access DiskOnChip.

4.3. Step 3: Create Nodes

Now we will create block devices, which are required to access the DOC These block devices will use the M-Systems driver that was built in Section 4.2 to access the DOC. The script mknod_fl in linux_binary.5_1_4/doc-linux-5_1_4_20/driver is used for this purpose.

We need to create the block devices with the major number of 62. For this purpose we will pass the argument 62 while creating the nodes:

./mknod_fl 62

This will create the following devices in /dev/msys with major number 62:


fla...fla4
flb...flb4
flc...flc4
fld...fld4

4.4. Step 4: Reboot with the new kernel

In order to have the DiskOnChip recognized by Linux OS, we need to insert the DOC driver module into the kernel. Since the currently running kernel doesn.t have support for the M-Systems Driver, we need to boot into new kernel we just compiled in .

For this purpose we need to add the following entries in the /boot/grub/menu.lst file:


title Debian GNU/Linux,Kernel 2.4.18
root (hd0,7)
kernel /boot/vmlinuz-2.4.18 root=/dev/hda8
safedefault
boot

Where (hd0,7) is the partition holding the kernel image vmlinuz-2.4.18 and /dev/hda8 is the partition holding the root filesystem. These partitions may vary from one system to another. Now reboot and choose the kernel 2.4.18 option (the kernel that has been compiled in Step 2) in the grub menu to boot into the new kernel.

4.5. Step 5: Insert M-Systems Driver/Module in the new Kernel

The M-Systems driver by default gets loaded with major number 100, but our newly created nodes (see Section 4.3) have a major number 62. Therefore we need to insert this module with a major number 62. This can be done in either of two ways:

  1. While inserting the module using insmod also mention the major number for the module which needs to be assigned to it otherwise it will take the default major number of 100:

    insmod doc major=62

  2. Add the following line to /etc/modules.conf:

    options doc major=62

    Then use modprobe doc to insert the modules.

Check for the correct loading of the module using the lsmod command without options.

4.6. Step 6: Create a filesystem on the DiskOnChip

Before we can start using DiskOnChip we need to create a filesystem on it. We will create an ext2 filesystem since it is small in size.

This involves a hidden step of making partitions on the DOC using fdisk. The actual steps are as follows:

  1. fdisk /dev/msys/fla

    This command will ask to create partitions. Create a primary partition number 1 with start cylinder as 1 and final cylinder as 1002.

    Check the partition table, which should look like this:

    
Device             Boot  Start      End        Blocks    ID     System
    /dev/msys/fla1            1         1002        255984   83     Linux
    
  2. Make the filesystem on /dev/msys/fla1 with the command

    mke2fs -c /dev/msys/fla1

    Where fla1 is the first primary partition on the DOC. (We have created only one partition in order to avoid unnecessary complexity.)

4.7. Step 7: Mount the newly created partition to start accessing DOC

Create a new mount point for the DiskOnChip in the /mnt directory:

mkdir /mnt/doc

Mount the DOC partition on the newly created directory:

mount -t auto /dev/msys/fla1 /mnt/doc

You will now be able to read and write to the DOC as an additional storage drive.

When you reboot your system, make the DOC available by inserting the driver into the kernel (see Section 4.5) and mounting the device.