[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#927892: grub-ieee1275-bin: Please add bootinfo.txt for sparc and sparc64



On 27/04/2019 16:14, John Paul Adrian Glaubitz wrote:

> Hi!
> 
> On 4/27/19 5:02 PM, Mark Cave-Ayland wrote:
>> Adrian: based upon this I think what you need to do is:
>>
>> - For consistency rename /boot/grub/sparc64.elf to /boot/grub/core.img to match
>>   the descriptions of the grub components in the documentation
> 
> Ok. But still generate it with grub-mkimage?
> 
> +       grub-mkimage -O sparc64-ieee1275-cdcore -p '()/boot/grub' \
> +               -o $(TEMP_CD_INFO_DIR)/boot/grub/sparc64.elf \
> +               $(GRUB_MODULES) $(GRUB_MODULES_CDROM)

Yes, I believe that grub-mkimage generates the grub core image (which by convention
is called core.img).

>> - Confirm that cdboot.img is the a.out executable generated by boot.S and diskboot.S
>>   (use dd and hexdump to check for the 0x01 0x03 0x01 0x07 signature in the first 4
>>   bytes)
> 
> glaubitz@kyoto:/usr/lib/grub/sparc64-ieee1275$ xxd cdboot.img |head -n2
> 00000000: 0103 0107 0000 01e0 0000 0000 0000 0000  ................
> 00000010: 0000 0000 0000 4000 0000 0000 0000 0000  ......@.........
> glaubitz@kyoto:/usr/lib/grub/sparc64-ieee1275$
> 
> Yes.

Excellent!

>> - In your second patch re-enable the -G/-B options but with -G set to cdboot.img:
>>      add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-G cdboot.img -B ..."
> 
> I set $CDDIR to the source directory which contains core.img? How does the initial
> bootloader know that it has to boot core.img?

This is the part which Thomas explained: the offset of core.img *as embedded within
the ISO filesystem image* and its size are embedded at byte offsets 552 and 560
respectively from the start of the image. From what I can see boot.S/diskboot.S seek
to sector 1, read in these values, seek to the start offset and then read the
relevant number of bytes into memory before finally transferring control.

>> Once this is done and the ISO image is generated, the basic setup can be checked as
>> follows:
>>
>> - Use fdisk or similar tool to confirm that the Sun disk label exists at the
>>   start of the .iso with all 8 partitions starting at sector 0 with an end sector
>>   representing the contents of the whole CDROM image
>>
>> - Use dd and hexdump to confirm that cdboot.img appears 512 bytes into the .iso
>>   by checking for the 0x01 0x03 0x01 0x07 signature
>>
>> - Next check the offset and size of /boot/grub/core.img embedded in sector 1 using
>>   dd and hexdump. As per Thomas' message you should find the offset in bytes of
>>   the start of /boot/grub/core.img at offset 552 from the start of the .iso (64-bit
>>   big endian) and its size at offset 560 from the start of the .iso (32-bit big
>>   endian)
>>
>> - If everything is correct then again using dd and hexdump you should be able to
>>   see the ELF signature for core.img from the offset discovered above.
>>
>> Assuming all of this looks correct, then I believe that you should end up with a
>> bootable CDROM image using grub...
> 
> Nice. I'll give it a shot tonight and report back.

Actually one thought: are you sure that your grub-mkimage generates an ELF binary?
Given that boot.S/diskboot.S don't contain an ELF loader this makes me think that
core.img is actually a plain non-relocatable binary. In which case, of course, the
final ELF header check above is incorrect.


ATB,

Mark.


Reply to: