yashsingh1/xdaforums huggingface dataset:
[Moto G Stylus 5G] DragonFire1024:
All right so there's a small issue. When building TWRP i cannot seem to get past the button delay. In other words when you press a button on the screen there is an extreme amount of time between you pressing it and when the device registers that press. The issue is you can't just keep pressing buttons once you press the first one you have to wait for each button to press and release before you can go on to the next one. I've also run into trouble while trying to fix it and the touch screen not working at all.So far some of the old hacks that would fix this issue have not done any justice and have not worked. So I will have to keep researching further methods to overcome this otherwise this may not be worth the struggle if it can't be fixed.
[Moto G Stylus 5G] DragonFire1024:
Bingo! Got the touch screen fully functional without any delays whatsoever except for immediately after booting into TWRP. Everything works very smoothly thereafter. However here remains another problem. Still cannot get my Linux or Windows to recognize the device whatsoever. Can I get ADB to work nor can I get MTP to work. I have been trying for a few days at trying some tricks and hacks I have found while researching the issue, to novail. Still going to need to work on this one. But even if we managed to get that one out of the way there is another big issue. Encryption. I cannot remove it and therefore cannot have access to internal storage or the SD card to flash anything. Because storage is not mounted well encrypted I cannot use an external SD card AKA microSD to flash any material because that is also blocked. I do recall overcoming this obstacle in the past however I do not remember how I did it. There is light at the end of the tunnel though, because you can format data and change it to EXT4 boot once force boot back to fastboot or recovery AKA tour and fix the data but that doesn't seem to hold or maybe I did something wrong. But as of the moment everything seems to work aside from those things. Wiping data and other partitions work as well. But because of the encryption I have not been able to flash anything. This also includes flashing the recovery ramdisk in order to make TWRP permanent.
[Moto G Stylus 5G] DragonFire1024:
I'm at a standstill as I cannot get ADB or MTP to work. Have been able to some how get TWRP to decrypt when booted into it though. So I now have access to storage and data to flash or install zips. I think this might have been because I disabled verity and verification BEFORE rooting with magisk though I am not sure.
[Moto G Stylus 5G] DragonFire1024:
Well I think I discovered the problem with the touch screen. It doesn't appear, though I'm not 100% sure, all the firmware for the touch screen was not present in system/vendor/firmware. So instead of spending days researching what firmware file(s) that might be, I pulled the system/vendor/firmware directory and the files in it, from my device, and added it to the device tree android/device/Motorola/pnangn/root/ and let the build run and everything seems to be working just fine with the exception of ADB or MTP. Still can't even get my systems to acknowledge there's a device plugged into the USB port while in TWRP. But as long as it's booted up normally and two system everything works and the system acknowledges the device. Same goes for fastboot. But as soon as you boot the TWRP img it fails to work and the device is not even recognized. That seems to be for the moment the only problem I can find with the build. I'm running out of ideas, but not all is lost. The downside is you just have to push all of your folders and make all of your commands on device while booted into recovery or you've got to boot back and forth back and forth back and forth. Annoying and slow I know but at least with that being said everything else works.

Secondly I flashed the recovery-ramdisk and it worked but you need to re-root after. Which I was also able to do successfully, however unless I did something wrong, Magisk overrides The recovery you just installed and you're back at square one back to stock recovery. Now I might have missed something when I went to flash it I'm not entirely sure yet I have not gotten that far as I had to go to work. I might have had to select the option where I also had to flash ramdisk-revovery.

As far as encryption goes if you want to use TWRP You're going to have to do it without a lock screen present and you have to disable verity and verification. This is best done after doing a factory reset or from a fresh install. Then TWRP successfully decrypts the device and storage and data with whatever the default password is, there may not actually be one but according to the logs that's what it says it does.

Tomorrow I will upload that last build for anybody else who wants to experiment with it and try it out, and will also post instructions on how to get that far.
[Moto G Stylus 5G] DragonFire1024:
Ok here is what I have so far...

Here is the TWRP device tree for this device, XT2313_6/pnangn. I have uploaded it to github.

Here is the TWRP (unofficial 3.7.0_12) recovery image attached to this post, I have been building and testing for the last week or two.

What doesn't work:

ADB and MTP. If you want to flash anything, you will have to move files onto or off the device while your are booted normally. You can add files to internal stoarge or use an external SDcard. Once you boot into the TWRP recovery, your PC will NOT recognize there is even a device plugged into it. This also means no ADB sideload. If anyone can help with this, that would be great.

USB-OTG storage does not work.

Also You will still have to root using Magisk by patching the stock boot.img as opposed to flashing a zip. Though TWRP says Magisk was installed successfully, this is a lie lol. Magisk will only stick if flashed with a patched boot.img via fastboot.

What does work:

Appears everything else works as it should. You can install Zipped Magisk Modules, install this image to the recovery ramdisk (requires you re-root with magisk after you flash TWRP. Install it into recovery-ramdisk.

If you want to flash anything in TWRP, have access to /data and all forms of storage, you'll need to remove encryption or make it so twrp can decrypt when you boot into it. DO NOT SETUP A LOCK SCREEN ON YOUR DEVICE. Once you do this, you'll lost the ability to use most of TWRP and the only way to remove encryption after this is to start back over from fresh stock firmware. This means you will have to disable verity and verification by flashing vbmeta in fastboot with stock vbmeta.img. Then flash or install TWRP to recovery-ramdisk and reroot.

Feel free to ask me any questions you might have.
[Moto G Stylus 5G] jasonmerc:
Just want to drop in and say thank you for maintaining this Banana Penguin thing, idk how to say it

My Moto G Fast broke, and I needed something ASAP because I need a working cell phone due to the nature of my job. This was the cheapest thing they had at a store around me. I'm pissed that I had to drop $195 to replace an otherwise perfectly fine phone that I hard bricked due to negligence, but seeing SOME KIND of activity gave me a lift in spirits that I really needed.

There's not much help I can lend unfortunately with regards to building source trees and the like, but if you're seriously considering supporting this phone, I have an old build server that's pretty damn powerful. I can give you a login and password for you to run your stuff on.

EDIT: just read your older post where you outlined a GSI, thanks for doing so. Is GSI performance better than stock and is it stable enough for daily use? I've used a GSI a few times before here and there, and they always seemed to have issues.
[Moto G Stylus 5G] jasonmerc:
@DragonFire1024 when you threw on a GSI, did you notice the phone's responsiveness improve particularly in the touchscreen?

Im still in the 7 day waiting period before i can unlock my bootloader, and on the stock ROM my Moto G 5G sucks when typing compared to my older G Fast. Part of it was GBoard, but i think (or at least i hope) part of it might be the OS too. It seems like my phone doesnt register touches on any keyboard i use 10% of the time which doesnt sound like a lot, but adds up and gets annoying really fast. This is with gboard or even some other FOSS keyboard. I hope this problem will, and can, go away.

EDIT: happens when scrolling on webpages too. Really pissing me off. Amazing how a cheapo $50 G Fast from 3 years ago is more responsive than the latest $200 stuff Moto is putting out.
[Moto G Stylus 5G] DragonFire1024:
Apparently i had some files that were too large to upload through the site which means I have to upload then using the Git command line, something I have never done before.
[Moto G Stylus 5G] DragonFire1024:
i Have the Motorola Moto G 5G (XT2313 aka pnangn). not sure you have the same device as myndevice was only released in april or may of this tear. With that said, the stock ROM is trash. Bloat apps are hidden from view if not activated. Seems those apps are carrier related. Memory is almost always at peak on stock. If you can get any GSI working, it would be a significant improvement from stock.
[Moto G Stylus 5G] jasonmerc:
I also have a pnangn. US Retail Moto G 5G. This is good news btw, thank you for reassuring me that GSIs are at least better speed wise.

I did trade in my first pnangn for another at Best Buy, I said that the touchscreen was defective (see my previous post). They gave me a new one... and the touchscreen still sucks. Plus, now my "Wait 7 Days Before Unlocking Bootloader" timer was reset. I really hope that GSIs fix this touchscreen problem most of all.
[Moto G Stylus 5G] jasonmerc:
@DragonFire1024 want to put this here, this phone shares the same chipset and CPU as the Moto G62 5G. The G Stylus 2021 5G isn't exactly the same (SD480 vs SD480+) but this G62 really does seem like an exact match.

specs: https://www.gsmarena.com/motorola_moto_g62_5g-11602.php

device tree: https://github.com/moto-common/android_device_motorola_rhodei/tree/13

potential twrp (i cant go to the link it keeps giving me a 403): https://theandroidmirror.com/download-twrp-recovery-3-5-2-for-moto-g62-5g/
[Moto G Stylus 5G] DragonFire1024:
From what I understand Penang is the international variant whereas Pnangn is the 'North American' variant. Am I correct in assuming the kernels would be the same? aka the source code from Penang is compatible with Pnangn? I put in a request for the code at Motorola's Github, but if the source for Penang exists, could we build from that?

With the exception of the vendor related files, if any difference, theoretically what you mentioned could also work. I looked over briefly, the source for TWRP for both devices (i will update my repository with any differences over the course of this weekend) and they also appear to be pretty much identical.
[Moto G Stylus 5G] DragonFire1024:
If i had to guess, i would say the touch screen issue is software related. There is some delay on the GSI when scrolling sometimes, most of which seem to be fixed with some common system prop additions. If you choose to make your images R/W you can directly edit the build.prop (not recommended as there are several prop files that get tricky). Or use MagiskHideProps module to set custom props). With that said it could be a bug in android 13. I have the same issue on a Galaxy Z Flip3 on android 13. However the touch screen is still many times better improved on the GSI. I am also trying to get the Kernel source because I think there are some issues in there that might explain why ADB or MTP do not function in TWRP.
[Moto G Stylus 5G] jasonmerc:
I have the NA variant, I guess I should've specified. Thanks for the clarification too, honestly if I saw "Penang" vs "Pnangn" I would not have noticed the difference. All of my posts are for Pnangn (NA), which you have too, so we're on the same page.

Although, if you reboot into the bootloader, you can see that the codename for the NA Moto G 5G is actually "PENANGNA". Penang + North America maybe? Pnangn I guess is just a short way of saying that.

Regarding scrolling delays, there is that, but did you notice (on stock firmware) dead spots on the keyboard sometimes? Meaning, sometimes you'll press a key particularly in the bottom left or right regions of the screen, and it won't register? That's really what has me annoyed thinking my phone has a hardware defect. I hope that GSIs or ROMs can fix this too. I think my 7 day Time Out Timer for unlocking the BL expires today.
[Moto G Stylus 5G] jasonmerc:
EDIT: I flashed a GSI, let me outline the steps I took. This was for the Lineage OS Android 13 GSI on that GitHub page you posted on the previous page. Big thanks to @PizzaG

Grab the latest ADB and fastboot, windows users can get it from HERE (this is the one I used).

Unlock bootloader, reboot and let it boot normally, set it up again but dont put in any accounts and dont put on any screen lock

Download the stock firmware from lolinet. Remember that our device is the Motorola Pnangn. Extract it somewhere since you'll need some stuff from it later.

copy the attached signed-copy-partitions ZIP to your phone, you will flash this in TWRP later

Reboot to bootloader

Fastboot boot the TWRP image DragonFire made above, then flash the signed copy partitions ZIP you put on your phone before. This copies the active partition to the other partition, so there is less chance of you bricking your phone if something goes wrong

Reboot the phone to stock android again, make sure it still boots, then reboot to fastboot again

fastboot getvar all, note what your current slot is. For me, it was current_slot=a. It SHOULD be this for you too.

fastboot flash --disable-verification vbmeta [the path to the stock vbmeta.img that you get from your stock firmware]

fastboot flash --disable-verification vbmeta_system [the path to the stock vbmeta_system.img that you get from your stock firmware]

Did you flash, while disabling verification, both vbmeta AND vbmeta_system? That's why I put them in different colors above.

fastboot -w to erase userdata

fastboot reboot fastboot, you will now be in fastbootd

Do a fastboot delete-logical-partition product_a if your active slot you checked earlier was A. If for some reason your active slot is B, then do product_b. You need to do this or else the GSIs wont have room to install on your phone

Do a fastboot flash system [path to gsi.img]

Reboot the phone with fastboot reboot

If your phone can't get mobile data, you might have to go and manually enable Mobile Data, and then go into your Mobile Internet settings and ensure that the right APN and Network Type (Global, LTE/CDMA, etc.) are set by hand.

OPTIONAL: grab the stock boot image from the stock firmware you downloaded earlier, patch it in android to have Magisk, then reboot your phone to fastbootd and flash the boot image that way to have Magisk root

Like I said I flashed the Lineage OS Android 13 image. I personally don't have 5G but I do have LTE. I am running my pnangn on Verizon. Maybe other GSIs or other carriers will have 5G enabled in a GSI.
[Moto G Stylus 5G] jasonmerc:
Bad news: my touch screen is still screwed up on the bottom corners it seems. And now that my bootloader is unlocked I can't get free warranty repairs anymore. Guess I'm stuck with this dog **** phone for life now. I'll try to make the most of it.

For those of you looking to buy a Moto G 5G 2023, make sure you CHECK THE BOTTOM CORNERS before committing to it. If you have occasional missing-touches, return it and get your money back.

UPDATE: I traded it in for a G Stylus 5G 2023. My new device actually functions correctly now. I no longer have this phone, but I'll leave all my stuff up here in case anyone else needs to reference it.
[Moto G Stylus 5G] DragonFire1024:
i will write up a more extensive how-to with the GSI. you gotta make sure you are at complete fresh, unrooted stock when flashing the GSI or you will boot loop. Problem with that is, you can't go back a few steps and redo any steps. If you boot loop, you have to reflash stock and start all over again.

I have downloaded the kernel source for penang, international version of the same device, and the configs for pnangn are indeed in the source. I started to build, and wouldn't you know, I of course get an error that I can't figure out how to fix yet. 🤦
[Moto G Stylus 5G] careloads:
Thank you for all your effort here! I have been out of the mod game for long enough to have been left in the dust. My last efforts were around the start of the Magisk era and I never actually had a successful root then. I am comitted to this pnangn model for the long haul though and willing to help where I can. My 7 day wait will be over tomorrow (Merry Christmas!) so bootloader unlock forthcoming.
[Moto G Stylus 5G] jasonmerc:
See the post with the attached zip, I edited it to be functional. Starting from stock, those are the steps needed to flash a GSI successfully.

However I don't have this phone anymore, couldn't stand the hardware issues I was having with the touchscreen and traded it in for a G Stylus 5G 2023. So unfortunately I might not be much help to you guys anymore, but if anyone has questions about what I posted I'll hang around and try to answer.
[Moto G Stylus 5G] careloads:
Thanks again for the help here! Can you provide more info on which firmware file to download from lollinet? I am using an XT2313-6 on the Verizon network in USA. There are many different ones to choose from and it is not obvious to me which one I need. View attachment 6048265
[Moto G Stylus 5G] jasonmerc:
So you always get the firmware that matches the phone, not the network you're using it on. If that's a retail unlocked variant (I forget the model number but I think that's it) you would get RETUS firmware which stands for Retail US. Meaning you bought it unlocked from some retail store like Best Buy.

Now sure, Verizon firmware might work, but if you do that now you're screwing yourself out of a bootloader unlock and you're also stuck with Verizon bloat forever too.

To double check, reboot the phone to bootloader and check the model number. Power the phone off, then hold Vol Down and power to get to the bootloader screen. If you see the codename is something like "Pnangn" or "Penangna" then that's the RETUS version.

EDIT: Out of sheer curiosity, please check the bottom left and right corners for a touchscreen issue. Enable show taps in the developer options, then go to some blank screen and start to semi-rapidly tap the bottom left or right corner. Try both out. Right around the area of the screen where the Enter button and the Numbers button would be on your keyboard if you had a keyboard open. If you see that the phone sometimes misses your touches (the circle doesn't show up) then you probably have a bad digitizer like mine did and you should consider swapping it out for another one.
[Moto G Stylus 5G] careloads:
Verified Pnangn model in bootloader, downloading RETUS now.

Screen test showed no issues so I think I am good to go with this phone. The only hesitation I have experienced so far is what feels like the classic data lag of what I usually attribute to excessive background operations from bloat. So hope to lose that!!!
[Moto G Stylus 5G] jasonmerc:
I personally did the Lineage 20 (A13) GSI from DragonFire's linked post. I lost 5G capabilites, but it was buttery smooth otherwise and very stable.

Or you can try EvolutionX if you want Gapps, but I think that GSI was still in beta so that's why I avoided it.
[Moto G Stylus 5G] DragonFire1024:
Apparently the problem I've run into and compiling the kernel is something to do with language encoding. And I have no idea how to fix it. What I can find on the issue isn't really written by other people where somebody could explain the fix on a less technical level. Now this is not my first time compiling a kernel but it is for such a recent version of android. The last Colonel I compiled was for Android 7 LOL. But for what I understand I have to change something in a database somewhere on Ubuntu and where I don't know and how is anyone's guess at this moment. So until I figure that out I'm kind of stuck. Also I have to jerry-rig the config files a certain way in order for the colonel source to make sure it's reading the configs for pnangn and not penang. Normally that wouldn't be a problem except for the fact that the configs don't actually exist for pnangn on their own so you have to pull out the information from the existing ones in order to create new ones. There's tools to do that but I have to make sure I do it right and miraculously I got it right on the first try. If I can get the thing finished and compiled this could actually help in identifying the issue with why a PC will not acknowledge it exists when plugged into it. I think I might have figured that out and it quite likely that once TWRP is flashed it doesn't acknowledge the device exists on a PC because none of the gadgets or the driver software is selected inside the source for this device so it's quite possible just adding that alone will fix the problem. So my guess is for whatever reason flashing a custom recovery voids that function likely because it's not compiled into the actual recovery ramdisk. But the only way I'll be able to figure that out if I can get the damn thing to build.
[Moto G Stylus 5G] jasonmerc:
Can you go to the Motorola GitHub and report an issue with this? I don't know if Motorola will help you out in a timely manner, but according to the GPL, they are contractually bound to not only give you the source code but also a reasonable amount of instructions to compile an identical copy of it.
[Moto G Stylus 5G] careloads:
I had Lineage 20 on my OnePlus 5T and liked it a lot. Ditching Gapps is the main reason for doing this.

So in reviewing the steps before I start the process I have a question, forgive me if its in front of my face and I cant see it, happens to me all the time!

Grab the latest ADB and fastboot, windows users can get it from HERE (this is the one I used)..... Had a fresh download of Platform Tools a few weeks ago.

Unlock bootloader, reboot and let it boot normally, set it up again but dont put in any accounts and dont put on any screen lock....ready to unlock with key in hand.

Download the stock firmware from lolinet. Remember that our device is the Motorola Pnangn. Extract it somewhere since you'll need some stuff from it later.....Check!

It is all good so far, until I get here:

Fastboot boot the TWRP image you made above.....are you referring to the image @DragonFire1024 posted? I guess I didnt connect the dots that you were able to make his work. I will use it and see when I get time this weekend.

Thanks again for your help!
[Moto G Stylus 5G] jasonmerc:
Yes use the TWRP image made by DragonFire. I will edit the post to make that more clear, that one's on me.
[Moto G Stylus 5G] DragonFire1024:
There is some light at the end of the tunnel. Seems like things are going to move along with my request for the kernel source code for this device. They made an update to the request today on GitHub and hopefully soon enough we will have a complete source code for the kernel. I have ran into some issues using the source code from penang. I don't know if it's because of the slight difference in devices or if it's a problem with the way the code is written but I'm having a lot of trouble getting past some errors. And it only seems like it is one or two errors and the rest of the colonel will build but I cannot for the life of me figure out how to fix them inside the code at least not yet. So hopefully when we do, if we do get this new source code it won't have this problem but time will tell and we shall see.