Getting AllShare Cast working on modified devices - Galaxy S 4 Developer Discussion [Developers-Only]

Solutions for devices:
Galaxy S4 (I9500) by @sorg
Galaxy Note 8.0 by @mrmrmrmr
Galaxy Note 2 (N7100 / 4.3 only) by doandu1234
Galaxy SIII (I9300 / 4.3 only) by @mrmrmrmr
Installation:
Using a root-enabled file explorer, like Root Explorer, make a backup of /system/lib/libWFD_ENGINE.so
Download the file corresponding to your device from above, unzip the zip file, and copy the so file to /system/lib, replacing the one already there (again, make a backup).
Set permissions to 644 / -rw-r--r-- and reboot.
Old post:
AllShare Cast is Samsung's implementation of Screen Mirroring. It refuses to work on a modified device:
Logcat of where the error occurs:
Code:
I/WFD_Rtsp( 2483): content protection info found!!!
I/WFD_Rtsp( 2483): HDCP is supported by sink
I/WFD_Rtsp( 2483): HDCP port is 1189
I/WFD_Rtsp( 2483): HDCP2 init failed:-650. time: 4155
I/WFD_Rtsp_Engine( 2483): RTSP_REQUEST_HDCP_FAIL
E/WFDSourceSignalTask( 2483): HDCP init fail
V/WFDSourceEngine( 2483): Called OnErrorNoti()
E/IWFDTask( 2483): is Passive Task, Can't Send Event
E/IWFDTask( 2483): is Passive Task, Can't Send Event
E/IWFDTask( 2483): SourceAudioTask is Passive Task, Can't Send Event
E/IWFDTask( 2483): is Passive Task, Can't Send Event
V/WFDNativeCPP( 2483): [Remote] WFD_NOTI_TO_APP_ERROR
D/WFDService( 2955): onDisplayError
D/WFDService( 2955): sendWfdStartForPopup

MohammadAG said:
AllShare Cast is Samsung's implementation of Screen Mirroring. It refuses to work on a modified device:
Logcat of where the error occurs:
Code:
I/WFD_Rtsp( 2483): content protection info found!!!
I/WFD_Rtsp( 2483): HDCP is supported by sink
I/WFD_Rtsp( 2483): HDCP port is 1189
I/WFD_Rtsp( 2483): HDCP2 init failed:-650. time: 4155
I/WFD_Rtsp_Engine( 2483): RTSP_REQUEST_HDCP_FAIL
E/WFDSourceSignalTask( 2483): HDCP init fail
V/WFDSourceEngine( 2483): Called OnErrorNoti()
E/IWFDTask( 2483): is Passive Task, Can't Send Event
E/IWFDTask( 2483): is Passive Task, Can't Send Event
E/IWFDTask( 2483): SourceAudioTask is Passive Task, Can't Send Event
E/IWFDTask( 2483): is Passive Task, Can't Send Event
V/WFDNativeCPP( 2483): [Remote] WFD_NOTI_TO_APP_ERROR
D/WFDService( 2955): onDisplayError
D/WFDService( 2955): sendWfdStartForPopup << POPUP_CAUSE_CONNECTION_DISCONNECT
I/WFDNativeCPP( 2483): [Remote] WFDNative_setParam type:40 data:0
D/RemoteDisplay_Java( 2955): nativeSetWFDParam:1
Looking through the system libraries, the error originates from a shared library: libWFD_ENGINE.so (the library also has a reference to libhdcp2.so)
I've gone through Android's source code and I can't seem to find a reference to that library anywhere in the source code, so I guess it's specific to Samsung.
Ways to get around this:
Use Cydia Substrate to hook the native code, making HDCP always init successfully.
Find out how the library gets system status.
The first way requires disassembling the shared library and looking for ways to get HDCP to work. This might be very hard to do.
The second part may be easier, if it's just parsing some file in procfs or sysfs or something it can be patched at the kernel level, which might be easier to do considering the kernel's source is out there.
The library doesn't check for su btw, there are reports of users having it work without unrooting their devices. The library also doesn't talk to SysScope, as that was patched numerous times by Xposed modules so it returns Official status, but that also doesn't work.
Click to expand...
Click to collapse
I'm guessing you're going to have to hack libhdcp2.so. I've found that it deals with 3 paths:
/data/system/hdcp2
/system/etc/srm.bin
/dev/qseecom
I'm guessing /dev/qseecom is the important one as that's the interface to ARM's TrustZone stuff. I'm no assembly expert though, so I have no idea how to interpret the decompiled library
EDIT: Don't know if it's helpful, but if you see something like:
Code:
_ZN11CWFD_HdcpCp22WFD_HdcpSessionConnectEm
when running "strings system/lib/...", run this to translate it into a readable function signature:
Code:
$ echo '_ZN11CWFD_HdcpCp22WFD_HdcpSessionConnectEm' | c++filt
CWFD_HdcpCp::WFD_HdcpSessionConnect(unsigned long)

chenxiaolong said:
I'm guessing you're going to have to hack libhdcp2.so. I've found that it deals with 3 paths:
/data/system/hdcp2
/system/etc/srm.bin
/dev/qseecom
I'm guessing /dev/qseecom is the important one as that's the interface to ARM's TrustZone stuff. I'm no assembly expert though, so I have no idea how to interpret the decompiled library
Click to expand...
Click to collapse
Hmm, I'm guessing you have a Qualcomm device? My libhdcp2.so doesn't have a reference to /dev/qseecom (it doesn't even exist), instead it seems to interface with /dev/s5p-smem.

MohammadAG said:
Hmm, I'm guessing you have a Qualcomm device? My libhdcp2.so doesn't have a reference to /dev/qseecom (it doesn't even exist), instead it seems to interface with /dev/s5p-smem.
Click to expand...
Click to collapse
Yeah, I should have mentioned that. I have the T-Mobile SGH-M919 model. I also don't have a libWFD_ENGINE.so, but I do have a libwfdhdcpcp.so.
I've attached the libhdcp2.so and libwfd* libraries from the Qualcomm variants.

chenxiaolong said:
Yeah, I should have mentioned that. I have the T-Mobile SGH-M919 model. I also don't have a libWFD_ENGINE.so, but I do have a libwfdhdcpcp.so.
I've attached the libhdcp2.so and libwfd* libraries from the Qualcomm variants.
Click to expand...
Click to collapse
I've been doing some tests on a Note 2, that also fails when the device is modified, but there are easy ways to get that back to stock.
* I've confirmed that SysScope isn't used at all, it works fine even when device status is Settings is modified.
* HDCP also fails to init on the Note 2, but the logcat is a bit more verbose. I didn't copy the logcat, but it does indeed state that TZ failed to open, or opened and then got closed, so this is a TrustZone issue for sure.
I've been digging around the kernel source code, and I found references to wfd in secmem.c, which does point to s5p-smem here https://github.com/AndreiLux/Perseus-UNIVERSAL5410/blob/perseus/arch/arm/mach-exynos/secmem.c#L43
I'm pretty sure the same goes for the Qualcomm variant.
What I'm not sure of is the CONFIG_EXYNOS_CONTENT_PATH_PROTECTION, it's set to y in the kernel config, I wonder if disabling it would make this all work.
Also, I can't grasp how to communicate with the TZ, trying to read from /dev/s5p-smem throws an Invalid Argument error.

MohammadAG said:
I've been doing some tests on a Note 2, that also fails when the device is modified, but there are easy ways to get that back to stock.
* I've confirmed that SysScope isn't used at all, it works fine even when device status is Settings is modified.
* HDCP also fails to init on the Note 2, but the logcat is a bit more verbose. I didn't copy the logcat, but it does indeed state that TZ failed to open, or opened and then got closed, so this is a TrustZone issue for sure.
I've been digging around the kernel source code, and I found references to wfd in secmem.c, which does point to s5p-smem here https://github.com/AndreiLux/Perseus-UNIVERSAL5410/blob/perseus/arch/arm/mach-exynos/secmem.c#L43
I'm pretty sure the same goes for the Qualcomm variant.
What I'm not sure of is the CONFIG_EXYNOS_CONTENT_PATH_PROTECTION, it's set to y in the kernel config, I wonder if disabling it would make this all work.
Also, I can't grasp how to communicate with the TZ, trying to read from /dev/s5p-smem throws an Invalid Argument error.
Click to expand...
Click to collapse
Hmm, I just tried reading from /dev/qseecom and I get the exact same Invalid Argument error. I've read somewhere on XDA that WIFI passwords are stored in TZ when a Samsung signed kernel is used and they're stored in wpa_supplicant.conf when the kernel is not official.
That leads me to think that TrustZone only works if the signatures match. There's also a chance that it won't work if the binary counter is not 0.
EDIT: Currently, only Qualcomm devices can have their counter reset though. Unfortunately, I don't have any Allshare/Miracast receivers to test with.
EDIT2: WFD apparently stands for WiFi Display: https://github.com/ktoonsez/KT-SGS4...n/devicetree/bindings/media/video/msm-wfd.txt
EDIT3: Don't know if this is useful. If you decompile SecSettings.apk and take a look at com/android/settings/DevelopmentSettings.java, there's this function:
Code:
private void removeHdcpOptionsForProduction()
{
if ("user".equals(Build.TYPE))
{
Preference localPreference = findPreference("hdcp_checking");
if (localPreference != null)
{
getPreferenceScreen().removePreference(localPreference);
this.mAllPrefs.remove(localPreference);
}
}
}
Changing the build type from user to userdebug in build.prop should enable the HDCP checkbox in development settings. I don't think this will work, but it's worth a try.

Well, i've hacked libWFD_ENGINE.so some time ago for my own needs. The way i've able to make it work only by disabling HDCP. So, this hacked version uses clear data without HDCP to talk with AllShareCast dongle.
I don't know if generic miracast dongles will accept data without HDCP as i don't have such device.
Included version for I9500 works with I9500XWUBMG1, I9500XXUBMG9, I9500UBUBMH1. Probably, it's compatible with other firmware versions.
P.S.: Since it's developers forum, you should know how to replace the file.
P.P.S: You can use this patched version in any ROM you want, but please give a credit to me.

chenxiaolong said:
EDIT3: Don't know if this is useful. If you decompile SecSettings.apk and take a look at com/android/settings/DevelopmentSettings.java, there's this function:
Code:
private void removeHdcpOptionsForProduction()
{
if ("user".equals(Build.TYPE))
{
Preference localPreference = findPreference("hdcp_checking");
if (localPreference != null)
{
getPreferenceScreen().removePreference(localPreference);
this.mAllPrefs.remove(localPreference);
}
}
}
Changing the build type from user to userdebug in build.prop should enable the HDCP checkbox in development settings. I don't think this will work, but it's worth a try.
Click to expand...
Click to collapse
Tried that, didn't work, pretty sure that's for MHL or plain HDMI ports on some devices.
sorg said:
Well, i've hacked libWFD_ENGINE.so some time ago for my own needs. The way i've able to make it work only by disabling HDCP. So, this hacked version uses clear data without HDCP to talk with AllShareCast dongle.
I don't know if generic miracast dongles will accept data without HDCP as i don't have such device.
Included version for I9500 works with I9500XWUBMG1, I9500XXUBMG9, I9500UBUBMH1. Probably, it's compatible with other firmware versions.
P.S.: Since it's developers forum, you should know how to replace the file.
P.P.S: You can use this patched version in any ROM you want, but please give a credit to me.
Click to expand...
Click to collapse
That actually worked (XWUMBG5). I'm no ROM dev, but if I do end up making a patch with Cydia Substrate (if I figure that out), I'll be sure to credit you
Thanks!

MohammadAG said:
making a patch with Cydia Substrate
Click to expand...
Click to collapse
I've thought Cydia Substrate gives something special, but after quick look i've found it providing not more than XPosed already provides. You cannot make patch for this using Cydia Substrate because the only thing you can do by this is to hook JNI functions called from Dalvik code (you can do the same in Xposed). You cannot hook internal lib functions where the "magic" happens.
The only way is to replace the whole lib i've provided so far.

sorg said:
I've thought Cydia Substrate gives something special, but after quick look i've found it providing not more than XPosed already provides. You cannot make patch for this using Cydia Substrate because the only thing you can do by this is to hook JNI functions called from Dalvik code (you can do the same in Xposed). You cannot hook internal lib functions where the "magic" happens.
The only way is to replace the whole lib i've provided so far.
Click to expand...
Click to collapse
Heh, ironic how iOS devs dissed Xposed as not hooking C++ code, I actually thought Cydia Substrate would hook any C++ code on the system.
Oh well, thanks for saving me hours of going through Cydia's docs.
BTW, you might want to post your solution here, http://forum.xda-developers.com/showthread.php?t=2269150
I don't think a lot of users read this forum.
Sent from my Samsung Galaxy S4 (i9500)

QA forum is also not so popular Actually the idea for separate QA forum is a big mistake because it's popular for those who ask. Not those who know the answer.
Do you want to throw away the topic? move it to QA forum!

sorg said:
QA forum is also not so popular Actually the idea for separate QA forum is a big mistake because it's popular for those who ask. Not those who know the answer.
Do you want to throw away the topic? move it to QA forum!
Click to expand...
Click to collapse
Hahaha, I recall your encounter with the binary counter issue that was pretty much nulled that way
Sent from my GT-I9500 using xda app-developers app

Using your lib on other devices.
Dear Sorg,
Thank you for providing this great lib hack. After reading your posts about the AllShare / ScreenCast feature broke by the root, I could fix it on my samsung galaxy S3 and I understoood the problem with my Cube U30GT2 tablet was probably due to the same HDCP issues.
About the SGS3:
I switched from a 4.1.2 official firmware to CyanogenMod 10.1 beta last January on my SGS3. I finally flashed the leaked XXUFME7 two weeks ago to experiment the AllCast feature of my new Samsung Smart TV. So I might have skipped the Samsung update 0f the bootloader / tz. The WFD worked fine until I rooted the phone last week with cf-root/odin.
I finally decided to give it a try with TriangleAway to see if it would be enough to restore the DRM management chain checkup and it worked fine.
However, for many of us whom have probably upgraded their bootloader/tz with the Samsung latest updates, a lib patch is probably less tricky than a push of some bootloader/tz image thru adb I just hope Samsung will not update the tv/Allshare cast dongle firmware to restrict the streams with HDCP.
The Cube U30GT2
I have installed the Kasty firmware. It's a custom from the official Cube 2.04 firmware based on Android 4.2.2. It includes the Rockchip tools to enable the ScreenMirroring. But as it's pre-rooted when I try to connect to my Samsung smart TV I experience the same problem than with the SGS3. In that case TriangleAway is not an option and i don't know how to find the original bootloader/tz and if it would even work.
All the other Samsung Allshare features are working properly like the UPNP / DLNA.
Sadly there is no libWFD_ENGINE in /system/lib
Rockchip implementation of the standard is named WIMO and is quite poorly documented.
I can copy a proc/kmsg log if someone would be kind to help.
Can you tell me is the libWFD_ENGINE is a generic android 4.2 part of the widi implementation or a Samsung Allshare proprietary lib ?
Thanks
Best regards,

e-dredon said:
Is the libWFD_ENGINE a generic android 4.2 part of the widi implementation or a Samsung Allshare proprietary lib ?
Click to expand...
Click to collapse
I have no idea.. I only have 2 devices capable wireless display and they are both from Samsung.
---------- Post added at 03:09 PM ---------- Previous post was at 03:00 PM ----------
e-dredon said:
After reading your few posts about your lib hack and the DRM chain corrupted causing the Allcast connection to fail I tried to reset the flash counter on my Galaxy S3 with TriangleAway and it worked !
Click to expand...
Click to collapse
Yeah, i've forgot to tell that you have to reset the counter in TriangleAway to make wireless display working even with old bootloader.
The main difference between old and new bootloader/tz is that new bootloader/tz update counter of customs with every boot - that's why it's impossible to make wireless display working with new bootloader/tz.
The same with SGS4 with only difference - there is no bootloader/tz exist without updating counters on every boot. So, the only way is to hack the lib.
e-dredon said:
a lib patch is probably less tricky
Click to expand...
Click to collapse
Not for those who(me) hack the lib.
For me it's more simple to skip bootloader and tz update than hack the lib with every new firmware.

Hi,
I need a similar solution on my Note 8.
How can I patch my libWFD_ENGINE.so ?
I'd appreciate if you could help me.
attached is the file from my Note 8.
when I try the patched file here, it causes a reboot. So it's not compatible with my device.

mrmrmrmr said:
Hi,
I need a similar solution on my Note 8.
How can I patch my libWFD_ENGINE.so ?
I'd appreciate if you could help me.
attached is the file from my Note 8.
when I try the patched file here, it causes a reboot. So it's not compatible with my device.
Click to expand...
Click to collapse
1) get unmodified libWFD_ENGINE.so from I9500 ROM (XX..MG1)
2) compare with my modified library to find what has been patched. I suggest to use IDAPro to analyze changed parts.
3) apply the same changes to library from Note 8 (or any other device using this library)
That's all i can tell to you. Sorry, i won't provide patches for device i don't own.

sorg said:
1) get unmodified libWFD_ENGINE.so from I9500 ROM (XX..MG1)
2) compare with my modified library to find what has been patched. I suggest to use IDAPro to analyze changed parts.
3) apply the same changes to library from Note 8 (or any other device using this library)
That's all i can tell to you. Sorry, i won't provide patches for device i don't own.
Click to expand...
Click to collapse
Thank you. I'll try to do it myself. That's better for me since I'll need to re-do it when I there is an update.
But can you tell me the tools that I need for comparing and patching ?
---------- Post added at 08:03 PM ---------- Previous post was at 07:52 PM ----------
btw, where can I find the rom you mentioned ?
I can't find a cwm zip for i9500 ending with MG1...

I've got IDA pro installed now.
I've also got libWFD_ENGINE.so from S4 rom UBUBMH1 (I hope the lib is the same as yours)
now how can I compare it in IDA ?
I'd be grateful if you could let me know what steps I need to do.
Thanks.

mrmrmrmr said:
now how can I compare it in IDA ?
Click to expand...
Click to collapse
you cannot compare it by IDA. IDA is to read the assembler code and understand changes.
According to your questions, you are not familiar with reverse engineering. So, wait for someone who can handle this.

No. I am not familiar but i believe I can do it. Besides there's noone interested in this.
Please help me. Just tell me the steps. Now i am trying to text compare both binary file's disassemled code in ultracompare. Would that help ?
Please. You're my only hope...

Related

USB Host Support for Custom Devices

The SGS2 supports USB OTG which means it can play host to certain low-powered USB devices. Unfortunately the kernel is configured with a whitelist that means it will only connect to HIDs, printers, PTP cameras and mass storage devices.
I wanted to begin developing an application using custom (vendor specific) USB hardware and so started experimenting to see if it was possible. There is a full description of how I went about it on my blog. To summarise, one of the ways to enable vendor specific USB devices is to edit the file "drivers/usb/core/sec_whitelist.h" and add the following to both whitelist tables:
Code:
{ USB_DEVICE_INFO(0xff, 0x0, 0x0) }, /* vendor specific USB devices */
There are two reasons for this post, the first is to provide information to help others that may want to do the same thing. The second is to try and encourage kernel modders to include my changes (or disable the whitelists altogether) thereby providing application developers the means with which to communicate with custom hardware.
Regards,
Dan
Nice idea, I may be completely wrong, but if you remove the white list it, will accept other hardware? or is it dependant on it being there?
Sent from my GT-I9100 using Tapatalk
Does you also test Google ADK ??
Do you know if it would work with the S2 ?
@MacaronyMax: As I mentioned in my blog post, it is possible to disable the whitelist entirely via the kernel options which I assume would allow any device to connect, but I have not tested this and so am unsure.
@xlanhackerx: The ADK relies on accessories that have been designed to act as host and use an Android specific protocol, whereas I am interested in the SGS2 acting as host so that I can connect custom third-party slave devices to it. Therefore I have not looked at the ADK at all and I do not have the hardware available to even play with it.
Regards,
Dan
Thank you. Maybe a custom ROM has it built in?
Thank you so much terranim for this discovery, and for posting it.
I have been struggling on that for a week now, not understanding why my driver was apparently not even called.
I was thinking it could exist a ROM that has this whitelist removed... anyone has a clue? (Lite'ning 6.1 / ninphetamin 2.0.5 or .11 have is using sec_whitelist.h)
I don't think that any kernel developers have disabled this whitelist yet! However there is now another major problem: In the latest ROM from Samsung it is reported that they have removed the USB host related libraries in the Android SDK!
My hack to the kernel will still work and allow devices to be connected, but we will no longer be able to communicate with custom USB devices via an Android application (unless we write a C library to talk to the devices directly or via libusb).
Hopefully developers will restore these libraries in their own custom ROMS.
I guess I am not too far from running this whitelist with your new line on a home compiled version of ninphetamine... see http://forum.xda-developers.com/showpost.php?p=18123923&postcount=2828 and http://forum.xda-developers.com/showpost.php?p=18123923&postcount=2833
I just got to to compile completely a minute ago, and will test it on Thursday.
I think I will stick to custom ROMs / kernel now... and possibly some I compile myself.
Did you read about libftdi? That could help you. Also that Samsung removed USB API might not harm as long as you use a serial port created by the serialusb driver.
edit / ps: nice to work in a team
guys,
is there any chance this USB Host mode could work with a headphones USB DAC/Amp like the FiiO E7?
I really envy the iPod/Pad/Phone users and their ability to have pure sound of their devices while on the go. I know we have HDMI/MHL but sadly there are no headphones amps using this link
I would be interested in this as well.
it is correct that Samsung have removed the USB Host API,
As far as I can tell, they never intended to leave it there to begin with, but I do know that the particular API was introduced in API 11 (Honeycomb).
Sent from my GT-I9100 using Tapatalk
What kernel options are required for this and what is needed to test connectivity? I have an older Galaxy S device and I'm trying to reproduce what you've done here. I just got an ADK for christmas and I've been working with Cyanogenmod kernel source in an attempt to get things operating. From what I can see I need a kernel driver. It would appear that it's begining to recognize that *something* is plugged in, but it's not enumerating.
Anything you can show me would be helpful. What do you see in dmesg when ADK or any other device is connected?
Hi. I know this is an old thread but I want to know if there is some patch to enable USB DACs on the S2. I can not find anything that can enable this like the S3. If some one knows some thing please reply.
Thanks

SU for Android on ChromeOS

This is a cross-post from a reddit thread I started, but this is probably a more appropriate location for it.
I have been trying to modify files in the system folder for the Android container on the Asus Flip so I can install SuperSu, but have run into some problems.
The system folder is contained in a squashfs image on the chromebook at /opt/google/containers/android/system.raw.img. Mounted squashfs images appear to not support read-write access. I have been able to unsquash the image, add the SuperSU apk to the /system/priv-app folder and su to the /system/xbin folder, and remake the image. This boots, but SuperSU force closes as soon as it starts.
To make tinkering easier, I've tried building a writable image using dd and mkfs. I placed it in a location that has rw access and modified the /etc/init/android-ureadahead.conf script which mounts it to enable rw access. Unfortunately though it won't boot. The boot logs for the android container show a litany of SELinux errors for different things that it could not set context, operation not permitted. I can post the exact log if necessary. Some googling led me to find that the SELinux security context attributes weren't being replicated in my image, so I tried mounting with context and fscontext options equal to the contexts from the original image, but I get the same problem.
If anyone has any ideas I'd be especially grateful.
lionclaw said:
This is a cross-post from a reddit thread I started, but this is probably a more appropriate location for it.
I have been trying to modify files in the system folder for the Android container on the Asus Flip so I can install SuperSu, but have run into some problems.
The system folder is contained in a squashfs image on the chromebook at /opt/google/containers/android/system.raw.img. Mounted squashfs images appear to not support read-write access. I have been able to unsquash the image, add the SuperSU apk to the /system/priv-app folder and su to the /system/xbin folder, and remake the image. This boots, but SuperSU force closes as soon as it starts.
To make tinkering easier, I've tried building a writable image using dd and mkfs. I placed it in a location that has rw access and modified the /etc/init/android-ureadahead.conf script which mounts it to enable rw access. Unfortunately though it won't boot. The boot logs for the android container show a litany of SELinux errors for different things that it could not set context, operation not permitted. I can post the exact log if necessary. Some googling led me to find that the SELinux security context attributes weren't being replicated in my image, so I tried mounting with context and fscontext options equal to the contexts from the original image, but I get the same problem.
If anyone has any ideas I'd be especially grateful.
Click to expand...
Click to collapse
Wayyyy out of my area of expertise, but here's my (completely novice) best guess.
>All Chromebooks are write-protected with a screw on the motherboard
>Putting a Chromebook in developer mode allows for some tinkering ie things like chroots, and on the asus flip, the ability to install apks from unknown sources.
>Unscrewing the write-protect screw allows for the ability to completely install a new operating system or dual boot setup.
>Maybe you need to do that before you're able to accomplish root access?
My other idea would be to try and figure out a way of doing a systemless root?
Also, total aside but since this is the only thread I've found on XDA about this device, I think chroots are theoretically possible now without the need to be in developer mode via Android apps (even without root on Android). Download the GIMP port from the Play Store to see what I'm talking about. Playing around with that for a few minutes really made me wish that it didn't use emulated mouse/keyboard in it's implementation. Also, it appears that apt-get is broken, but regardless it might interest someone out there looking for a project.
back from the dead, any progress on this?
I have been able to successfully root the Android image on my Asus Flip.
I built a blank image with dd in /usr/local, formatted it with mkfs, mounted it to a folder, mounted the original system.raw.img to a folder, copied the files across, placed *all* the SuperSU files listed as 'required' in the SuperSU update-binary in the relevant places in /system in my new image, set permissions & contexts for those files, edited arc-system-mount.conf and arc-ureadahead.conf to point to the new image and, finally, patched /etc/selinux/arc/policy/policy.30 with the SuperSU sepolicy patching tool in order to boot my rooted Android instance with selinux set to enforcing.
I have created a couple of scripts which more-or-less fully automate this procedure, which can be downloaded from nolirium.blogspot.com. Please feel free to download, open the scripts in a text editor to check them out, and try them out if you like. Only tested on Asus Flip, though.
I seem to be unable to post attachments at the moment so I will just add the descriptions here, I could probably post the entire scripts here too if anyone wants. Feel free to let me know what you think.
DESCRIPTIONS:
1-3.sh
Combines the first three scripts listed below.
01Makecontainer.sh
Creates an 900MB filesystem image in /usr/local/Android_Images, formats it, then copies Android system files therein.
02Editconf.sh
Modifies two system files: arc-system-mount.conf - changing the mount-as-read-only flag and replacing the Android system image location with a new location; and arc-ureadahead.conf - again replacing the Android system image location. Originals are renamed .old - copies of which are also placed in /usr/local/Backup.
03Androidroot.sh
Mounts the previously created Android filesystem image to a folder, and copies SuperSU files to the mounted image as specified in the SuperSU update-binary.
04SEpatch.sh
Copies an SELinux policy file found at /etc/selinux/arc/policy/policy.30 to the Downloads folder, opens an Android root shell for the SuperSU policy patching command to be entered, then copies the patched policy back to the original location. A copy of the original policy.30 is saved at /etc/selinux/arc/policy/policy.30.old and /usr/local/Backup/policy.30.old
Uninstall.sh
Removes the folder /usr/local/Android_Images and attempts to restore the modified system files arc-system-mount.conf and arc-ureadahead.conf.
ok so two questions, one do you think this would work on the Acer r13 convertable? and 2 where can I find the actual instructions/scripts
keithkaaos said:
ok so two questions, one do you think this would work on the Acer r13 convertable? and 2 where can I find the actual instructions/scripts
Click to expand...
Click to collapse
The R13 has a 64-bit Mediatek processor, right?
I have added a version for ARM64, but I haven't tested it.
You can find the instructions and scripts at nolirium.blogspot.com
ya, its a mediatek. and thanks ill go see if i can find it
---------- Post added at 03:31 AM ---------- Previous post was at 02:58 AM ----------
wow, ok. i can do this but im not sure i want to.. after reading the possible problems i may run into. Im going to be getting the G. Home in a couple weeks and i gotta keep things running smooth. This seems like going a tad too far then i need to. The other day i had action launcher going and it looked pretty damn good but i really want to try and get the action3.apk that i have put into the pri-app folder or whatever the chromebook uses i found the syst folder but cant access it. Im wondering if i make the machine writable it would work but im afraid of losing my updates, as long as i could do them manualy, i guess that would be cool. Also since im already going on... has anyone found a way to disable the dev boot screen without tinkering with the physical chromebook yet?
SuperSU on Chromebook
Hey there I love this post but unfortunately im on the mediatek (well not unfortunately cause i love it) but i do really want super su .. But i found this other post that i tried out but i am having a problem executing the scripts. When i go to run the first one, it says can not open "name of script" but the dev takes a pretty cool approach. Im still new to Chrome OS but thanks for the post and if you have any advice on executing scripts id love to hear it!! http://nolirium.blogspot.com/
I'm guessing the above post was moved from another thread...
Anyway, it turns out that zipping/unzipping the files in Chrome OS's file manager sets all the permissions to read-only. Apologies! sudo chmod+x *scriptname* should fix it...
Regarding OS updates, I actually haven't had a problem receiving auto-updates with software write-protect switched off; the main possible potential issue I could imagine arising from the procedure I outlined would involve restoring the original conf files if both sets of backups get deleted/overwritten. This seems unlikely, but in that case either manually editing the files to insert the original string (/opt/google/containers/android/system.raw.img), or doing a powerwash with forced update might be necessary in order to get the original Android container booting again.
I don't think anyone's found a way to shorten/disable the dev boot screen without removing the hardware write-protect screw - from what I've read, the flags are set in a part of the firmware which is essentially read-only unless the screw is removed. Perhaps at some point the Chrome OS devs will get fed up of reading reports from users whose relatives accidentally reset the device by pressing spacebar, and change the setup. Here's hoping.
Hey just jumpig in the thread right quick to see if these instructions are old or what-- got a chromebook pro and the notion of having to update a squashed filesystem every timeto install su seems like a pain..
Is there any kind of authoritative documentation/breakdown regarding what Chromeos is mounting where before I start breaking things? Also anyone happen to know if there's a write-protect screw anywhere in the chromebook plus/pro?
Other questions:
* adbd is running, but is not accessible from adb in the (linux) shell, which shows no devices. Do I need to access adb from another device (i'm short a usb c cable right now) or can I use adb (which is there!) on the chrome side to access adbd on the android side?
* Anyone know if adb via tcp/ip is available? Don't see it in the android settings.
Hey,
There's no real documentation AFAIK, the thing is that ARC++ is a bit of a moving target, as it's so actively being developed/reworked. For instance, with the method described earlier in the thread - it started off being possible to just swap out a file location in arc-ureadahead.conf, then they changed it to arc-setup-conf, and now, since a few CrOS versions ago, the rootfs squashfs image is mounted in a loop fashion via the /usr/sbin/arc-setup binary instead, making an overview of the setup somewhat opaque to the casual observer.
I was kind of hoping to implement a kind of hybrid systemless root style setup myself, but unfortunately I haven't really managed to find the time to sit down and fully figure out a few parts of the puzzle, in particular relating to minijail and working with namespaces. So, I'm still using the method mentioned in posts above for my rooting needs at the moment, the only significant changes being that at the moment I'm replacing /opt/google/containers.android.system.raw.img with a symlink to my writeable rooted rootfs img, and also that in recent CrOS versions the mount-as-read only and debuggable flags can be found in /etc/init/arc-setup-env ("Environment variables for /usr/sbin/arc-setup").
In general though, one can kind of get an idea of what's going on in the default setup by reading through the various /etc/init/arc-* Chrome OS upstart jobs (and their logs in /var/log). Though, like I say, things keep changing around somewhat with every CrOS update, as the implementation 'improves'. As time goes by, and the subsystem matures, it'll certainly be interesting to see what other approaches are possible relating to customizing Android on Chrome OS.
There should definitely be a write protect screw somewhere on the motherboard for the Samsungs, but so far I haven't come across any pics showing exactly which screw it is. So far, no-one seems to have been brave/foolhardy enough to fully tear down their own machine and locate the screw!
Regarding adb, on my device I found the following in arc-setup-env:
# The IPV4 address of the container.
export ARC_CONTAINER_IPV4_ADDRESS=100.115.92.2/30
adb 100.115.92.2 (in Chrome OS's shell) works fine for me, the authorisation checkbox pops up and then good to go. su works fine through adb as expected. There's also a useful little nsenter script in Chrome OS to get into the android shell; /usr/sbin/android-sh, which I've been using in my script to help patch SE linux.
I actually just updated my rooting scripts recently to support 7.1.1, though I've only tested on my own Armv7 device (Flip C100).
I'll attach them to this post in case anyone wants to take a look. There's a readme in the zip, some more details can also be found here and below
EDIT: Fixed the SE Linux issue occurring with the previous version I uploaded (it was launching daemonsu from u:r:init:s0 instead of u:r:supersu:s0).
Anyone considering giving them a spin should bear in mind that the method does involve creating a fairly large file on the device as a rooted copy of the android rootfs. (1GB for arm, 1.4GB for Intel). There's a readme in the zip but the other couple of important points are that:
a) The SuperSU 2.82 SR1 zip also needs to be downloaded and extracted to ~/Downloads on the Chromebook.
b) Rootfs verification needs to be off. The command to force this is:
Code:
sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --force --partitions $(( $(rootdev -s | sed -r 's/.*(.)$/\1/') - 1))
or the regular command to do it is:
Code:
sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification
c) If, subsequent to running the scripts, there's a problem loading Android apps (e.g. after a powerwash or failed install), the command to restore the original rootfs image is:
Code:
sudo mv /opt/google/containers/android/system.raw.img.bk /opt/google/containers/android/system.raw.img
Hey this is a great response.. thanks!
Nolirum said:
Hey,
There's no real documentation AFAIK, the thing is that ARC++ is a bit of a moving target, as it's so actively being developed/reworked. For instance, with the method described earlier in the thread - it started off being possible to just swap out a file location in arc-ureadahead.conf, then they changed it to arc-setup-conf, and now, since a few CrOS versions ago, the rootfs squashfs image is mounted in a loop fashion via the /usr/sbin/arc-setup binary instead, making an overview of the setup somewhat opaque to the casual observer.
Click to expand...
Click to collapse
verity
Yeah playing with it now, I'm looking at these /etc/init/arc-*-conf files... I see that the /dev/loop# files are being set up... (more below)
Nolirum said:
I was kind of hoping to implement a kind of hybrid systemless root style setup myself, but unfortunately I haven't really managed to find the time to sit down and fully figure out a few parts of the puzzle, in particular relating to minijail and working with namespaces. So, I'm still using the method mentioned in posts above for my rooting needs at the moment, the only significant changes being that at the moment I'm replacing /opt/google/containers.android.system.raw.img with a symlink to my writeable rooted rootfs img, and also that in recent CrOS versions the mount-as-read only and debuggable flags can be found in /etc/init/arc-setup-env ("Environment variables for /usr/sbin/arc-setup").
Click to expand...
Click to collapse
Sorry not sure what you mean by "hybrid systemless root style setup"? I take it you're modifying the startup script and replaced the squashfs file in /opt... my concern about doing it was whether they were implementing some kind of dm-verity equivalent to the squashfs file to make sure it hasn't been tampered with (say, by adding /sbin/su or whatever) or whether it's safe to replace that file.. Sounds like you're saying it is? (update: I guess that's what rootfs verification does, and we can turn it off....)
Also you mean arc-setup.conf:
env ANDROID_DEBUGGABLE = 0
right?
Nolirum said:
In general though, one can kind of get an idea of what's going on in the default setup by reading through the various /etc/init/arc-* Chrome OS upstart jobs (and their logs in /var/log). Though, like I say, things keep changing around somewhat with every CrOS update, as the implementation 'improves'. As time goes by, and the subsystem matures, it'll certainly be interesting to see what other approaches are possible relating to customizing Android on Chrome OS.
Click to expand...
Click to collapse
I hadn't realized the boot was still in flux-- I'd have figured they'd worked that out by now...
Nolirum said:
There should definitely be a write protect screw somewhere on the motherboard for the Samsungs, but so far I haven't come across any pics showing exactly which screw it is. So far, no-one seems to have been brave/foolhardy enough to fully tear down their own machine and locate the screw!
Click to expand...
Click to collapse
Heh.. not gonna be me..
Nolirum said:
Regarding adb, on my device I found the following in arc-setup-env:
# The IPV4 address of the container.
export ARC_CONTAINER_IPV4_ADDRESS=100.115.92.2/30
adb 100.115.92.2 (in Chrome OS's shell) works fine for me, the authorisation checkbox pops up and then good to go. su works fine through adb as expected. There's also a useful little nsenter script in Chrome OS to get into the android shell; /usr/sbin/android-sh, which I've been using in my script to help patch SE linux.
Click to expand...
Click to collapse
Cool-- adb connect 100.115.92.2 does indeed work I was gonna use netcat to open port 5555 in chromeos and pipe it through, but looks like nc isn't here and I'm not yet ready to start changing the FS..though probably will be soon... btw any idea which partitions get overwritten when chrome it does it's updates? Will /root and /etc get overwritten, for example... would a "powerwash" overwrite it or can you get easily get into an unbootable state on these things?
It's also kind of strange that adb is listening to port 30 at that (internal?) bridge address by default witho no UI to turn it off.. and it's inaccessible from outside.. i wonder if there's an easy way to change the bridge to share the same IP as the actual interface...
Final thought-- I'd love to build that system image myself soup-to-nuts, but I can't find any "caroline" device tree set up... do you or anyone else happen to know if there's a standalone AOSP device tree for the chromebooks? It would be cool to have a mashup AOSP/lineageos if such a think could be possible-- I'm guessing chromiumos is just taking the android tree, building it and then adding it into their build... I Haven't build chromiumos for many years now so I can't even begin to imagine how this android build integrates with the whole emerge thing they had going.. but I bet it takes a while
Nolirum said:
I actually just updated my rooting scripts recently to support 7.1.1, though I've only tested on my own Armv7 device (Flip C100).
Click to expand...
Click to collapse
Cool I'll take a look at these scripts.
So I haven't yet run the scripts-- just looking through them-- I noticed the section starting:
if [ -e /etc/init/arc-setup-env ]; then
echo "Copying /etc/init/arc-setup-env to /usr/local/Backup"
This doesn't exist on the x86 CB Pro. There's an arc-setup.conf that sets up the environment variables though. It sets WRITABLE_MOUNT to 0, but then so does arc-system-mount.conf
Not sure if these are different between x86 and ARM or if it's just in the latest update.. but figured I'd let you know. Wanna throw thse scripts up on github somewhere? (Or I can do it) and we can maybe look at keeping them up to date and/or standardizing them? It wouldn't be hard to determine if it's running on ARM or x86_64 (uname -i for example)..
fattire said:
So I haven't yet run the scripts-- just looking through them-- I noticed the section starting:
if [ -e /etc/init/arc-setup-env ]; then
echo "Copying /etc/init/arc-setup-env to /usr/local/Backup"
This doesn't exist on the x86 CB Pro. There's an arc-setup.conf that sets up the environment variables though. It sets WRITABLE_MOUNT to 0, but then so does arc-system-mount.conf
Not sure if these are different between x86 and ARM or if it's just in the latest update.. but figured I'd let you know. Wanna throw thse scripts up on github somewhere? (Or I can do it) and we can maybe look at keeping them up to date and/or standardizing them? It wouldn't be hard to determine if it's running on ARM or x86_64 (uname -i for example)..
Click to expand...
Click to collapse
Oh, the arc-setup-env thing is intentional. There does appear to be another issue with the x86 version though. I've written up a detailed response to your previous post; it's in a text file at the moment so I'll copy it over and format it for posting here with quotes etc now - should only take a few minutes. Yeah, sticking them on github might be a good idea; I've been meaning to create an account over there anyway.
Yeah, so... Regarding the scripts, since I've put them up here for people to download - I should mention that the first person to test them (aside from me) has reported that something's not working right (I'm waiting for confirmation but I think he tried out the x86 version). It's likely either an error on my part when copying across from my Arm version, or perhaps something not working right with conditionals, meant to deal with the various OS versions ('if; then' statements, I mean). Once I find out more, I'll edit my earlier post...
fattire said:
Sorry not sure what you mean by "hybrid systemless root style setup"? I take it you're modifying the startup script and replaced the squashfs file in /opt... my concern about doing it was whether they were implementing some kind of dm-verity equivalent to the squashfs file to make sure it hasn't been tampered with (say, by adding /sbin/su or whatever) or whether it's safe to replace that file.. Sounds like you're saying it is?
Click to expand...
Click to collapse
Oh, sorry for being a bit vague - I just mean perhaps implementing a kind of systemless root à la Magisk/SuperSU (from what I understand of how these work) - avoiding the need to actually replace files in /system. Since I'm mainly just using su for the privileges rather than actually wanting to write to /system, I had the idea that perhaps a sort of overlay on e.g. xbin and a few other locations, rather than actually rebuilding the whole of /system, might be an interesting approach....
Yep, I've been replacing /opt/google/containers/android/system.raw.img with a symlink to my modified image lately. Works fine... I think they've been focused on just getting the apps working properly, maybe something like dm-verity is still to come.
Although, one of the cool things with Chromebooks IMO is that once the Developer Mode (virtual) switch has been flipped, the system's pretty open to being hacked around with. I think a large part of the much-trumpeted "security" of the system is thanks to the regular mode/Dev mode feature, once in Dev Mode with verified boot disabled on the rootfs, we can pretty much do what we want (I like the message that comes up in the shell when entering the first command I posted under the spoiler - it literally says "YOU ARE ON YOUR OWN!").
So yeah, with Dev Mode switched off, verified boot switched on, we can't even get into the shell (just the walled-off 'crosh' prompt), making the system indeed rather secure (but, for some of us, rather limited).
fattire said:
Also you mean arc-setup.conf:
env ANDROID_DEBUGGABLE = 0
right?
Click to expand...
Click to collapse
That's what I mean by a moving target, lol. On my device the Canary channel is at Chrome OS version 61; I think they started to move out some ARC++ (the acronym stands for Android Runtime on Chrome, version 2, if anyone's wondering, btw) environment variables to a separate file in version 60, or maybe 61. Problems with being on the more 'bleeding edge' channels include:
#Sometimes stuff gets broken as they commit experimental changes.
#Any updates sometimes overwrite rootfs customizations; the higher the channel - the more frequent the updates occur.
#Some of the stuff that gets updated, may later get reverted.
And so on...
fattire said:
I hadn't realized the boot was still in flux-- I'd have figured they'd worked that out by now...
Click to expand...
Click to collapse
Yeah you'd think so. Honestly, the more I use CrOS the more it seems like a (very polished) work-in-progress to me. Though, I guess most modern OSs are also works-in-progress though. (I don't mean the former statement in a critical way; I'm very happy that new features keep getting added to the OS - Android app support being a perfect case in point, that was a lovely surprise, greatly extending the functionality of my Chromebook).
fattire said:
Cool-- adb connect 100.115.92.2 does indeed work I was gonna use netcat to open port 5555 in chromeos and pipe it through, but looks like nc isn't here and I'm not yet ready to start changing the FS..though probably will be soon...
Click to expand...
Click to collapse
Netcat's not there but socat, which I haven't any experience with but have seen described as a "more advanced version of netcat", is listed in /etc/portage/make.profile/package.installable, meaning that adding it to CrOS is supported, and as simple as:
Code:
sudo su -
dev_install #(sets up portage in /usr/local)
emerge socat
I tried socat out and it seems to work, might be interesting to play around with.
fattire said:
btw any idea which partitions get overwritten when chrome it does it's updates? Will /root and /etc get overwritten, for example...
Click to expand...
Click to collapse
Theres a question. I forget some of the exact details now (gleaned from browsing the developer mailing lists and the documentation on chromium.org), but from what I do remember and my experiences tinkering, I can say:
The auto-update model uses kernel/rootfs pairs, e.g. at the moment my device is booting from partition 2 (KERN-A) with the rootfs being partition 3 (ROOTFS-B). My understanding is that with the next OS update pushed to my device, CrOS will download the deltas of the files to be changed, and apply the changes to partitions 4 and 5 (KERN-B and ROOTS-B), setting new kernel GPT flags (priority=, tries=, successful=), which will, post-reboot, let the BIOS know that 4 and 5 will form the new working kernel/rootfs pair. Then the following update will do the same, but with partitions 2 and 3, and so on and so forth, alternating pairs each time. It's a pretty nifty system, and I think something similar might be happening with new Android devices from version O onward (?).
So partitions 2,3,4,5 are fair game for being overwritten (from the perspective of the CrOS updater program). Partition 1, the 'stateful partition') is a bit special, in addition to a big old encrypted file containing all of the userdata (/home/chronos/ dir?), it also has some extra dirs which get overlaid on the rootfs at boot. If you have a look in /mnt/stateful/, there should also be a dir called 'dev_image', which (on a device in Dev mode) gets mounted up over /usr/local/ at boot. As I mentioned above, if you do
Code:
sudo su -
dev_install
you can then emerge anything listed in /etc/portage/make.profile/package.installable (not a great deal of stuff admittedly, compared to Gentoo), which gets installed to subdirs in /usr/local/. So I think stuff in partition 1; /mnt/stateful/, should be safe from being overwritten with an OS update. I think crouton chroots get put there by default.
Most of the other partitions don't really get used, and shouldn't get touched by the updater, here's a design doc on the disk format, and here's a Reddit post (from a Google/Chromium employee) mentioning dual booting from partitions 6 and 7.
fattire said:
would a "powerwash" overwrite it or can you get easily get into an unbootable state on these things?
Click to expand...
Click to collapse
It's not too hard to mess up the system and get it into an unbootable state, lol. The "powerwash" just seems to remove user data, mainly. If you change up (the contents of) some files in /etc, or /opt, for example, then powerwash, normally they won't get restored to their original state (unless you also change release channel).
But, as long as the write-protect screw's not been removed and the original BIOS overwritten, it's always possible to make a recovery USB in Chrome's Recovery Utility on another device, and then restore the entire disk image fresh (this does overwrite all partitions). Another thing that I did was make a usb to boot into Kali; I was experimenting with the cgpt flags on my internal drive and got it into an unbootable state, but was still able to boot into Kali with Ctrl+U, and restore the flags manually from there. (To successfully boot from USB, it was essential to have previously run the enable_dev_usb_boot or crossystem dev_boot_usb=1 command in CrOS). I understand also that the BIOS type varies with device release date and CPU architecture, and that Intel devices may have some extra potential BIOS options ('legacy boot').
fattire said:
It's also kind of strange that adb is listening to port 30 at that (internal?) bridge address by default with no UI to turn it off.. and it's inaccessible from outside.. i wonder if there's an easy way to change the bridge to share the same IP as the actual interface...
Click to expand...
Click to collapse
I think I saw something related to this on the bug tracker. If I come across any info, I'll let you know...
fattire said:
Final thought-- I'd love to build that system image myself soup-to-nuts, but I can't find any "caroline" device tree set up... do you or anyone else happen to know if there's a standalone AOSP device tree for the chromebooks? It would be cool to have a mashup AOSP/lineageos if such a think could be possible-- I'm guessing chromiumos is just taking the android tree, building it and then adding it into their build... I Haven't build chromiumos for many years now so I can't even begin to imagine how this android build integrates with the whole emerge thing they had going.. but I bet it takes a while
Click to expand...
Click to collapse
Yeah, I haven't built Chromium OS or anything, but apparently, there's an option to create a 'private' overlay for the build, which doesn't get synced with the public stuff.
I think that the higher-ups at Google might be still umming and ahing as to whether or not to make source code available for the Android container, it's certainly not been made public yet. Actually, I remember seeing a Reddit post from a Google/Chromium employee mentioning this.
"That article is a little misleading in terms of open source. While the wayland-server and services that communicate with the ARC++ container are open source, the actual ARC++ container is not."
Perhaps they're waiting to see how similar implementations of Android within a larger Linux setup (e.g. Anbox) fare.
There doesn't seem to be too much that differs from AOSP in the ARC++ container - a few binaries and bits and pieces linking the hardware to the container (e.g. the camera etc), maybe some stuff related to running in a container with the graphics being piped out to Wayland?, and so on.
Oh, I was searching the bug tracker for something else, and just saw this (quoted below). Looks like it might be possible to run AOSP based images on CrOS soon!
arc: Implement android settings link for AOSP image
Reported by [email protected], Today (72 minutes ago)
Status: Started
Pri: 1
Type: Bug
M-60
When ARC started without the Play Store support there is no way for user to activate Android settings. We need implement corresponded section that has
Title: Android settings:
Link: Manage android preferences:
Inner bug: b/62945384
Click to expand...
Click to collapse
Great response! I read it once and I'll read it again in more detail then will probably have questions For whatever it may be worth, my only experience with chromiumos was building the whole thing maybe 4 years ago for my original 2011 Samsung "snow" Chromebook-- and making a bootable USB (or was it an SDcard?) to run it on (with a modified firmware that did... something I can't remember.. i think it was basically a stripped down uboot and I remember adding a simple menu or something-- I think I was trying to bypass that white startupscreen or something..). However, after doing this a few times to play with it, I realized that Chromiumos without the Chrome goodies kinda sucks and I promptly forgot everything and went back to stock.
I did have it re-partitioned to run linux as a dual boot from the SD slot or something-- I remember using that cgpt thing to select the different boot modes and vaguely recall the way it would A/B the updates (which "O" is now doing)... but anyhoo I was using the armhf ubuntu releases with the native kernel and ran into all kinds of sound issues and framebuffer only was a little crappy so...
I'm gonna re-read in more detail soon and I'm sure I'll have questions-- one of which will be-- assuming that most stuff is the same on x86 vs arm, why are there two scripts? How do they differ?
ol. On my device the Canary channel is at Chrome OS version 61; I think they started to move out some ARC++ (the acronym stands for Android Runtime on Chrome, version 2, if anyone's wondering, btw) environment variables to a separate file in version 60, or maybe 61.
Click to expand...
Click to collapse
This is the -env file I'm missing, I presume?
I think that the higher-ups at Google might be still umming and ahing as to whether or not to make source code available for the Android container, it's certainly not been made public yet. Actually, I remember seeing a Reddit post from a Google/Chromium employee mentioning this.
Click to expand...
Click to collapse
It looks from the response that the gapps portion might be what's in question-- just like ChromiumOS vs Chrome has all the proprietary bits taken out?
Here's what I'd ideally like to see:
* Rooted Android, with a toggle switch to hide su in settings a la lineage (requires a kernel patch something like this one) + settings changes from lineageos
* adb access from outside the device-- critical for quickly testing apks from android studio w/o a cable. Basically put the chromebook in a "device mode" where adb is passed through... I'm going to see if I can pipe adb through with socat as you suggest...
* what else... I dunno watch this space.
An update from a couple of guys that have tested out the scripts on Intel: It seems to be that while they are able to launch daemonsu manually (with daemonsu --auto-daemon), it apparently does not seem to be getting launched at boot.
I am waiting for some more information on this. Previously, for Marshmallow, the script was setting up the app_process hijack method in order to to launch daemonsu at boot; to support Nougat I changed it to instead create an .rc file with a service for daemonsu, and add a line to init.rc importing it. This works for me, and from what I can gather, it copied/created all files successfully on the testers devices, too, so I'm not sure at this point what the issue is there.
Edit: Fixed the issue. I updated my previous post with further details.
fattire said:
I realized that Chromiumos without the Chrome goodies kinda sucks and I promptly forgot everything and went back to stock.
Click to expand...
Click to collapse
lol yeah. True, that.
fattire said:
...assuming that most stuff is the same on x86 vs arm, why are there two scripts? How do they differ?
Click to expand...
Click to collapse
It's literally just two things that differ: the few lines where we copy the su binary over e.g.
/x86/su.pie → /system/xbin/su, daemonsu, sugote
vs
/armv7/su → /system/xbin/su, daemonsu, sugote
...and also the size of the created container. The x86 container is about 30 percent larger than the Arm one.
I had a little look at how to determine the CPU architecture programmatically on Chrome OS a while back, but couldn't seem to find a reliable way of doing this, at least not without maybe getting a bunch of people with different CrOS devices to run something like, as you mentioned, uname -i (which returns 'Rockchip' on my device, uname -m (which returns 'armv7'), or such similar, and collating the results. It was just easier to do separate versions for x86/arm, rather than introduce more conditionals (with potential for errors). I'm certainly not averse to adding a check for $ARCH, and thus standardizing the script, as long as it's reliable.
fattire said:
This is the -env file I'm missing, I presume?
Click to expand...
Click to collapse
Yep! It's just the same few envs as in the .confs, moved into a new file. I'm fairly confident that the script's conditionals deals with them OK.
fattire said:
It looks from the response that the gapps portion might be what's in question-- just like ChromiumOS vs Chrome has all the proprietary bits taken out?
Click to expand...
Click to collapse
Yeah, although the respondant there perhaps doesn't seem to realise that he's talking to a Google/Chromium dev, the way he responds. Not that that makes anything he says in his post is necessarily less valid, though.
fattire said:
Here's what I'd ideally like to see:
* Rooted Android, with a toggle switch to hide su in settings a la lineage (requires a kernel patch something like this one) + settings changes from lineageos
* adb access from outside the device-- critical for quickly testing apks from android studio w/o a cable. Basically put the chromebook in a "device mode" where adb is passed through... I'm going to see if I can pipe adb through with socat as you suggest...
Click to expand...
Click to collapse
Interesting... I agree, those would both be useful additions to the functionality of ARC++...
Quick question-- has Samsung provided the source for the GPL components (including the kernel, obviously)? I looked here but didn't see anything...? Previously the kernel was included along with the chromium source and there was like a kernel and kernel-next repository.. but this was like five years ago. I think the codename for the samsung chromebook pro is called caroline... let me quickly see if I can find a defconfig in the chromium source...
Back.. nothing here in the chromeos-4.4 branch. Nothing here either in the master branch. Maybe I'm looking in the wrong branches-- master is probably mainline kernel. Also the directories.. it took me five minutes to realize it wasn't going to be in arch/arm - force of habit I guess. I'll keep looking unless anyone knows. This "chromium-container-vm-x86" one seems to have dm_verity as an unused option. Ah, this is looking promising.
...and... here!
So it would seem that this would be built as part of the chromiumos build system, which seemed to be half gentoo five years ago building out of a chroot and was kind of a pain to set up... still, I'm guessing that since it's got that weird script to make the defconfig, what you could do is use google's chromiumos build script to make the kernel image (with whatever changes you want), then, assuming that it doesn't care if you replace the kernel, just throw it over the right Kernel A/B partition and see if it boots and starts up chromeos... it's weird cuz the kernel has to do double-duty for chromeos and android.. but I bet you can just replace it and it would work fine...
I had a cursory go at building a couple of kernel modules for my Flip C100 a while back - I didn't get too far though, lol. People do seem to have had success building their own kernels and running them with Chrome OS though, as with most things I suppose it's just how much time/effort you're willing to put in.
I think I used this and maybe this, from the crouton project to guide me.
From what I remember, I just got fed up of all the arcane errors/config choices. I remember that even though I'd imported my current device config from modprobe configs, there were then such an incredibly long string of hoops/config choices to have to go through one by one, to then be confronted with various errors (different every time ISTR) that I think I just thought "screw this". I think there were some other issue with the Ubuntu version I was using at the time as well. I know that sort of stuff's kind of par for the course with kernel compilation, but I was mainly only doing it so I could edit xpad in order to get my joypad working, in the end I found a different solution.
It shouldn't be too much hassle though, in theory I guess.... Oh, also, in order to get a freshly built kernel booting up with the CrOS rootfs, in addition to the gpt flags, I think you might have to sign it, too? (just with the devkeys & vbutil_kernel tool provided on the rootfs), some info here, and here.
From what I remember, the build system would do whatever key signing was necessary.... although I do now remember you're right there was some manual step when I was building the kernel, but I can't remember if that's because of MY changes or that was just part of the build process.
I I just dug out the old VM (Xubuntu) I was using to build and, well, let's just say I'll be doing a LOT of ubuntu updates before I can even realistically look at this. I do kinda recall setting up the environment was a huge pain so I'm going to see if I can just update the 5 year old source, target the pro and just build the kernel image and see what pops out the other end. At least I won't have to deal with the cross compiler, though I think it should hopefully take care of that itself.
Interesting to see that those crouton projects have emerged (no pun intended) so I'll check them out too while ubuntu updates itself
Thanks for the github links.. I'm going to go read that wiki.
Update: Looked at it-- funny they just stripped out the chromeos-specific parts they needed rather than emerge everything which is smart. My only question is now that Android is involved, there's that script I linked to earlier that seems to say "if you want Android support you'll need these bits too"-- wonder if the same config scripts apply, and if there are any other device tree considerations as well...
I may play a bit and see how smoothly it goes.. Unfortunately I don't have unlimited time either :/
Also, please do let me know if you put the scripts on github and I can send you pull requests if I come up with anything.
Update: Finally updated like 3 major versions of ubuntu... the "depot_tools" repo had its last commit in 2013, so I updated that. Wow, this is so much clearer than previous docs... it looks like something called gclient is used now, which I configured with:
gclient config --spec 'solutions = [
{
"url": "https://chromium.googlesource.com/chromium/src.git",
"managed": False,
"name": "src",
"deps_file": ".DEPS.git",
"custom_deps": {},
},
]
'
that let me do gclient sync --nohooks --no-history ...which i think is updating the ancient source. I probably should have just started over, but anyway... we'll see what happens.
Update again: After updating with this new gclinet tool, it appears that the old repo sync method is still required as described here. That hasn't changed after all, so now I'm going to go through this old method, which will probably completely overwhelm my storage as it's downloading with history.. but anyway, in case anyone is trying this-- looks like the whole chroot/repo sync thing may still be how it's done... the /src directory described above may only be for building just the browser, not the whole OS...
...and here it is. I will have zero room to actually build anything tho, but hey.
* [new branch] release-R58-9334.B-caroline-chromeos-3.18 -> cros/release-R58-9334.B-caroline-chromeos-3.18
Note to self: use cros_sdk --enter to actually get in the chroot. Then:
~/trunk/src/scripts $ ./setup_board --board=caroline
to set up the build for caroline. Then to build:
./build_packages --board=caroline --nowithdebug
Useful links:
* Building ChromiumOS
* [URL="http://www.chromium.org/chromium-os/how-tos-and-troubleshooting/portage-build-faq"]eBuild FAQ
[/URL]

Who wants to help finish proprietary vendor blobs?

"Blobs" are the files specific to each device that we need in order to compile custom ROMS that work on our device. The process of finding them is tedious and slow... I have been picking away at them for months when I have time. There are over 600 files so far! But there are also references to files that are not being found. They are either missing, or they are not located where they are expected to be located. This is where I need help.
So, if you want to help, go HERE:
https://github.com/mightysween/android_vendor_motorola_payton
and look through the proprietary-files.txt file for anywhere that it says "warning".... and then search inside of the firmware (working on 8.0+ now, not 7.1 please) and try to track down the file that it says is missing [obviously, you will need a system dump, or to search on a rooted device]. If you find it, please post below like this:
LINE NUMBER OF THE WARNING (from github)
PATH TO THE MISSING FILE (relative to /system... in other words, don't inlude your own local path)
Once this file is complete, we can use it to automatically pull the correct vendor files into our build environments... having a working recovery, active kernel developement and completed vendor blobs should open us up to more development efforts.
Also, if anyone has done any testing and knows of other proproetary files that are needed, please post them here so I can include them.
My time at the computer to work on this is really limited, so I have only identified a dozen or so daemons that definitely call for proprietary libs... I am sure there are more
I would love to pitch in on this but have zero experience with anything related to development. Do you think I could still be of help? Sounds like a basic enough task that it wouldn't be too difficult. Let me check and see that I understand the process.
Went to github and looked at proprietary-files.txt. The first warning I found was in line 49: "blob file libpn553_fw.so missing or broken". Then searched for that file in my device's system folder using ES File Explorer with Root Explorer enabled.
So is this what you're looking for?
49
/system/vendor/firmware/libpn553_fw.so
---------- Post added at 14:31 ---------- Previous post was at 14:07 ----------
I'd like to contribute in some way but if this is best not left to a complete noob then I totally understand
mightysween said:
Also, if anyone has done any testing and knows of other proproetary files that are needed, please post them here so I can include them.
My time at the computer to work on this is really limited, so I have only identified a dozen or so daemons that definitely call for proprietary libs... I am sure there are more
Click to expand...
Click to collapse
Do you have a link to a system dump?
TheBassDude said:
I would love to pitch in on this but have zero experience with anything related to development. Do you think I could still be of help? Sounds like a basic enough task that it wouldn't be too difficult. Let me check and see that I understand the process.
Went to github and looked at proprietary-files.txt. The first warning I found was in line 49: "blob file libpn553_fw.so missing or broken". Then searched for that file in my device's system folder using ES File Explorer with Root Explorer enabled.
So is this what you're looking for?
49
/system/vendor/firmware/libpn553_fw.so
---------- Post added at 14:31 ---------- Previous post was at 14:07 ----------
I'd like to contribute in some way but if this is best not left to a complete noob then I totally understand
Click to expand...
Click to collapse
Thanks, that is all there is to it
Just time consuming (especially after the first 500)...lol
QWZR said:
Do you have a link to a system dump?
Click to expand...
Click to collapse
Nah, too big to conveniently upload... but if you are rooted, you can use the phone to search
mightysween said:
Nah, too big to conveniently upload... but if you are rooted, you can use the phone to search
Click to expand...
Click to collapse
Mine gets here next week
mightysween said:
Nah, too big to conveniently upload... but if you are rooted, you can use the phone to search
Click to expand...
Click to collapse
If you have root on the system you can find the files for, you should be able to find any given filename with:
find / -name "filename" -print
And it should output any filenames that match. I don't have time at the moment to dig into this any more, but would this resolve much of it?
ebrandsberg said:
If you have root on the system you can find the files for, you should be able to find any given filename with:
find / -name "filename" -print
And it should output any filenames that match. I don't have time at the moment to dig into this any more, but would this resolve much of it?
Click to expand...
Click to collapse
Any way that works is fine by me
I am on the road a lot and just don't have enough time to sit and work on it... so it is taking months. I bet a few people helping could finish it in a matter of hours.
I am hoping to have a few hours next week to work on it. But the sooner this is done, the sooner I can shift to trying to compile Lineage OS with working hardware.
BTW, Lineage *does* compile if I comment out all the stuff causing make errors... not much works, obviously.
The next step will be compiling with these blobs, then logging all the new errors and chasing down all the additional broken symlinks... and then adapting the kernel as needed.
Then, MAYBE we can get a base Lineage tree up and open up the X4 to building for other roms. I know someone started a skeleton tree for Carbon already on Github... they are likely just waiting for the completed device tree, too.
mightysween said:
Thanks, that is all there is to it
Just time consuming (especially after the first 500)...lol
Click to expand...
Click to collapse
ebrandsberg said:
If you have root on the system you can find the files for, you should be able to find any given filename with:
find / -name "filename" -print
And it should output any filenames that match. I don't have time at the moment to dig into this any more, but would this resolve much of it?
Click to expand...
Click to collapse
I don't own this device yet, but I was thinking of getting one. I figured this might help you all out (you'll need to be running linux):
First, let's get a list of all the files on the phone, to make searching faster.
Code:
adb shell
su
find / > /sdcard/allfiles.txt
exit
exit
adb pull /sdcard/allfiles.txt
Now you should have allfiles.txt on your machine. Also grab the proprietary-files.txt, and then run this:
Code:
grep -Po '(?<=(blob file )).*(?= missing or broken)' proprietary-files.txt | xargs -I @ grep "@" allfiles.txt
That should find the paths of all the missing files (except the ones marked "wildcard")
BLuFeNiX said:
I don't own this device yet, but I was thinking of getting one. I figured this might help you all out (you'll need to be running linux):
First, let's get a list of all the files on the phone, to make searching faster.
Code:
adb shell
su
find / > /sdcard/allfiles.txt
exit
exit
adb pull /sdcard/allfiles.txt
Now you should have allfiles.txt on your machine. Also grab the proprietary-files.txt, and then run this:
Code:
grep -Po '(?<=(blob file )).*(?= missing or broken)' proprietary-files.txt | xargs -I @ grep "@" allfiles.txt
That should find the paths of all the missing files (except the ones marked "wildcard")
Click to expand...
Click to collapse
Thanks, I had recently completed this, but your code worked fantastic for double checking, and actually helped me find one that I had missed :good:
Now, on to identifying any more daemons that need proprietary files... and then assembling the tree itself... PROGRESS!
PHASE 1 is complete!
https://github.com/mightysween/android_vendor_motorola_payton
I am 99% sure that this is only ~75% of what will be needed to actually build LOS15. But it is a good foundation to work off of now.
My plan is to start attempting to compile LOS and take error logs to chase down the remaning missing stuff. LOTS to be done still to get to that point...hoping for some other builders/devs to materialize here and help out
Hi! Just a question: it´s mandatory to use A/B partition scheme to build a custom ROM for this device or it will be possible to use a traditional partition scheme and free up some GBs of internal storage for use?
christianrj said:
Hi! Just a question: it´s mandatory to use A/B partition scheme to build a custom ROM for this device or it will be possible to use a traditional partition scheme and free up some GBs of internal storage for use?
Click to expand...
Click to collapse
It would seem that we will still be stuck with A/B, as the bootloader does the initial check of the active slot. Perhaps there may be some clever ways around this in the future...but nothing I will be tackling.
mightysween said:
It would seem that we will still be stuck with A/B, as the bootloader does the initial check of the active slot. Perhaps there may be some clever ways around this in the future...but nothing I will be tackling.
Click to expand...
Click to collapse
You would probably need a custom kernel to do it properly. The bootloader passes a kernel param (androidboot.ro.boot.slot_suffix) specifying which slot to use. In the absense of a kernel param, the value is read from the ro.boot.slot_suffix build property.
That being said, you might be able to just repartition your device to only have 1 slot, flash your ROM, and use
Code:
fastboot --set-active=_a
. If your ROM has disabled OTA updates from the OEM, you should be fine.
I'm going to get an X4 in the coming weeks. I'd like to help with this soon. I'm a seasoned developer by trade and can collab on GitHub. Hope to be able to start working with you soon. :good:
I don't know if any of you have seen this article, but it seems promising that it might not be too difficult to achieve for this device:
https://www.xda-developers.com/xiaomi-redmi-note-4-project-treble/
Hariiiii said:
I don't know if any of you have seen this article, but it seems promising that it might not be too difficult to achieve for this device:
https://www.xda-developers.com/xiaomi-redmi-note-4-project-treble/
Click to expand...
Click to collapse
@vache at the Moto G5 Plus forums has already managed it using the /oem partition which is otherwise unused for custom ROMs
Hariiiii said:
I don't know if any of you have seen this article, but it seems promising that it might not be too difficult to achieve for this device:
https://www.xda-developers.com/xiaomi-redmi-note-4-project-treble/
Click to expand...
Click to collapse
Cool... seems it may be possible. Will follow the progress on the Redmi and G5 devices
navenedrob said:
I'm going to get an X4 in the coming weeks. I'd like to help with this soon. I'm a seasoned developer by trade and can collab on GitHub. Hope to be able to start working with you soon. :good:
Click to expand...
Click to collapse
The more I am reading about enabling Treble, the more I think it is entirely possible.... and probably the best direction to focus our efforts.
Seems like we have partitions that could be used as /vendor. I am reading up on exactly how the Treble vendor partition is set up. Tricky, but not implausible.
EDIT: Actually, none of the partitions we could potentially re-purpose for /vendor are big enough. So, it may be harder on this device than on others. It may require repartitioning.

Exchange platform-signature in custom ROM

Hi there -
short prologue: I am working on my bachelor thesis and must develop a service that keeps a record of how often a user actively uses the application permission settings of Android 6 and above. The main goal is to have a custom ROM which can be deployed on several phones to conduct a survey.
I identified the file where these settings are stored:
Code:
/system/users/0/runtime-permissions.xml
I want to set up a service running a FileObserver to keep track of the changes in this file. The file is not accessible by normal applications (permission -rw-------) but the service has to run without superuser.
So I want to sign my application with the platform key to obtain system permissions. I am totally clear on the purpose of this security concept and I know that I cannot get the original key. The resulting ROM is not going to be public and is used only in a controlled group for research purposes.
My question is how to exchange the signature/key with what the system applications of my actual ROM are signed. So that I sign my own apk with the same key so it has the special permission. I found the answer to this exact question on stackoverflow but it is quite old and I did not succeed with this explanation.
Do you know if there is another, more current approach?
Thanks in advance!
Device is a Xiaomi Redmi 4X running stock MIUI 9 (Android 7.1.2)
Just have the app built as part of the rom. This will make sure they both have the same signature.
zelendel said:
Just have the app built as part of the rom. This will make sure they both have the same signature.
Click to expand...
Click to collapse
What do you mean by "built as part of the rom"? I cannot build the rom from aosp because the device should run the original MIUI firmware. I used SuperR's Kitchen to modify the rom. Is this not suitable?
That will not work no. Maybe you could try using their patch rom setup. As very little is done with miui here, you mugjt be better off asking in n their forums.
zelendel said:
That will not work no. Maybe you could try using their patch rom setup. As very little is done with miui here, you mugjt be better off asking in n their forums.
Click to expand...
Click to collapse
Can you explain, why this wont work? I supposed I just have to exchange all the signed apk files. When I re-sign them with apksigner then they also obtain the self-signed certificate containing the public key. So why is this not enough? Is there another instance in the OS which checks the app signature on boot?
The entire system partition uses the same signature. So I guess you could go through and recompile everything with the new key but I doubt it would work. Many oem system apps won't work without their oem signature.
Like I said. You maybe better off asking over in the miui forums as very little is done here for it.

What is a PSCI repartition?

.
Hi forum!
So I own a Project Tango Development Kit Tablet (device name: Yellowstone) which appears to be a Tango-purposed Nvidia Shield K1 tablet. There's just a few threads about the yellowstone in the Shield forum and it's an old device now, that's why I'm posting the question here, in the hopes that the question is not device-related but something more general.
So, I wanted to use this tablet and the stock ROM just made it bootloop ad infinitum. Nothing I did could make it boot. So I went to the Shield forum and I found a TWRP image that would work on it. I rooted it, installed TWRP and I installed a ROM that I found around an old thread. So far so good, the tablet now boots but the audio, microphone and camera doesn't work. I want to use it as an intercom system so, that's the stuff I really want it to be in a working state.
By chance I found a LineageOS 16 ROM for the yellowstone (https://updater.oddsolutions.us/yellowstone) but it's description says "PSCI Repartition ONLY". The author hasn't replied to me to what it means. Googling doesn't give useful results regrettably. So I wonder if anyone around this parts could enlighten me about what is it, and how can it be performed?
Many thanks!
REPARTITION ONLY:
I guess it means that /system and /vendor partitions must get re-partitioned ( increasing their sizes ) what must be done before flashing the ROM.
This usually is done by a "Repartition Pack".
PSCI:
The Power State Coordination Interface (PSCI) is an ARM standard introduced for its new ARMv8 64bit architecture to virtualize CPU power management across exception levels i.e. between software working at different privilege levels: OS kernel, hypervisor and Secure Platform Firmware (SPF).
jwoegerbauer said:
REPARTITION ONLY:
I guess it means that /system and /vendor partitions must get re-partitioned ( increasing their sizes ) what must be done before flashing the ROM.
This usually is done by a "Repartition Pack".
PSCI:
The Power State Coordination Interface (PSCI) is an ARM standard introduced for its new ARMv8 64bit architecture to virtualize CPU power management across exception levels i.e. between software working at different privilege levels: OS kernel, hypervisor and Secure Platform Firmware (SPF).
Click to expand...
Click to collapse
Ahaaa, that's excellent information. I guess they're separated concepts then, not directly related. I'll have to contact the owner then for the repartition pack. Many thanks!
Darius_bd said:
Ahaaa, that's excellent information. I guess they're separated concepts then, not directly related. I'll have to contact the owner then for the repartition pack. Many thanks!
Click to expand...
Click to collapse
Did you ever get a response from npjohnson? I've been folliwing his roms for tango for about a year (if not longer) he did say he was aiming to bring it as an official lineage build......but while i see it's been in development. Nothings been released.
So i am interested to know if you got a response.
Darius_bd said:
Ahaaa, that's excellent information. I guess they're separated concepts then, not directly related. I'll have to contact the owner then for the repartition pack. Many thanks!
Click to expand...
Click to collapse
I also am interested in whether or not you found the PSCI for Android 9. I have a Tango I am wanting to put to use.

Categories

Resources