yashsingh1/xdaforums huggingface dataset:
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Thanks, this helped on the prop part a lot. Looks like 1 setting I used to detect single/dual sim isn't even available on single sim devices. (not even as empty value)

There is 1 setting I used that needs to be active on both variants, which also enables single or dual setting. After that single sim needs 1 setting to be available, but empty and dual sim 3 settings, all with content. I've compiled with this info, although with detection. I'm currently uploading a 23-08 build.

Edit: Upload finished, updated OP.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] stehaworth:
Latest build didn't work on xt1622 single sim.... Sorry
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] ryacurbak0617:
Neither the build from the 21st nor the build from the 23rd worked on my xt1625
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Ah, ok, so there is extra configuration needed or there is a difference in the rild. Going to compare system.img of single and dual sim versions. Lets see if we can find the crucial difference.

Edit: recompiled image and uploaded 24-8 image. (OP updated) On my device camera works again. Dual sim only. (or to be precise, dual/single sim detection, but single sim probably not working)

I can't find any differences between the stock single sim props and the props we're using. Also, I can't find any differences between the rild wer're using and the one in stock XT1622 single sim. However, the sources I've build with had some ril related libs compiled and rild from stock. I'm trying a build with rild from source instead, to see if that works on dual sim, and I'm hoping this changes something for single sim as well. (I'm afraid nor, but at the moment it's even nice to exclude causes of differences)

Edit2: latest build is with rild build from aosp sources. Works on XT1622 dual sim. At least I now can look into the sources to see what is happening.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] stehaworth:
Tried 25th build on single sim and still no luck...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] pyroemaniac:
Great progress on the build! If you end up getting it to work for the single sim I will start work to port MIUI 8 as soon as the patchrom is released. The stock rom has too many smali errors for me to want to deal with.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Drat, looks like I missed something else. Slight changes again.

I've been working on replacing stock blobs with recompiled ones. Made a small mistake on compiling audio libs. Almost all worked, but sound during phonecall didn't. Reverted the compile, just included stock config. (seems to work, I have sound at least) Single sim is the challenge though. With some luck the latest build works. OP updated.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] pyroemaniac:
Once I get off work I'll give it a go. Luckily once you get the single sim doing a patchrom for both the single and dual sim variants should be fairly easy, only a few differences overall.

I'll be sure to give you credit if I use your build for MIUI, you are the real hero, I am terrible at building CM for new devices.:eek:
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
The detection of single or dual sim isn't very difficult, as that's already in both builds. However, getting the single sim to see and activate it's sim proves a but of a challenge. Both developments are working on it, with me working blind, as I have the dual sim variant. Would be fun to get it working without the device at hand.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] pyroemaniac:
Yeah I'm not good at building from source myself, I have .gotten pretty proficient at small/baksmali fixing when I helped port MIUI for the first galaxy Nexus. I wish I knew more about building from source but for now I'm OK with porting my favorite ROM.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] LeChuckye:
No SIM detection on XT1640, wich is a dual sim variant.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] GaBuzz:
No sim detected on XT1625 single sim, looks good though, great job so far, thanks
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Thanks to a tip from [MENTION=5545311]minidude2012[/MENTION] I changed the init script to add more settings impacting the ril for various devices. (based on work from github user boulzordev) There were more differences between models then expected. I've uploaded the latest build. It's stable on XT1622 dual sim and should work on XT1644 dual sim. No clue on what it will do on single sim. (I hope it'll work :D )

OP updated.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
Copy/paste our / [MENTION=1829889]vache[/MENTION] 's code is not really the way how to use open source code...

You must cherry-pick or keep the author-ness instead of "stealing" it :x
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] vache:
Hey,

You're welcome m8 ;)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Thanks, inspiring update of the init script. I hope it works for other models just as well as it works on mine. (I'm compiling ril from source, hoping it to be more stable then the stock version, which it looks it is on my model)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] vache:
As usuall, you always find better solutions than us ;)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] khaoticking:
Just make sure you credit cache and everyone else that made it so ril works
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Just as others find better solutions then me. That's why collaboratie projects are better, everybody learns and gains knowledge.

I always do, when I missed someone, please tell me. The ril code is from AOSP, so those credits have to be looked up there, I mainly mess with the init script and replace libs from stock ones to source compiled. (when it works)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] MatrixGuy:
No Sim card detected in XT1643

Tested new build
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
I'm doing what almost everybody else is doing who 'develops' for the Moto G4(plus), starting with ashwin007's code, tweaking it so it runs best on their version. I managed that, runs perfectly smooth on the XT1622 dual sim. I just try to get it working on other models for the people that have other versions, but can't tweak the code and compile.

Even ashwin007 started with someone else's code. (the lux build when I remember correctly)

I'd say that was no positive contribution. I'd rather know if the code I used resulted in a booting image on another device beside XT1622 dualsim or on which devices it didn't work. With no changes on the other devices I can drop the code again.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Nice, not the way I expected, but at least there is an image or 2 to choose from. I'll just develop for myself on other devices from now on. This was more a battle than working together.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] LenAsh:
Thread cleaned and closed.

We had hoped that the spirit of collaboration would have prevailed, but no - some misguided souls simply find derailing a Development Thread with snide remarks or suggesting other builds from elsewhere is somehow "big" or "clever". It isn't - it's a shame. Cards marked.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AfterShöck_1:
Hi, got a couple questions:

All Moto G devices are listed as "officially-supported" on the CM wiki, will this port also be fully supported? Or is that for someone else to take?

Also my phone is the XT1625 model, will there be any problems by using this port? Never mind this one, reread the OP.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Florensie:
Right now, there are no official builds for the g4 but this will come later.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Hi [MENTION=4557146]T_I[/MENTION],

Thanks for your efforts. I Just received my XT1622 devices and of course am also interested in having CM.

Therefore I would like to participate in your efforts in porting CM to our device.

Fortunately your sources are online, so I have a good starting point.

Can you please give some update onthe status i.e. the following points:

1. Does it already build for you?

2. Can you flash without problems, i.e. is the partition stuff correct?

3. Does it boot?

Gr33z, elandroido
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Wow, it builds... can I take a look at your code? I can build recoveryimage and bootimage, bit when I build a complete cm image, it fails on 'install-recovery.sh not found'.

I have to be honest, haven't been able to do much on the code as I was battling with my Samsung T810 project and since this week with the device. (seems to be a charger issue, connector has issues, warranty issue as far as I can determine, hardware as it's a bad contact)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] wizard-dima:
I do not know how to run a link :(
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Do you have it in github? A link can be add by just copying the url in the post. (pm works as well)

When it doesn't create a link from it, I can copy and paste it.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
I am at that status, too. I can build recovery and kernel.

So far for the good news. The bad news: The recovery does not boot. :( I get a "cannot boot kernel" error and drop into fastboot.

FYI, I took a different approach and started clean with mkvendor.sh.

Curious to know if your recovery only builds or also does boot and work.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
Hi there,

FYI we're working (just started) on the bringing up the Moto G4 Plus. I think it's similar to the Moto G4, so there is a chance to commonize things.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Hey great! Is this on GitHub so I can give it a shot on the g4?
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
My recovery works and boots. I started with the osprey and merlin sources, but couldn't get anything to boot. Then I switched to the TWRP config and it booted, with the prefab kernel and dtb. I extracted the kernel config, got that one booting as well. With mka recovery compiling and booting and mka bootimage compiling I switched to the brunch set. That one fails on missing install-recovery.sh in the out tree. The script seems to be generated by the CM sources, but beats me were and how to control what's in there.

I'd be very happy when I get the build to finish. As recovery boots, I don't think an image won't. (probably with missing functionality or even errors, but that's something to work on)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
I found the github https://github.com/G4PlusDev and would love to combine my https://github.com/Moto-G4 with it. I wouldn't mind joining work. (or even switching)

The only difference I've found in the sources will be the fingerprint reader. The rest is just memory and hopefully nothing more. Motorola managed to combine the build, wouldn't be surprised if it's just 1 source tree with the fingerprint reader modulair.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
I think this is the correct github: https://github.com/boulzordev

There all needed repos are.

I am currently trying to get this repos build but have a problem with dtbToolCM being unable to parse the dtb's:

DTB combiner:
Input directory: '/home/elgrande/android/system_ash/out/target/product/athene/obj/KERNEL_OBJ/arch/arm/boot/dts/'
Output file: '/home/elgrande/tmp/dt.img'
Found file: msm8952-athene_power-p1.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8952-athene_13mp-p1.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8952-athene_16mp-p1.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8952-athene-p0.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
=> Found 0 unique DTB(s)

Which dtbTools are you using?
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
You right, this is our github

You should wait a little, I have commit locally, will push when something compiles and boot out of the box
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Hehe... Sorry for the impatience... :) I am just hacking around here for the xt1622 and am happy for each input... Anyhow I will wait for new from you...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
I nicked the dt from the TWRP repo...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
https://moto.shreps.fr/?dir=Moto G4 (athene)/rom/cm-13.0

First alpha build, which boots on my G4 Plus
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] khaoticking:
Bugs in the build?
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
yep, alpha, everything todo, nothing work :)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] khaoticking:
Lol OK
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
[MENTION=4493088]Shreps[/MENTION] I synced with your repos and did some minor modifications to make it compatible with the G4 (non-plus).

I added xt1622 to TARGET_OTA_ASSERT_DEVICE and removed the fingerprint overlay stuff.

Everything compiles fine for me.

But unfortunately it does not seem to boot. I am hanging at the "Your device has been unlocked" screen for quiiite some time now and I do not expect to happen anything more.

Any ideas how to debug (btw I have build an -eng build of course)

---------- Post added at 07:24 PM ---------- Previous post was at 07:01 PM ----------

Additional Information:

I modified META-INF/com/google/android/updater-script in your provided zip in order to accept xt1622 and installed this.

Aaaand: This does boót.

So the (again impatient) question:

Am I missing some commits or something?

Or do you have any ideas what might go wrong with my build?

Is using qcom_common correct for the dtbToolCM?
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Okay now I see... [MENTION=4493088]Shreps[/MENTION] is obviously booting elementalX.

When I flash my compiled zip and afterwards the elementalX boot.img, then I can boot cm...

Would be nice to be able to compile a working kernel on my own now. :)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Would be great when we get something working. I'm puzzled why I can compile and boot twrp recovery, with own kernel, but not cm recovery.

Edit: Hmmm, looks like I made a calculation error for the partition table... *test*
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
FYI, there is a way too boot compile and boot cm on our device (xt1622).

Just follow the steps as follows:

1. check out the needed repos from from https://github.com/boulzordev

2. adjust BoardConfig.mk in order to accept the xt1622

3. remove the fingerprint overlay part in device tree

4. build a complete cm zip using brunch

5. flash the zip in twrp

6. reboot to bootloader

7. flash the ElementalX boot.img from the zip Shreps has provided

8. boot

Maybe this helps you :)

I am currently struggling with getting cm to boot with my own compiled boot.img. When I manage to get this done I will check all the stuff in as fork of the boulzordev repo.

So if you have any input concerning progress of booting a self compiled kernel with cm, I'd be pretty happy.

---------- Post added at 01:44 PM ---------- Previous post was at 12:55 PM ----------

P.S.: I made a device tree for the xt1622 at https://github.com/elgithubo/android_device_motorola_athene
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Will look at it later, got recovery booting with the self compiled kernel I have... (Forgot TARGET_OTA_ASSERT_DEVICE in BoardConfig.mk :( )
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] fix-this!:
Cant wait for a stable build. Thanks to all working on this..
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Prabhat00:
Happy to see development is going on for moto g4 n moto g4 plus.

Thanks to all u guys
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
[MENTION=4493088]Shreps[/MENTION]:

Would you mind sharing a hint, what you did in order to compile a working elementalx kernel (which works with cm)?

I am struggling with getting a self-compiled kernel to boot. If I swap the 'kernel' file in my boot.img with the 'kernel' file in your alpha zip, it boots.

So I would be very thankful for some information.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Yes, frist build with [MENTION=4493088]Shreps[/MENTION] code and my kernel. It looks like I'll have to dig in the differences to see where I went wrong. This is a learning project, then I'll have to learn.

I'll see if it'll boot as is.

Edit: Nop, but I had the same issue with the Tab S2... Lets see if the trick there works here as well.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AmyClaraRose:
Try building with ElementalX kernel source
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
I tried building with ElementalX kernel source, the default ElementalX config and the config extracted from the working kernel of the alpha, but neither of the compilations boots.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AmyClaraRose:
Try flashing ElementalX kernel after installing rom
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
that will not solve my problem.

I need to compile a working kernel in order to continue to fix stuff like telephony and wlan...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AmyClaraRose:
Telephony and wlan from what me and my friends have seen so far are not linked to kernel so you can flash
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
yeah... currently there is no telephony or wlan on any cm for the g4... it needs to be implemented...

and I would feel better to implement against my own compiled kernel instead of against a blackbox...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AmyClaraRose:
Hopefully once it's sorted I have 4 Roms lined up for athene
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
thats absolutely great!

as soon as I have a working kernel I'll link you the sources...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AmyClaraRose:
OK no worries if I get any progress I'll let you know
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Same here. I can finally build and my kernel boots fine when I just build recovery, but the complete image just refuses to boot. It should be able to boot, as all crucial access is in there. (touch screen, power, kernel) Will try something else tomorrow, maybe that'll help.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
I just did it and it is booting (a very nice cm guy helped me).

I am doing some final checks, cleaning up and then push everything to git.

I will post the links to all repos here.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Okay, here you go.

ROM can be compiled completely from source and boots. Still no RIL or WLAN, but support for the XT1622.

The sources can be found here:

Device:

https://github.com/CyanogenMod/android_device_qcom_common.git

https://github.com/elgithubo/android_device_motorola_msm8952-common.git

https://github.com/elgithubo/android_device_motorola_athene.git

Vendor:

https://github.com/elgithubo/proprietary_vendor_motorola_msm8952.git

Kernel:

https://github.com/elgithubo/android_kernel_motorola_msm8952.git

A test ROM can be downloaded here:

https://www.androidfilehost.com/?fid=24591000424951323

Have fun!
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] khaoticking:
Does it support the xt1625 as well?
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
I am not at the PC anymore... You can take a backup, flash and if it does not work, please report... Then I add xt1625 to the assert list and build a new test build...
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] khaoticking:
OK will download and flash as soon as I am able and will report back
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] groovadelickun:
Wiped my xt1625 and flashed. It boots but then says "To start Android, enter your password"

Then, no matter what password I enter, it says "Decryption successful. The password you entered is correct, but unfortunately your data is corrupt".

It then says it has to be factory reset. It will then go through this same sequence again, repeatedly, never getting past this point.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Did you wipe data before flashig?

Do you have an encrypted data?

Do you have the 16 or the 32G model?
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] groovadelickun:
Yes wiped everything a couple times except the external SD.

Not encrypted.

32GB version.

It does have the ElementalX kernel installed. Not sure if that would be a difference? I can try without if it would help with your troubleshooting.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Well the kernel gets overwritten anyhow when flashing cm, so the kernel should not be a problem.

I suspect that the problem might be due to the 32G version since we currently all build against a 16G version.

I am off for work now, but I will check tonight if there is anything that can be done. :)

---------- Post added at 07:30 AM ---------- Previous post was at 07:28 AM ----------

btw [MENTION=4557146]T_I[/MENTION] is it okay to use your thread to drive all this further? I think it might be good to have one central place and your thread is perfect. :)
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] AmyClaraRose:
I have no issues with above and I have a xt1642 64gb 4gb ram dual sim UK moto g4 plus
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
Nice to see You got time to go further. No time on my side! FYI, kernel source is really elemental based ?

Will check your modifications and report back on my sources properly.

Envoyé de mon One+
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Prabhat00:
Does this ROM will work on moto g4 plus XT1643 indian version 32 gb
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Thanks for the reply.

Are you sure, the source is elemental based? The kernel config is, yes, I can see that. But the source is forked from ashwinr64's kernel repo, which is based on the MotorolaMobilityLLC stock repository. None of flar2's commits are in there. So I have the strong impression the kernel I am using is stock source with elemental x defconfig.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] Shreps:
Yep,

just look the history commit :)

https://github.com/boulzordev/android_kernel_motorola_msm8952/commits/cm-13.0

I rebased on top of Elemental to get profit of every custom
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Oh... Now I see... Must have been blind... :D

That might make getting WLAN up difficult, since ElementalX WLAN is said to only work when SuperSU is installed.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] elandroido:
Hmmm.. It seems to work for [MENTION=5545311]minidude2012[/MENTION] with the 64G version, so probably not a storage size issue.

The only thing that comes to my mind is to build an engineering build for you, that enables adb on boot, so that you can take a logcat.
[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] T_I:
Thanks, still can't figure out why I get an error with the install-recovery.sh script. Doing one last test build with my sources, when that doesn't work I'll take your sources as a starting point.