Project

General

Profile

Replicant 6.0 for the Samsung Galaxy S3

Added by Wolfgang Wiedmeyer almost 9 years ago

This post contains outdated information and links to outdated images. See the wiki and blog for development updates, up-to-date documentation and current images!
See the archived post for documentation about my initial work and findings
See this post for the Galaxy S2

Changelog of the latest version (replicant-6.0-beta-0001 from 27.1.17)

  • Added support for external WiFi dongles that use the AR9271 chipset
    Makes it possible to use WiFi with only free software as free firmware exists for the chip
  • January security updates for the kernel

Changelog of the sixth alpha release (replicant-6.0-alpha-0006 from 6.1.17)

Only the most relevant changes are listed.

  • Fixed sending of longer SMS messages
  • Fixed entering the SIM lock PIN
    Previously, if the PIN was entered incorrectly once, every subsequent try failed, even if the PIN was correct.
  • Fixed network operator recognition in countries that have MNC codes with three digits (e.g. U.S., Canada, India)
  • Removed the nonfree unrar tool
  • Synced the source code with the latest changes from CyanogenMod, including security fixes from December 2016 and performance improvements for the Galaxy S3
  • Made it possible to update the F-Droid app itself
  • Added the F-Droid privileged extension
    This makes automatic background updates of apps possible (needs to be enabled in the settings).
  • Fixed camera app freezes by restarting the camera and redoing the snapshot if the shutter button is pressed a second time
  • Made barcode scanning (including QR codes) work
    See Tips section below
  • Reduced the camera preview resolution to speed up the preview a little bit
  • Moved the build system from Debian Jessie to Debian Stretch and fixed various build errors
    This allows to use the manifest merger tool and the Eclipse Java compiler from Debian.
  • Added the possibility to enable llvmpipe as software renderer by making it buildable for ARM
    See the Tips section below
  • Applied various performance improvements and fixes for graphics rendering, mostly from the Android-x86 project
  • Ported various security/privacy enhancements from the CopperheadOS project
    This includes the possibility to set an encryption password that is different from the lock screen pin/password.
    The phone will reboot if the PIN was entered incorrectly more than four times.
    Some privacy enhancements for the browser
  • Added a new wallpaper to the Replicant wallpapers

Tips

Enabling llvmpipe as software renderer

llvmpipe has more complete EGL support than the Android software renderer, so more apps work with it, like Firefox-based browser or more recent webviews. Unfortunately, llvmpipe is still too slow to be the default renderer, but I made it possible to switch back and forth between llvmpipe and the Android software renderer. ADB and root over ADB needs to be enabled in the developer settings.

The following commands are necessary to enable llvmpipe:

adb root
adb remount
adb shell "grep -q "ro.libagl=1" /system/build.prop && sed "s/ro.libagl=1/ro.libagl=0/" -i /system/build.prop || sed "s/ro.libagl=0/ro.libagl=1/" -i /system/build.prop" 

If you want to go back to the Android sofware renderer, you will need to run the above commands again. A reboot is always necessary for the changes to be applied.

Barcode scanning

The mostly used barcode scanner app ZXing has a pretty slow preview. This barcode scanner app from F-Droid has a much faster preview.

Using an external wifi dongle

See this post.

Known issues

  • Some SIM cards are not recognized.
  • The camera "locks" sometimes or the error "Can't connect to camera" is displayed.
    Logs might help debugging this, at least the issue with the error message.
    Recent versions have a fix which allows to take a picture if the camera app seems to be unresponsive and you press the shutter button a second time.
  • The camera preview is slow
    See this mail for more info.
  • Only the Galaxy S2 and S3 are supported.
    If you want to help getting other Replicant devices supported: Add the missing device repositories and try to merge the changes from CyanogenMod. If the device is not supported on the CyanogenMod 13.0 branch, you will have to look at forks that took up the development. Merging with an older branch could also be sufficient to get basic functionality working.
  • Newer webviews can't be used because they don't work with the software rendering
    Webview version 43.0.2357.134 is currently in use. It was released in July 2015. This can be fixed by making llvmpipe fast enough so it can be used as the default software renderer. Currently, the Android software renderer is the default.
  • There are still prebuilt binaries in the source tree
    I got rid of a lot of prebuilt binaries to make the build more trustworthy and to ensure that all tools are properly built from source with free software, but there are still a few left. The gcc-arm-linux-androideabi toolchain needs to be bootstrapped with proper 1st and 2nd stage compilers so it doesn't rely on the sysroot from the NDK. In general, there are still some prebuilt binaries from the NDK, SDK and other places in use, but nearly all of them shouldn't run on the host, but only on the Replicant device.

Build instructions

For now, only Debian Stretch is supported as build system. See this blog post on my personal blog for instructions on how to set up a Debian Stretch build environment in a chroot.

You need to install the following dependencies:

sudo apt-get build-dep gcc binutils llvm-defaults
sudo apt-get install gcc-arm-none-eabi cmake python-dev swig ant bc proguard maven-debian-helper libemma-java libasm4-java libguava-java libnb-platform18-java libnb-org-openide-util-java libandroidsdk-ddmlib-java libmaven-source-plugin-java libfreemarker-java libmaven-javadoc-plugin-java repo ca-cacert curl gawk libgmp3-dev libmpfr-dev libmpc-dev git-core gperf libncurses-dev squashfs-tools pngcrush zip zlib1g-dev lzma libc6-dev-i386 g++-multilib lib32z1-dev lib32readline-dev lib32ncurses5-dev zlib1g-dev:i386 xsltproc python-mako schedtool gradle dirmngr libandroidsdk-sdklib-java eclipse-jdt libgradle-android-plugin-java android-sdk-build-tools android-sdk-platform-23 aapt lzop

All my code is hosted at https://code.fossencdi.org. You can get the source code with the following commands:

repo init -u https://code.fossencdi.org/replicant_manifest.git -b replicant-6.0

If you want to contribute or if you simply want the latest and possibly unstable changes, you can also initialize with the development branch:

repo init -u https://code.fossencdi.org/replicant_manifest.git -b replicant-6.0-dev

Please note that the build might even be broken on this branch and there are no git tags on this branch which pin the source code to certain versions.

Then download the source code:

repo sync

The F-Droid binary is downloaded separately. The download script will check if the signature of the F-Droid binary comes from the F-Droid release signing key. You can retrieve the current signing key with the command gpg --recv-key 7A029E54DD5DCE7A. Run the download script to get F-Droid:

./vendor/replicant/get-prebuilts

Before you can build the ROM in the regular way, you need to run a build script that takes care of building the toolchain:

./vendor/replicant/build-toolchain

In order to prevent strange errors, I recommend running the script in a newly opened shell, in which you haven't already run one of the commands like . build/envsetup.sh, lunch or make that change the environment.

Then you can run the regular build commands to create a Replicant 6.0 zip and recovery:

. build/envsetup.sh
lunch replicant_i9300-userdebug
make -j $(nproc) bacon

I also added a script that signs your build, takes care of generating the necessary keys and puts everything in the out/dist directory. Using this script, it is possible to rely on your own keys and not on the test keys which are not recommended to use because the private test keys are publicly available. Building from source and flashing the default image that is signed with the test keys basically disables all the security measures in Android that are based on signing keys. The script also makes it possible to use password-encrypted private keys. The images below are signed with my keys using this script. You can run the script the following way:

./vendor/replicant/sign-build i9300

And finally you can flash the recovery in the download mode and sideload the zip in recovery mode:

heimdall flash --BOOT out/dist/recovery.img
adb sideload out/dist/replicant-6.0.zip

If you have already built Replicant at some point and now you are getting build errors: Run make clobber and retry in a newly opened shell.
If make fails, it may be necessary that run mka org.cyanogenmod.platform-res.

Compiled images (build date: 18.2.17):

  1. Download the following files:
    https://fossencdi.org/replicant/replicant-6.0-i9300.zip
    https://fossencdi.org/replicant/replicant-6.0-i9300.zip.asc
    https://fossencdi.org/replicant/recovery-i9300.img
    https://fossencdi.org/replicant/recovery-i9300.img.asc
    https://fossencdi.org/replicant/images-i9300.sha256
  2. Add my key to your GPG keyring
    You can retrieve it from the keyserver of your choice (gpg --recv-key 5816A24C10757FC4).
    Alternatively, you can download it from here: https://wiedmeyer.de/keys/ww.asc
    and import it with gpg --armor --import path/to/5816A24C10757FC4.asc
    The key should have the following fingerprint: 0F30 D1A0 2F73 F70A 6FEE 048E 5816 A24C 1075 7FC4
  3. Verify the signatures of the files:
    gpg --armor --verify path/to/replicant-6.0-i9300.zip.asc path/to/replicant-6.0-i9300.zip
    gpg --armor --verify path/to/recovery.img-i9300.asc path/to/recovery-i9300.img
    
  4. Check the checksums (in the folder with all the downloaded files):
     sha256sum -c images-i9300.sha256
    

Only install the images if all of these checks are successful!

You need to flash the new recovery first before you can flash the zip to your device. A full wipe is also necessary. Updating your ADB installation might help if you have problems with ADB.
See the wiki for more details.


Replies (135)

RE: Replicant 6.0, at least for the Samsung Galaxy S3 - Added by David Pizarro almost 8 years ago

Gumbor W wrote:

Again, please provide more information like the output from the script.

Thanks for the fast reply! The script says that everything is successful. It is just not working on my phone (WiFi is turning off again and the camera app is unable to connect to the front camera). My script output is attached to this message.

I completely forgot to mention: Great work! Great to see that this project is getting better and better.

UPDATE Now that I looked into it.. it only seems to push the first line in fw_file.txt .
UPDATE2 Found the bug.. I just do not know how to fix the script. $ADB shell mkdir -p "$path" somehow messes with the while loop. Making sure the folder is already created on the phone and uncommenting it fixes the issue.

so maybe the script should improve. Here's my output.

output.txt (5.21 KB) output.txt firmwares_nonfree log

RE: Replicant 6.0, at least for the Samsung Galaxy S3 - Added by Wolfgang Wiedmeyer over 7 years ago

Gumbor W wrote:

Thanks for the fast reply! The script says that everything is successful. It is just not working on my phone (WiFi is turning off again and the camera app is unable to connect to the front camera). My script output is attached to this message.

I completely forgot to mention: Great work! Great to see that this project is getting better and better.

UPDATE Now that I looked into it.. it only seems to push the first line in fw_file.txt .
UPDATE2 Found the bug.. I just do not know how to fix the script. $ADB shell mkdir -p "$path" somehow messes with the while loop. Making sure the folder is already created on the phone and uncommenting it fixes the issue.

Thanks for looking into this! I can't reproduce the issue. I guess it happens with certain ADB versions. I updated the script and simplified the path creation. The script also prints now the ADB version. I hope it works now.

RE: Replicant 6.0, at least for the Samsung Galaxy S3 - Added by David Pizarro over 7 years ago

Wolfgang Wiedmeyer wrote:

Gumbor W wrote:

Thanks for the fast reply! The script says that everything is successful. It is just not working on my phone (WiFi is turning off again and the camera app is unable to connect to the front camera). My script output is attached to this message.

I completely forgot to mention: Great work! Great to see that this project is getting better and better.

UPDATE Now that I looked into it.. it only seems to push the first line in fw_file.txt .
UPDATE2 Found the bug.. I just do not know how to fix the script. $ADB shell mkdir -p "$path" somehow messes with the while loop. Making sure the folder is already created on the phone and uncommenting it fixes the issue.

Thanks for looking into this! I can't reproduce the issue. I guess it happens with certain ADB versions. I updated the script and simplified the path creation. The script also prints now the ADB version. I hope it works now.

Excellent!! I congratulate you! Now it works perfectly.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by pitr lolo over 7 years ago

Hello,

Wolfgang, I've asked on the blog, but no one responded, so going to ask here, is there any way on how to upgrade to the current build release without losing any user data using compiled images? I cannot seem to find any "check for updates" in the replicant settings. Would be cool to have something like cyanogenmod nightly updates feature.

Thanks.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Wolfgang Wiedmeyer over 7 years ago

pitr lolo wrote:

Wolfgang, I've asked on the blog, but no one responded, so going to ask here, is there any way on how to upgrade to the current build release without losing any user data using compiled images? I cannot seem to find any "check for updates" in the replicant settings. Would be cool to have something like cyanogenmod nightly updates feature.

Usually, it should be fine to upgrade to a newer Replicant 6.0 release from a previous Replicant 6.0 version without wiping data. But it's always possible that there are some incompatibilities that cause issues. AFAIK there was never such an update check in Replicant. It's worth discussing such a feature, but only after the official release of this version and after some of the current infrastructure issues are sorted out. I don't think that it makes sense if I implement it now when it's not sure where the images will be hosted and what can be done on the server side.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Thomas Bertrand over 7 years ago

First of all thank you so much for the provided efforts to make the world a better(safer) place!

My question is related to the proprietary GPS blob. I know that having it installed on Replicant ruins the whole experience but for testing reasons I would like to install it.
I have been following these instructions https://gitlab.com/snippets/25705
The only problem that I came across was to uncomment everything at the end of the init.target.rc file regarding the gps deamon.
Every time I reboot the phone, changes are back to original.
I have read a bit of doc but I am not expert enough to recompile the whole thing myself. Is there a workaround to have this file with the bottom lines uncommented? Alternatively, is there a possibility to write a script that would launch the deamon and everything necessary to make GPS working (that I would execute manually in a terminal for instance)? I am not familiar with keywords that are at the end of the init.target.rc file and I don't know how to past them as arguments in the command line.
Any help appreciated.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Daniel Kulesz over 7 years ago

I assume, to make changes permanent, you will have to compile them into the boot partition. To do that, you probably have to modify this file:

https://code.fossencdi.org/device_samsung_i9300.git/tree/rootdir/init.target.rc?h=replicant-6.0

As you can see, the respective lines are commented there. You could probably also unpack the (precompiled) boot image, apply the changes there, repack it and flash it.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Simon Josefsson over 7 years ago

Thomas Bertrand wrote:

First of all thank you so much for the provided efforts to make the world a better(safer) place!

My question is related to the proprietary GPS blob. I know that having it installed on Replicant ruins the whole experience but for testing reasons I would like to install it.
I have been following these instructions https://gitlab.com/snippets/25705
The only problem that I came across was to uncomment everything at the end of the init.target.rc file regarding the gps deamon.

Maybe this helps you:

https://blog.josefsson.org/2017/03/04/gps-on-replicant-6/

I am hoping a patch can be applied to make this much easier though.

/Simon

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Thomas Bertrand over 7 years ago

Thanks Daniel!
I have been following your advice and unpacked/modified/repacked the boot.img then rezipped the whole thing but unfortunately impossible to flash again as the signature is not correct. I don't know what to do now except using TWRP that allows flashing without caring of signatures.... The other way I tried was to fastload flash the boot.img but unfortunately my S3 is never recognized, even in root on a windows PC, Debian, or MacOS, using different packages, even the android-sdk package. There is something wrong with the device bootloader.... What a hassle, just because a few lines were commented out...

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Thomas Bertrand over 7 years ago

Hurray! Thank you Simon!
I used heimdall to reflash the boot.img and not fastboot (everything else that was described on your nice blog I already found on the net).
worked like a charm.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Simon Josefsson over 7 years ago

Thomas Bertrand wrote:

Thanks Daniel!
I have been following your advice and unpacked/modified/repacked the boot.img then rezipped the whole thing but unfortunately impossible to flash again as the signature is not correct. I don't know what to do now except using TWRP that allows flashing without caring of signatures.... The other way I tried was to fastload flash the boot.img but unfortunately my S3 is never recognized, even in root on a windows PC, Debian, or MacOS, using different packages, even the android-sdk package. There is something wrong with the device bootloader.... What a hassle, just because a few lines were commented out...

I use the recovery image from replicant. I assume that is required, maybe I should update my blog post stating that.

/Simon

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by robin p over 7 years ago

On the topic of proprietary GPS drivers:
hi folks, please remember the reason we build replicant is to get away from the proprietary software foisted on us by the likes of samsung and google, this isn't the place to discuss non-free binary blobs and how to use them. there are many forums for talking about software where the posters don't understand what free software is about, perhaps you would be better off discussing this topic there? i believe xda forum is one such place.

cheers

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by David Pizarro over 7 years ago

So, the image form https://redmine.replicant.us/projects/replicant/wiki/ReplicantImages for the S3 is the same as replicant-6.0-beta-0001 from 27.1.17? I think not, right? that image is based on LineageOS, in the case there are differences, where can I see that changelog? Thanks

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by David Pizarro over 7 years ago

Kurtis Hanna wrote:

David, I don't know if this is what you are looking for or not, but I did find these links:
https://git.replicant.us/replicant/device_samsung_i9300/commits/replicant-6.0-0001
https://git.replicant.us/replicant/release-scripts/commit/9d7a7dc094f56d04610c2917af37cb9c48e99961
https://code.fossencdi.org/device_samsung_i9300.git/diff/?h=replicant-6.0

Oh, thanks, seems that this is what I was looking for. Based on the info you gave me the changes are basically minor fixes and the LineageOS rebranding. I'll wait for a major update to do the upgrade.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Wolfgang Wiedmeyer over 7 years ago

I definitely recommend upgrading to the latest released images. They contain security fixes and security enhancements in the kernel were enabled.
Featurewise, most notably is the addition of the RepWifi app for Wi-Fi usage with a dongle.

The upgrade doesn't require a factory reset if the latest beta was previously installed.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by robin p over 7 years ago

I'm having problems encrypting my phone. It's a Galaxy S3, as of this week running the latest r6, taken from http://ftp-osl.osuosl.org/pub/replicant/images/

If I tap "Encrypt phone", I get all the warnings about not unplugging the power and asking me for PIN, then the process starts. After several reboots it hangs at the red skating robot - the first time I left it for several hours, just to make sure it wasn't still processing. Nothing. I forced a reboot and the same thing happened. So, I reflashed and tried again yesterday (after a factory reset of course). Same thing again, it hangs at boot time.

I upgraded clockwork recovery first and followed the instructions on the wiki (I've done this all a few times before, with r4.2 and earlier r6).

Any suggestions? I can't look at logs because of course I can't start the phone.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Daniel Kulesz over 7 years ago

Encryption takes very long and is more error-prone if you have lots of data on your device. If you are fine with deleting all data before encrypting it, you can run the following command via adb as root:

vdc cryptfs enablecrypto wipe password super-secure-long-password noui

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by robin p over 7 years ago

Daniel Kulesz wrote:

Encryption takes very long and is more error-prone if you have lots of data on your device. If you are fine with deleting all data before encrypting it, you can run the following command via adb as root:

the second time i did it, i had wiped the device. i tried again last night, with adb logcat as mea ron suggested. it worked fine, i don't know what the difference was though.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Gu W over 7 years ago

I tried building Replicant yesterday on Arch Linux, but it failed. I saw some errors when trying to build the toolchain, because GCC 7 produces some warnings that were not present in older versions. So in the end I set up a Stretch build environment in a chroot, as mentioned on Wolfi's blog. However, it did not work for me out of the box on Arch Linux.

After chrooting into Debian I need to run export PATH="$PATH:/usr/sbin:/sbin:/bin". Also, I needed to use locale-gen en_US.UTF-8 before reconfiguring the locales. I am mentioning this just in case someone wants to build Replicant on a similar system. Maybe that should be mentioned somewhere for other users wanting to try out building Replicant (either on the blog or on the wiki page).

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Daniel Kulesz over 7 years ago

Maybe this issue is specific to Arch Linux? Building in Stretch chroot from a Jessie base system it worked for me without the need for the tweaks you described.

RE: Replicant 6.0 for the Samsung Galaxy S3 - Added by Gu W over 7 years ago

Daniel Kulesz wrote:

Maybe this issue is specific to Arch Linux?

Yes it's specific to Arch. I think this info could be helpful for other Arch users.

RE: Replicant 6.0, at least for the Samsung Galaxy S3 - Added by Fil Lupin over 7 years ago

Fendo Malaĉa wrote:

As for the features, the phone recognized my SIM card just fine. SMS and calls are both working very well. WiFi does not work (as expected)

Hi Fendo,
I would like to understand how you succeed into keeping your SMS.
Did you keep them between a former replicant 6 alpha and the new replicant 6 version, or did you succeed into keeping from an old/different android/replicant version?

Could you explain me how you did? (or anyone who could help me)
Thank you

(101-125/135)