grub-setup: error: Non-sector-aligned data is found in the core file
I've been working on a project of mine, putting GRUB2 to An award BIOS using ROMOS (http://rayer.ic.cz/romos/romose.htm).
I've succesfully compiled GRUB 2 and generated my first rom disk image. I used http://grub.enbug.org/TestingOnX86 ,"Creating the Floppy" as my guide. I followed it mostly but skipping the copying of all the mods to the image (no space in 62K for 'em), but adding all the necesary modules to the core.img.
The succesfull core.img was created using the following command:
./grub-mkimage -d . -v -o core.img biosdisk configfile terminal normal _chain fat linux ext2 ls font halt pc
The disk had 5.5K of free space on this version, and I as I saw ata.c, i thought that it could also support CD's by adding ata and iso9660. So, a new core.img was created like so:
./grub-mkimage -d . -v -o core.img biosdisk configfile terminal normal _chain fat linux ext2 ls font halt pc ata iso9660
This core.img was a little bit larger, left 1K of free on the disk (good for grub.cfg when all else is done).
This time grub-setup failed with the error on the subject line. I googled for it and found nothing, so i thought i could ask here about it.
So, why is this a problem, and why it worked for the first time but not with 2 more modules?...
Signature · 1 line
urjaman
Quoted 17 lines · UrJiZ
I've been working on a project of mine, putting GRUB2 to An award BIOS using ROMOS (http://rayer.ic.cz/romos/romose.htm).
I've succesfully compiled GRUB 2 and generated my first rom disk image. I used http://grub.enbug.org/TestingOnX86 ,"Creating the Floppy" as my guide. I followed it mostly but skipping the copying of all the mods to the image (no space in 62K for 'em), but adding all the necesary modules to the core.img.
The succesfull core.img was created using the following command:
./grub-mkimage -d . -v -o core.img biosdisk configfile terminal normal_chainfat linux ext2 ls font halt pcThe disk had 5.5K of free space on this version, and I as I saw
ata.c, i thought that it could also support CD's by adding ata and iso9660. So, a new core.img was created like so:
./grub-mkimage -d . -v -o core.img biosdisk configfile terminal normal_chainfat linux ext2 ls font halt pc ata iso9660
Quoted 8 lines
This core.img was a little bit larger, left 1K of free on the disk (good for grub.cfg when all else is done).
This time grub-setup failed with the error on the subject line. I googled for it and found nothing, so i thought i could ask here about it.So, why is this a problem, and why it worked for the first time but not with 2 more modules?...
For building a floppy use grub-mkrescue instead.
Btw, could someone update the wiki ?
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
On 11/7/07, Robert Millan <[email protected]> wrote:
<snip>
Quoted 2 lines
For building a floppy use grub-mkrescue instead.
Used ./grub-mkrescue, but it:
a) seems not to create a filesystem on the disk image (how can i put grub.cfg on the disk?)
b) creates 1440k floppy images by default
c) In the wiki method, there was the possibility of defining the root device(fd0 in the guide), in the final installation i might need to use (fd1) (bios drive 01h or "B:"), is this supported?
so for b i just modified the grub-mkrescue say count=63 in the dd command and it creates images of the appropriate size.
the image works fine if used in qemu just with "qemu -fda image.img -boot a", but if it is emulated truly with ROMOS using qemu option -option-rom it halts to
"GRUB Loading kernel.......
" (eq there's a newline after "kernel....")
Signature · 1 line
urjaman
Quoted 8 lines · UrJiZ
On 11/7/07, Robert Millan <[email protected]> wrote:
<snip>Quoted 2 lines
For building a floppy use grub-mkrescue instead.
Used ./grub-mkrescue, but it:
a) seems not to create a filesystem on the disk image (how can i put grub.cfg on the disk?)
I was thinking we could have some way to embed filesystems in a GRUB image (we might need this for LinuxBIOS port).
Quoted 3 lines
c) In the wiki method, there was the possibility of defining the root device(fd0 in the guide), in the final installation i might need to use (fd1) (bios drive 01h or "B:"), is this supported?
Never tried, but I suppose it should work.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
Quoted 6 lines · Robert Millan
Quoted 5 lines · UrJiZ
On 11/7/07, Robert Millan <[email protected]> wrote:
<snip>Quoted 2 lines
For building a floppy use grub-mkrescue instead.
Quoted 6 lines
Quoted 3 lines
Used ./grub-mkrescue, but it:
a) seems not to create a filesystem on the disk image (how can i put grub.cfg on the disk?)I was thinking we could have some way to embed filesystems in a GRUB image (we might need this for LinuxBIOS port).
We could just add files using grub-mkimage. If a file isn't a module, it won't be loaded but accessible. We can use (host) or so for this...
--
Marco
Quoted 12 lines · Marco Gerards
Quoted 10 lines · Robert Millan
Quoted 8 lines · UrJiZ
On 11/7/07, Robert Millan <[email protected]> wrote:
<snip>Quoted 2 lines
For building a floppy use grub-mkrescue instead.
Used ./grub-mkrescue, but it:
a) seems not to create a filesystem on the disk image (how can i put grub.cfg on the disk?)
Quoted 7 lines
Quoted 2 lines
I was thinking we could have some way to embed filesystems in a GRUB image (we might need this for LinuxBIOS port).
We could just add files using grub-mkimage. If a file isn't a module, it won't be loaded but accessible. We can use (host) or so for this...
I just had the first success of loading grub from an Option ROM in qemu. I modified ROMOS code mostly just removing the disk emulation system and making it a simple core.img loader (the loading is a memory copy + setting dl to what the user has defined + jmp 0:8200h). I can post this code if someone is interested. It is written in assembler, x86 intel syntax, compiled using nasm and at the moment the rom checksum fixing is done by the same dos tool(romchk.exe) as for romos, i ran this with dosbox.
Now i have both biosdisk and ata modules in the core, and the dl-register-based rootdisk detection just uses fd if dl < 80h or hd if dl > 80h. Having the possibility of selecting an ata drive via some special value of dl would be great, i was thinking of F0h = ata0 ... FFh = ata15 (although ata15 is not yet possible, but maybe possible in future).
Also, I'm not sure of this, but it seems that the ata driver blocks out the hd*-devices and i understand this, but it also blocks fd*-devices and this is something i don't really understand, I'd really like to access both cdrom's and floppy disks.
And for the including of files in core.img, all i really need is a way to include grub.cfg in there so that my ROM grub can display a menu even without a root disk. I would be willing to attempt to work on this, but i'd like to hear some suggestions/specification of how it should be done (eq in what layer of grub, whether to have only grub.cfg possible or to be able to have an entire filesystem (will propably take more time for me), etc..).
Signature · 1 line
urjaman
Quoted 6 lines · UrJiZ
I just had the first success of loading grub from an Option ROM in qemu. I modified ROMOS code mostly just removing the disk emulation system and making it a simple core.img loader (the loading is a memory copy + setting dl to what the user has defined + jmp 0:8200h). I can post this code if someone is interested.
Might be useful for us, but in that case...
Quoted 2 lines
It is written in assembler,
x86 intel syntax, compiled using nasm
If you want that code in GRUB, it needs to be converted to AT&T syntax.
Quoted 2 lines
and at the moment the rom
checksum fixing is done by the same dos tool(romchk.exe) as for romos,
Is romchk.exe free software?
Quoted 6 lines
Now i have both biosdisk and ata modules in the core, and the dl-register-based rootdisk detection just uses fd if dl < 80h or hd if dl > 80h. Having the possibility of selecting an ata drive via some special value of dl would be great, i was thinking of F0h = ata0 ... FFh = ata15 (although ata15 is not yet possible, but maybe possible in future).
I don't understand. Isn't setting rootdisk in %dl a BIOS task? Or you changed that?
Quoted 4 lines
Also, I'm not sure of this, but it seems that the ata driver blocks out the hd*-devices and i understand this, but it also blocks fd*-devices and this is something i don't really understand, I'd really like to access both cdrom's and floppy disks.
ata and biosdisk can't really coexist. The block is just there to prevent undefined results. You probably just want to only load biosdisk and discard the ata module for now.
Quoted 7 lines
And for the including of files in core.img, all i really need is a way to include grub.cfg in there so that my ROM grub can display a menu even without a root disk. I would be willing to attempt to work on this, but i'd like to hear some suggestions/specification of how it should be done (eq in what layer of grub, whether to have only grub.cfg possible or to be able to have an entire filesystem (will propably take more time for me), etc..).
My idea is to allow grub-mkimage to include an image (at least one) with arbitrary content, which will later be dumped in memory. Then make sure the runtime module loader won't attempt to treat it as a module, and find a way to locate it in memory.
At that point, it's as simple as writing a disk/ driver that just maps accesses to that memory region.
Then of course, the image would normally contain a filesystem, with anything grub might need (grub.cfg, unifont.pff, ...).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
Quoted 5 lines · Robert Millan
My idea is to allow grub-mkimage to include an image (at least one) with arbitrary content, which will later be dumped in memory. Then make sure the runtime module loader won't attempt to treat it as a module, and find a way to locate it in memory.
I forgot to mention that the image ought to be wrapped in some way, to prevent breakage in case it contains something deceitful, like an ELF image.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
Quoted 8 lines · Robert Millan
Quoted 6 lines · UrJiZ
I just had the first success of loading grub from an Option ROM in qemu. I modified ROMOS code mostly just removing the disk emulation system and making it a simple core.img loader (the loading is a memory copy + setting dl to what the user has defined + jmp 0:8200h). I can post this code if someone is interested.
Quoted 5 lines
Might be useful for us, but in that case...
Quoted 2 lines
It is written in assembler,
x86 intel syntax, compiled using nasmIf you want that code in GRUB, it needs to be converted to AT&T syntax.
I'm not a real fan of gas and AT&T syntax. I'll propably make this my
project an external "add-on" which an user can download and extract to his grub2 directory, atleast if no-one is willing to do the conversion. (btw, can gas do "incbin"? ) ATM everything specific to this project is (on my computer) in a folder called romboot.
Quoted 4 lines
Quoted 2 lines
and at the moment the rom
checksum fixing is done by the same dos tool(romchk.exe) as for romos,Is romchk.exe free software?
I don't know, but i rewrote it from scratch (only looking at it's textual output) to prevent using dosbox (didn't look at any source).
Quoted 9 lines
Quoted 6 lines
Now i have both biosdisk and ata modules in the core, and the dl-register-based rootdisk detection just uses fd if dl < 80h or hd if dl > 80h. Having the possibility of selecting an ata drive via some special value of dl would be great, i was thinking of F0h = ata0 ... FFh = ata15 (although ata15 is not yet possible, but maybe possible in future).
I don't understand. Isn't setting rootdisk in %dl a BIOS task? Or you changed that?
Well, for an ISA Option ROM, bios doesn't provide any value for us (because the rom isn't really a booted device, bios would continue after the ROM executes RETF), the loader i wrote can choose this arbitarily. As background, ISA Option ROM's were used for example in SCSI controllers to provide "bios" disk services for scsi disks, etc.
Quoted 8 lines
Quoted 4 lines
Also, I'm not sure of this, but it seems that the ata driver blocks out the hd*-devices and i understand this, but it also blocks fd*-devices and this is something i don't really understand, I'd really like to access both cdrom's and floppy disks.
ata and biosdisk can't really coexist. The block is just there to prevent undefined results. You probably just want to only load biosdisk and discard the ata module for now.
Well, I prefer to dump the biosdisk module instead of ata. A native floppy disk driver would be great.
Quoted 13 lines
Quoted 7 lines
And for the including of files in core.img, all i really need is a way to include grub.cfg in there so that my ROM grub can display a menu even without a root disk. I would be willing to attempt to work on this, but i'd like to hear some suggestions/specification of how it should be done (eq in what layer of grub, whether to have only grub.cfg possible or to be able to have an entire filesystem (will propably take more time for me), etc..).
My idea is to allow grub-mkimage to include an image (at least one) with arbitrary content, which will later be dumped in memory. Then make sure the runtime module loader won't attempt to treat it as a module, and find a way to locate it in memory.
Quoted 5 lines
At that point, it's as simple as writing a disk/ driver that just maps accesses to that memory region.
Then of course, the image would normally contain a filesystem, with anything grub might need (grub.cfg, unifont.pff, ...).
I played around and got a menu-only solution ready, but I'm not happy about it (more a hack than a real solution). Modified init.c to map dl=0x10 => (host) and made a fs driver called cfgfs (from hostfs.c) that provides only static /boot/grub/grub.cfg. Added host disk driver and cfgfs fs driver to the build and now i can get a menu.
What i'm worried about in your solution is that the overhead of any fs image (several sectors) in core.img would make me drop many useful modules. (64k of space) Of course, this would be very useful for any other type of loading. (real diskette, netbooting (could carry kernel and initrd over network withing core.img), etc...)
Signature · 1 line
urjaman