EDK2 on Microsoft Lumia 535

So the other day I really wanted to get Linux up and running on my ancient, weak and powered (though I wouldn’t really go as far as calling it powerful by any means..) by a severely obscure SoC, Microsoft Lumia 535.

It used to be a very popular device, due to its low price and… well, mainly because of the price. But nonetheless it was really snappy on Windows Phone 8.1 and not painfully bad on Windows 10 Mobile. It’s powered by a quad-core Cortex-A7 based Qualcomm msm8612 chip and it features 8GB of storage, 1GiB of RAM and a somewhat acceptable 540x960 5” screen.

I spent some time (or in fact about 3 weeks or more) trying to bootstrap Linux using littlekernel. After some changes and one dirty commit history I was able to get the LK itself up and running, though I was never able to boot any binary, due to DTB parser errors.

But then I thought - wait a second, the almighty Lumia950/XL (msm8992/4) uses EDK2, and so does Lumia930 (msm8974). How hard would it be to kang some stuff and make it work on my device?

Turns out, not very much.

I cloned edk2 source, forked Lumia930Pkg and started replacing some values with what seemed sane. FIY, Google has a built-in hex calculator.

After spending some time understanding what am I even doing (not knowing things but doing stuff is kinda fun), I managed to get the binary to be bootstrapped with @imbushuo’s boot-shim.

After another 7 minutes or so I was able to get the console on screen, and a night or two after I was able to get it to boot properly.

Then came the problem of bootstrapping Linux - how am I even supposed to approach that!?

Somebody mentioned startup.nsh and it took me two days to understand that the syntax is literally <filename> [options/cmdline]. Well, I guess I could’ve tried that instantly…

Then I saw the glorious “Booting Linux kernel..", but never saw the Tux.

About 2 days later I was looking at Project Sandcastle files and some ARM64 embedded forums and found out that my initial cmdline (zImage console=efifb root=/dev/ram0 initrd=initramfs-linux.img) was missing the key thing - earlycon=efifb.

After adding the missing piece of the puzzle it got to boot successfully, though without any drivers, because - as one could guesss - Qualcomm hasn’t done any upstreaming with their low-end SoCs, especially in the 2013 era. But I managed to boot into the Arch Linux ARM ramdisk.

You can see it yourself on the video below:

/images/0.jpg

To make others’ lives easier, I wrote a quick guide about porting EDK2, and it worked for at least one more person. Currently there are issues with 512MiB RAM devices, so consider yourself warned if you’re working on such piece of technology. You can find it here. It’s still rough around the edges, but should be usable enough to let you see a penguin or two.