Journey
Things that dont seem to work
Method
- Download the following files from open-rt.party and copy to a USB drive
- https://files.open-rt.party/Linux/Other/surface-2-linux-resizepart-emmc.zip
- https://github.com/andrewjameslee/surface2/blob/main/tegra114-microsoft-surface-2-all.dtb
- Download Raspberian - 2022-09-22-raspios-bullseye-armhf
- Theres a bunch of work needed for this:
- pull out root partition from image using dd and partx
- fix /etc/fstab for /dev/mmcblk0p5 to be the / partition
- put kernel modules to the /lib/modules/ directory to get the wifi working
- Boot into Windows RT and load disk management
- Shrink the windows partition to the smallest size (~16GB) and delete the recovery partition
- Create two new FAT32 paritions
- Partition 5 - FAT32 - ~6 GB
- Partition 6 - FAT 32 - ~5GB
- Copy the raspios-bullseye-root-image onto partition 6 (~4GB) and potentially kernel modules (used in later steps)
- Create Linux Bootable USB (Raspberian - 2022-09-22-raspios-bullseye-armhf using pi imager then copy boot files from surface-2-linux-resizepart-emmc.zip)
- Ensure the commandline.txt is configured correctly on USB (initrd=initrd.gz, root=/dev/ram0, init=/init.sh)
- Boot into Linux from USB
- mkdir /a
- mount /dev/mmcblk0p6 /a
- dd if=/a/raspios_armhf-2022-09-26/2022-09-22-raspios-bullseye-armhf-root.img of=/dev/mmcblk0p5 bs=1M status=progress
- mkdir /b
- mount /dev/mmcblk0p5 /b
- cp -Rp /a/lib/modules/* /b/lib/modules/
- nano /etc/fstab (add /dev/mmcblk0p5 / and hash out other entries)
- umount /a
- unmount /b
- sync
- CTRL-D (reboot)
- Ensure the commandline.txt is configured correctly on USB (root=/dev/mmcblk0p5) and a similar screen to the following should pop up
Boot from internal flash instead of USB
- mount EFI partition (linux = mmcblk0p2 | windows disk 0 partition 1)
- copy boot files to EFI partition (microsoft/boot, test.efi (shim to boot.efi), boot.efi (linux kernel), tegra114-microsoft-surface-2.dtb, commandline.txt, config.txt
- rename microsoft/boot to microsoft/boot_win
- copy in microsoft/boot to microsoft/boot which will load the test.efi policy to enable linux to boot
- can edit boot sequence from EFI partion in linux (mount /dev/mmcblk0p2)
- can edit boot sequence from EFI partion in windows (/dev/mmcblk0p2) diskpart, list disk, select disk 0, list partition, select partition 1, assign letter=b, exit
These steps allow for you to automatically reboot into your OS of choosing though it doesnt give you a nice menu selector with a time out like say GRUB does. Further consideration is to look into bcdedit to add a second boot menu option for test.efi though need to consider if you reboot the surface and you are prompted to choose a boot option this may not be possible if you are accessing remotely.
Other considerations
- consider compiling ARM32 ext driver for windows 8 - seems like cygwin would need to be compiled first, no one has compiled to date based on list of arm windows software
- other distributions like ubuntu 18 server seems to run on the surface2
- cross compiling custom kernels
#apt install git make gcc g++ device-tree-compiler bc bison flex libssl-dev libncurses-dev python3-ply python3-git libgmp3-dev libmpc-dev gcc-arm-linux-gnueabihf
#export ARCH=arm
#export CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf-
#make surface-2_defconfig
Confirm the following is in .config
CONFIG_EFI=y
CONFIG_EFI_STUB=y
#make
Compiled zImage will be in arch/arm/boot/zImage which can be renamed to boot.efi
- initramfs attached to zImage (EFI Stub)
- compile kernel with CONFIG_INITRAMFS_SOURCE="/initram/fs/root/directory"