DeveloperGuide » History » Revision 80

Revision 79 (Denis 'GNUtoo' Carikli, 04/09/2019 03:33 PM) → Revision 80/104 (Denis 'GNUtoo' Carikli, 04/10/2019 01:12 PM)

h1. Developer guide 


 h2. Prerequisites 

 Developing on Replicant isn't much harder than developing on any other free software project as it doesn't require specific knowledge. In fact, you'll probably learn a lot along the way regarding how hardware works, how the Android system is composed, how the kernel works, etc, but you don't need to know all of this to start. However a basic set of skills is required, among which: 
 * C language programming skills and the ability to understand other languages such as C++ and Java 
 * Makefile skills (no need to know every detail about it, a general idea of how Makefiles work is enough) 
 * Git skills (basically, how to commit changes, send them to our repos, dealing with branches without making a mess, etc) 
   You can find some documentation about Git at: 

 If you think you can cope with the requirements, then developing on Replicant should cause you no particular issue. 

 The [[Index#Replicant-porting-guides|porting guides]] provide instructions for porting a new device to Replicant and also offer some tips for developing on Replicant. 

 Have a look at the [[Tasks]] page and feel free to [[Index#Contact|ask around]] for help to get started. 

 h3. Notes on writing free software replacements 

 Writing free software replacements for non-free components may require more skills depending on what you're trying to achieve, though there may be people with the adequate knowledge to help you and from whom you will likely learn a lot. 


 h2. Code hosting and submitting patches 

 Replicant's source code is hosted at "": If you plan to regularly contribute to Replicant and if you don't yet have a code hosting provider that satisfies your needs, you are welcome to host your Replicant-related projects there under your own username. You only need to [[People#Active-developers|contact one of Replicant's developers]] and ask for an account. Please include in your request the name, username and Email address that should be used for creating your account. Your repos will then show up on the "contributor repos": page. 

 Replicant currently doesn't accept merge requests. There are two ways to get your patches included: You can either send them to the "mailing list": or open an issue on the "issue tracker":/projects/replicant/issues and attach the patches to the issue. Replicant developers will then review your changes. 

 See the Git documentation for "creating a patch": Patches can be sent with "@git send-email@": If it's too much hassle for you to set up @git send-email@, sending the patches with your favorite mail client should be fine, too. 


 h2. Writing free software replacements 

 Here are some tips that may help you achieving a free software replacement for a specific component (some may be more or less relevant regarding the nature of what the component does): 
 * Look for interested people from other projects: LineageOS people are constantly fighting with non-free blobs and are sometimes happy to help replacing one. 
 * Use tools such as @strings@, @objdump@ and @radare2@ against the non-free binary to have a better idea of how things work. (*Make sure this is legal where you live!*) 
 * Try to make the non-free binary as verbose as possible by enabling all the possible debug options on the config file or such. 
 * Run the program in @strace@ and analyze the trace to understand what the program does. 
 * Add verbose debug prints in the concerned kernel driver (with @printk@ and show them via the @dmesg@ tool). 
 * Read the corresponding kernel driver: you can sometimes learn a lot by reading comments or headers. 
 * Collect data out of the kernel driver (via debug prints) and out of the non-free binary (via debug prints on the upper-layer). 
 * If there is a mathematical algorithm involved, force the values returned by the kernel to the non-free binary and analyze how it reacts, for instance with spreadsheet software. 
 * If you're directly dealing with a hardware component, try to find a datasheet for the chip, it may hold precious details. In the best case, you may also be able to find a reference software implementation! 

 h2. Upstreaming work 

 It is generally a good idea to send some changes back to upstream, assuming that they will benefit from it as well. 

 When it is about the replacement of a non-free component present in the upstream systems, make sure that your replacement is reliable and complete. 
 Contact the interested developers on the upstream projects before attempting to send your replacement. 

 h3. LineageOS 

 The LineageOS team uses Gerrit to manage patch submissions. The process to get your patch included in LineageOS repos is explained on their wiki: "Gerrit": 

 You can also push directly using git using the following scheme (untested): 
 git push ssh://<sshusername><projectname> HEAD:refs/for/<branchname> 

 h3. AOSP 

 The Android Open Source Project uses Gerrit to manage patch submissions. Some information about submitting patches to AOSP is available: 

 You can push to AOSP's review using: 
 git push HEAD:refs/for/master 

 h2. Commonly-used terminology 

 In order to keep everything clear and consistent, we use the following terms with a precise meaning in mind: 
 * *Driver*: Software that is part of the *kernel* (builtin or as a module) and deals with communicating with the hardware 
 * *Hardware Abstraction Layer (HAL)*: Software that runs in *user-space* and deals with communicating with the hardware (usually through a kernel driver) 
 * *module*: Android HALs are also often called modules, so we may referrer to e.g. the @audio HAL@ as the @audio module@ 
 * *blob*: Proprietary HAL 
 * *firmware*: Software that does not run on the main processor (the CPU) but rather in a separate chip (e.g. the Wi-Fi firmwares runs on the Wi-Fi chip) 

 h2. Wiki guidelines 

 In order the keep the wiki simple and consistent, a few guidelines must be followed when editing. 

 Regarding the content: 
 * Only Replicant-specific topics should be covered by the wiki: there is no point in writing usage guides for generic Android aspects, such as the user interface. 
 * The content on each page should *only* be relevant to the latest Replicant version: make sure to update the content with newer Replicant versions. 
 * Substantial changes must be discussed before modifying the wiki. 
 * A comment should be added in the comment field at the bottom that shortly describes the change. 
 * Make use of the wiki formatting possibilities: "quick reference":/help/en/wiki_syntax_textile.html and "detailed syntax overview":/help/en/wiki_syntax_detailed_textile.html 
   By using @[[Index]]@, it's possible to link to the start page of the wiki. 

 Regarding the writing style: 
 * Every page in the wiki has to be written in correct English, we do not aim to provide information in any other language. 
 * Addressing readers directly should be avoided when possible: Instead, what is described should always be the subject of sentences. 
 * Links to pages should be incorporated in text (Instructions to [[ToolsInstallation#ADB|install ADB]] shouldn't be: Instructions to install ADB: [[ToolsInstallation#ADB]]). 

 Regarding the naming of pages: 
 * Pages must be named in a consistent manner ([[NexusSI902xFirmwares]] is not to be called [[FirmwaresOnTheI902xNexusS]]). 
 * Common prefixes and suffixes should be used for naming new pages ([[BuildDependenciesInstallation]] is not to be called [[InstallationOfBuildDependencies]]). 
 * Page and section names should always be named using nouns, not verbs, either active or not ([[DeveloperGuide]] is not to be called [[DevelopingGuide]]). 
 * Page titles shouldn't contain space or any delimiter character (such as - or_) but use upper-case characters as word delimiters ([[BuildDependenciesInstallation]] is not to be called [[Build_dependencies_installation]]). 
 * Page titles *as shown on the page* should use lower-case when upper-case is not needed, even if the page name uses upper-case as word delimiters. 

 Regarding the naming of devices: 
 * Devices should be named after their model number and codename, without mention of the manufacturer. 
 * Common device naming conventions should be followed consistently (the @Galaxy S 3 (I9300)@ is not to be called @Samsung S3 GT-I9300@ or @Galaxy S III@). 


 h2. Repositories 

 When working with Replicant repos, make sure to avoid breaking things. For instance, if you push a commit introducing a compilation error, it will break the whole build process. 
 It is better to create separate branches (that are not used by the official manifest branches) when your work is still in progress. 
 Creating branches that add debug infos on a particular topic is usually a good idea since it will save you time next time you want to debug the same component. 

 See [[SourceCodeRepositories]] [[UpstreamSourceCodeMirrors]] details the setup of the upstrream source code mirrors mirror. Below are the instructions for more details about how to create or mirror repositories on repos in the Replicant server. group. 

 h3. When creating a repository 

 In order to keep repo naming consistent, please name repositories by their name on the tree, replacing the @/@ by @_@. 
 For instance, when forking the LineageOS repo: @android_device_samsung_crespo@, rename it to @device_samsung_crespo@ on the Replicant repos. 
 This creates a more consistent way of naming repositories and makes it easier when pushing: just look at the location in the source tree and replace @/@ by @_@. 

 h3. When creating a branch 

 Official Replicant branches are named the following way: 
 * The @replicant-@ prefix 
 * The Replicant version 

 Such as: @replicant-2.3@ This should be used on the projects repositories as well as the manifest repository. 
 Any other branch should be considered as Work In Progress (WIP) and thus not be part of any official branch of the manifest. 

 There is although one exception, with the @master@ branch, that can be used by any project and be in any manifest given that the code held in the @master@ branch will work on any Replicant version. 


 h2. New images release 

 # Modify the changelog in the vendor files: 
 cd path/to/replicant-6.0/vendor/replicant 
 edit CHANGELOG.mkdn 
 git add CHANGELOG.mkdn 
 git commit -sS -m "Replicant 6.0 0001 images release" 
 git push replicant-6.0 
 # Increment the release in the "release scripts": 
 cd path/to/release-scripts 
 git add 
 git commit -sS -m "Replicant 6.0 0001 images release" 
 git push replicant-6.0 
 # Tag all the repositories with the release tag script: 
 path/to/release-scripts/ path/to/replicant-6.0 
 # In the manifest repo, merge the replicant-6.0-dev branch into the replicant-6.0 branch and increment the release in the manifest: 
 cd path/to/manifest 
 git checkout replicant-6.0 
 git merge replicant-6.0-dev 
 edit default.xml 
 git add default.xml 
 git commit -sS -m "Replicant 6.0 0001 images release" 
 git push replicant-6.0 
 # Tag the manifest: 
 git tag -u 5816A24C10757FC4 replicant-6.0-0001 -m "Replicant 6.0 0001 images release" 
 git push replicant-6.0-0001 
 # Verify all tags: 
 cd .repo/manifests 
 git verify-tag $(git describe) 
 cd ../.. 
 repo forall -ec ' { echo "Verifying $REPO_PROJECT" && git verify-tag $(git describe) 2>/dev/null; } || { echo "Error: verification failed!" && exit 1; } ' 
 # Update prebuilts and start the build (in a newly opened shell with the Replicant keys and certificates installed): 
 path/to/release-scripts/ path/to/replicant-6.0 
 # Release the images with the release script: 
 rm -rf path/to/images/replicant-6.0/0001 
 mkdir -p path/to/images/replicant-6.0/0001 
 path/to/release-scripts/ path/to/replicant-6.0 path/to/images/replicant-6.0/0001 
 # Sign the binaries with the release script: 
 path/to/release-scripts/ path/to/replicant-6.0 path/to/images/replicant-6.0/0001 signatures 
 # Compress the release files 
 cd path/to/images/replicant-6.0 
 tar -cjf 0001.tar.bz2 0001 
 # Upload the release to OSUOSL: 
 rsync -P -4 -ze ssh 0001.tar.bz2 
 # Unpack the release on OSUOSL, ensure permissions are correct and run the @trigger-replicant@ script 
 # Update [[ReplicantImages]] with the release 
 # Update each device's page with the release 
 # Update [[ReplicantStatus]] with the latest status 
 # Verify if other wiki pages need to be updated due to changes introduced by the release (e.g. [[Index#Replicant-build|build pages]] or [[ToolsInstallation]]) 
 # Announce the release on the blog 
 # Update the release on the website and IRC topic 


 h2. New device documentation 

 1. Create the device main page, following the naming guidelines applied to other devices (e.g. the Samsung Galaxy S II GT-I9100 is called *Galaxy S 2 (I9100)* and its page is [[GalaxyS2I9100]]) 
 2. Create all the related sub-pages (build guide, install guide and firmwares list at least), following the naming guidelines applied to other devices (e.g. [[GalaxyS2I9100Build]], [[GalaxyS2I9100Installation]] and [[GalaxyS2I9100LoadedFirmwares]]) 
 3. Link the sub-pages to the main page in the index 
 4. Update the [[ReplicantStatus]] page of the wiki with the current status of the device 
 5. Modify the [[Index]] page of the wiki and add the new device in the following sections: 
 * [[Index#Replicant-status|Replicant status]] 
 * [[Index#Replicant-installation|Replicant installation]] 
 * [[Index#Replicant-build|Replicant build]] 
 * [[Index#Supported-devices|Supported devices]] 

 6. Add new issues categories to the Replicant project Redmine 

 7. Add the device to the "Supported devices page": on the website