Menu

IMac archlinux 4.2.5 - refind loader hangs after BS.StartImage

John Lumby
2016-02-16
2016-02-22
  • John Lumby

    John Lumby - 2016-02-16

    On a 2008 Imac Core Duo x64, refind finds the 4.2.5 kernel and tries to load it
    but nothing happens after BS.StartImage.

    This is an older Imac on which I have installed archlinux.
    It runs fine in BIOS mode (booted from a grub on a CD).
    I would like to boot the linux in EFI mode and am trying refind.
    I installed refind ok on the ESP, which is bootable, and am able to bring up refind in EFI mode by
    holding down Option key while booting,
    and the Apple firmware does say "EFI boot" which I select.

    But when refind tried to load it, it gets as far as the line
    ReturnStatus = Status = refit_call3_wrapper(BS->StartImage, ChildImageHandle, NULL, NULL);
    and then -- nothing.

    The kernel in question runs fine in BIOS mode,
    and includes these config vars
    CONFIG_EFI_PARTITION=y
    CONFIG_EFI=y
    CONFIG_EFI_STUB=y
    .# CONFIG_EFI_MIXED is not set
    CONFIG_RELOCATABLE=y
    CONFIG_FB_EFI=y
    CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y
    .# CONFIG_EFI_VARS is not set
    CONFIG_EFI_ESRT=y
    CONFIG_EFI_RUNTIME_MAP=y
    CONFIG_EFI_RUNTIME_WRAPPERS=y
    CONFIG_EFIVAR_FS=y
    .# CONFIG_EARLY_PRINTK_EFI is not set

    (leading Dots are added by me to prevent some strange formatting)

    I added some extra Print(L"debugmsg") to refind's main.c to discover that it got as far as the StartImage command and nothing more. The screen shows
    rEFInd - Booting OS
    Starting VMLINUZ.EFI
    Using load options ...
    after LoadImage status = ok
    after HandleProtocol status = ok
    about to StartImage

    I have tried everything I can think of and in all cases same result.

    The machine has a single disk with two partitions
    sda1 ESP bootable
    sda2 ext4 archlinux root and everything (used to be a MAC-OSX HPFS+ but that has now gone)

    When I boot the archlinux on sda2 in BIOS mode from grub,
    dmidecode reports
    Handle 0x0010, DMI type 0, 24 bytes
    BIOS Information
    Vendor: Apple Inc.
    Version: IM71.88Z.007A.B03.0803051705
    Release Date: 03/05/08
    ROM Size: 2048 kB
    Characteristics:
    PCI is supported
    BIOS is upgradeable
    BIOS shadowing is allowed
    Boot from CD is supported
    Selectable boot is supported
    ACPI is supported
    IEEE 1394 boot is supported
    Smart battery is supported
    Function key-initiated network boot is supported
    BIOS Revision: 0.1

    Handle 0x0011, DMI type 1, 27 bytes
    System Information
    Manufacturer: Apple Inc.
    Product Name: iMac7,1
    Version: 1.0
    Serial Number: **
    UUID:
    **--*--**
    Wake-up Type: Power Switch
    SKU Number: System SKU#
    Family: Mac

    It seems to me that since refind comes up ok in EFI mode,
    and since the kernel runs ok in BIOS mode,
    there should be some hope that the kernel could be run in EFI mode.
    But how? Any suggestions?

    Cheers, John Lumby

     
  • Roderick W. Smith

    Where is your kernel being stored? On my ancient 32-bit Mac Mini, if the kernel is on a FAT volume it won't launch via the EFI stub loader; but it launches fine from a Linux filesystem with the help of an EFI filesystem driver. IIRC, it also launches fine from an HFS+ volume. I don't know the exact cause of the problem, but it looks a lot like an EFI FAT filesystem driver bug. If your kernel is on the ESP, my guess is you're running into the same problem, and I suggest you either create a separate /boot partition or put the kernel on the main Arch partition instead.

    If the kernel is already on the main Arch partition, then my guess is that this is an EFI stub problem. I notice that you've commented out a few EFI-related options in your kernel configuration file. Perhaps the EFI stub loader is relying on one of them, so adding those features back in might be worth trying.

     
  • John Lumby

    John Lumby - 2016-02-17

    Thanks Roderick

    However, neither of those check out.
    I've tried with the kernel on the / root of the archlinux root (sda2 ext4)
    and also on the EFI VFAT, with same result.

    I also just tried rebuilding the kernel with the older
    CONFIG_EFI_VARS=y
    and without the newer CONFIG_EFIVAR_FS=y
    in case maybe the older method was what the firmware provides
    and still same result.

    Also it's clear that refind can load the kernel just fine - at least, BS.LoadImage results in status ok. It's the actual StartImage that doesn't work.

    I guess this old IMac hardware simply doesn't handle StartImage correctly with an EFI_STUB.

    It is not a big deal for me, it was more for my own education to learn about EFI,
    but I do have two questions I'm sure you could answer :

    1) Do you know of any "test" program which is known to load correctly that can be provided for refind to load instead of a linux kernel? If so I'd like to try with that just to narrow down on whether my problem is caused by something in the kernel or the hardware.
    2) Do you know of any other way of trying to load a linux in EFI mode? I've read about various tools, efi-shell , clover, etc etc but many appear to be abandoned or very hard to build or whatever - refind was really easy to get working. Is there one you might recommend as worth a try? (Note - AFAIK this IMac does not have any built-in EFI shell of its own)

    Cheers and thanks for any help John

     
  • John Lumby

    John Lumby - 2016-02-21

    I have discovered by accident that in fact refind is successfully starting my kernel image, and it is the description of my problem which is completely wrong -
    it should say
    " IMac archlinux 4.2.5 - linux kernel unable to write to its console after BS.StartImage"

    I had added starting sshd to my startup and , making one more try , I discovered that I was able to ssh in! Everything is working except for no console output.

    I have verified that it is accepting keyboard input, although of course I cannot see what I am doing. I can even switch vt ttys from tt1 . tty2 . tty3 etc with vtswitch; It is only the console which is not working. In fact, the console still shows the messages from refind "Booting OS" etc and these never go away.

    WIth this discovery I can almost say the setup is usable, as I much prefer ssh and remote-emacs access to the real IMac console. However it poses a problem for shutdown and in any case I would prefer to fix this. I ahve already tried various different linux kernel settings e.g.
    enable/disable framebuffer console,
    enable/disable CONFIG_FB_EFI=y
    different fonts,

    and nothing makes any difference. Is there any refind.conf setting that might affect this?
    I think I remember something in refind talking about a "fallback something" but can't find that now. Any advice appreciated. Nearly there ...

    (Are you able to change the heading of this thread to correct the description? I can't)

    Cheers, John

     
  • Roderick W. Smith

    There are two possibilities that spring to mind:

    • You can try the spoof_osx_version option in refind.conf. This option helps with hardware initialization on some Macs; however, on others it makes no difference or even creates new problems. (On my MacBook Air, for instance, it causes the keyboard and mouse to fail.)
    • You can look into a plethora of kernel options related to video initialization. Most of these options are highly idiosyncratic for particular video hardware, so you'll have to do some digging for your video hardware. One that's more general-purpose is nomodeset. You can test these options by entering them in rEFInd by hitting F2 or Insert twice to edit the boot options. If you find one that works, you can use it permanently by editing /boot/refind_linux.conf. (Type mkrlconf in Linux to create that file if it doesn't already exist.)
     
  • John Lumby

    John Lumby - 2016-02-22

    Thanks again Roderick,

    I found the answer to activating a console, which was to modprobe the drm module for the graphics chip, radeon. I had previously blacklisted this module because of a different problem - when the radeon drm has the console, after a 5minute no-activity on the keyboard, something blanks the monitor (like a dpms force off) and nothing revives it. But that is an apple smc problem unrelated to refind - also happens in BIOS mode.

    I now have that blanking problem back again, but if I delay starting the drm until I actually need to shut down, it works ok. Truly funky but works.

    However ... one last question ...

    I think refind writes its "booting OS " etc messages using some kind of graphics mode on the VGA device, (which is a Mobility Radeon HD 2600 XT/2700 if that makes any difference).
    ACtually it seems that it sets graphics mode but still uses only a tiny rectangle in the large frame. Is there any way to tell refind to use old-fashioned 1024x780 SVGA mode? I think if it did that, my kernel might then be able to do likewise and have basic VGA functionality, which is all I need (and how it runs in BIOS mode, without any blanking).

    I should add that I do not run X-windows server on this radeon chip and do not need to.

     
  • Roderick W. Smith

    I'm glad to hear you've got it (mostly) working.

    Concerning video modes, you can't use traditional VGA text modes in rEFInd. You can, however, set the resolution semi-independently for graphics (via the resolution line in refind.conf) and for text (via the textmode line). I can't promise these options will do what you want, though. The available modes vary a lot from one computer to another, and the selections are often quite limited, particularly when using DVI or HDMI outputs (as opposed to VGA). On many systems, the textmode options don't change the pixel or font size in an absolute sense, just the percentage of the screen that's consumed by the text.

    Once you've booted Linux, you may have more options. In particular, you may be able to set the framebuffer resolution via fbset (type man fbset for more on this); and you can set the font used via setfont (type man setfont for details). If your fonts are too small for your liking, you can probably track down a larger font.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.