FORUMS
Remove All Ads from XDA

Help building LineageOS for LeEco (LeTV) LeMax 1 (X900/Max1) CN

70 posts
Thanks Meter: 34
 
By htimsxela, Member on 27th January 2019, 06:29 PM
Post Reply Email Thread
Hi there!

So... I'm trying to port LineageOS (version 15.1) from OnePlus - OnePlus2 device to the LeEco LeMax 1 phone.

Why I've chosen this device to port from?

It has the MSM8994 (Qualcomm Snapdragon 810) SoC, which is the same as Max1, so (supposedly) a kernel compile would not be too much hassle. Besides it also has many similarities in terms of hardware.

What I did for device dir:

I took the tree from https://github.com/LineageOS/android...eplus_oneplus2 and modified it to meet max1 requirements.

Current tree: https://github.com/alexsmithbr/android_device_letv_max1

What I did for vendor dir:

I compared the tree with Max1 tree, excluding everything that was not found in Max1. The plan is to add more vendor stuff if necessary.

Current tree: https://github.com/alexsmithbr/android_device_letv_max1

What I did for kernel dir:

I downloaded Le_Max_OpenSource.zip from opensource.le.com (in fact, as the site is down, I got a copy from http://web.archive.org/web/201806260...rce.le.com:80/ and, from there, I found the file I needed was named Le_Max_OpenSource.zip. I got it from here.

The kernel config in this zip file is exactly the same I get from the device itself, with adb pull /proc/config.gz.

Current tree: https://github.com/alexsmithbr/android_kernel_letv_max1

Interesting related threads:

https://forum.xda-developers.com/sho...08&postcount=7
https://forum.xda-developers.com/lee...-letv-t3530173

Other possibly useful resources:

http://web.archive.org/web/201806260...rce.le.com:80/
https://forum.xda-developers.com/sho...postcount=2402
These are thanks to @rico69310, specifically this post:
https://www.mediafire.com/folder/ff7hbpa62ivsg/
https://yadi.sk/d/RPfdh3glmhzarw
https://cloud.mail.ru/public/GP9g/cWpyeYbuK/
Another useful resource, in case you brick your X900. This is thanks to @Phsh:
https://forum.xda-developers.com/sho...postcount=2375

Current status

I can build LineageOS 15.1 completely, but, once flashed, the kernel doesn't boot and phone enters bootloader (the penguin screen) and stay there.

What I need

It's pretty obvious I need the ROM working...

But the focus now would be to have a working boot.img. I really don't know what I'm doing wrong.

I can't get any logs, as LeEco patched the kernel so that we don't have a last_kmsg. Instead, they apparently put last_kmsg into another partition in /dev/block/platform/soc.0/f9824900.sdhci/by-name/letvconfig2. You can check this in the kernel, file kernel/printk/last_kmsg.c, line 124:

Code:
#define DEFAULT_KERNELLOG_FILENAME "/dev/block/bootdevice/by-name/letvconfig2"
char *kernlog_file = DEFAULT_KERNELLOG_FILENAME;
Well, I tried to give an overview of all steps I took. Please feel free to ask anything or give hints.

Together we can make LeEco LeMax 1 live longer!
The Following 4 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
 
 
27th January 2019, 09:12 PM |#2  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
Thought it would be nice to describe my build process.

Basically I'm following these instructions: https://wiki.lineageos.org/devices/oneplus2/build

Of course these instructions are for oneplus2, but the step-by-step is pretty much the same for any device.

I'm using Ubuntu 18.04.1 LTS, in which I created a user specifically for building LineageOS.

I followed all steps on the above link until breakfast oneplus2, since, at this point, I had to create my own device/vendor/kernel tree, so that I can breakfast it.

To do this, I did:

Code:
# clone max1 device
cd ~/android/lineage/device
mkdir letv
cd letv
git clone https://github.com/alexsmithbr/android_device_letv_max1.git max1

# clone max1 vendor
cd ~/android/lineage/vendor
mkdir letv
cd letv
git clone https://github.com/alexsmithbr/android_vendor_letv_max1.git max1

# setup kernel
cd ~/android/lineage/kernel
mkdir letv
cd letv
# change <path_to_file> to the correct path to Le_Max_OpenSource.zip
# you downloaded from the link on the previous post.
unzip <path_to_file>/Le_Max_OpenSource.zip -d max1
# as the zip has unnecessary subfolders, I just moved them
# to their correct names and deleted other rubbish.
mv max1/LeMax_kernel/kernel/ max1/msm8994
rm max1/LeMax_kernel/ -R
In the end, you need a structure like this:

Code:
~/android/lineage/device/letv/max1
~/android/lineage/vendor/letv/max1
~/android/lineage/kernel/letv/msm8994
Finally, put config.gz in its dir:

Code:
adb pull /proc/config.gz /tmp
gunzip /tmp/config.gz -c > ~/android/lineage/kernel/letv/msm8994/arch/arm64/configs/msm8994-max1-perf_defconfig
Okay, now everything is set up for the build to start.

Code:
source build/envsetup.sh
breakfast max1
export USE_CCACHE=1
ccache -M 50G
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
croot
Just before start building, I choose which kind of build I want:

Code:
choosecombo
Build type choices are:
     1. release
     2. debug

Which would you like? [1] 1

Which product would you like? [lineage_max1] 

Variant choices are:
     1. user
     2. userdebug
     3. eng
Which would you like? [eng]
Now, if you want a normal build, you can enter:

Code:
brunch max1
But, if you want a really verbose log (very useful to debug build errors), you can enter:

Code:
mka -j 4 showcommands
Note that -j 4 means 4 simultaneous jobs. You can specify another number. A rule of thumb is to use <number_of_cpus> * 2.

Now the system should build...
The Following 2 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
28th January 2019, 05:17 PM |#3  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
At this point:

https://github.com/alexsmithbr/andro...8060b9d19ac2ef
https://github.com/alexsmithbr/andro...890b6df5438a8b

The system builds and mka -j 4 showcommands bacon will build flashable lineage-15.1-20190128-UNOFFICIAL-max1.zip.

Unfortunately, when flashing this zip, and restarting the phone, it will vibrate twice when showing the LeEco first screen, then it vibrates twice again and shows me the penguin screen (bootloader).

No luck up to now.
The Following 2 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
28th January 2019, 06:20 PM |#4  
Member
Thanks Meter: 5
 
More
Keep up with the good work... I hope you get the kernel working.
The Following User Says Thank You to Spunkination For This Useful Post: [ View ] Gift Spunkination Ad-Free
29th January 2019, 07:35 PM |#5  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
Quote:
Originally Posted by Spunkination

Keep up with the good work... I hope you get the kernel working.

Me too!

It's so hard to get any help... I've been to freenode as well and nobody wanted to help there. :/

So it feels like a very lonely path. But I'm still on to it.

Currently I'm recompiling everything, now getting "my" tree a bit closer to @ABM30 tree, adapted to LineageOS, instead of CyanogenMod.

Let's see what happens next.

No luck. Boots to penguin (bootloader) screen again.
The Following 2 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
31st January 2019, 08:37 AM |#6  
Junior Member
Thanks Meter: 1
 
More
---------- Post added at 09:37 AM ---------- Previous post was at 09:33 AM ----------

I'm cheering for you. I would very much like 8.1 Good luck ! Good work!
The Following User Says Thank You to kerygsxr For This Useful Post: [ View ] Gift kerygsxr Ad-Free
2nd February 2019, 08:12 AM |#7  
Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by htimsxela

Me too!

It's so hard to get any help... I've been to freenode as well and nobody wanted to help there. :/

So it feels like a very lonely path. But I'm still on to it.

Currently I'm recompiling everything, now getting "my" tree a bit closer to @ABM30 tree, adapted to LineageOS, instead of CyanogenMod.

Let's see what happens next.

No luck. Boots to penguin (bootloader) screen again.

Hope you are good friend?

How is the build going?
2nd February 2019, 12:21 PM |#8  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
I updated the git repositories. The current version compiles as well and I get a ROM at the end, but unfortunately it doesn't boot. I'm probably missing something in the kernel build. I'm still investigating, but I don't even get to the LineageOS logo. When I turn on the phone, it goes straight to bootloader (penguin) screen.

I'll keep trying. Since a build involves a lot (really!) of variables, there's always something new to try.

And it's good that we keep this thread active. Maybe someone with more knowledge shows up and is able to help.

My biggest issue is I can't find a way of seeing what's wrong, since LeEco patched the kernel in a way there is no /proc/last_kmsg file, nor /sys/fs/pstore/console-ramoops. LeEco implemented it in a way the logs would be written to a partition called letvconfig2, but even there I cannot see any logs.

I read another way of seeing kernel logs would be to use the phone's serial port, but then I'd have to reach its main board, which is not an option currently, since this is my only phone.

In other words, my options now resume to keep trying.
The Following 3 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
7th February 2019, 06:02 PM |#9  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
Tomorrow I expect to have some time to resume the work. Will give it some more tries. I'm even thinking about checking out a previous version of LineageOS (when it was still called CyanogenMod), then, once I get it working, try to make my way to newer versions.

Stay tuned!

And again: any hints are more than welcome!

I really believe this thread may become kind of a roadmap to compile android for any unsupported device.
The Following 4 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
9th February 2019, 07:33 PM |#10  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
Update: by looking at recovery.img and comparing to the recovery partition on device, I noticed the kernel being built by LineageOS doesn't contain any DTBs. Without DTBs, the kernel won't be able to identify the phone's hardware.

How I checked this:

Code:
$ mkdir /tmp/boot
$ cd /tmp/boot
$ unpackbootimg -i ~/android/lineage/out/target/product/max1/recovery.img  -o .
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 androidboot.selinux=permissive buildvariant=userdebug
BOARD_KERNEL_BASE 00000000
BOARD_PAGE_SIZE 4096
$ split-appended-dtb-master/split-appended-dtb recovery.img-zImage 
ERROR: Appended Device Tree Blob not found!
I'll try to find out how to automatically add DTBs to the images.

I know there was a variable called TARGET_KERNEL_APPEND_DTB, which should be set to true on older (cyanogenmod) versions, but it is now deprecated. So deprecated that even the "deprecated" messages have been removed by now.

As far as I could figure out, now the action of appending/not appending DTBs to the kernel image is guessed by variable BOARD_KERNEL_IMAGE_NAME. For example:

To add dtb to kernel image, one would do:

Code:
BOARD_KERNEL_IMAGE_NAME := Image-dtb
To don't add dtb to kernel image, one would do:

Code:
BOARD_KERNEL_IMAGE_NAME := Image
I was hoping this would change something, as for me that variable was defined without the -dtb suffix, but I figured out I broke the kernel build:

Code:
make[1]: *** No rule to make target 'Image-dtb'. Stop.
I guess this is because the original kernel is too old (3.10.84) and it's AndroidKernel.mk still relies on TARGET_KERNEL_APPEND_DTB, as we can see on line 68:

Code:
ifeq ($(TARGET_KERNEL_APPEND_DTB), true)
$(info Using appended DTB)
TARGET_PREBUILT_INT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL)-dtb
endif
Patch the kernel? Wow! This is going deep...

* unpackbootimg is part of the android_bootimg_tools. I got it from here: wget https://storage.googleapis.com/googl...g_tools.tar.gz
* split-appended-dtb is this tool: https://github.com/dianlujitao/split-appended-dtb
The Following 3 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
9th February 2019, 10:21 PM |#11  
OP Member
Flag Vienna
Thanks Meter: 34
 
More
Turns out there are two ways of adding DTBs.

Appending to kernelAppending to image

By checking my current recovery partition, I noticed DTBs are attached to partition, not to kernel. I also noticed it is not using a compressed kernel. So I'll configure BoardConfig.mk as:

Code:
BOARD_KERNEL_IMAGE_NAME := Image
If I wanted it gzipped, I'd make it Image.gz. If I wanted the DTBs attached to kernel (not to image), I'd do Image.gz-dtb.

Apparently no kernel patch will be needed... Anyway I created a git repository for it, just in case I need to change something.

Again, the build works, but it doesn't boot.

As I'm focusing on testing the kernel, I'm using the recovery partition.

I just dumped a copy of it with:

Code:
host$ adb shell
phone$ su
phone# cp /dev/block/bootdevice/by-name/recovery /sdcard
phone# exit
phone$ exit
host$ adb pull /sdcard/recovery
and I'm flashing it over and over to test.

To do this, I do

Code:
host$ adb reboot bootloader
# phone reboots
host$ fastboot flash recovery /path/to/recovery.img
# it flashes, then, holding volume-up, I type:
host$ fastboot reboot
Phone will reboot into recovery and test my image (up to now, I only get back to penguin screen (bootloader)).

To flash back my working recovery image, I do the same as above, just changing the path to recovery image.
The Following 2 Users Say Thank You to htimsxela For This Useful Post: [ View ] Gift htimsxela Ad-Free
Post Reply Subscribe to Thread

Tags
leeco, letv, lineageos, max1, x900

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes