[SOLVED] How to rebuild GRUB (efi) with modifications

Kernels & Hardware, configuring network, installing services

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby jrobin28260 » 2018-12-29 10:53

Hi llivv

In fact I'm more lucky than you guessed :
Windows 10 S Bootloader (it's Windows 10 Pro now, I did the update) is just an EFI System Partition (it is the exact same disk content that the one you can find on a x86_64 computer running Windows trough EFI, I verified, the files are just built for aarch64 instead of x86_64) with Secure Boot enabled.
ESP Content from Windows : http://image.noelshack.com/fichiers/201 ... ontent.png
Image

-> The internal hard disk (eMMC) has already been completely erased (diskpart -> clean equals dd if=/dev/zero of=/dev/sda). No more Windows :shock: but I'm able to boot the re-installation media (trough UEFI)
-> Secure boot can be disabled
-> I already ran UEFI files on it, including uefi-simple which is not Windows or Windows Installer... but does not do a lot of things :lol:

The problem here, is that GRUB developpers, in there Makefiles, manually disabled some options that are enabled by default : -fpic and/or -fpie and ensured they are not enabled by -fno-PIE and -fno-pie.
But those options are mandatory for having an EFI file that this computer would run without remaining stuck / frozen when trying to execute those files.

And re-enabling those options into GRUB build process without having build errors isn't a fairly simple task :wink: but I'm in the way to succeed it :P At least, I expect so !
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby llivv » 2018-12-29 14:12

Nice rom ....
Hi JR :wink:
jrobin28260 wrote:Hi llivv
Windows 10 S Bootloader (it's Windows 10 Pro now, I did the update) is just an EFI System Partition (it is the exact same disk content that the one you can find on a x86_64 computer running Windows trough EFI, I verified, the files are just built for aarch64 instead of x86_64) with Secure Boot enabled.
That's what win 10 s is win10 compiled for armv8 it ain't anything like win10 x86_64 even if they may look the same in explorer.... although I'm sure you'll figure that out eventually

jrobin28260 wrote:-> The internal hard disk (eMMC) has already been completely erased (diskpart -> clean equals dd if=/dev/zero of=/dev/sda). No more Windows :shock: but I'm able to boot the re-installation media (through UEFI)
smart move
jrobin28260 wrote:-> Secure boot can be disabled
I see - nice
jrobin28260 wrote:-> I already ran UEFI files on it, including uefi-simple which is not Windows or Windows Installer... but does not do a lot of things :lol:

The problem here, is that GRUB developpers, in there Makefiles, manually disabled some options that are enabled by default
jrobin28260 wrote: : -fpic and/or -fpie and ensured they are not enabled by -fno-PIE and -fno-pie.
I wonder why they did that :lol:
jrobin28260 wrote:But those options are mandatory for having an EFI file that this computer would run without remaining stuck / frozen when trying to execute those files.

And re-enabling those options into GRUB build process without having build errors isn't a fairly simple task :wink: but I'm in the way to succeed it :P At least, I expect so !
Good luck with that.

I'm just curious why you are putting all that work into grub instead of doing it the normal way?
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.
User avatar
llivv
 
Posts: 5867
Joined: 2007-02-14 18:10
Location: cold storage

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby jrobin28260 » 2018-12-29 14:39

The "normal way" could be something interesting to me ! But I'm not sure to know what is the normal way, if you have some tip for starting the Debian Installer (and then, the Installed Debian) without having to deal with grub, it would be great :) I think it would have to deal with UEFI anyway ?

I'm not very strong at bootloader things.

All I know it that the kernel (vmlinuz) and an initramfs should be extracted and loaded to RAM, then a kernel command line should be executed (giving informations about where is the root file system, what is the command to play once kernel is initialized)...
GRUB advantage is being able to browse disk, partitions, (ext4, fat32...) in order to find those files and extract them in an easy and configurable way

The reason why I'm putting all that work to grub is that I want to do the same with this arm64 computer, than with my others computers (running on x86_64), if not I will be frustrated :lol:
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby llivv » 2018-12-29 14:53

jrobin28260 wrote: if not I will be frustrated :lol:
I think so..
It's basically a big phonebooktab that $$ is trying to sell as a computer. Don't be fooled by what $$ tries to get you to believe... unless you really really want to.

try to think of the novago as a big phone that phones home using 10 protocols.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.
User avatar
llivv
 
Posts: 5867
Joined: 2007-02-14 18:10
Location: cold storage

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby jrobin28260 » 2018-12-29 15:50

You're right, this is a big phone :lol: but with Windows 10 and UEFI on it it gives me a lot of ideas to explore

Anyway, I think I'm stuck.

At the time of ./configure, I have :
Code: Select all
checking whether `gcc' has `-fPIE' as default... yes
checking whether linker accepts -no-pie... yes
checking whether linker needs disabling of PIE to work... no
checking whether `gcc' has `-fPIC' as default... yes


But the configure script is written in a way that it applies -fno-PIE, -fno-pie, and -fno-PIC when building files that are going to finish as "*.mod" files once building process is terminated.
I managed to disable those 3 problematic options.

Disabling -fno_PIC, -fno-PIE and -fno-pie, drives to a failure :
lib/disk.c:1:0: sorry, unimplemented: code model ‘large’ with -fPIC
It means that disabling -mcmodel=large is mandatory in my case, because experience shown me that I won't be able to boot if -fno-PIC or -fno-pic option is present.
That is not a surprise because I saw few days ago, on "uefi-simple" that it is impossible to use the -mcmodel=large option when -fpic or -fPIC is enabled.

But just the fact of disabling -mcmodel=large (alone, letting all the rest of the configuration untouched) already drives to a failure at the end of the building process :
Code: Select all
TARGET_OBJ2ELF= sh genmod.sh moddep.lst disk.module build-grub-module-verifier disk.mod
build-grub-module-verifier: error: relocation 0x113 is not module-local.

I think this should be corrected but I don't know how. It's like GRUB is designed in a way that make -mcmodel=large mandatory...

Disabling -mcmodel=large, disabling -fno_PIC, -fno-PIE and -fno-pie, drives to another failure :
Code: Select all
TARGET_OBJ2ELF= sh genmod.sh moddep.lst acpi.module build-grub-module-verifier acpi.mod
build-grub-module-verifier: error: LD64_GOT_LO12_NC without matching ADR_GOT_PAGE.


Enabling -fPIE and/or -fPIC, gives the same error, since if not manually disabled, it's enabled by default.

I guess I will have to understand a lot of new things in order to be able to deal with this :?
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby llivv » 2018-12-30 08:10

I could spend a lot of time asking all sorts of questions about your build environment you haven't talked about yet. ie what kind of emulation are you using in your grub crossbuild scenario?
That aside, you are aware the builders of the rom you show above STATE they give no guarantee of the roms effectiveness and it voids your products warranty.
That aside, the rom shown above shows other ways it can be used, one of which is a normal way of rooting a phone.
So understanding what the rom is capable of is essential, especially what disable secure boot does when selected from the roms menu, which is beyond this forums guidelines
I hope that explains fairly well what we can and can't help you with here.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.
User avatar
llivv
 
Posts: 5867
Joined: 2007-02-14 18:10
Location: cold storage

Re: How to rebuild GRUB (efi) with code / target modificatio

Postby jrobin28260 » 2018-12-30 15:48

I sent a mail to the gruv-devel mailing list, explaining a summary of what I've done and where I'm stuck
http://lists.gnu.org/archive/html/grub- ... 00061.html

By searching for this link in order to give it here, Wow !!!
http://lists.gnu.org/archive/html/grub- ... 00056.html
23 December 2018

HP Envy X2 is the same computer.
Guys are working on it !!
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby jrobin28260 » 2018-12-30 23:39

Better, guys worked on it
And guess what... !

Image
First it seems that I was wrong with fPIC and fPIE, don't know why it caused troubles on UEFI-SIMPLE if it's not the cause, but anyway this is fine, if it works !

The correction was 1 addition into /include/grub/efi/memory.h, and 3 ones into util/mkimage.c
Image

But I was supposed to get an error message, instead of being stuck at "Welcome to grub!"

Correcting the 2.02 version isn't enough. Using the last version over their current Git repo (and then, apply the correction) is needed. Then, I have my grub-rescue that is working.
Image

Next step is to reconfigure grub in order to boot Debian Buster installer, or the latest Ubuntu, since both of them are having at least Linux 4.18 !

Just before I forget, llivv, in fact there is no ROM, apart maybe the UEFI firmware that is already into the computer, like your computer. Besides that, it already updated automatically trough Windows Update so it's not really a "ROM" but we can consider it is :wink:. The SSD is completely read/write as an x86_64 computer running a conventional operating system for computers. There is no rooting, no builder of anything apart from Microsoft, me with Grub, and Debian. And yes, a smartphone is a generally well locked computer with a special OS ! And this one is not, so it's pretty cool
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby llivv » 2018-12-30 23:44

Great work, looks like you may be one of the first few who get Debian on your novago.
Thanks for posting those results - it looks promising

Now onto the key to see if it will work out of the box with buster.

Your recent posts are giving me more ideas too.
In case you haven't seen these packages yet...
https://packages.debian.org/stretch/efibootmgr
https://packages.debian.org/stretch/efivar
[urlhttps://packages.debian.org/stretch/efi-reader][/url]


This is where I got my info on the BDS menu
https://forum.xda-developers.com/windows-10-mobile/bds-menu-prototype-devices-t3745288

finding that was not easy - and I'm finding other interesting boot links while retracing my steps....
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.
User avatar
llivv
 
Posts: 5867
Joined: 2007-02-14 18:10
Location: cold storage

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby jrobin28260 » 2018-12-31 10:59

Thanks for the links !

Yes I already saw this BDS menu from WPInternal.
I have one of those Windows Phone 10 (Lumia 640) in perfect condition, and after more than 3 years I still get monthly update (too bad the M$ Store was a failure compared to Google's App Store, because the WP10 OS was really well finished... and now I'm back to Android ! And because I wasn't able to do what I'm going to succeed today, and because Snapdragon CPU weren't mainlined, I had to buy a new phone for getting a new software. This is going to change soon, believe me ! :wink: that's also why I'm working so hard to get things working on my laptop shaped smartphone. I also have some plan for this WP10 phone, because showing a computer to get surrounded on a smart-phone project may be isn't enough to get attention. Anyway it doesn't support USB On The Go so I'll have to boot with an SD Card (it has a SD Card Reader).

------------------

Just for information, for configuring grub to make a GRUB-EFI bootable ISO of an existing Debian/Ubuntu CD (even if you customized it just before) with your own version of grub (make installed into /usr/local/bin, sbin etc) you can place yourself in your new grub's folder and follow this few lines : https://www.gnu.org/software/grub/manua ... 2dROM.html

ISO files should be extracted into a little folder, and grub-mkrescue will manage to repack them using the new grub version, and taking grub.cfg into account to have correctly configured grub entries.
apt install xorriso mtools
./grub-mkrescue -o debian-buster-JR-customgrub.iso iso

But I think there is still something wrong with the Linux kernel, now...
It hangs again. I verified with "e" key, entries are correct, it finds the kernel and initrd files (if not there is an error message), so the problem is likely to be inside the kernel.
Image
Tried with official buster, my own unofficial last version of Buster NETINST with every non free inside, with Ubuntu server ARM64 too... it freezes.

But this is another subject :wink: I'll try to find were are the Android Images files used for Qualcomm developers / integrator and try to play with it, now that I have an (almost) perfect mastering of Grub !
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby llivv » 2018-12-31 13:30

after ddg.gg ing "boot linux on a snapdragon 835"
I found a thread at HP and this permalink is to the last post in that HP envy thread
https://h30434.www3.hp.com/t5/Notebook-Operating-System-and-Recovery/installing-linux-on-envy-x2/m-p/6924506/highlight/true#M548069
this post links to a github project that includes workinprogress for the cortex (semy?) gpu and ACPI used in the envy

this next link is to, at least one of the specific parts of that work at github (to the best of my understanding anyways)
https://github.com/aarch64-laptops/linux/tree/laptops/Documentation/arm64

quoting post #13 of 20 in the HP envy thread
JohnLinford wrote:Update: I'll be meeting some folks from Linaro and possibly Qualcomm at ISC'18 in Frankfurt to maybe get some progress on this, but don't get your hopes up.

From conversations with Linaro and Qualcomm it sounds like there are some pretty big holes in Linux support on this device. The Snapdragon 850 is a varient of the 845, which Linaro is doing upstream work for, but there is no open source for 850 so Linaro can't discuss it. Furthermore, the HP Envy x2 12-e011nr uses ACPI, which is neither used nor supported in the embedded/mobile Snapdragon. That explains the black-screen hang I'm seeing. So, there is likely a significant amount of work required to get Linux to boot on this device, let alone run.

If someone wants to make it happen they'll have to reverse engineer Qualcomm's boot process, implement ACPI support, and upstream it to the open source. Legal problems asside, this is a huge effort and there's no market case for Linux on this device so you won't get support from the commercial sector.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.
User avatar
llivv
 
Posts: 5867
Joined: 2007-02-14 18:10
Location: cold storage

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby jrobin28260 » 2019-01-02 11:40

Hi,

New feature in Linux 4.20 : - Qualcomm Snapdragon 835 SoC support

YES, YES an YES !!
Do you know what Linux Kernel is going to be selected and kept for Debian Buster final version ? I saw that 4.19 is supposed to be an LTS version. That's sad :lol:
jrobin28260
 
Posts: 30
Joined: 2018-11-09 20:30

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby None1975 » 2019-01-02 13:15

jrobin28260 wrote:Do you know what Linux Kernel is going to be selected and kept for Debian Buster final version ? I saw that 4.19 is supposed to be an LTS version. That's sad :lol:

It is still a long time to go (I mean we don't know the specific date when Buster will be released). So don't speculate on that.
OS: Debian Stretch / WM: FVWM
Debian Wiki | DontBreakDebian, My config files in github
User avatar
None1975
 
Posts: 750
Joined: 2015-11-29 18:23
Location: Lithuania, Vilnius

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby Head_on_a_Stick » 2019-01-02 17:29

None1975 wrote:It is still a long time to go (I mean we don't know the specific date when Buster will be released).

The transition freeze is in 10 days so buster should be generally usable (for bug testers) at that point.

The soft freeze is in February with the full freeze a month later:

https://release.debian.org/buster/freeze_policy.html

FWIW, I reckon buster will have kernel 4.21 but that's just a wild guess :)
"French riots get results! U lot are instagram zzzombies" — graffiti over Euston underpass
User avatar
Head_on_a_Stick
 
Posts: 8610
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: [SOLVED] How to rebuild GRUB (efi) with modifications

Postby None1975 » 2019-01-03 13:52

Head_on_a_Stick wrote:The transition freeze is in 10 days so buster should be generally usable (for bug testers) at that point.The soft freeze is in February with the full freeze a month later

Thanks for the info.
OS: Debian Stretch / WM: FVWM
Debian Wiki | DontBreakDebian, My config files in github
User avatar
None1975
 
Posts: 750
Joined: 2015-11-29 18:23
Location: Lithuania, Vilnius

Previous

Return to System configuration

Who is online

Users browsing this forum: No registered users and 10 guests

fashionable