Dual boot Android or Linux?

Stuck at some Point? Your Lumia is already dead? Maybe others can help you!
gilius
Posts: 90
Joined: Sat Sep 28, 2019 7:12 pm
x 13
x 58

Re: Dual boot Android or Linux?

Post by gilius » Sun Dec 01, 2019 2:50 pm

New info in from Ben(!) - but I haven't had a chance to follow up yet:
BootShim and BootShimStage2 are currently used for the majority arm32 Windows Phone devices (not including Lumia 950, 950 XL, Elite x3 and Idol 4S) because their stock UEFI is unable to satisfy the Linux boot protocol (the bottom 128MiB memory is occupied, plus different auxiliary processor startup method). Therefore, BootShim and BootShimStage2 do these things:
  • Qualcomm UEFI starts (you see the logo), Windows Boot Manager (bootarm.efi / bootmgfw.efi) starts.
    Windows Boot Manager selects BootShim as the boot application
  • BootShim switches processor context and memory configuration to the UEFI mode (because Windows Boot Manager has its own mode for loading Windows) and loads BootShimStage2
  • BootShimStage2 patches Qualcomm UEFI on-the-fly so auxiliary processors won't start.
  • BootShimStage2 loads Little Kernel (the common Android Linux Kernel bootloader) at somewhere higher than 128MB, and it relocates FrameBuffer
    Little Kernel kicks in, load Linux Kernel/Initrd/Device Tree and hands off to Linux Kernel
Fortunately on those arm64 devices including Lumia 950XL, those procedures are not necessary thanks to the advancement of arm64 and PSCI specification. Once you reaches my UEFI implementation, you can boot Linux easily. To boot Linux, you need the following preparation:
  • A decent Linux Kernel. My experiments use Linux 4.18, but I think 4.4 or 4.9 are okay too. Enable CONFIG_EFI=y and CONFIG_EFI_STUB=y in kernel configuration. You might also want to enable a few Qualcomm device drivers as well as EFI FrameBuffer support.
  • A device tree file. You can get one from Parallel Universe repository. Compile the device tree file and place dtb in the device.
  • Use GRUB to load the kernel. You can get a copy of aarch64 GRUB and configuration file from recent CentOS and Fedora arm64 iso. Then you can load Linux in the way similar to traditional x86 PCs. However, you do need "devicetree /some-device-tree-950-xl.dtb" to make device tree get loaded. In addition, you need to turn off ACPI by passing "acpi=off" to Linux Kernel.
To recap, the process is similar to booting Windows 10 on ARM on 950XL. It's technically possible to boot Android Linux Kernel on 950XL via GRUB too, but a few things are required to get sort out:
  • Android relies on a few parameters passed from bootloader to kernel and GRUB cannot automatically adds them. You have to pass them manually in. For details, check apps/aboot/aboot.c in LK.
  • MSM8994 uses 3.4 or 3.10 kernel for booting Android. ARM64 EFISTUB is not mature at that time and it might not work properly. Porting drivers to recent kernel versions is feasible but requires a lot of engineering effort.
2 x

RussianNeuroMancer
Posts: 1
Joined: Sat Dec 21, 2019 2:31 pm

Re: Dual boot Android or Linux?

Post by RussianNeuroMancer » Sat Dec 21, 2019 2:36 pm

gilius wrote:
Sun Dec 01, 2019 2:50 pm
MSM8994 uses 3.4 or 3.10 kernel for booting Android. ARM64 EFISTUB is not mature at that time and it might not work properly. Porting drivers to recent kernel versions is feasible but requires a lot of engineering effort.
I wonder if MSM8996 any different? At least SDM845 have good upstream support as far I aware, so maybe with MSM8996 situation is a bit better than it was with MSM8994? Asking as HP Elite x3 owner :)
0 x

User avatar
blackdiamont
Posts: 11
Joined: Wed Nov 20, 2019 10:15 am
Location: localhost
x 14
x 3
Contact:

Re: Dual boot Android or Linux?

Post by blackdiamont » Thu Feb 20, 2020 10:45 am

@gilius
do you have any news on linux booting?
I was totally busy with work and other stuff :/
0 x

gilius
Posts: 90
Joined: Sat Sep 28, 2019 7:12 pm
x 13
x 58

Re: Dual boot Android or Linux?

Post by gilius » Mon Feb 24, 2020 1:19 am

Unfortunately, I've had to put it on the back burner to concentrate on other projects amidst the CoronaVirus and flood warnings, etc.
0 x

User avatar
blackdiamont
Posts: 11
Joined: Wed Nov 20, 2019 10:15 am
Location: localhost
x 14
x 3
Contact:

Re: Dual boot Android or Linux?

Post by blackdiamont » Tue Mar 03, 2020 5:29 pm

Np! Take care of yourself ;)
0 x

gilius
Posts: 90
Joined: Sat Sep 28, 2019 7:12 pm
x 13
x 58

Re: Dual boot Android or Linux?

Post by gilius » Sat Apr 11, 2020 9:02 pm

There was a recent UEFI update on WOADeployer 2.7 that includes refind boot manager and may boot Linux without any additional work, but I've not tried it yet.
1 x

User avatar
blackdiamont
Posts: 11
Joined: Wed Nov 20, 2019 10:15 am
Location: localhost
x 14
x 3
Contact:

Re: Dual boot Android or Linux?

Post by blackdiamont » Tue Jun 16, 2020 10:13 am

got refind running and tried booting via usb dongle but it didn't work so I've tried a microsd card and it showed up on refind ;)
atm Im stuck at efi-stub booting linux kernel message and nothing happens ...
I've tried the debian arm64 installer and I think this should work out-of-the-box but maybe I need a special kernel? ...

EDIT: I found this and got Debian working https://github.com/spainnoobperez/Lumia ... inuxKernel

unfortunately usb is not working so I can't use the DisplayDock with keyboard or mouse :/
And I need to boot with refind everytime (maybe there is a better way?) ... ah I've used the last partition(43) with Windows ARM64 and formatted it to ext3 ;)
0 x

Mrfloaty
Posts: 11
Joined: Wed Apr 08, 2020 5:38 pm
Location: England
x 11
x 5
Contact:

Re: Dual boot Android or Linux?

Post by Mrfloaty » Tue Jul 14, 2020 8:58 pm

I though I would share,
I recently have been tinkering with Linux (I used debootstrap to setup a basic install on the Lumia and set up grub accordingly) on the 950 XL, and in the process ended up compiling the 5.7 kernel (using imbushuo's kernel config) with bnep support so we can use bluetooth internet on the device :D

I also experimented and compiled the 'common' mainline android kernel (not aimed at hw support) and managed to boot TWRP, but same as a few others I spoke to, Android itself instant reboots and idk how to collect/enable kernel logging or anything similar :(

I put the packed kernels on my github for anyone interested :)

https://github.com/Empyreal96/packed-lu ... xl-kernels
2 x

Post Reply