Skip to contentSkip to conversation

GRUB on DoC Millennium/2000 - Instructions

DISCUSSION Mark Meade 4 participants 5 messages Jun 18, 2002 – Jun 24, 2002 Memory technology devices (MTD)

lore
Share & tools
lore

Mark Meade

author
#0 lore raw

My apologies for screwing up the attachment. Here it is in text:

Booting GRUB on the DiskOnChip Millennium

1.  Preliminaries

The following procedure was done on a desktop PC, using an 8MB DoC Millennium and the M-Sys ISA Evaluation card.  A DOS partition was used to run the M-Sys utilities, prior to installing GRUB.   This procedure *might* work with a DoC 2000 -- but it has not been verified.

The Linux kernel must have the following MTD options either built-in or compiled as modules:

        MTD Support: MTD, Debugging, Direct char device access, NFTL, NTFL
write support:

                CONFIG_MTD=y
                CONFIG_MTD_DEBUG=y
                CONFIG_MTD_CHAR=y
                CONFIG_NFTL=y
                CONFIG_NFTL_RW=y

        Self-contained MTD Device Drivers: M-Systems DiskOnChip 2000 and
Millennium:

                CONFIG_MTD_DOC2000=y
                CONFIG_MTD_DOCPROBE=y

In the following examples, a 2.4.18 kernel called "vmlinuz-doc" with the above MTD options built-in was used.

2.  Save DoC contents, and the Bad Block Table

Get the latest version of the DOS based M-Systems DiskOnChip Software Utilities from www.m-sys.com.  If desired, the GETIMAGE utility can be used to save the current contents of the DoC:

        getimage /win:xxxx <filename>

(where xxxx is the DoC base memory address in hex (window), for example:
/win:d000)

**IMPORTANT**: Save the Bad Block Table!  Before attempting to boot with GRUB, make sure that the bad block table has been saved.  Doing this insures you can always restore the BBT in the event of the DoC being corrupted or completely erased:

        dformat /win:xxxx /noformat /log:<filename.txt>

This creates a text file containing a list of all the bad blocks on the DoC.
The dformat "uselog" option may be used to restore the BBT if needed.

        dinfo /BBT

will also display some detailed information about the DoC and the bad block table.

3.  Verify TrueFFS Driver Version

The newer versions (5.0 or later) of the M-Systems DOC firmware may not work correctly with the latest version of the MTD drivers. This has something to do with the "UnitSizeFactor != 1" problem documented elsewhere.  An earlier version (4.2) seems to work fine.

Using version 4.2 of the DOS TrueFFS utilities available from M-Systems (www.m-sys.com), verify that the DOC is recognized, and that the firmware version is 4.2:

        dinfo

If the firmware version is 5.0 or later, run the DFORMAT utility:

        dformat /win:xxxx /s:doc42.exb

4.  Patch and compile GRUB

Get the latest grub sources:

        mkdir grub-doc
        cd grub-doc
        ftp alpha.gnu.org
        cd gnu/grub
        get grub-0.92.tar.gz
        tar xzvf grub-0.92.tar.gz

Get the latest MTD sources:

        cvs -d :pserver:[email protected]:/home/cvs login (password = anoncvs)
        cvs -z3 -d :pserver:[email protected]:/home/cvs co mtd

Patch GRUB with DiskOnChip updates:

        cd grub-0.92
        patch -p0 -i ../mtd/patches/grub-2002-02-19-doc.patch

This patch may fail on the "ChangeLog" file, but all other files should patch correctly.  The 2002-02-19-doc patch was originally a patch against grub version 0.90.

5.  Build GRUB:

        aclocal && automake && autoconf

If there are any error messages here, you'll probably need up update automake and autoconf to the latest versions.

        ./configure --enable-diskonchip-mil512 --enable-ext2fs --enable-diskonchip-biosnetboot \
                --disable-ffs --disable-xfs --disable-jfs --disable-vstafs --disable-reiserfs --disable-minix --disable-fat
        make

See "README_DiskOnChip" for more information regarding the ./configure options, specifically the difference between "-mil256" and "-mil512".

6.  Copy GRUB to DOC

        cd ../mtd/util
        make doc_loadbios
        ./doc_loadbios /dev/mtd0 ../../grub-0.92/stage1/grub_firmware

If an error is reported regarding /dev/mtd0, you might need to run the ./MAKEDEV script to create the proper device MTD device entries in the /dev directory.

7.  TURN OFF PC!

**IMPORTANT** - The PC should be turned off (not just rebooted) after running doc_loadbios.  This may not be necessary on all types of hardware, but it was required on my PC.  From M-Systems application note DOC-044:

The boot block is implemented as a XIP block located between the flash media and the system bus.  After the DiskOnChip Millennium powers-on, or when its reset signal is negated, the contents of the first page of flash memory are copied into the Boot Block.

The "doc_loadbios" utility copies data to this first page of flash memory. My PC must not be "negating the reset signal" to the DoC on a normal reboot -- a full power cycle is required to copy the flash memory to the boot block.

8.  Change Boot Sequence

In the BIOS setup, select NETWORK (or NIC, or its equivalent) as the first boot device.

Selecting "--enable-diskonchip-biosnetboot" causes the GRUB/DoC code to hook INT 18H, which is historically known as the "BASIC interrupt" or "Diskless Boot Interrupt".  Using this option with the DoC on a PC is useful because you change easily change the boot sequence back to the hard drive when needed.

If the BIOS does not have a NETWORK boot option, it may be possible to disable the "biosnetboot" option, rebuild GRUB, and copy grub_firmware to the DoC again.  In this case, the GRUB/DoC code will hook the INT 19H (bootstrap) handler.  This doesn't work at all on my PC, but theoretically it should override any boot sequence options in the BIOS setup.

The downside of this option (in a PC environment, anyway) is that you may need to physically remove the DoC (or eval-board) to get the PC to boot from the hard drive again.  If that happens, it may be necessary to reinstall the DoC *after* the PC has booted, into a powered up eval board.  Of course, this is *not* recommended, but it has been done...

9.  Verify GRUB boot

The PC should now boot from the DiskOnChip.  The BIOS may say something like "Searching for boot record from Network...".  The first DoC messages displayed should be:

        DoC Mil D000
        Jumping to Grub
        DiskOnChip Millennium found at d0000

Where D000 is the "window" described earlier.

When the boot process completes, there should be a "grub>" command line.  We haven't installed a kernel or a "menu.lst" file on the DiskOnChip yet, so this step is just to verify that the "grub_firmware" was installed correctly, and that the DoC will boot.

At this point, you can either reboot again, change the boot sequence back to IDE (or whatever), and boot back into Linux.  Alternatively, if you know where your kernel and root filesystem is on the hard drive, simply type something like:

        kernel (hd0,0)/vmlinuz-doc root=/dev/hda2
        boot

10.  Partition the DiskOnChip

        fdisk /dev/nftla

If /dev/nftla is recognized, there will probably be one FAT12 partition on the DiskOnChip.  In this case, it won't be necessary to run the Linux "nftl_format" or "eraseall" utilities.  Use fdisk to delete this partition, and continue with step #11.

NOTE:  The "eraseall" utility can be dangerous as it will complete erase the DoC, including the bad block table -- saving the BBT as described in step #2 is highly recommended.

If /dev/ntfla is NOT recognized, use the nftl_format program:

        ./nftl_format /dev/mtd0 98304

The "start offset" of 98304 insures that the grub_firmware is not overwritten.  As nftl_format runs, there should be notices about "skipping bad zone (factory marked)".  The bad zone values should be identical to the values in the file created in step #2.

After nftl_format is complete, reboot the PC.

11.  Create ext2 partition

To boot directly from the DoC, we'll need to create an ext2 partition, and install the kernel and GRUB menu.lst file:

        fdisk /dev/nftla
        n p 1 <enter> <enter>   (create new primary partition, using defaults)
        w                        (save new partition info)

        mke2fs /dev/nftla1
        mkdir /mnt/doc
        mount -t ext2 /dev/nftla1 /mnt/doc
        mkdir -p /mnt/doc/boot/grub
        cp /boot/vmlinuz-doc /mnt/doc/boot

Now create a "menu.lst" file in /mnt/doc/boot/grub.  This file should contain the following:

        timeout 10
        default 0

        title DoC Millennium Boot
        kernel (dc0,0)/boot/vmlinuz-doc root=/dev/hdaX

Where hdaX is the hard drive that contains your root Linux filesystem.  You could also add another entry to the file to boot directly from the hard drive, if desired.

Umount the /mnt/doc directory, and reboot the PC.

At this point, the PC should boot entirely from the DoC, and attempt to mount the root filesystem on your hard drive.  If this works, the next step to a fully self-contained boot is to create a full root filesystem or ramdisk on the DoC.  Once that has been done, change the "root=/dev/hdaX" option to "root=/dev/ntfla1".

Credits:

Thanks to Ilguiz Latypov <[email protected]> for reviewing these instructions, and for answering many questions related to GRUB on the DiskOnChip.

#1 lore raw

Mark, that's excellent documentation -- thanks. Is it OK for me to put that on the web site?

I have only one suggestion -- rather than using fdisk to create a single partition and then formatting that as ext2, we might as well just put the ext2 file system on /dev/nftla (i.e. the whole device), and use (dc0) in Grub instead.

BTW, did your 'factory marked' bad blocks in step 10 really match the ones from step 2? I'm still suspicious of nftl_format. It would be _really_ nice if we could use DFORMAT -- either a Linux port of DFORMAT to replace nftl_format and/or working out how to turn our Grub image into a .EXB file so it can be loaded directly by DFORMAT.

--
dwmw2

author
#2 lore raw
Quoted 2 lines · David Woodhouse

Mark, that's excellent documentation -- thanks. Is it OK for me to put that on the web site?

Absolutely!

Quoted 4 lines

I have only one suggestion -- rather than using fdisk to create a single partition and then formatting that as ext2, we might as well just put the ext2 file system on /dev/nftla (i.e. the whole device), and use (dc0) in Grub instead.

Agreed. I vaguely recall questions related to multiple partitions on the DoC -- my thought was writing it up as one big /dev/nftla1 partition may make it more obvious for those wanting to extend that to nftla2, 3, etc.

Quoted 2 lines

BTW, did your 'factory marked' bad blocks in step 10 really match the ones from step 2? I'm still suspicious of nftl_format.

Yes, it did. The /LOG option in DFORMAT stuffs the bad blocks, in hex, into a text file. They matched the bad blocks reported by nftl_format.

Quoted 4 lines

It would be _really_ nice
if we could use DFORMAT -- either a Linux port of DFORMAT to replace nftl_format and/or working out how to turn our Grub image into a .EXB file so it can be loaded directly by DFORMAT.

The latest DFORMAT has an option "/BDKF:<boot image file>" that supposedly will place a boot image file in the "binary (BDK) partition". I tried this with grub_firmware, and I think it actually worked. I'll try again, and if I can make this work reliably, I'll post the details.

A Linux DFORMAT that would load the grub firmware and create one ext2 partition all in one shot (like the DOS version does with the M-Sys firmware and FAT12 partition) would be nice!

Regards,

Mark

#3 lore raw
In reply to Mark Meade

Thanks, Mark. Your procedures work for me so you can make it the official HOWTO. I guess the difference is dformat. eraseall seems to make the DoC Mil oblivious to the BIOS. Only annoying thing is you have to boot it in DOS and run dformat. A linux version of dformat would be nice. How do we go about it? Is there code to port it?

Quoted 192 lines · Mark Meade

My apologies for screwing up the attachment. Here it is in text:

Booting GRUB on the DiskOnChip Millennium

1. Preliminaries

The following procedure was done on a desktop PC, using an 8MB DoC Millennium and the M-Sys ISA Evaluation card. A DOS partition was used to run the M-Sys utilities, prior to installing GRUB. This procedure *might* work with a DoC 2000 -- but it has not been verified.

The Linux kernel must have the following MTD options either built-in or compiled as modules:

MTD Support: MTD, Debugging, Direct char device access, NFTL, NTFL write support:

CONFIG_MTD=y
CONFIG_MTD_DEBUG=y
CONFIG_MTD_CHAR=y
CONFIG_NFTL=y
CONFIG_NFTL_RW=y

Self-contained MTD Device Drivers: M-Systems DiskOnChip 2000 and Millennium:

CONFIG_MTD_DOC2000=y
CONFIG_MTD_DOCPROBE=y

In the following examples, a 2.4.18 kernel called "vmlinuz-doc" with the above MTD options built-in was used.

2. Save DoC contents, and the Bad Block Table

Get the latest version of the DOS based M-Systems DiskOnChip Software Utilities from www.m-sys.com. If desired, the GETIMAGE utility can be used to save the current contents of the DoC:

getimage /win:xxxx <filename>

(where xxxx is the DoC base memory address in hex (window), for example: /win:d000)

**IMPORTANT**: Save the Bad Block Table! Before attempting to boot with GRUB, make sure that the bad block table has been saved. Doing this insures you can always restore the BBT in the event of the DoC being corrupted or completely erased:

dformat /win:xxxx /noformat /log:<filename.txt>

This creates a text file containing a list of all the bad blocks on the DoC. The dformat "uselog" option may be used to restore the BBT if needed.

dinfo /BBT

will also display some detailed information about the DoC and the bad block table.

3. Verify TrueFFS Driver Version

The newer versions (5.0 or later) of the M-Systems DOC firmware may not work correctly with the latest version of the MTD drivers. This has something to do with the "UnitSizeFactor != 1" problem documented elsewhere. An earlier version (4.2) seems to work fine.

Using version 4.2 of the DOS TrueFFS utilities available from M-Systems (www.m-sys.com), verify that the DOC is recognized, and that the firmware version is 4.2:

dinfo

If the firmware version is 5.0 or later, run the DFORMAT utility:

dformat /win:xxxx /s:doc42.exb

4. Patch and compile GRUB

Get the latest grub sources:

       mkdir grub-doc
       cd grub-doc
       ftp alpha.gnu.org
       cd gnu/grub
       get grub-0.92.tar.gz
       tar xzvf grub-0.92.tar.gz

Get the latest MTD sources:

cvs -d :pserver:[email protected]:/home/cvs login (password = anoncvs)
cvs -z3 -d :pserver:[email protected]:/home/cvs co mtd

Patch GRUB with DiskOnChip updates:

       cd grub-0.92
       patch -p0 -i ../mtd/patches/grub-2002-02-19-doc.patch

This patch may fail on the "ChangeLog" file, but all other files should patch correctly. The 2002-02-19-doc patch was originally a patch against grub version 0.90.

5. Build GRUB:

       aclocal && automake && autoconf

If there are any error messages here, you'll probably need up update automake and autoconf to the latest versions.

       ./configure --enable-diskonchip-mil512 --enable-ext2fs 
--enable-diskonchip-biosnetboot \
               --disable-ffs --disable-xfs --disable-jfs --disable-vstafs 

--disable-reiserfs --disable-minix --disable-fat
make

See "README_DiskOnChip" for more information regarding the ./configure options, specifically the difference between "-mil256" and "-mil512".

6. Copy GRUB to DOC

       cd ../mtd/util
       make doc_loadbios
       ./doc_loadbios /dev/mtd0 ../../grub-0.92/stage1/grub_firmware

If an error is reported regarding /dev/mtd0, you might need to run the ./MAKEDEV script to create the proper device MTD device entries in the /dev directory.

7. TURN OFF PC!

**IMPORTANT** - The PC should be turned off (not just rebooted) after running doc_loadbios. This may not be necessary on all types of hardware, but it was required on my PC. From M-Systems application note DOC-044:

The boot block is implemented as a XIP block located between the flash media and the system bus. After the DiskOnChip Millennium powers-on, or when its reset signal is negated, the contents of the first page of flash memory are copied into the Boot Block.

The "doc_loadbios" utility copies data to this first page of flash memory. My PC must not be "negating the reset signal" to the DoC on a normal reboot -- a full power cycle is required to copy the flash memory to the boot block.

8. Change Boot Sequence

In the BIOS setup, select NETWORK (or NIC, or its equivalent) as the first boot device.

Selecting "--enable-diskonchip-biosnetboot" causes the GRUB/DoC code to hook INT 18H, which is historically known as the "BASIC interrupt" or "Diskless Boot Interrupt". Using this option with the DoC on a PC is useful because you change easily change the boot sequence back to the hard drive when needed.

If the BIOS does not have a NETWORK boot option, it may be possible to disable the "biosnetboot" option, rebuild GRUB, and copy grub_firmware to the DoC again. In this case, the GRUB/DoC code will hook the INT 19H (bootstrap) handler. This doesn't work at all on my PC, but theoretically it should override any boot sequence options in the BIOS setup.

The downside of this option (in a PC environment, anyway) is that you may need to physically remove the DoC (or eval-board) to get the PC to boot from the hard drive again. If that happens, it may be necessary to reinstall the DoC *after* the PC has booted, into a powered up eval board. Of course, this is *not* recommended, but it has been done...

9. Verify GRUB boot

The PC should now boot from the DiskOnChip. The BIOS may say something like "Searching for boot record from Network...". The first DoC messages displayed should be:

DoC Mil D000
Jumping to Grub
DiskOnChip Millennium found at d0000

Where D000 is the "window" described earlier.

When the boot process completes, there should be a "grub>" command line. We haven't installed a kernel or a "menu.lst" file on the DiskOnChip yet, so this step is just to verify that the "grub_firmware" was installed correctly, and that the DoC will boot.

At this point, you can either reboot again, change the boot sequence back to IDE (or whatever), and boot back into Linux. Alternatively, if you know where your kernel and root filesystem is on the hard drive, simply type something like:

       kernel (hd0,0)/vmlinuz-doc root=/dev/hda2
       boot

10. Partition the DiskOnChip

fdisk /dev/nftla

If /dev/nftla is recognized, there will probably be one FAT12 partition on the DiskOnChip. In this case, it won't be necessary to run the Linux "nftl_format" or "eraseall" utilities. Use fdisk to delete this partition, and continue with step #11.

NOTE: The "eraseall" utility can be dangerous as it will complete erase the DoC, including the bad block table -- saving the BBT as described in step #2 is highly recommended.

If /dev/ntfla is NOT recognized, use the nftl_format program:

       ./nftl_format /dev/mtd0 98304

The "start offset" of 98304 insures that the grub_firmware is not overwritten. As nftl_format runs, there should be notices about "skipping bad zone (factory marked)". The bad zone values should be identical to the values in the file created in step #2.

After nftl_format is complete, reboot the PC.

11. Create ext2 partition

To boot directly from the DoC, we'll need to create an ext2 partition, and install the kernel and GRUB menu.lst file:

fdisk /dev/nftla
n p 1 <enter> <enter> (create new primary partition, using defaults)
w (save new partition info)

mke2fs /dev/nftla1
mkdir /mnt/doc
mount -t ext2 /dev/nftla1 /mnt/doc
mkdir -p /mnt/doc/boot/grub
cp /boot/vmlinuz-doc /mnt/doc/boot

Now create a "menu.lst" file in /mnt/doc/boot/grub. This file should contain the following:

timeout 10
default 0

title DoC Millennium Boot
kernel (dc0,0)/boot/vmlinuz-doc root=/dev/hdaX

Where hdaX is the hard drive that contains your root Linux filesystem. You could also add another entry to the file to boot directly from the hard drive, if desired.

Umount the /mnt/doc directory, and reboot the PC.

At this point, the PC should boot entirely from the DoC, and attempt to mount the root filesystem on your hard drive. If this works, the next step to a fully self-contained boot is to create a full root filesystem or ramdisk on the DoC. Once that has been done, change the "root=/dev/hdaX" option to "root=/dev/ntfla1".

Credits:

Thanks to Ilguiz Latypov <[email protected]> for reviewing these instructions, and for answering many questions related to GRUB on the DiskOnChip.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#4 lore raw
In reply to Mark Meade

Hello.

First off, this is very well written; I like it. I got this far:

Quoted 10 lines · * on the Tue, Jun 18, 2002 at 12:55:17PM -0400, Mark Meade wrote:

9.  Verify GRUB boot

The PC should now boot from the DiskOnChip.  The BIOS may say something like "Searching for boot record from Network...".  The first DoC messages displayed should be:

        DoC Mil D000
        Jumping to Grub
        DiskOnChip Millennium found at d0000

Quoted 6 lines

Where D000 is the "window" described earlier.

When the boot process completes, there should be a "grub>" command line.  We haven't installed a kernel or a "menu.lst" file on the DiskOnChip yet, so this step is just to verify that the "grub_firmware" was installed correctly, and that the DoC will boot.

Since I can't boot from NIC, I have it booting normal, like a disk. Everytime, that is. Now I can't change back to lilo on the harddisk. I have no floppy of course. And I don't like soldering the DoC off.

Quoted 7 lines

At this point, you can either reboot again, change the boot sequence back to IDE (or whatever), and boot back into Linux.  Alternatively, if you know where your kernel and root filesystem is on the hard drive, simply type something like:

        kernel (hd0,0)/vmlinuz-doc root=/dev/hda2
        boot

I'd love to. Of course, for some reason my grub can't read the filesystem on the disk. The Question now is:

"If grub can't read the filesystem, how do I tell grub where the kernel resides, and how do I find this out where it is?".

This probably belongs to some grub-mailinglist, but I don't feel like subscribing one more mailinglist, and more importantly, I think it would be nice to have that information included in this text as well.

Right now I'm trying to reformat and setup the disk in another machine, in the hope that "kernel (hd0,0)/vmlinuz-doc root=/dev/hda1\nboot" will do the trick then; if not, I really need a solution as outlined above..

Cheers
Peter

Signature · 2 lines
Those who give up essential liberties for temporary safety deserve 
neither liberty nor safety. -- Benjamin Franklin