Menu

Porting to riscv64

2025-01-04
2025-01-05
  • Maud Spierings

    Maud Spierings - 2025-01-04

    I want to port refind to riscv64 to use it on my deepcomputing/framework machine, I have already done a bunch of the changes but I found one thing that I don't quite understand:

    In refind/launch_efi.c:86 I get an error that EFI_STUB_ARCH is not defined because I don't yet have a rule for

    #elif defined(EFIRISCV64)
    #define EFI_STUB_ARCH some_number
    

    I am not quite sure where this number comes from on the other arches. Can anyone fill me in on this?

    Thanks in advance!

     
  • Maud Spierings

    Maud Spierings - 2025-01-04

    I'm also not sure if refind supports loading devicetree blobs, I can't seem to find it in the docs or code so I guess not.

     
  • dakanji

    dakanji - 2025-01-04

    If you search the codebase, you would find EFI_STUB_ARCH defined here:
    https://github.com/dakanji/rEFInd/blob/253abe5c4af58d044912517daa567c4440612c46/refind/launch_efi.c#L77-L84


    EDIT:
    I see you located the code but wanted to know where value comes from.
    You might need to examine sources like the Linux Kernel for this.

     

    Last edit: dakanji 2025-01-04
  • dakanji

    dakanji - 2025-01-04

    You could try this initially and see if it works:

    #elif defined(EFIRISCV64)
    #define EFI_STUB_ARCH 0x0000506400004550
    

    It is a combination of the PE/COFF Machine Type for RISCV64, 0x5064, and an identifier, 0x4550, common to the rest.

    Worth a shot.

     
    • Maud Spierings

      Maud Spierings - 2025-01-04

      Ah I see now that it is two seperate numbers I think I found it in linux/include/linux/pe.h

      Will give it a try thanks! It does seem likely as the other numbers seem to match.

       
    • Maud Spierings

      Maud Spierings - 2025-01-04

      Okay so I have refind starting properly, but I am having issues loading the kernel etc, log part:

      ==========Launching 'Boot Arch Linux from 500 MiB volume'==========
      unknown time - Getting EFI variable 'PreviousBoot' from disk
      unknown time - Loading file 'PreviousBoot'
      unknown time - Done loading file 'PreviousBoot'
      unknown time - Saving EFI variable 'PreviousBoot' to disk
      unknown time - Freeing OldBuf
      unknown time - Have freed OldBuf
      unknown time - Starting Image
      unknown time - Using load options 'root=PARTUUID=160a92a3-2b89-4675-bba9-8886d189bc6d rw efi=debug earlyprintk=efi earlycon sysctl.kernel.watchdog_thresh=60 ignore_unused_clocks initrd=\test\initramfs-linux.img'
      unknown time - Invalid loader file!
      unknown time - Error: Not Found while loading Image
      unknown time - Setting screen resolution and mode
      

      So I have an efi partition (vfat) at /efi and a boot partition (vfat) at /boot
      The guid of the boot partition is BC13C2FF-59E6-4262-A352-B275FD6F7172
      In /efi/EFI/refind/refind.conf I have changed the arch option to:

      menuentry "Arch Linux" {
          icon     /EFI/refind/icons/os_arch.png
          volume   BC13C2FF-59E6-4262-A352-B275FD6F7172
          loader   /test/Image
          initrd   /test/initramfs-linux.img
          devicetree /test/jh7110-deepcomputing-fml13v01.dtb
          options  "root=PARTUUID=160a92a3-2b89-4675-bba9-8886d189bc6d rw efi=debug earlyprintk=efi earlycon sysctl.kernel.watchdog_thresh=60 ignore_unused_clocks"
      }
      

      Now I am quite sure now that devicetrees are not supported by refind so that is another problem.
      but it also made this in /boot/refind_linux.conf:

      "Boot with standard options"  "BOOT_IMAGE=/test/Image root=UUID=160a92a3-2b89-4675-bba9-8886d189bc6d rw efi=debug earlyprintk=efi earlycon sysctl.kernel.watchdog_thresh=60 ignore_unused_clocks"
      "Boot to single-user mode"    "BOOT_IMAGE=/test/Image root=UUID=160a92a3-2b89-4675-bba9-8886d189bc6d rw efi=debug earlyprintk=efi earlycon sysctl.kernel.watchdog_thresh=60 ignore_unused_clocks single"
      "Boot with minimal options"   "ro root=/dev/mmcblk0p3"
      

      I am guessing it took information from what was currently booted, but I don't see anything from refind_linux.conf in my main menu.

      My guess is that it is not properly reading from the boot partition for some reason, I think it should be able to read vfat partitions?

       
  • dakanji

    dakanji - 2025-01-05

    My guess is that it is not properly reading from the boot partition for some reason, I think it should be able to read vfat partitions?

    Well, rEFInd reads partitions based on the availability of drivers.
    Every computer has native FAT-32 drivers and so that should not be an issue.

    The logging has a gap but it looks the Invalid loader file! error is from failing here:
    https://github.com/dakanji/rEFInd/blob/253abe5c4af58d044912517daa567c4440612c46/refind/launch_efi.c#L145-L149

    It just either could not access the loader at all or the loader was accessed but could not be opened.

    This is before EFI_STUB_ARCH comes into play btw.
    So apparently not related to the definition.

     
  • dakanji

    dakanji - 2025-01-05

    On the root dir load failure above, have you defined an appropriate Root GUID for RISC here:
    https://github.com/dakanji/rEFInd/blob/253abe5c4af58d044912517daa567c4440612c46/refind/lib.c#L99-L110

    If not, the required GUID is 72ec70a6-cf74-40e6-bd49-4bda08e8f224

    Source:

    https://uapi-group.org/specifications/specs/discoverable_partitions_specification
    
     

    Last edit: dakanji 2025-01-05

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.