├── README.md └── steps ├── SourceforgeUpload.md ├── StepFive.md ├── StepFour.md ├── StepOne.md ├── StepThree.md └── StepTwo.md /README.md: -------------------------------------------------------------------------------- 1 | # Build a ROM for your Device! 2 | 3 | If you already have these: 4 | * A linux Environment (Recommended : Ubuntu 20.04 LTS) 5 | * A decent Internet Connection (Better if it's a 1Mb/S plan at the least). Because ROM sources could be 16 GB approx. even when shallow cloned. 6 | * CPU: 4 core 8 thread is the bare minimum or else it takes an eternity to build 7 | * RAM: 8 GB Minimum (+ ZRAM + SWAP optional and it is better to have 16 Gigs of RAM afterall) 8 | * Storage: SSD is better and it will build if you have HDD too.. 250GB is a decent amount of space 9 | * Some Linux knowledge and Basic ideas about Git. 10 | * You need to have the TREES.. ( Device Tree , Kernel Tree {Or use a prebuilt one - not recommended} , Vendor Tree {And A Common Tree if available}) 11 | * A GitHub Account or a GitLab account! (Preferably with the trees forked/imported) 12 | 13 | *Yaay! You're ready to build 14 | 15 | # Steps: 16 | 17 | 1. [**Set Up a Build Environment**](https://github.com/AtlanPrime/customromguide/blob/master/steps/StepOne.md) 18 | 2. [**Downloading a ROM Source**](https://github.com/AtlanPrime/customromguide/blob/master/steps/StepTwo.md) 19 | 3. [**Know your Device sources aka Tree**](https://github.com/AtlanPrime/customromguide/blob/master/steps/StepThree.md) 20 | 4. [**Basic Bringup and Sync device source**](https://github.com/AtlanPrime/customromguide/blob/master/steps/StepFour.md) 21 | 5. [**Lets build it!**](https://github.com/AtlanPrime/customromguide/blob/master/steps/StepFive.md) 22 | 6. [**Upload to SourceForge**](https://github.com/AtlanPrime/customromguide/blob/master/steps/SourceforgeUpload.md) 23 | 24 | 25 | With Love, 26 | @AtlanPrime 27 | -------------------------------------------------------------------------------- /steps/SourceforgeUpload.md: -------------------------------------------------------------------------------- 1 | # Upload to Sourceforge 2 | 3 | At first go to the rom output directory where the zip is present so that it is easier to upload from there 4 | ex: 5 | ```bash 6 | [baby@linux ~]$ cd rom/out/target/product/devicename 7 | * here if you do ls you can see the rom zip if compiled fully! 8 | ``` 9 | Secondly go to [SourceForge](https://sourceforge.net/) and create an account as well as a new project. Make sure you remember your 10 | * "Username: Your SourceForge.net Username" and 11 | * "Password: Your SourceForge.net Password" 12 | 13 | An example session might look like (where Username="baby", Project UNIX name="babyproject",Release dir is "folder1"): 14 | 15 | *Type in the following according to your username, project name, folder name 16 | ```bash 17 | [baby@linux ~]$ sftp baby@frs.sourceforge.net 18 | Connecting to frs.sourceforge.net... 19 | The authenticity of host 'frs.sourceforge.net (216.34.181.57)' can't be established. 20 | RSA key fingerprint is 68:b3:26:02:a0:07:e4:78:d4:ec:7f:2f:6a:4d:32:c5. 21 | Are you sure you want to continue connecting (yes/no)? yes 22 | Warning: Permanently added 'frs.sourceforge.net,216.34.181.57' (RSA) to the list of known hosts. 23 | jsmith@frs.sourceforge.net's password: 24 | sftp> cd /home/frs/project/babyproject/folder1 25 | sftp> put rom.zip 26 | Uploading rom.zip to /home/frs/project/babyproject/folder1/rom.zip 27 | rom.zip 100% 241 30.2MB/s 00:51 28 | sftp> exit 29 | ``` 30 | 31 | * i.e First type 32 | ```bash 33 | sftp baby@frs.sourceforge.net 34 | ``` 35 | * When asked for "Are you sure you want to continue connecting" type in "yes" 36 | * Type in your password when asked 37 | * You will be seeing this now 38 | ```bash 39 | Connected to frs.sourceforge.net. 40 | sftp> 41 | ``` 42 | * Now cd into your project location 43 | ```bash 44 | cd /home/frs/project/babyproject/ 45 | * here after the projectname you can add the folder name or else it'll directly be uploaded into the project root 46 | ``` 47 | * Now type put followed by the rom.zip name 48 | ```bash 49 | sftp> put rom.zip 50 | Uploading rom.zip to /home/frs/project/babyproject/rom.zip 51 | rom.zip 100% 241 30.2MB/s 00:51 52 | sftp> exit 53 | ``` 54 | 55 | There! Now you have uploaded your ROM to SF. 56 | It might take up to 10 Min to show up on the SF server. 57 | Be patient.. Enjoy!! 58 | -------------------------------------------------------------------------------- /steps/StepFive.md: -------------------------------------------------------------------------------- 1 | # Lets build it! 2 | 3 | Instructions to build are pretty straight and most of the time it's specified in the manifest (android- in case of lineageos) 4 | 5 | * First thing to do is set up build enviromnent 6 | 7 | ```bash 8 | . build/envsetup.sh 9 | ``` 10 | 11 | * Now we need to lunch 12 | 13 | "lunch lineage_$device-userdebug", 14 | "lunch lineage_$device-eng", 15 | "lunch lineage_$device-user" 16 | 17 | These are the three types of lunch commands.. 18 | "userdebug" is the normal lunch type for release builds 19 | "eng" is an even more deuggable version 20 | 21 | In our case we use userdebug, so 22 | 23 | ```bash 24 | lunch lineage_tulip-userdebug 25 | ``` 26 | 27 | * Now, to start building we use, 28 | 29 | ```bash 30 | mka bacon 31 | ``` 32 | 33 | # Now wait till the rom is compiled! 34 | # Happy Waiting! 35 | -------------------------------------------------------------------------------- /steps/StepFour.md: -------------------------------------------------------------------------------- 1 | # Basic Bringup and Sync device source 2 | 3 | Files to change for AOSP Android 10 Bringup 4 | * AndroidProducts.mk 5 | * romname_devicecodename.mk (eg: lineage_tulip.mk) 6 | 7 | Example Bringup Commits: 8 | 9 | Bringup for DU: 10 | https://github.com/AtlanPrime/decommonised_device_xiaomi_miatoll/commit/7077b40c32f45f730bbf3604375b5a8a7a1dc39b 11 | 12 | Here, all you have to do is edit the AndroidProducts.mk file and romname_devicecodename.mk according to 13 | the rom u want to build. 14 | Use the example commit as a reference 15 | 16 | We can either do the bringup locally on any low spec pc or after syncing the trees within the source too! 17 | 18 | for that clone the trees to the specific folders as shown in example below: 19 | 20 | ```bash 21 | #Enter the synced ROM's directory 22 | cd lineage 23 | 24 | #Clone the device tree 25 | git clone https://github.com/xiaomi-sdm660/android_device_xiaomi_tulip -b ten device/xiaomi/tulip 26 | 27 | here the text after "-b" defines the branch you want to clone, if no branch is specified 28 | the default branch will be synced and the text after branch name, "device//", 29 | specifies the location to clone it to. 30 | 31 | #Clone the common device tree if it exists 32 | git clone https://github.com/xiaomi-sdm660/android_device_xiaomi_sdm660-common -b ten device/xiaomi/sdm660-common 33 | 34 | #Clone the kernel tree 35 | git clone https://github.com/xiaomi-sdm660/android_kernel_xiaomi_sdm660 -b 10.0-eas kernel/xiaomi/sdm660 36 | 37 | #Clone the vendor tree 38 | Sometimes devs decides to put the common vendor tree and vendor tree in a single repo.. 39 | so it would be vendor_xiaomi.. 40 | but in this specific case we have the vendor and the common vendor tree as seperate repos so.. 41 | 42 | git clone https://github.com/xiaomi-sdm660/android_vendor_xiaomi_sdm660-common vendor/xiaomi/sdm660-common 43 | 44 | git clone https://github.com/xiaomi-sdm660/android_vendor_xiaomi_tulip vendor/xiaomi/tulip 45 | 46 | notice that I did not specify branches here, because the default one will be synced! 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /steps/StepOne.md: -------------------------------------------------------------------------------- 1 | #Set Up a Build Environment 2 | 3 | * A) The Way I do.. 4 | 5 | 6 | ```bash 7 | # get superuser access. 8 | sudo su 9 | 10 | # install JDK 11 | add-apt-repository ppa:openjdk-r/ppa 12 | 13 | # update all packages. 14 | apt-get update 15 | 16 | # install Java packages. 17 | apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig 18 | 19 | # become a normal user. 20 | exit 21 | 22 | # creating a bin folder and setting up AkhilNarang Script. 23 | 24 | mkdir ~/bin 25 | 26 | PATH=~/bin:$PATH 27 | 28 | cd ~/bin 29 | 30 | curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 31 | 32 | chmod a+x ~/bin/repo 33 | 34 | git clone https://github.com/akhilnarang/scripts.git scripts 35 | 36 | cd scripts 37 | 38 | bash setup/android_build_env.sh 39 | ``` 40 | 41 | * B) The AOSP way to do.. 42 | 43 | https://source.android.com/setup/build/initializing 44 | -------------------------------------------------------------------------------- /steps/StepThree.md: -------------------------------------------------------------------------------- 1 | * Device sources aka Trees 2 | 3 | So, you probably downloaded the rom sources and set your git id. Well the next step is to find your device sources (Device Tree , Kernel Tree , Vendor Tree {And A Common Tree if available for both vendor and device}) 4 | 5 | * The prerequisites are: 6 | 7 | - to know your device code name 8 | - to know what platform it is (would make it easier to find the common trees) 9 | - to know if the trees are readily avialable (for most xiaomi/oneplus/etc.. devices its a true case scenario) 10 | - to clone them to your github account so that u can do a bringup of the tree for the ROM 11 | 12 | Here is an example device ( Redmi Note 6 Pro ) 13 | 14 | > Code Name: tulip, SoC: Snapdragon 636, Platform: SDM660 15 | 16 | Here, the common tree for tulip is sdm660-common (this exists for thr vendor too). 17 | Also, the trees are avialable in the following orgs 18 | - https://GitHub.com/Xiaomi-SDM660 19 | - https://GitHub.com/Xiaomi-SDM660-Devs 20 | 21 | Now, tulip is not the only device with the SDM660 platform. 22 | Devices like Whyred (Redmi Note 5/Pro), Wayne/Jasmine (Mi 6x/Mi A2) etc are also belonging to the SDM660 Platform. 23 | The only thing u need to be aware of is the manufacturer because motorola, nokia, etc.. also has SDM660 Platform devices.. 24 | 25 | Examples of Other Platforms are SDM660 SM6150 SM6250 SM8150 SM8250 SD845 etc... 26 | -------------------------------------------------------------------------------- /steps/StepTwo.md: -------------------------------------------------------------------------------- 1 | #Downloading a ROM Source 2 | 3 | * This is important to do before cloning the device specific trees 4 | 5 | But before that we need to configure our git as shown below 6 | Open the command line. 7 | Set your username: 8 | ```bash 9 | git config --global user.name "FIRST_NAME LAST_NAME" 10 | ``` 11 | Set your email address: 12 | ```bash 13 | git config --global user.email "MY_NAME@example.com" 14 | ``` 15 | Some Popular ROMs 16 | 17 | * [**DirtyUnicorns**](https://github.com/DirtyUnicorns) 18 | * [**LineageOS**](https://github.com/LineageOS) 19 | * [**AOSPA**](https://github.com/AOSPA) 20 | 21 | Now find the GitHub org of the ROM you need to build and sync it like shown below 22 | 23 | ```bash 24 | # we need to make a folder for the ROM first (Example LineageOS) 25 | mkdir Lineage 26 | 27 | # Connect your Github account. 28 | git config --global user.name "FIRST_NAME LAST_NAME" git config --global user.email "YOUR EMAIL" 29 | 30 | # Go to ROM folder. 31 | cd lineage 32 | 33 | # Now we need to initialize LineageOS Source 34 | # For that, go the LineageOS git and find the manifest (https://github.com/LineageOS/android this may vary from ROM to ROM) 35 | # Choose the Branch (this is actually the version of android) 36 | # Let's choose Android 10, so as an example the branch here would be "lineage-17.1" 37 | 38 | # So it goes like: 39 | repo init -u git://github.com/LineageOS/android.git -b lineage-17.1 40 | 41 | # As an alternative you can do a shallow clone to reduce size of the source.. 42 | # A Shallow Clone only clones the source with the last commit history specified 43 | 44 | repo init --depth=1 -u git://github.com/LineageOS/android.git -b lineage-17.1 45 | 46 | 47 | # And to Sync it 48 | repo sync 49 | ``` 50 | 51 | This would actually depend on your internet speed.. the size of the LineageOS repo would be around 60GB or more, probably 52 | --------------------------------------------------------------------------------