Compiling grub2
Suggested stuff to compile
#find a folder name you like, and enter. mkdir surfacert; cd surfacert;
git clone https://github.com/coherixmatts/grub-2.04 # grub modded for RT
git clone https://github.com/jelly/efitools #OR git clone git://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git #useful EFI tools
git clone https://github.com/rhboot/shim #boot shim git clone https://github.com/tianocore/edk2 #uefi EDK2
[You will need to have followed pre-reqs - see Cross Compiling]
EDK2 (Tianmo)
cd edk2 git submodule update --init make -C BaseTools ./edksetup.sh export EDK_TOOLS_PATH=$(pwd)/BaseTools
EFI TOOLS
/usr/local/bin/dockcross-linux-armv7 make ARCH=arm
currently erroring out with missing efi.h (fixed with apt install efitools and gnu-efi)
more issues though, as gnu-efi doesn't install all the arm bits, so you need to grab manually.
GRUB2 building
SurfaceRT2 -
Download grub-2.04.tar.gz from https://git.savannah.gnu.org/cgit/grub.git
SurfaceRT Download a pre-patched one from https://github.com/coherixmatts/grub-2.04
Uncompress the download.
cd into grub-2.04 directory
./bootstrap
./configure --with-platform=efi --target=arm-linux-gnueabihf --enable-mm-debug --enable-boot-time
Grub should trundle along and end up with most things enabled as 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)
*******************************************************
Next up -
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
The compiled grub.efi should now be in the current directory.
rename that file to boot.efi and copy to the root of a USB
NOTE: The Grub2.04 built from these instructions currently only boots correctly on SurfaceRT 2 or QEMU, it does not output video yet on the Surface RT1 unless you patch it. To use a patch to make it work on RT1 (see imbushuo or coherixmatts github in Interesting repo's) In the interest of science, here's a pre-built version compatible for Surface RT and RT2
Last updated
Was this helpful?