Translation in english of https://framagit.org/feinstaub/tp64/blob/master/weitere/workshop-smartphone/mobile-os-installieren/2017-10-replicant6-auf-samsung-s2/README.md


Replicant 6 on Samsung Galaxy S2
=================================

OK

<!-- toc -->

- [Background](#Background)
- [Installation](#Installation)
  * [Create working directory](#create-working-directory)
  * [Download files](#download-files)
  * [Install Heimdall](#install-heimdall)
  * [Install adb](#install-adb)
  * [Copying files to the device](#copying-files-to-the-device)
  * [Prepare device](#prepare-device)
  * [Install images](#install-images)
  * [Setup](#setup)
- [File transfer](#file-transfer)
  * [USB mass storage does not seem to work](#usb-mass-storage-does-not-seem-to-work)
  * [via ADB](#via-adb)
- [Reverse Thethering (helping the smartphone to access the Internet via USB)](#reverse-thethering-helping-the-smartphone-to-access-the-internet-via-usb)
  * [Preparation](#preparation)
  * [Root access for ADB](#root-access-for-adb)
  * [Copy and start script](#copy-and-start-script)
  * [Create a new Internet connection with plasma (was not possible)](#create-a-new-internet-connection-with-plasma-was-not-possible)
- [End of 2017: Hardware error](#end-of-2017-hardware-error)

<!-- tocstop -->

Background
----------

* Replicant website: https://www. replicant. us/
* Material:
    * Device: Samsung Galaxy S2
    * Computer with openSUSE Linux Tumbleweed
    * USB cable (normal to Micro-USB)
* Implementation: 2017 => SUCCESS

Installation
------------
Sources:

* Wiki page about the device: https://redmine.replicant.us/projects/replicant/wiki/GalaxyS2I9100
* installation guide: https://redmine.replicant.us/projects/replicant/wiki/GalaxyS2I9100Installation
    * "Moreover, it is assumed that anyone performing the installation knows how to use command lines in a terminal and has basic knowledge about it."

### Working directory attach

    $ mkdir ~/dev/replicant_s2/
    $ cd ~/dev/replicant_s2/

### Files download

Source: https://redmine.replicant.us/projects/replicant/wiki/ReplicantImages#Replicant-60-0002-images files:

* replicant-6.0-i9100.zip, approximatively 270 MB
* replicant-6.0-i9100.zip.asc
* recovery-i9100.img, approximatively 5 MB
* recovery-i9100.img.asc
* i9100.sha256

Release keys import:

    $ gpg --recv-key 5816A24C10757FC4

    key 16D1FEEE4A80EB23:
    5 signatures not checked due to missing keys
    gpg: key 16D1FEEE4A80EB23: public key "Replicant project release key <contact@replicant.us>" imported
    gpg: marginals needed: 3  completes needed: 1  trust model: pgp
    gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
    gpg: Total number processed: 1
    gpg:               imported: 1

Downloads - signature verifcation:

    $ gpg --armor --verify replicant-6.0-i9100.zip.asc replicant-6.0-i9100.zip

    gpg: Signature made So 10 Sep 2017 16:55:49 CEST
    gpg:                using RSA key 0F30D1A02F73F70A6FEE048E5816A24C10757FC4
    gpg: Good signature from "Wolfgang Wiedmeyer <wolfgang@wiedmeyer.de>" [unknown]
    gpg:                 aka "Wolfgang Wiedmeyer <wreg@wiedmeyer.de>" [unknown]
    gpg:                 aka "Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>" [unknown]
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4

    $ gpg --armor --verify recovery-i9100.img.asc recovery-i9100.img

    gpg: Signature made So 10 Sep 2017 16:55:46 CEST
    gpg:                using RSA key 0F30D1A02F73F70A6FEE048E5816A24C10757FC4
    gpg: Good signature from "Wolfgang Wiedmeyer <wolfgang@wiedmeyer.de>" [unknown]
    gpg:                 aka "Wolfgang Wiedmeyer <wreg@wiedmeyer.de>" [unknown]
    gpg:                 aka "Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>" [unknown]
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4


Downloads - test sums verify:

    $ sha256sum -c i9100.sha256

    recovery-i9100.img: OK
    replicant-6.0-i9100.zip: OK


### Heimdall installation

Heimdall is a Flash program for Samsung devices.

Installation from openSUSE: https: // software.opensuse.org/package/heimdall with 1 Click Install from:

* Repository **hardware** / version 1.4.2

### adb installation

ADB = Android Debug Bridge

    $ sudo zypper install android-tools

### Files on the device copy

* Device connect with USB with the computer
* Previous operating system: Android 4.1.2
* Settings > Wirelessly and networks > other settings > USB connection > mass warehouse procedure activate > warehouse with PC connect
* "USB is connected. Remove the cable"
* Disconnect cable. Click again. Connect cable.
* "Warehouses with PC connect"> OK. Wait a few seconds.
* Plasma Device Notifier> Open with file manager
* The file **replicant-6.0-i9100.zip** in the root directory (= copy a highest level(plain)).

* Plasma: "Savely Remove" device
* Device: "USB warehouses switch off"

### Device preparation
WARNING. Here begins the possible complete overrun on the device.

* "Make sure the device is completely turned off and the USB cable is disconnected from the device "
    * Switch off, USB cables distinguish
* "Start the device by holding company the following key combination: to volume down, Select, power"
    * "Volume down " (left side button), "Home button" (middle button in front below), "Power button" (right side)
    * Hold these buttons make a warning appears: "Warning!! A custom OS can cause critical of problem in phone and installed applications "
* "Volume up: Continue" select.
* The screen displays
    "ODIN MODE
    PRODUCT NAME: GT-i9100
    CUSTOM BINARY DOWNLOAD: NO
    CURRENT BINARY: SAMSUNG OFFICIAL

    Downloading...
    Do not turn off target !!"

* "Connect the USB cable to both the computers and the device

### Images installation

Flash with Heimdall (duration: 10 seconds)

    $ heimdall flash --KERNEL recovery-i9100.img

    Heimdall v1.4.2

    Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
    http://www.glassechidna.com.au/

    This software is provided free of charge. Copying and redistribution is
    encouraged.

    If you appreciate this software and you would like to support future
    development please consider donating:
    http://www.glassechidna.com.au/donate/

    Initialising connection...
    Detecting device...
    Claiming interface...
    Setting up interface...

    Initialising protocol...
    Protocol initialisation successful.

    Beginning session...

    Some devices may take up to 2 minutes to respond.
    Please be patient!

    Session begun.

    Downloading device's PIT file...
    PIT file download successful.

    Uploading KERNEL
    100%
    KERNEL upload successful

    Ending session...
    Rebooting device...
    Releasing device interface...

Device restarts. One sees a yellow exclamation mark with the Samsung-start screen.
Then one sees the following screen:

    Replicant
    RECOVERY

    - Reboot system now
    - Apply update
    - Factory reset
    - Advanced

* select **Factory reset** ("A data wipe is necessary if you switch from the factory image or a different Android distribution to Replicant")
* select **Wipe data (keep media)**
* select **YES**
* Wait (a few seconds)
* Press "Back" (to the main menu)
* select **Apply update**
* select **Choose from sdcard0**
* select **replicant-6.0-i9100.zip**
* Wait (a few minutes). One sees an installation animation, a yellow progress beam and status text editions.
    * with approximatively 25% it does not go on for a while. Then it is finished suddenly and one sees the "Replicant RECOVERY" screen again

* "If you did the data wipe ani step 2, you wants need to do a factory reset ace wave:"
    * Select **Factory reset**
    * Select **Full factory reset**
    * Confirm the factory reset by selecting **Yes**
    * Press the **back key** (if necessary) to get back to the general menu
* Select **Reboot system now** to reboot the device

* **Your device should now be running Replicant!**
    * However, one still sees the Samsung-start screen with the yellow exclamation point.
        * TODO: Is this normal?
    * Then appears the Replicant boat screen and remains surely for a long time (more than 1 minute)
    * Then below a progress beam appears where 85 apps are prepared (more than 3 minutes)

### Configuration

* Language choice
    * English (United States)
* Date and time
    * Amsterdam, Berlin (GMT+1:00)
    * configure Date and time
* "SIM card missing" message
    * Skip
* Choose screen lock
    * PIN: 0000
* Replicant features
    * Enable Privacy guard? -> only not.
* READY

* After a few clicks
    * e.g., camera functions
    * Root access for RepWifi configuration. However, it works only if the Wifi adapter is connected.
* start again.

File transfer
-------------

### USB degree Storage does not seem to go
(TODO)

### via ADB
* Developer Options> Debugging> Android Debugging (Enable adb)> Confirm of computer fingerprint

    $ adb devices

    List of devices attached
    00095da2148b6f  device

    $ adb push BoxCat_Games_-_19_-_Mission\ \(freemusicarchive.org\).mp3 /storage/611C-161B/Music

* Where from one knows "/storage/611C-161B"? See file manager
* Music works.

Reverse Thethering (which Smartphone via USB help to Internet)
--------------------------------------------------------------

* Why? Because no WLAN works or not be applied.
* STATUS: up to now failed
* After this manual: https: // redmine.replicant.us/projects/replicant/wiki/ReplicantUSBNetworking



### Preparations

    $ cd ~/dev/replicant_s2/
    $ mkdir tether
    $ cd tether
    $ wget https://git.replicant.us/replicant/user-scripts/plain/networking/usb/usb_networking_device.sh

### Root access for ADB
Settings> Developer Options (second from below)> **Android debugging** (about in the middle)> enable

    $ adb devices
    $ adb shell
    $ adb root
    restarting adbd as root

Settings> Developer Options (second from below)> **Root access** (approx. 10 options from above)> "Apps and ADB"

    $ > logout
    $ adb remount
    remount succeeded

### Script copy and start

    $ adb push usb_networking_device.sh /data/
    $ adb shell chmod a+x /data/usb_networking_device.sh
    $ adb shell /data/usb_networking_device.sh start1
    Starting Replicant USB networking, phase 1

It poppt a new connection on, but it does not work (no connection found)

### New Internet Connection with plasma attach (did not go)

1. In the network manager applet, create a new "Ethernet" or "Wired" connection.
2. In the tab for IPv4 settings, select the method "Shared to other computers".
3. Save the connection, preferably with a distinguishable name (The name can be changed at the top of the edit window).
4. Select this connection for your device. (todo: what is it?)

    $ adb shell /data/usb_networking_device.sh start2
    error: insufficient permissions for device
--> TODO

reconnect

or: without start1:

    $ adb shell /data/usb_networking_device.sh start2
    Starting Replicant USB networking, phase 2
    Clearing network configuration
    400 0 destroyNetwork() failed (Machine is not on the network)
    200 0 Interface IP addresses cleared
    Configuring DHCP, please wait
    ifconfig: ioctl 8913: No such device


WAIT: https://redmine.replicant.us/boards/9/topics/6915

In the end of 2017: hardware error
----------------------------------

Suddenly the mobile radio-connection does not function anymore. No net. Thus no phone or data transfer possible.

