[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Back to recovery. I guess the problem with installing in recovery is that there is no /sbin/sh… The update-binary in the zip file is a shell script…

Just checked, on my Lollipop tablet I don’t have a /sbin/sh either

OK. I only have twrp. There is busybox installed. So, without /sbin/sh, how is recovery supposed to run a shell script?

If according to your post there is busybox, it is possible it is used - because busybox contains a sh applet. Was a “not” missing in your post ?

Probably it was a bit too dense. On my S3mini with twrp installed, there is busybox. Not in FP2’s recovery

#### make completed successfully (01:04:40 (hh:mm:ss)) ####

Here is my feedback, hopefully it well help some people.

  • Have an SSD with lots of space ready (~75 Gb for the full build with the repro checked out.)
  • repo init with http works, no ssh needed for just having a look around (good, a ‘developer only’ corner in the forum is odd enough)
  • Use gcc-4.8 (or 4.6) newer gcc’s will give you trouble with webkit and gcc is not loved anymore by the Android-SoC people anyway. I think there will be/is a switch to LLVM underway. Read about it. It comes with interesting implications licenses-wise. If you have issues on a Debian based system, try using update-alternatives to change the gcc-version.
  • The FairphoneUpdater is under the Apache License 2 (I had this discussion with someone, so I looked it up).

Here are the files I got in the end, not sure if this really helps

$ sha256sum *.img
43983a57804b235ea50c2ce1401394dec1fc94664695acec887b0c585e8a2f53  boot.img
0f1efa291c13b35e5b1fe2d95196bb45fa781213c76bc95a0fce739b4c50f5bc  cache.img
34e5437a02bb2113437dbee43f94f79f263bd90e17c82e6b14b5ae466eadb964  dt.img
3951c0240c0618b07557fb1f6776141dd85caf1f666c605b1bd724acd90ff150  persist.img
c60ff2990ecc2bef16f7bb79737aafe149128ce7c87033503aa99e914f66cc8f  ramdisk.img
a13b5bc41c9aba0b5e825b4cfd04bd7b4580ca6325b0412993a562c15d416368  ramdisk-recovery.img
2ee6a816424c041db44a3c5cb6ba76d3715171864caee47e07ee1f4be7639ef7  recovery.img
f677a06184aa290296c67f0766d6b19b5df66ab71fffd31e7b7ab261ec915ff9  splash.img
a6d699917777bd29099425110f046b0b3fc33221244ad9d2c561cd77aa251453  system.img
9cc1cb81cdc5562d7c21c5929299cee21d879748cd8c6537a8555631f71b7c9e  userdata.img

If you build on a Debian based system like Ubuntu … while you wait … read about Ian Murdock. Not sure what kind of person he really was, but he had pretty good ideas for setting up communities in the beginning of Debian. Maybe some of his ideas are also helpful for phones, who knows?

Judging from th official image, there are more files missing:

cp vendor/qcom/proprietary/target/product/FP2/obj/lib/{libart.so,libloc_ds_api.so,libmdmdetect.so,libOmxVdecHevc.so,libOmxVdec.so,libwpa_client.so} vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/

also, they all have a different checksum in the images.

@lklaus: maybe you can give it a try?

Btw. links to the images can be found in here: http://ota.fairphone.com/FP2/updater.zip (as found in packages/apps/FairphoneUpdater/{README.md,res/values/config.xml} and you can mount them on Linux using https://github.com/xpirt/sdat2img and it should be possible to flash them using fastboot as well.

2 Likes

Thanks for your tips and for finding the misssing libs !

I’ve extracted the update but sadly simg2img doesn’t seem to be able to read the outputted system.img :confused:

$ simg2img system.img system.img.raw
Invalid sparse file format at header magi
Failed to read sparse file

EDIT : Nvm I just mounted it directly and it worked. Great.

For reference:
python3 sdat2img.py system.transfer.list system.new.dat system.raw sudo mount -o loop system.raw /mnt

Hi,
right now I’m out of compiling the ROM … I decided that, as my original plan was, cherry picking of features right now is way too time consuming for me. As I need the Google framework, I’m not that pressed to have the alternate ROM.
Waiting for the official root.
I’m still looking into TWRP, though. But as work has begun for me, time is precious :wink:

Sorry

No problem, thanks for beta testing it :slight_smile: I’m waiting to have a full stock rom with stock recovery.img etc… before fiddling with my phone, then I’ll give it a try (I got a few builds ready to be tried out !)

Does anyone know if Qualcomm provides some flashing software that would allow to recover from a hard bricked phone such as SP Flash Tool for Mediatek devices and NVFlash for Nvidia ones ?

Same over here,

Work began. I will give compiling a try tonight, including the files Jochen suggested. If anyone wants to try flashing, volunteers forward! I don’t have my phone, yet.

On the other hand, I think we have given the Fairphone programmers quite some home…eeeh businesswork to do to correct the published self-compiling version of the OS. :wink:

I was about to post a link to my build of AOSP with @jochensp’s modifications for those who feel like trying it without having the means to build it (building from source is a 14GB+ download plus a RAM/CPU heavy, time consuming process after all) but the FP2 BInary Blobs’ license agreement probably forbids me to do so (well, it basically forbids you to do anything with the blobs anyway but I am mostly concerned about sharing stuff derived from them) :

  • The rights are non-sublicenseable and non-transferable
  • I am also not allowed to remove portions of the Software, alter or otherwise modify it, or translate, reproduce, copy, reverse engineer, reverse compile, disassemble or transfer the Software.

I’d like to have @anon90052001’s or someone from Fairphone’s consent before publishing WIP AOSP builds for the FP2.

Happy new year everyone… Great to see so much action here already!

Some remarks, which I hope help you all getting started.

First, our binary blob package indeed is missing the libart*.so libraries in the system/lib directory. The workaround posted by @jochensp should get you going. We will publish an updated blob package soon. So until we have put this online copy libart.so and libart-compiler.so to out/target/product/FP2/system/lib/. After running source build/envsetup.sh is a good moment to do that.

Further, it is important that you source build/envsetup.sh every time the output directory got cleaned. Otherwise the blob’s vendorsetup.sh doesn’t have opportunity to place the blobs in the in right directory.

About the typo in FP2_USE_PREBUILT_LIBART_COMPILTER. It is indeed a typo :blush:
but luckily I made the same typo twice, so it is a “functional” typo. :sweat:

I hope that helps for the start.

5 Likes

Now that’s a funny bug :smiley: thanks for your update
Do you know if it is officially OK to provide our builds publicly ?

1 Like

Soo I went ahead and flashed everything on the phone without waiting for custom recoveries (because why the hell not ?). I flashed the version I was talking about in my antepenultimate post, and so far everything seems to be working quite well (apart… you know… from the obvious lack of apps).

  • Wifi OK
  • Bluetooth OK
  • Camera OK
  • SMS OK
  • Keyboard still can’t do gesture typing OK
  • Ugly “no sim card” icon OK
  • Only red led notifications OK
  • Fairphone apps work well (FairphoneLauncher3, PrivacyIndex, Updater)

Terminal emulator says I don’t have a SU binary. adb root works though, and I can adb shell su which shows a root shell prompt but no command works (it just hangs). Can’t wait to share :slight_smile:

Btw does anyone know if it is possible to erase userdata and cache from fastboot without having to flash them (I guess it’s with the -w option) ? I don’t want to have to share userdata.img and cache.img but I had to flash them in order for the phone to boot correctly.

1 Like

Ok,

I have done:
Deleting all files in ~/fairphone_os/out/target/product/FP2
(Not anything in it’s subfolders!)

then:

cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libart.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libloc_ds_api.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libmdmdetect.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libOmxVdecHevc.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libOmxVdec.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libwpa_client.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
cp vendor/qcom/proprietary/target/product/FP2/obj/lib/libart-compiler.so ./vendor/qcom/proprietary/target/product/FP2/system/vendor/lib/
source build/envsetup.sh
make -j8

It now gave me a system.img of 430.2 MB.

Klaus, if you should find some minutes to give it a last try, you have the link to the file. :wink:

Just a tip, jochensp’s command line works directly in a shell, no need to copy-paste it every time modifying the lib !

My working version with all these libs included weighs 431MB, don’t you want to try flashing yours (provided the build actually showed it succeeded) ? :slight_smile:

I don’t have a Fairphone, yet, so I can’t flash it myself! :frowning:

My order number is somewhere in the 11.000’s. Jochen’s command did not work, somehow. So I split it up to see where the error is. Like this, there wasn’t any.

Did you run a repository sync today? I did not, maybe this explains the difference in file size. And: I didn’t delete the subfolders, resulting in a complilation being ready after like 5 minutes.

I am still interested in the official one but if you get the ok of FP for sharing I would be very interested in trying out as well :smile: since my compilation did not succeed as written earlier…
To have (working) root would be nice of course but maybe this could be added later.

Just for clarification: If you take out your userdata.img and cache.img what would be needed to be put in its place - something I could back-up from my phone already?

In any case, great thanks to all of you having (tried to) compile(d) the sources into a (more or less) working build!