Booting from DOC2000 with GRUB loader
Hi all (and Russ in particular)
I've got the same problem as previous post on this subject:
---------------------------------------
Quoted 7 lines · Zhiwei Yu
Hi,
I am working on booting from DOC2000, LILO works on my box but GRUB doesn't. After I patched the latest patch for GRUB, I got grub-fireware and sucessfully load the fireware in DOC.
Quoted 7 lines
For now, everytime I boot up, I got grub prompt, but I failed to load kernel, the command I using is kernel (dc0,0)/boot/bzImage.
This problem is not new to the list, I found several similar mails, All of them didn't have the answer. DI u have any idea? Thanks in advance.
probably because you overwrote some nftl stuff with grub. Erase the whole thing (eraseall /dev/mtd0), put grub on it, find the next free block directly past grub and nftl_format at that offset. fdisk your nftla, mkfs the partition, add the kernel, and maybe a menu.lst.
----------------------------------------------
My question is: *how* do I "find the next free block directly past grub"?
When I put grub on there (not at that stage realising I was going to trash my existing nftl partitions and so I omitted to record the output), I *seem to* recall that doc_loadbios reported needing 6 x 16k "blocks" to store the grub firmware - which fits, because the grub_firmware file is 87k.
So, in what units is the <start offset> argument to nftl_format? i.e. do I do :
nftl_format /dev/mtd0 6 (16k blocks)
or nftl_format /dev/mtd0 96 (1k blocks)
or nftl_format /dev/mtd0 98304 (bytes)
etc...?
I'm nervous about messing this up because since I put grub on the DoC, the machine only ever boots from the DoC - completely ignores floppy, scsi disks and cdrom. So if I screw up this nftl_format and trash grub, I'm going to end up with an unbootable system ;-( (OK, I'll just have to pull the DoC chip out of the board *again*, but even this gives me the eebies, so tight is the damn thing stuck in its socket! And anyway, if the system is unbootable with the DoC chip in there, how am I ever going to reprogram it?)
Help much appreciated!
TIA
John
***************************************************
John Sutton
SCL Internet
URL http://www.scl.co.uk/
Tel. +44 (0) 1239 711 888
***************************************************
From the commands pondered upon -
nftl_format /dev/mtd0 98304
works fine for me in a similar setup. The same was given as a reference, the first time the grub and DOC2000 patch showed up.
Quoted 70 lines · John Sutton
Hi all (and Russ in particular)
I've got the same problem as previous post on this subject:
---------------------------------------
Quoted 7 lines · Zhiwei Yu
Hi,
I am working on booting from DOC2000, LILO works on my box but GRUB doesn't. After I patched the latest patch for GRUB, I got grub-fireware and sucessfully load the fireware in DOC.
Quoted 6 lines
For now, everytime I boot up, I got grub prompt, but I
failed to load kernel, the command I using is kernel (dc0,0)/boot/bzImage.This problem is not new to the list, I found several similar mails, All of them didn't have the answer. DI u have any idea? Thanks in advance.
probably because you overwrote some nftl stuff with grub. Erase the whole thing (eraseall
/dev/mtd0), put grub on it, find the next free block directly past grub andnftl_formatat that offset. fdisk your nftla, mkfs the partition, add the kernel, and maybe a menu.lst.
----------------------------------------------My question is: *how* do I "find the next free block directly past grub"?
When I put grub on there (not at that stage realising I was going to trash my existing nftl partitions and so I omitted to record the output), I *seem to* recall that
doc_loadbiosreported needing 6 x 16k "blocks" to store the grub firmware - which fits, because thegrub_firmwarefile is 87k.So, in what units is the <start offset> argument to
nftl_format? i.e. do I do :
nftl_format/dev/mtd06 (16k blocks)or
nftl_format/dev/mtd096 (1k blocks)or
nftl_format/dev/mtd098304 (bytes)etc...?
I'm nervous about messing this up because since I put grub on the DoC, the machine only ever boots from the DoC - completely ignores floppy, scsi disks and cdrom. So if I screw up this
nftl_formatand trash grub, I'm going to end up with an unbootable system ;-( (OK, I'll just have to pull the DoC chip out of the board *again*, but even this gives me the eebies, so tight is the damn thing stuck in its socket! And anyway, if the system is unbootable with the DoC chip in there, how am I ever going to reprogram it?)Help much appreciated!
TIA
John***************************************************
John Sutton
SCL Internet
URL http://www.scl.co.uk/
Tel. +44 (0) 1239 711 888
***************************************************______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Hi John,
Quoted 1 line · John Sutton
or
nftl_format/dev/mtd098304 (bytes)
The third option is the right one. The start offset of the NFTL layer must be specified in bytes.
Quoted 2 lines
And anyway, if the system is unbootable with the DoC chip in there, how am I ever going to reprogram it?)
Install GRUB or LILO on your hard disk. Insert the DOC chip when you've gotten to the boot prompt.
Ilguiz
Quoted 2 lines
or
nftl_format/dev/mtd098304 (bytes)
this one is correct
Quoted 9 lines
I'm nervous about messing this up because since I put grub on the DoC, the machine only ever boots from the DoC - completely ignores floppy, scsi disks and cdrom. So if I screw up this
nftl_formatand trash grub, I'm going to end up with an unbootable system ;-( (OK, I'll just have to pull the DoC chip out of the board *again*, but even this gives me the eebies, so tight is the damn thing stuck in its socket! And anyway, if the system is unbootable with the DoC chip in there, how am I ever going to reprogram it?)Help much appreciated!
*** WARNING *** WARNING *** WARNING *** WARNING ***
THIS CAN DAMAGE YOUR HARDWARE AND BLOW YOU UP
(but it seems to work for me)
*** WARNING *** WARNING *** WARNING *** WARNING ***
I have an ISA card for the DOC2000, I boot up my workstation, carefully plug in the isacard, modprobe doc2000, insmod docprobe insmod mtdchar (if necessary) insmod nftl (if necessary). Do whatever I need to do, rmmod nftl, rmmod docprobe, rmmod doc2000, and remove the card. On my machine, doing this using the devfsd nodes causes an oops after the first time, a simple workaround is using hand made device files.
*** WARNING *** WARNING *** WARNING *** WARNING ***
THIS CAN DAMAGE YOUR HARDWARE AND BLOW YOU UP
(but it seems to work for me)
*** WARNING *** WARNING *** WARNING *** WARNING ***
Hi again
Many thanks for all that feedback! Definitely a positive consensus about the units for start_offset ;-)
Jasmine suggests that I should leave some extra after the end of grub for future expansion, which seems a good idea, but raises in my mind the question as to how grub (or anything else) knows where the nftl partition starts? Does nftl_format also write a pointer to the start block somewhere else? Or does the format contain some kind of signature?
Re the suggestions as to how to recover from an unbootable system! To an old fool like me, the idea of pushing a chip into a live board makes my hair curl! Anyways, I hope it doesn't come to that as it would in my case be extremely difficult, if not impossible - I'm using an SBC plugged into a passive backplane and the DoC socket is right at the bottom next to the edge connector ;-(
Jasmine also comments that:
Quoted 10 lines
Quoted 2 lines
and cdrom. So if I screw up this
nftl_formatand trash grub, I'm going to end up with an unbootable system ;-(no you aren't. If you tell grub:
rootnoverify (fd0)
chainloader +1
bootit will boot off the floppy.
But this assumes that I *haven't* trashed grub?
Quoted 2 lines
(If you totally trash grub, the BIOS won't load
anything off the DoC in the first place.)
Can it take that to mean that the BIOS will do some kind of checksum on the code it's going to pass control to (i.e., in this case, grub) and *won't* jump to it if the checksum fails? That would be nice but I fear it's not the case given the advice from the other guys who have obviously on occasion found themselves in exactly this kind of mess?
And finally, off-list (so to speak) I've had this email from Cfowler <[email protected]>:
Quoted 3 lines
Do not use grub. You have erased the badblock table on that DOC and it is no logner good for production. I spent 2 days recovering from this mess.
What am I to make of that?
TIA
John
Quoted 34 lines · you
Quoted 1 line
or
nftl_format/dev/mtd098304 (bytes)this one is correct
Quoted 9 lines
I'm nervous about messing this up because since I put grub on the DoC, the machine only ever boots from the DoC - completely ignores floppy, scsi disks and cdrom. So if I screw up this
nftl_formatand trash grub, I'm going to end up with an unbootable system ;-( (OK, I'll just have to pull the DoC chip out of the board *again*, but even this gives me the eebies, so tight is the damn thing stuck in its socket! And anyway, if the system is unbootable with the DoC chip in there, how am I ever going to reprogram it?)Help much appreciated!
*** WARNING *** WARNING *** WARNING *** WARNING ***
THIS CAN DAMAGE YOUR HARDWARE AND BLOW YOU UP
(but it seems to work for me)*** WARNING *** WARNING *** WARNING *** WARNING ***
I have an ISA card for the DOC2000, I boot up my workstation, carefully plug in the isacard, modprobe doc2000, insmod docprobe insmod mtdchar (if necessary) insmod nftl (if necessary). Do whatever I need to do, rmmod nftl, rmmod docprobe, rmmod doc2000, and remove the card. On my machine, doing this using the devfsd nodes causes an oops after the first time, a simple workaround is using hand made device files.
*** WARNING *** WARNING *** WARNING *** WARNING ***
THIS CAN DAMAGE YOUR HARDWARE AND BLOW YOU UP
(but it seems to work for me)*** WARNING *** WARNING *** WARNING *** WARNING ***
Signature · 6 lines
*************************************************** John Sutton SCL Internet URL http://www.scl.co.uk/ Tel. +44 (0) 1239 711 888 ***************************************************
Quoted 10 lines · John Sutton
Hi again
Many thanks for all that feedback! Definitely a positive consensus about the units for
start_offset;-)Jasmine suggests that I should leave some extra after the end of grub for future expansion, which seems a good idea, but raises in my mind the question as to how grub (or anything else) knows where the nftl partition starts? Does
nftl_formatalso write a pointer to the start block somewhere else? Or does the format contain some kind of signature?
just sure to erase any unused sectors.
nftl looks for a media header signiture
Quoted 6 lines
Re the suggestions as to how to recover from an unbootable system! To an old fool like me, the idea of pushing a chip into a live board makes my hair curl! Anyways, I hope it doesn't come to that as it would in my case be extremely difficult, if not impossible - I'm using an SBC plugged into a passive backplane and the DoC socket is right at the bottom next to the edge connector ;-(
maybe something in bios could help (shadow regions, etc)
Nearly there ;-)...
Quoted 6 lines · Russ Dill
Quoted 5 lines · John Sutton
Hi again
Many thanks for all that feedback! Definitely a positive consensus about the units for
start_offset;-)
Quoted 7 lines
Quoted 5 lines
Jasmine suggests that I should leave some extra after the end of grub for future expansion, which seems a good idea, but raises in my mind the question as to how grub (or anything else) knows where the nftl partition starts? Does
nftl_formatalso write a pointer to the start block somewhere else? Or does the format contain some kind of signature?just sure to erase any unused sectors.
Is a sector a block? And what is a block?
Here's where I'm up to now:
./nftl_format /dev/mtd0 98304
$Id: nftl_format.c,v 1.17 2001/08/29 14:28:48 dwmw2 Exp $ Erase size not 8Kb - I'm confused
So I put a %d for meminfo.erasesize in the printf and I get:
./nftl_format /dev/mtd0 98304
$Id: nftl_format.c,v 1.17 2001/08/29 14:28:48 dwmw2 Exp $ Erase size not 8Kb - I'm confused 16384
So I've got a 16Kb erase size. What now? If I hack the source so that it just falls through this test and proceeds to malloc(meminfo.erasesize * 5) am I heading for big trouble or success?
Once I've gotten past this little gotcha, how do I go about using the erase util to erase the piece between the end of the grub and the start of the nftl partition? I'm thinking that if I start the nftl at 98304 then I don't need to erase anything because doc_loadbios will have already erased the unoccupied 96k-87k=9k at the end of the last of the 6 blocks. Whereas, if I do:
./nftl_format /dev/mtd0 114688 ( i.e. 7 x 16k block )
then I'll need to do:
erase /dev/mtd0 6 1
or, should that be:
erase /dev/mtd0 98304 16384
Sorry to be a dummy ;-(
Thanks again!
***************************************************
John Sutton
SCL Internet
URL http://www.scl.co.uk/
Tel. +44 (0) 1239 711 888
***************************************************
John,
Quoted 1 line · John Sutton
Erase size not 8Kb - I'm confused
Do I understand correctly from the numerous clarifications in this mailing list that the nftl_format utility may result in an NFTL layer incompatible with the M-System's one when the chip's erase size is not 8Kb? I myself removed the check and was able to format and use the chip.
I am dumber when it comes to the bad block table issue. My guess is that nftl_format marks bad erase sectors in the NFTL bad block table. No way GRUB itself is aware of any bad sectors in its own area. My impression is that erase sectors can be marked as bad in their ECC header, but others may give you a less idiotic answer.
Ilguiz
Quoted 2 lines · Ilguiz Latypov
I am dumber when it comes to the bad block table issue. My guess is that
nftl_formatmarks bad erase sectors in the NFTL bad block table.
It's supposed to but David wasn't sure whether this code worked properly. Regardless of that, the blocks have their good/bad status marked in the OOB area and nftl_format, while it doesn't necessarily handle it correctly, certainly doesn't destroy that data.
Quoted 2 lines
No way
GRUB itself is aware of any bad sectors in its own area.
If that area was bad, the chip would most likely be unusable- the IPL code isn't smart enough to take notice of such things, so any chips that had badness in the first 48k or so would have failed M-Systems factory QC.
Jas.
Quoted 2 lines · John Sutton
Nearly there ;-)...
Indeed so :-)
Quoted 3 lines
So I've got a 16Kb erase size. What now? If I hack the source so that it just falls through this test and proceeds to
malloc(meminfo.erasesize * 5)am I heading for big trouble or success?
I *think* it works.
Quoted 3 lines
Once I've gotten past this little gotcha, how do I go about using the erase util to erase the piece between the end of the grub and the start of the nftl partition?
Why not just erase the entire thing, then do doc_loadbios to put the grub firmware into it, and then nftl_format? Then you'd be sure it was all clean and empty.
That's how I did it, anyway.
Jas.
I have some poblem getting grub+doc working.
I followed the instructions :
1- patched grub-0.91 with mtd/patches/grub-2002-02-19-doc.patch 2- ./configure --enable-diskonchip-2000
3- make
4- cp stage2/pre_stage2 mtd/grub
5- cd mtd/grub
6- make
7- ../util/doc_loadbios /dev/mtd0 grub_firmware
8- reboot (I have a nftl partition right after the grub on the doc 2000)
I get the grub prompt but it does not know about dc0. When I enter "root (dc0,0)", I get : "Error 21: Selected disk does not exist".
Did I do something wrong?
Fred
Frederick,
There can be 2 things missing:
a) the *.in files must be re-generated with
aclocal && automake && autoconf
as John Sutton showed in the RPM spec file. Also, there is README_DiskOnChip file in the patch that advises the same.
b) The only block device layer supported by the DoC MTD patch to GRUB is NFTL. This means you may need to create a filesystem on top of the /dev/nftla device or partition it into pieces with fdisk. In the first case you may need to specify "root (dc0)".
If you don't want to mess with NFTL layer, you might be interested in another bootloader based on FFS2 filesystem. I saw it in the boot directory of the MTD CVS repository, but never tried it.
Perhaps, the GRUB bootloader can be modified to access a read-only filesystem created on top of the raw NAND flash sectors.
And finally, the read-write JFFS2 filesystem was specifically designed with flash memory in mind. I heard about experimental work to enable JFFS2 on NAND flash chips. See the mailing list archives. It would be nice to make GRUB recognize JFFS2 filesystem.
Ilguiz
Quoted 1 line · Frederick Lefebvre
"root (dc0,0)", I get : "Error 21: Selected disk does not exist".
Ah, sweet success!
After a number of you made clear that you'd already blazed this trail, I took the plunge and commented out the "I'm confused" check in nftl_format, and ran it:
[root@spartam util]# ./nftl_format /dev/mtd0 98304
$Id: nftl_format.c,v 1.17 2001/08/29 14:28:48 dwmw2 Exp $ Phase 1. Checking and erasing Erase Zones from 0x00018000 to 0x01000000 Skipping bad zone (factory marked) #672 @ 0xa80000
Checking Zone #1023 @ 0xffc000
Phase 2.a Writing NFTL Media Header and Bad Unit Table Phase 2.b Writing Spare NFTL Media Header and Spare Bad Unit Table Phase 3. Writing Unit Control Information to each Erase Unit
All looks good to me, and the stuff about skipping factory marked zones and writing bad unit tables certainly give the impression that it knows what it's doing! So my previous concern re "You have erased the badblock table on that DOC and it is no logner good for production" was probably misplaced? Anyway, in my application, once I've put this thing to bed, I only expect to have to rewrite a small part of the doc, and only that say half a dozen times in the lifetime of the system. So with an expected minimum rewrites of 100,000 (according to M-systems web site), I'm surely in the clear.
After that I fdisked /dev/nftla and set up partitions, mke2fs, mkdir /boot, put a kernel in it, mkdir /boot/grub and put a menu.lst in there, reboot, bingo!
I realise with the benefit of hindsight that to avoid the danger of ending up with an unbootable system when doing the nftl_format, all that's necessary is to always follow it with (another) doc_loadbios. So, even if you can't figure out the numbers exactly, you'll get there eventually by trial and error.
Some outstanding oddities with my grub on DoC:
1) At the command line (at least) the backspace key seems to have gotten munged? It seems to be emitting a single ^H rather than ^H<space>^H so it's not clear that you've actually deleted a character (but you have). Maybe this is the same with vanilla grub (i.e. without mtd patch) but I didn't notice it before?
2) More disconcerting, the TAB completion of valid devices in the "root" command does not wholly recognise the "dc" prefix. The behaviour, which is rather complex, is as follows:
root ( hit TAB sees only my scsi disks hd0 and hd1
root (d
root (dc hit TAB both give errors root (dc0 hit TAB its happy with but it doesn't give you the comma root (dc0, hit TAB now its motoring! It's shows me my 2 partitions 0 and
1 and, once I've selected one, TAB completion of filenames in the partition when using the "kernel" command works fine.
Maybe both of these problems arise from the fact that I applied the latest mtd patch (grub-2002-02-19-doc.patch) against a *later* grub source (0.92)? A few of the hunks were "shifted" (applied at different line numbers) but they did stick.
Here are a few observations on the whole process which haven't come up (explicitly at least) in this thread so far and which might be of help to others:
1) I've you've already gotten lilo going on your doc and are now trying to get grub going, note the crucial difference: when you put grub on the doc as opposed to putting it on a floppy or hard disk, you are putting both stage1 AND stage2 on there. Which is nice once you've understood that ;-) But if (like me) you thought you were just putting a 512 byte boot loader on the grub which then knows the address of an mtd-aware stage2 stored in an nftl partition, then it comes as a rather rude surprise to find that you've trashed your existing efforts.
2) Related to 1 (and here I'm only clear about the generalities and not the details), note that the nftl format which exists on the doc when you take it out of the wrapper - which is put on there by M-systems - is not the same thing as that which you end up with (and need) to use grub. Quite why we've got 2 different implementations of this format on the go, I don't know, but I became aware of it rather painfully ;-).
I started with the 2.4.18 kernel sources and using the help in make menuconfig put together a kernel which looked like it would do the job. And it did, so far as it went - on booting the kernel I could see the chip, fdisk /dev/nftla, mke2fs, everything sorted. But then (no big surprise) I found that vanilla lilo couldn't deal with it, so I downloaded M-systems patched lilo, installed that and everything looked good. The point here however is that up to this point I am still using the nftl format put on there by M-systems. Once you want to have a go with grub, this is no good. (Presumably precisely because the mtd-patched grub insists on putting stage2 onto the doc thus trashing this existing format?
Can't see why you couldn't have a "standard" grub installation which
would only need to overwrite 512 bytes like lilo does? Not that that would have much merit in itself.)
Anyway, upshot of all this is that the kernel I'd built (and which I'd imagined was everything needed because this far it had done everything required of it) was no good because I'd omitted CONFIG_MTD_CHAR. So when I tried doc_loadbios /dev/mtd0 it wouldn't work because there was nothing listening. (Cannot open device, or something like that.) After some digging about in the kernel sources, I realised what was missing, built a new kernel, ran doc_loadbios and THEN, when I saw it erasing 96k instead of 512 bytes, the penny finally dropped!
Here are the kernel config options which I've ended up with for my DoC2000 chip (and with everything paranoid switched on ;-) :
CONFIG_MTD=mCONFIG_MTD_CHAR=mCONFIG_NFTL=mCONFIG_NFTL_RW=y
CONFIG_MTD_DOC2000=mCONFIG_MTD_DOCPROBE=mCONFIG_MTD_DOCPROBE_ADDRESS=0
CONFIG_MTD_NAND=mCONFIG_MTD_NAND_ECC=yCONFIG_MTD_NAND_VERIFY_WRITE=y
I started off with all this built in the kernel rather than as modules but was getting fed up with docprobe (CONFIG_MTD_DOCPROBE) making a mess of my console and syslog. And on reading docprobe.c turns out that this probing process is sometimes dangerous as well as messy, so I changed to building as modules because then you can pass a single address in modules.conf:
options docprobe doc_config_location=0xcc000
Of course, YMMV in respect of the particular address at which your chip presents itself. (Mine is set with jumpers on the motherboard). No doubt this will end up being available as a kernel parameter in due course but as best I can tell it has to be a module option at present.
So, happy grubbing and many thanks to all. Hopefully I'll get this damn thing out of the door pretty soon and will not be bugging you guys any longer, but I'd be pleased to give assistance to any newbies out there. But note, I'm not subscribed to the list so be sure to copy any post to me [email protected] if you think I can help you.
***************************************************
John Sutton
SCL Internet
URL http://www.scl.co.uk/
Tel. +44 (0) 1239 711 888
***************************************************
Quoted 4 lines · John Sutton
...the nftl
format put on there by M-systems. Once you want to have a go with grub, this is no good. (Presumably precisely because the mtd-patched grub insists on putting stage2 onto the doc thus trashing this existing format?
Yes. The M-systems stuff reserves a block at the start of the DoC for the BIOS extender- however it only seems to be 48kbytes on any of the parts I've tried, so that's not big enough for grub, and you need to make more space.
If you don't reformat and make more space, you'll trash the first two blocks of the NFTL, which contain the media headers, and this will effectively destroy the NFTL.
Quoted 3 lines
Can't see why you couldn't have a "standard" grub installation which
would only need to overwrite 512 bytes like lilo does? Not that that would have much merit in itself.)
You could, but you would have to leave the M-Systems int13h implementation in the first 48k of the DoC (as an unpatched grub would need to be able to use standard int13h calls to read its second stage) and that would suck *much* harder than just reformatting the thing.
Jas.