User:Srilakshmi sonim/sandbox/CM Reference page

 CM Reference page 

Create SSH key
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.   Login to 10.15.1.31 (ANDBUILD) using your id and create a directory using the following command. 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
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
Repo is a repository management tool built on to of Git it makes easier to work with multiple git repositories.

  Create a bin directory under your home directory and included it in path environment variable. $ mkdir ~/bin $ PATH=~/bin:$PATH

 Download the Repo tool and change it as executable. $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo 

Initializing a Repo client
  Create an empty directory to hold your working files.  $ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY

 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.  $ repo init -u ssh://username@10.15.1.31:29418/simt_mirror/platform/manifest -b 

Downloading Source Tree
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
Refer to http://kip.sonimtech.com/kip/index.php/Prashant_new_empty_repo_creation for more information.

Initializing the Environment
Initialize the environment with the envsetup.sh script. $ . build/envsetup.sh

Choosing a target
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
Run the following commands to clean the target. $ make clean $ make update-api

Building the Code
Below command build the source, number adjecent to -j signifies the parallel jobs. $ make -j4

Creating a Distribution TAR file
Run the below command to create target file which is used in FOTA packages. $ make dist

Global Configuration
<ol> <li>To set default editor like vim, invoke emacs while editing comments.</li>

git config --global core.editor "vim"

<li>Enter global username and email ID</li>

git config --global user.name "ABC" git config --global user.email abc@example.com

Creating a New Tag
<OL> <LI>You can create a new tag on the local workspace using the below command.</li>

Lightweight Tag
repo forall -p -c 'git tag <tag_name>'

Annotated Tag
git tag -a <tag_name> -m "message"

<li>Push the new tag to remote repository. For example, the following sample contains remote git repository url</li>

repo forall -p -c 'git push sim <tag_name>'

<li>Run the following command to view the difference between the two tags. </li>.

repo forall -p -c 'git diff .. ' | grep ^project </OL>

Updating tag to different commit
git tag -a <tag_name> <commit_id> -f git push <remote_name> <tag_name

Renaming the Tag
<ol><li> Create a new tag pointing the old tag, in working directory.</li> git tag <new_name> <old_name>

<li> Push tag from working directory to remote repository.</li> git push --tags

<li>Delete the old tag on remote repository.</li> git push origin :refs/tags/<old_name>

<li>Delete tag from working directory. </li> git tag -d <old_name> </OL>

Checking Out from Tag
<ol> <li> Check out the source from the tag. </li> git checkout -b <branch_name> <tag_name> </ol>

Remote Branching
Follow the below steps to create a remote branch.

Project Branching
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.

<ol> <li>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 </li>

<Li>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 </li>

<li> 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 </li>

<li> 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 </li>

<li> Push all branches to remote server.</li> repo forall -c 'git push sim ' Example: repo forall -c 'git push sim 8926-X700-10152-COMMON-TECH' </li>

<li> Verify the newly created branch by following command. repo branches </li> </ol>

Manifesting the Branch
<OL> <li> Go to directory .repo/manifests from the root directory of workspace. cd .repo/manifests </li>

<li> Create the manifest branch with git command. git checkout -b <branch_name> </li>

<li> Verify if the branch is created, using the following command. git branch </li>

<li> Set revision to new branch name in file \.repo\manifests\default.xml. <default remote="sim" revision="branch_name"/> </li>

<li>Commit changes to local repository. git commit -am "Changed manifest file to reflect new branch" </li>

<li>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.</li>

<li>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 </li>

<li>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" </li></ol>

Deleting a Remote Branch
<ol><li> git push origin --delete <branchName> </li></ol>

Cherry-pick from Remote Branch
Complete the following steps to cherry-pick from remote <from_branch_name> to local <to_branch_name>. <ol> <li>Fetch the remote branch to local workspace. git fetch <remote_name> <from_branch_name> </li>

<li>Checkout the branch where cherry-pick to be applied. git checkout -b <to_branch_name> </li>

<li>Run cherry-pick with commit id. git cherry-pick <commit_id> </li>

<li>Once the cherry-pick commit is verified run the following command to push change to remote repository. git push <remote_name> <to_branch_name> </li> </ol>

Identifying the Commit ID
<ol> <li>Find the branch from which the commit was generated. git branch -a --contains <commit_id> </li>

<li>Find the common ancestors between two commits. git merge-base <commit_id_1> <commit_id_2> </li>

<li>Identify the changes done in commit. git show --format=full <commit_id> </li> </ol>

Amending the Commit
<ol> <li> Edit the commit message. git commit --amend </li>

<li>Change the author details. git commit --amend --author "New Author Name <email@address.com>" </li> </ol>

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

<ol> <li>Build the apk file. </li> <li>Download the platform keys from Image:PlatformKeys.zip</li> <li>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 </li>

<li> 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.</li> </ol>

How can I upgrade Fota manually using adb side load?
To upgrade Fota manually using adb side load, complete the following steps. <ol> <li>Enter into fast boot (Power Key + Volume Up).</li> <li>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. </li> <li>Enter adb sideload package path(c:/).</li> </OL>

How to do Fota Upgrade through Air
To upgrade Fota manually through air, complete the following steps.

<ol> <li>Place a package in Innopath server.</li> <li>Launch MU Update app and download software and install the update.</li> </ol>

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

<ol> <li> Press Vol down + power key. </li> <li> Enter the following command, to erase the user build boot image. fastboot erase boot </li> <li>Keep the boot image file of ENG build in the command path and enter the following command. fastboot flash boot boot.img </li> <li>Reboot the device.</li> <li>Pull the last log from the path to your system with the below command. adb pull /cache/recovery/last_log c:/ </li>

Creating a checking of the projects
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
Source code received from SIMT is mirrored at 10.15.1.31 (ANDBUILD) machine, follow the below steps to download the local copy.

Syncing Modem code
<OL> <li> Login to repouser on build server 10.15.1.31 (ANDBUILD). Follow the below steps to sync the modem code. </li> <li> 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 </li></ol>