User:Srilakshmi sonim/sandbox/CM Reference page

CM Reference page

Create SSH key

edit

SSH public key is used to access source code present at build server 10.15.1.31 (ANDBUILD). Follow the below steps to generate the SSH key.

  1. Login to 10.15.1.31 (ANDBUILD) using your id and create a directory using the following command.
  2. mkdir ~/.ssh
    chmod 700 ~/.ssh
    ssh-keygen -t rsa -C "username@sonimtech.com" 

Note: When prompt to enter passphrase skip by pressing enter key.

Public key will be generated at ~/.ssh/id_rsa.pub , share this key with server admin (Naveen Balaji K) to provide access for git repositories.

Downloading the source

edit

Source code received from SIMT is mirrored at 10.15.1.31 (ANDBUILD) machine, follow the below steps to download the local copy.

Installing Repo Tool

edit

Repo is a repository management tool built on to of Git it makes easier to work with multiple git repositories.

  1. Create a bin directory under your home directory and included it in path environment variable.
  2. $ mkdir ~/bin
    $ PATH=~/bin:$PATH 
  3. Download the Repo tool and change it as executable.
  4. $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    $ chmod a+x ~/bin/repo 

Initializing a Repo client

edit
  1. Create an empty directory to hold your working files.
  2. $ mkdir WORKING_DIRECTORY
    $ cd WORKING_DIRECTORY 
  3. Run repo init to bring down the latest version of code and must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
  4. $ repo init -u ssh://username@10.15.1.31:29418/simt_mirror/platform/manifest -b <branch_name>  

    Downloading Source Tree

    edit

    Move the Android source tree to your working directory from the repositories as specified in the default manifest.

    repo forall –p –c $ repo sync 

    Initializing a empty repo on a requested branch

    edit

    Refer to http://kip.sonimtech.com/kip/index.php/Prashant_new_empty_repo_creation for more information.

    Building the source

    edit

    Initializing the Environment

    edit

    Initialize the environment with the envsetup.sh script.

    $ . build/envsetup.sh 

    Choosing a target

    edit

    Choose which target to build with lunch. The exact configuration can be passed as an argument, e.g

    $ lunch XP6700-Bell_Gen-eng 

    Cleaning the target

    edit

    Run the following commands to clean the target.

    $ make clean
    $ make update-api 

    Building the Code

    edit

    Below command build the source, number adjecent to -j signifies the parallel jobs.

    $ make -j4 

    Creating a Distribution TAR file

    edit

    Run the below command to create target file which is used in FOTA packages.

    $ make dist 

    Git Configuration

    edit

    Global Configuration

    edit
    1. To set default editor like vim, invoke emacs while editing comments.
    2. git config --global core.editor "vim" 
    3. Enter global username and email ID
    4. git config --global user.name "ABC"
      git config --global user.email abc@example.com 

      Tagging

      edit

      Creating a New Tag

      edit
      1. You can create a new tag on the local workspace using the below command.
      2. Lightweight Tag
        edit
        repo forall -p -c 'git tag <tag_name>' 
        Annotated Tag
        edit
        git tag -a <tag_name> -m "message"
      3. Push the new tag to remote repository. For example, the following sample contains remote git repository url
      4. repo forall -p -c 'git push sim <tag_name>'
      5. Run the following command to view the difference between the two tags.
      6. .
        repo forall -p -c 'git diff <oldtag>..<newtag>' | grep ^project 

      Updating tag to different commit

      edit
      git tag -a <tag_name> <commit_id> -f
      git push <remote_name> <tag_name 

      Renaming the Tag

      edit
      1. Create a new tag pointing the old tag, in working directory.
      2. git tag <new_name> <old_name> 
      3. Push tag from working directory to remote repository.
      4. git push --tags
      5. Delete the old tag on remote repository.
      6. git push origin :refs/tags/<old_name>
      7. Delete tag from working directory.
      8. git tag -d <old_name>

      Checking Out from Tag

      edit
      1. Check out the source from the tag.
      2. git checkout -b <branch_name> <tag_name>

      Remote Branching

      edit

      Follow the below steps to create a remote branch.

      Project Branching

      edit

      Create a workspace on the parent branch (i.e. from which child needs to be pulled) and sync it. For example, to create a branch 8926-X700-10152-COMMON-TECH (child branch) from 8926-X700-10152-COMMON (parent branch), complete the following steps.

      1. Login to 10.15.1.31 (with your user id) and create a branch directory.
        mkdir <workspace_child_branch_name>  
        cd <workspace_child_branch_name> 
        Example: mkdir workspace_8926-X700-10152-COMMON-TECH   
        Example: cd workspace_8926-X700-10152-COMMON-TECH
        
      2. Run the init command to get the latest of the parent branch, to create branch at HEAD of the parent branch.
        repo init -u repouser@10.15.1.31:/home/repouser/gitrepos/simt_mirror/platform/manifest -b <parent-branch>  
        Example:  repo init -u repouser@10.15.1.31:/home/repouser/gitrepos/simt_mirror/platform/manifest -b 8926-X700-10152-COMMON 
      3. If you need to use a manifest file, to create a branch at a stable point, follow the step 2 with -m option.
        repo init -u repouser@10.15.1.31:/home/repouser/gitrepos/simt_mirror/platform/manifest -b <parent-branch > -m  <manifest-file> 
        Example: repo init -u repouser@10.15.1.31:/home/repouser/gitrepos/simt_mirror/platform/manifest -b 8926-X700-10152-COMMON  -m <manifest-file> 
        repo sync
        Example:  repo sync 
         
      4. Create branch on all projects using repo tool.
        repo forall -p -c 'git checkout -b <new-branch_name / child branch>'
        Example: repo forall -p -c 'git checkout -b 8926-X700-10152-COMMON-TECH 
      5. Push all branches to remote server.
      6. repo forall -c 'git push sim <child branch >'
        Example: repo forall -c 'git push sim 8926-X700-10152-COMMON-TECH' 
      7. Verify the newly created branch by following command.
        repo branches 

      Manifesting the Branch

      edit
      1. Go to directory .repo/manifests from the root directory of workspace.
        cd .repo/manifests 
      2. Create the manifest branch with git command.
        git checkout -b <branch_name> 
      3. Verify if the branch is created, using the following command.
        git branch 
      4. Set revision to new branch name in file \.repo\manifests\default.xml.
        <default remote="sim" revision="branch_name"/> 
      5. Commit changes to local repository.
        git commit -am "Changed manifest file to reflect new branch" 
      6. Push the manifest branch to remote repository.
        git push origin <branch_name> 
        Note: This is the branch name given with -b option in repo init command.
      7. Add the following entry to the wiki: http://10.15.1.17/kip/index.php/Smart_Phone_Release_Notes#AP_Source_Code
        repo init -u ssh://username@10.15.1.31:29418/simt_mirror/platform/manifest -b  <child branch / new branch>  
         Example: repo init -u ssh://username@10.15.1.31:29418/simt_mirror/platform/manifest -b  8926-X700-10152-COMMON-TECH 
      8. Test syncing a sample repo to verify the branch creation.
        mkdir test_workspace 
        cd test_workspace 
        repo init -u ssh://username@10.15.1.31:29418/simt_mirror/platform/manifest -b  <child branch / new branch>  
        repo sync <test project / repo> 
        Example : repo sync "platform/project" 

      Deleting a Remote Branch

      edit
      1. git push origin --delete <branchName>

      Cherry-pick from Remote Branch

      edit

      Complete the following steps to cherry-pick from remote <from_branch_name> to local <to_branch_name>.

      1. Fetch the remote branch to local workspace.
        git fetch <remote_name> <from_branch_name>
      2. Checkout the branch where cherry-pick to be applied.
        git checkout -b <to_branch_name>
      3. Run cherry-pick with commit id.
        git cherry-pick <commit_id>
      4. Once the cherry-pick commit is verified run the following command to push change to remote repository.
        git push <remote_name> <to_branch_name>

      Identifying the Commit ID

      edit
      1. Find the branch from which the commit was generated.
        git branch -a --contains <commit_id>
      2. Find the common ancestors between two commits.
        git merge-base <commit_id_1> <commit_id_2>
      3. Identify the changes done in commit.
        git show --format=full <commit_id>

      Amending the Commit

      edit
      1. Edit the commit message.
        git commit --amend
      2. Change the author details.
        git commit --amend --author "New Author Name <email@address.com>"

      How to sign apk with platform keys?

      edit

      To sign the apk file with platform keys complete the following steps.

      1. Build the apk file.
      2. Download the platform keys from Image:PlatformKeys.zip
      3. Run the below command to sign it with platform signature.
        java -jar signapk.jar [platform cert *.pem] [platform cert *.pk8] [Source Apk path] [Target Apk path]
        Example: java -jar signapk.jar platform.x509.pem platform.pk8 bin/Test1.apk Test.apk
      4. The following git error might be generated.
         error.GitError: manifests rev-list (u'^bbf87fd82774c4ffcaa46f12a04b969f68010880', 'HEAD', '--'): fatal: bad revision 'HEAD
        This problem is due to wrong/corrupted .repo folder. locate this folder and delete the same, to resolve the issue. This folder is created accidentally in user home folder(~/) or (.) current folder.

      FAQ FOTA

      edit

      How can I upgrade Fota manually using adb side load?

      edit

      To upgrade Fota manually using adb side load, complete the following steps.

      1. Enter into fast boot (Power Key + Volume Up).
      2. Select the 2nd option in fast boot mode(apply update from ADB) and press OK(Power key). To navigate to 2nd option use volume down button.
      3. Enter adb sideload package path(c:/).

      How to do Fota Upgrade through Air

      edit

      To upgrade Fota manually through air, complete the following steps.

      1. Place a package in Innopath server.
      2. Launch MU Update app and download software and install the update.

      How to change User build boot image file to ENG build boot image to collect the last_log

      edit

      To change User build boot image file to ENG build boot image to collect the last_log, complete the following steps.

      1. Press Vol down + power key.
      2. Enter the following command, to erase the user build boot image.
        fastboot erase boot 
      3. Keep the boot image file of ENG build in the command path and enter the following command.
        fastboot flash boot boot.img
      4. Reboot the device.
      5. Pull the last log from the path to your system with the below command.
         adb pull /cache/recovery/last_log c:/ 
      6. Creating a checking of the projects

        edit

        SSH public key is used to access source code present at build server 10.15.1.31 (ANDBUILD). Follow the below steps to generate the ssh key.

        mkdir ~/.ssh
        chmod 700 ~/.ssh
        ssh-keygen -t rsa -C "username@sonimtech.com"
        

        Note: When prompted to enter passphrase skip by pressing enter key.

        Public key will be generated at ~/.ssh/id_rsa.pub , share this key with server admin (Naveen Balaji K) to provide access for git repositories.

        Downloading the source

        edit

        Source code received from SIMT is mirrored at 10.15.1.31 (ANDBUILD) machine, follow the below steps to download the local copy.

        Installing Repo Tool

        edit

        Syncing Modem code

        edit
        1. Login to repouser on build server 10.15.1.31 (ANDBUILD). Follow the below steps to sync the modem code.
        2. Check the modem code / path for the url: 10.15.1.17/kip/index.php/Smart_Phone_Release_Notes#CP_Source_Code, based on the the CP init commands and cd to the corresponding paths (inside the /home/repouser/gitrepos/)and run below commands. Refer to the following example for syncing modem code on 8926-X700-1011310-DEV branch.
          login to 10.15.1.31 using userid repouser 
          Example : cd  /home/repouser/gitrepos/modem_code/AMSS.git
          git fetch --all