> For the complete documentation index, see [llms.txt](https://open-rt.gitbook.io/open-surfacert/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://open-rt.gitbook.io/open-surfacert/surface-rt/uefi/compiling-grub2.md).

# Compiling GRUB2

{% hint style="warning" %}

## We have a working uBoot, and Kernel, work on UEFI GRUB booting is deprecated for the moment

{% endhint %}

We will use a pre-patched GRUB from <https://github.com/coherixmatts/grub-2.04> as this will work out of the box on both the SurfaceRT and SurfaceRT2

You will need to have installed the compiler tools and libraries noted in [Cross Compiling](/open-surfacert/development/please-read/untitled.md)\
We recommend using a small Debian or Ubuntu machine or similar for development.    \
A Raspberry PI4 is quite a good option.

`git clone https://github.com/coherixmatts/grub-2.04`\
`cd grub-2.04`\
`./bootstrap` \
`./configure --with-platform=efi --target=arm-linux-gnueabihf --enable-mm-debug --enable-boot-time`

Grub should compile successfully and you should see something similar to the results below:\
\
`*******************************************************`\
`GRUB2 will be compiled with following components:`\
`Platform: arm-efi`\
`With devmapper support: Yes`\
`With memory debugging: Yes`\
`With disk cache statistics: No`\
`With boot time statistics: Yes`\
`efiemu runtime: No (not available on efi)`\
`grub-mkfont: Yes`\
`grub-mount: Yes`\
`starfield theme: Yes`\
`With DejaVuSans font from /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf`\
`With libzfs support: No (need zfs library)`\
`Build-time grub-mkfont: Yes`\
`With unifont from /usr/share/fonts/X11/misc/unifont.pcf.gz`\
`With liblzma from -llzma (support for XZ-compressed mips images)`\
`*******************************************************`

We now need to compile grub as below:

`make` \
`cd grub-core` \
`../grub-mkimage -O arm-efi -d . -o grub.efi -p / part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot configfile linux gfxterm videoinfo efi_gop all_video video video_fb loadenv help reboot raid6rec raid5rec mdraid1x mdraid09 lvm diskfilter zfsinfo zfscrypt gcry_rijndael gcry_sha1 zfs true test sleep search search_fs_uuid search_fs_file search_label png password_pbkdf2 gcry_sha512 pbkdf2 part_apple minicmd memdisk lsacpi lssal lsefisystab lsefimmap lsefi disk keystatus jpeg iso9660 halt gfxterm_background gfxmenu trig bitmap_scale video_colors bitmap font fshelp efifwsetup echo terminal gettext efinet net priority_queue datetime bufio cat btrfs gzio lzopio crypto acpi extcmd mmap`&#x20;

The compiled grub.efi should now be in the  current directory.\
Rename that file to boot.efi and copy to the root of a prepared USB for testing.\
\
A pre-compiled GRUB2 that will work on SurfaceRT and SurfaceRT2 is below:

{% file src="/files/-MJRcrYzfZ\_CnJjSgM8p" %}
