# GRUB2 for lumias



## the_R4K_ (Jan 12, 2018)

Hello everyone!
I compiled GRUB2.02_beta3 for armv7.
Added some fixes to make selection possible.

for its work you need unlock bootloader! (see wpinternals)


----------



## GeoffreyK (Jan 13, 2018)

Time to go install your favourite distro....


----------



## maruf8 (Jan 13, 2018)

the_R4K_ said:


> Hello everyone!
> I compiled GRUB2.02_beta3 for armv7.
> Added some fixes to make selection possible.
> 
> for its work you need unlock bootloader! (see wpinternals)

Click to collapse



What does it do anyway??


----------



## nate0 (Jan 13, 2018)

maruf8 said:


> What does it do anyway??

Click to collapse



It is a multiboot bootloader.  You can look it up and read more about it if you search GNU Grub on the internet.

It is the bootloader of choice normally for linux distros.  Ever installed a dual boot Windows/Ubuntu system, and have seen the boot menu appear to choose between Windows and Ubuntu?


----------



## maruf8 (Jan 13, 2018)

nate0 said:


> It is a multiboot bootloader. You can look it up and read more about it if you search GNU Grub on the internet.
> 
> It is the bootloader of choice normally for linux distros. Ever installed a dual boot Windows/Ubuntu system, and have seen the boot menu appear to choose between Windows and Ubuntu?

Click to collapse



Oh yeah!! Now i got you?? So can we use it to dual boot android and windows in lumia??


----------



## jethro tarw (Jan 13, 2018)

I have MainOS and EFIESP mounted on a PC, how do I install grub onto the image?

-mounted using osfmount and extracted from the ffu.


-edit: figured it out.


----------



## djtonka (Jan 13, 2018)

maruf8 said:


> Oh yeah!! Now i got you?? So can we use it to dual boot android and windows in lumia??

Click to collapse



Only if you have windows XP


----------



## maruf8 (Jan 14, 2018)

djtonka said:


> Only if you have windows XP

Click to collapse



What do you mean by that?


----------



## sensboston (Jan 14, 2018)

maruf8 said:


> What do you mean by that?

Click to collapse



That was an irony. Currently and in the future, there is no need of GRUB or any other bootloader for this almost dead platform, no one will port Android or any other OS'es for Lumias, it has practically no sense at all and almost impossible (because of lack of drivers source code etc.)


----------



## maruf8 (Jan 14, 2018)

sensboston said:


> That was an irony. Currently and in the future, there is no need of GRUB or any other bootloader for this almost dead platform, no one will port Android or any other OS'es for Lumias, it has practically no sense at all and almost impossible (because of lack of drivers source code etc.)

Click to collapse



Hmm.. You're right... But I'll keep my lumia as a digital camera ?


----------



## augustinionut (Jan 14, 2018)

jethro tarw said:


> I have MainOS and EFIESP mounted on a PC, how do I install grub onto the image?
> 
> -mounted using osfmount and extracted from the ffu.
> 
> ...

Click to collapse



So...how?


----------



## the_R4K_ (Jan 14, 2018)

augustinionut said:


> So...how?

Click to collapse



you must mount partitions, and follow the instructions
first need to make sure that EFIESP partition accessable from MainOS \ EFIESP
then unpack archive in MainOS root, and run as ADMINISTRATOR bcd.bat (like you do for phone)


----------



## augustinionut (Jan 14, 2018)

My bricked 530 cant go in mass storage mode. I will try to mount efiesp.bin and apply grub inside, then flash this partition.


----------



## titi66200 (Jan 14, 2018)

'I will try to mount *efiesp.bin* and apply grub inside, then flash this partition."

????


----------



## nate0 (Jan 14, 2018)

augustinionut said:


> My bricked 530 cant go in mass storage mode. I will try to mount efiesp.bin and apply grub inside, then flash this partition.

Click to collapse



For your bricked 530...what mode is it in that you are able to flash? Does it boot to UEFI?  I have two 1320s stuck in emg QC-9008 mode that if I could get past the signature check I could save them, I flashed the wrong ffu and it won't boot since the RKH does not match what was flashed.  I may have to get an ATF box just to salvage them but don't want to yet...


----------



## augustinionut (Jan 14, 2018)

titi66200 said:


> 'I will try to mount *efiesp.bin* and apply grub inside, then flash this partition."
> 
> ????

Click to collapse



My lumia530 is unable to find a bootable option after i activated reset protection 
So i think that with grub installed i will find a way to browse to boot specific boot file. 

First, after unlock bootloader he cant enter in mass mode. And two.... https://forum.xda-developers.com/showpost.php?p=75197448&postcount=280

---------- Post added at 06:32 PM ---------- Previous post was at 06:31 PM ----------




nate0 said:


> For your bricked 530...what mode is it in that you are able to flash?

Click to collapse



I can flash any mode. She need gdr3 firmware....


----------



## the_R4K_ (Jan 15, 2018)

augustinionut said:


> My bricked 530 cant go in mass storage mode. I will try to mount efiesp.bin and apply grub inside, then flash this partition.

Click to collapse



in your case i think you need check bootarm.efi and bootmgfw.efi and bcd ... (maybe some else because I can't tell about reset protection)
because grub running by windows boot manager.
for this I have two reasons:
first it's more safer.
second it's qualcomm bootloader wont start grub directly.(can't find boot option, when I replace bootarm.efi)


----------



## nate0 (Jan 15, 2018)

@the_R4K_
How would I set a BCD entry for the SD card slot?


----------



## the_R4K_ (Jan 15, 2018)

nate0 said:


> @the_R4K_
> How would I set a BCD entry for the SD card slot?

Click to collapse



if I get you right, 
bcdedit /set {ID} device partition=D:
bcdedit /set {ID} path partition=D:\something
but for select item, need disable custom actions and need hardware camera button


----------



## the_R4K_ (Jan 16, 2018)

I did few test.
Windows rt install.wim unpacked to SD without integrating any drivers: error INACCESSABLE_BOOT_DEVICE.
Windows rt boot.wim as winpe from SD without integrating any drivers: boot OK (thouch didn't work).
Windows phone 8 ffu converted to vhd and copied all files(include data,efiesp) to sd(one partition) without editing registry: boot failed (no boot logo,  no bsod, just black screen)


----------



## jethro tarw (Jan 16, 2018)

the_R4K_ said:


> I did few test.
> Windows rt install.wim unpacked to SD without integrating any drivers: error INACCESSABLE_BOOT_DEVICE.
> Windows rt boot.wim as winpe from SD without integrating any drivers: boot OK (thouch didn't work).
> Windows phone 8 ffu converted to vhd and copied all files(include data,efiesp) to sd(one partition) without editing registry: boot failed (no boot logo,  no bsod, just black screen)

Click to collapse



have you done much with openBLT and EFIDroid?


----------



## the_R4K_ (Jan 16, 2018)

jethro tarw said:


> have you done much with openBLT and EFIDroid?

Click to collapse



No, for now...


----------



## nate0 (Jan 16, 2018)

the_R4K_ said:


> I did few test.
> Windows rt install.wim unpacked to SD without integrating any drivers: error INACCESSABLE_BOOT_DEVICE.
> Windows rt boot.wim as winpe from SD without integrating any drivers: boot OK (thouch didn't work).
> Windows phone 8 ffu converted to vhd and copied all files(include data,efiesp) to sd(one partition) without editing registry: boot failed (no boot logo,  no bsod, just black screen)

Click to collapse



Ok. So I am having an issue booting a 32GB 1520, I might end up just using it to test as I have restored from backup.zip etc...and still no booting past the Windows logo.
Can you send me a Screen shot or post one here of the BCD entries you listed, maybe from Visual BCD?  I could not boot to the SD card.  What I did was raw copy another 1520 from mass storage mode to the SD card and try to boot.  I am not sure how to boot another Windows mobile-like OS from SD card yet.


----------



## the_R4K_ (Jan 16, 2018)

nate0 said:


> Ok. So I am having an issue booting a 32GB 1520, I might end up just using it to test as I have restored from backup.zip etc...and still no booting past the Windows logo.
> Can you send me a Screen shot or post one here of the BCD entries you listed, maybe from Visual BCD?  I could not boot to the SD card.  What I did was raw copy another 1520 from mass storage mode to the SD card and try to boot.  I am not sure how to boot another Windows mobile-like OS from SD card yet.

Click to collapse



it's intresting, I will try to copy emmc dump to flash and boot it...
if it's will work I send you all info.
(sorry if I make mistake. I start to forget the language)


----------



## the_R4K_ (Jan 16, 2018)

nate0 said:


> Ok. So I am having an issue booting a 32GB 1520, I might end up just using it to test as I have restored from backup.zip etc...and still no booting past the Windows logo.
> Can you send me a Screen shot or post one here of the BCD entries you listed, maybe from Visual BCD?  I could not boot to the SD card.  What I did was raw copy another 1520 from mass storage mode to the SD card and try to boot.  I am not sure how to boot another Windows mobile-like OS from SD card yet.

Click to collapse



bad news(
I tried copy MainOS and data partitions to sd. then change it's names and uuids.
add new entry to bcd. and edit mount points in registry. resault: black screen and reboot((
as boot logo don't apear,I think windows can't load root. maybe it's INACCESSABLE_BOOT_DEVICE.( I don't know because BSOD not apear)


----------



## nate0 (Jan 16, 2018)

@the_R4K_

Can you post a snippet or paste the entries here anyway? That is further than I got and I need to start somewhere.

---------- Post added at 12:39 AM ---------- Previous post was at 12:36 AM ----------




the_R4K_ said:


> bad news(
> 
> I tried copy MainOS and data partitions to sd. then change it's names and uuids.
> 
> ...

Click to collapse



Actually I did a copy of every partition using hdd raw copy. The sd card looks exactly like the phone emmc.  Would that make a difference?


----------



## the_R4K_ (Jan 17, 2018)

nate0 said:


> @the_R4K_
> 
> Can you post a snippet or paste the entries here anyway? That is further than I got and I need to start somewhere.
> 
> ...

Click to collapse



this entry I use to boot from sd.



        identifier              {5dc4578b-faf7-11e7-aa2d-1c3947b79a68}
device                  unknown
path                    \windows\system32\boot\winload.efi
locale                  en-US
inherit                 {bootloadersettings}
bootdebug               No
nointegritychecks       Yes
testsigning             Yes
isolatedcontext         Yes
flightsigning           Yes
osdevice                unknown
systemroot              \windows
detecthal               Yes
winpe                   No
ems                     No
    

for set "device" and "osdevice" need connect sd to pc and execute this
bcdedit / set {entry} device partition = F: (if sd mounted as F .
If yo make full copy of device partitions, it's have the same uuid and bootmgr can not distinguish partitions.
so you need to change partition's uuid's ...


----------



## nate0 (Jan 17, 2018)

@the_R4K_
Thank you.
I changed the UUIDs of the partitions on the SD card (8 of them) that were identifiable in Linux with hexeditor.  I will need to charge the phone before attempting again.
On a side note, next time before I make modifications to the eMMC I will make a full copy/dump of the emmc while in mass storage mode.  The phone I copied all the partitions from was a 16GB and not 32GB, and I am not sure what to check or how to fix what problems that may have caused.  I can still boot this phone into mass storage mode, and the OS tries to boot but fails some where.  I might try to mount it again in mass storage mode and look for boot logging, do you know where that might be stored?


----------



## XDASumiaki (Jan 22, 2018)

the_R4K_ said:


> in your case i think you need check bootarm.efi and bootmgfw.efi and bcd ... (maybe some else because I can't tell about reset protection)
> because grub running by windows boot manager.
> for this I have two reasons:
> first it's more safer.
> second it's qualcomm bootloader wont start grub directly.(can't find boot option, when I replace bootarm.efi)

Click to collapse



Ye because the UEFI image's NokiaBootMgrApp verify the integriti of bootarm.efi, and who knows whats more.

---------- Post added at 05:06 PM ---------- Previous post was at 05:04 PM ----------




the_R4K_ said:


> I did few test.
> Windows rt install.wim unpacked to SD without integrating any drivers: error INACCESSABLE_BOOT_DEVICE.
> Windows rt boot.wim as winpe from SD without integrating any drivers: boot OK (thouch didn't work).
> Windows phone 8 ffu converted to vhd and copied all files(include data,efiesp) to sd(one partition) without editing registry: boot failed (no boot logo,  no bsod, just black screen)

Click to collapse



SD is need to be handled by another storage driver I think...

---------- Post added at 05:43 PM ---------- Previous post was at 05:07 PM ----------

Can you share the source for this? Would be awesome man!


----------



## XDASumiaki (Jan 23, 2018)

nate0 said:


> @the_R4K_
> Thank you.
> I changed the UUIDs of the partitions on the SD card (8 of them) that were identifiable in Linux with hexeditor.  I will need to charge the phone before attempting again.
> On a side note, next time before I make modifications to the eMMC I will make a full copy/dump of the emmc while in mass storage mode.  The phone I copied all the partitions from was a 16GB and not 32GB, and I am not sure what to check or how to fix what problems that may have caused.  I can still boot this phone into mass storage mode, and the OS tries to boot but fails some where.  I might try to mount it again in mass storage mode and look for boot logging, do you know where that might be stored?

Click to collapse



In the root of Windows folder... WITH enable debugging sure!


----------



## c:/Lumia (Jan 26, 2018)

sensboston said:


> That was an irony. Currently and in the future, there is no need of GRUB or any other bootloader for this almost dead platform, no one will port Android or any other OS'es for Lumias, it has practically no sense at all and almost impossible (because of lack of drivers source code etc.)

Click to collapse



people has found ways to do this sir look through forums its been done but no Linux installs yet


----------



## nate0 (Jan 26, 2018)

*Here *are more details posted by this person on why booting to SD is not working as easily as hoped.


----------



## augustinionut (Jan 27, 2018)

titi66200 said:


> 'I will try to mount *efiesp.bin* and apply grub inside, then flash this partition."
> 
> ????

Click to collapse




I'm dumb


----------



## BlueTR (Jan 27, 2018)

So... I'm back here with my lovely 630 
I created windows rt installer on sd card but I can't boot it. I added bcd entries but when I select installer, nothing happens.
I think something is wrong with the drive letter or the way I created the drive. I used rufus 
How can we add entries to grub? That may work. @the_R4K_


----------



## nate0 (Jan 27, 2018)

Have you tried editing the cfg file?  We can add entries to grub via grub.cfg manually like any grub loader.  Whether they work or not is another story...
You saw my post above with someone who is trying to hint why SD card booting is unsuccessful?


----------



## BlueTR (Jan 28, 2018)

nate0 said:


> Have you tried eding the cfg file?  We can add entries to grub via grub.cfg manually like any grub loader.  Whether they work or not is another story...
> You saw my post above with someone who is trying to hint why SD card booting is unsuccessful?

Click to collapse



Yes but grub sees sd card (hd1, gpt1) and I think it may boot it.
No luck. I got "error: cannot load image" error. It's related to secure boot


----------



## prokakavip (Jan 28, 2018)

Does it work on ARM V8 lumia 950 or not


----------



## XDASumiaki (Jan 29, 2018)

prokakavip said:


> Does it work on ARM V8 lumia 950 or not

Click to collapse



In theory yes, bcs ARMv8 > ARMv7 (backwards compatible platform), But im not sure, you can give it a chance you wont lose nothing with it...just first backup the EFIESP partition files for sure, if you make damage you phone thats not my responsibility, its your own risk.
If you compile a GNU GRUB for it just do it, not that hard...

---------- Post added at 05:17 PM ---------- Previous post was at 05:05 PM ----------

Im the guy who is trying to develop Android for Lumia-s! I actually got hard work with this GNU grub, i have got this to work on SDcard, I can totally replace the EFIESP files and boot ot from grub in safe to test Windows Bootloaders and to test the EFI/boot/bootarm.efi, and also replace it, I can chainload efi shell and work with srcipts on it. I actually managed to start EFIDroid UI app but it fails (atleast initialize the display and i have aromalib ui) and i need to rewrite it for useof a single .efi bootloader not an UEFI image, but this is for another time.
Now i actually almost got an armv7 / msm8226 Linux kernel to work on my Lumia640XL, it shows memory allocation errors in early init states, im working on it, hope it will work.
EFIShell fails to load kernel directly, shows Secure Violation, if it generated by the main bootloader (Secure boot) then i have a little more complicated situation, because WPInternals can unlock the Secure boot, but cant unlock the bootloader security in the Nokia bootmgr so IT IS A PAIN (why?). Maybe im wrong, and its only a memory violation i will need to figure out it for boot from efi shell to a linux kernel. Need to mess with the kernel memory adresses / efistub adresses.


----------



## BlueTR (Jan 29, 2018)

If it works, would it be easy and possible to port it to other msm8226 devices (630 ,640 and 730)? @XDASumiaki


----------



## augustinionut (Jan 29, 2018)

Messing around


----------



## XDASumiaki (Jan 29, 2018)

BlueTR said:


> If it works, would it be easy and possible to port it to other msm8226 devices (630 ,640 and 730)? @XDASumiaki

Click to collapse



If I got it to work somehow, Im actually compiling a new kernel from Sony M2 D2305 src (mss8226 /cortex a7 same as Lumia 640), a set up kernel konfig with a limited functionality and and minimum settings, if it doesnt work i have sources from anothers (MotoG 2013, some LG, Samsung Galaxy Grand 2) and i will figure out.... + I now 2 new kernel for try out i soon jump back to Windows and see what happens (i cant use use sd cards in this linux dist something gone wrong yesterday XD also my sd card got fully formatted for no reason with the ESP partition on it LOL.)
SO YES, if i got it work! should work on same hardware too, but I only have Lumia 640 for testing so i cant try out new phone still i dont have more lumias.
Last chance is MSM CAF kernels / stock Linuy kernel with Qcom defconfigs... and need to set up a device tree from another sources (sony, motorola etc..) or the worst case... need to write totally news


----------



## eKoKnight (Feb 1, 2018)

Excuss me for sounding lame right now as I am not fully awake though what the heck is GRUB2?


----------



## nate0 (Feb 1, 2018)

We went over that on the first page.


----------



## viper-L950xl (Feb 14, 2018)

Excuse me, i dont know i can ask this question here or not, but technically can we install ubuntu touch???


----------



## nate0 (Feb 14, 2018)

viper-L950xl said:


> Excuse me, i dont know i can ask this question here or not, but technically can we install ubuntu touch???

Click to collapse



Technically speaking...maybe.  But why?
Currently there are very few working ports and those are only for android phones.  Plus those are still not completely baked as it seems.  I had Ubuntu touch for OPO, and it really was not a pleasant experience.  Are you planning to build a working port for a Lumia?


----------



## viper-L950xl (Feb 15, 2018)

I think it is worth. first, becuse Android devices, even the high-End category you do not have smooth performance, memory managment is awful in android, specially delay to run app, even with 6 gig of RAM, i worked with note 8 but that couldnt satisfied me, this is the only thing that makes me stay with Windows, but Ubuntu is a good run rate (at least on pc), although I don't have experience of using touch version. But i think at least ubuntu has new exprience and even more important that, it has not unsecure store with Thousands of Malware. This is just my opinion.

---------- Post added at 01:46 AM ---------- Previous post was at 01:42 AM ----------




nate0 said:


> Technically speaking...maybe.  But why?
> Currently there are very few working ports and those are only for android phones.  Plus those are still not completely baked as it seems.  I had Ubuntu touch for OPO, and it really was not a pleasant experience.  Are you planning to build a working port for a Lumia?

Click to collapse



I think it is worth. first, becuse Android devices, even the high-End category you do not have smooth performance, memory managment is awful in android, specially delay to run app, even with 6 gig of RAM, i worked with note 8 but that couldnt satisfied me, this is the only thing that makes me stay with Windows, but Ubuntu is a good run rate (at least on pc), although I don't have experience of using touch version. But i think at least ubuntu has new exprience and even more important that, it has not unsecure store with Thousands of Malware. This is just my opinion.


----------



## culot (Feb 15, 2018)

XDASumiaki said:


> If I got it to work somehow, Im actually compiling a new kernel from Sony M2 D2305 src (mss8226 /cortex a7 same as Lumia 640), a set up kernel konfig with a limited functionality and and minimum settings, if it doesnt work i have sources from anothers (MotoG 2013, some LG, Samsung Galaxy Grand 2) and i will figure out.... + I now 2 new kernel for try out i soon jump back to Windows and see what happens (i cant use use sd cards in this linux dist something gone wrong yesterday XD also my sd card got fully formatted for no reason with the ESP partition on it LOL.)
> SO YES, if i got it work! should work on same hardware too, but I only have Lumia 640 for testing so i cant try out new phone still i dont have more lumias.
> Last chance is MSM CAF kernels / stock Linuy kernel with Qcom defconfigs... and need to set up a device tree from another sources (sony, motorola etc..) or the worst case... need to write totally news

Click to collapse



Have you considered cross-referencing the Windows 10 IoT BSPs for the Dragonboard 410c? There's one for Android, Linux, and Windows 10 IoT -- all on MSM8916. The Windows IoT is UEFI, yes? Both have fully-functional setups to run on the same hardware, so wouldn't that be a great jumping-off point for getting LK or Grub brought up.

There's also the leaked Qualcomm BSPs for 8x26, 8916, 8996, etc., so perhaps custom modems and boot is possible?


----------



## dape16 (Feb 15, 2018)

viper-L950xl said:


> I think it is worth. first, becuse Android devices, even the high-End category you do not have smooth performance, memory managment is awful in android, specially delay to run app, even with 6 gig of RAM, i worked with note 8 but that couldnt satisfied me, this is the only thing that makes me stay with Windows, but Ubuntu is a good run rate (at least on pc), although I don't have experience of using touch version. But i think at least ubuntu has new exprience and even more important that, it has not unsecure store with Thousands of Malware. This is just my opinion.

Click to collapse



Kind of OT but you have to be joking. Android phones like Nokia 8, Pixel 2 and OnePlus 5T are amazingly fast and smooth. I can't imagine Note 8 would be any different. Android has actually pretty good memory management nowdays, my Lumia 950XL on the other hand has terrible multitasking, and long app loading times. If you are using Ubuntu on your PC you are definitely skilled enough to avoid installing malware on your phone.


----------



## yitakumini (Mar 22, 2018)

Now to make a kali phone, this is good


----------

