• Login:

Welcome to the Toshiba Thrive Forum.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Page 1 of 7 123 ... LastLast
Results 1 to 10 of 65
Like Tree27Likes

Thread: [HOW-TO] Set up a build environment for CM10

  1. #1
    Developer

    Member #
    3341
    Join Date
    Sep 2011
    Posts
    262
    Liked
    147 times

    [GUIDE] Build and Debug CM10 for THRiVE

    In the interest of getting more people involved in this project, I'm going to write up a basic how-to for setting up a build environment to compile CM10 for the THRiVE and give some tips for debugging issues. I will assume a basic knowledge of the linux shell prompt, but don't let that scare you away. I'm going to be providing a few scripts that I use to make some common tasks easier.


    I. Requirements

    • Ubuntu 12.04 x64
    This tutorial is going to be based on Ubuntu 12.04, which is the current LTS (Long-term Support) version of Ubuntu. You must also have a 64 bit system to build the source code. If you are currently running Windows, you have a couple of options:

    Dual Booting

    I recommend this method, as it gives the Ubuntu OS full access to your system resources, which results in faster build times. There's a couple ways to do this. You can install Ubuntu as a Windows program, which is the easiest way and allows for easy removal of Ubuntu should you no longer need it. Otherwise, you can partition your hard drive and run Ubuntu on a separate partition. Either way, it can be downloaded from this page. The big "Start Download" button will download a disc image of Ubuntu which can be burned to a DVD. Once you boot into this live installation, you can use the installation wizard to partition your hard drive and install Ubuntu. Otherwise, you can click "Windows Installer" to install it as a Windows program. This is the easiest way to install it

    Virtual Machine

    If you don't want to dual-boot Ubuntu alongside Windows, you can use it inside a virtual machine. My favorite virtualization program is VMware Player, which can be downloaded here. Once you download and install it, you'll want to download the disc image of Ubuntu from the link above. Create a new virtual machine, then boot from the disc image you just downloaded. Then proceed to install Ubuntu using the wizard from the live installation.
    • Required Packages & Programs
    In order to build Android, your system needs a bunch of packages. I got this list from this guide. Run the following commands in a shell prompt:

    Code:
    sudo apt-get install git-core gnupg flex bison python rar original-awk gawk p7zip-full gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool
    sudo apt-get install libc6-dev x11proto-core-dev libx11-dev libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils
    sudo apt-get install g++-multilib lib32z1-dev ia32-libs lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib g++-multilib
    ADB, fastboot, and repo

    I have, so far, not needed to install the android SDK. Instead I have just copied the adb and fastboot executables to /bin. Here is an archive with both the tools. You'll also need repo to download the CM10 source code. To install these files, download the archive, extract it, and then run the following code:

    Code:
    sudo cp <path_to_extracted_archive>/adb /bin
    sudo chmod 0755 /bin/adb
    sudo cp <path_to_extracted_archive>/fastboot /bin
    sudo chmod 0755 /bin/fastboot
    sudo curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > /bin/repo
    sudo chmod 0755 /bin/repo
    • CyanogenMod 10 Source Code
    Now that we have all the needed packages and tools, we can download the CM10 source code. This part will take a while-- the source is ~ 10gb. Pick a folder to house all of your THRiVE development files, then make a folder inside that for the CM10 source code. For example, my development folder is /media/Storage/dev, and my source code folder is /media/Storage/dev/CM10_SOURCE. I'll use these in my examples. So the code to make the folders and set up the source code repository would be the following:

    Code:
    mkdir /media/Storage/dev
    mkdir /media/Storage/dev/CM10_SOURCE
    cd /media/Storage/dev/CM10_SOURCE
    repo init -u git://github.com/CyanogenMod/android.git -b jellybean
    Then, you're ready to download the source code:

    Code:
    repo sync -j16
    If you have trouble downloading the source code, you can change -j16 to a lower number or get rid of it altogether (e.g. repo sync -j5 or simply repo sync). This will use fewer threads when downloading, which means your download speed will be a little slower.


    II. The first build

    From here on, <dev> will refer to your development folder and <src> will refer to your CM10 source code folder. (In my example above, <dev> would be /media/Storage/dev and <src> would be /media/Storage/dev/CM10_SOURCE.)

    • Downloading the device and vendor trees for the THRiVE
    The next thing you're going to want to do is to download the device and vendor trees from my github. I keep a separate directory called github that I use to stage my device and vendor trees when I want to sync them. I'll show you how to do the same (though you won't be able to sync the changes up to github).

    The following code will set up these directories and download the device and vendor trees.

    Code:
    mkdir <dev>/github
    cd
    Code:
     <dev>/github
    git clone git://github.com/nothingisdead/tostab03_device_cm10.git
    git clone git://github.com/nothingisdead/tostab03_vendor_cm10.git
    You should now have the folders <dev>/github/tostab03_device_cm10 and <dev>/github/tostab03_vendor_cm10 with the device and vendor trees inside. You will now copy these trees to your CM10 source code folder. Create the following folders inside your source code directory: device/toshiba/tostab03 and vendor/toshiba/tostab03. Then copy the files inside <dev>/github/tostab03_device_cm10 to <src>/device/toshiba/tostab03 and the files inside <dev>/github/tostab03_vendor_cm10 to <src>/vendor/toshiba/tostab03. If you want to do it programmatically, execute the following code (you should be in <dev>/github):

    Code:
    mkdir ../CM10_SOURCE/device/toshiba
    mkdir ../CM10_SOURCE/device/toshiba/tostab03
    cp -r tostab03_device_cm10/* ../CM10_SOURCE/device/toshiba/tostab03
    mkdir ../CM10_SOURCE/vendor/toshiba
    mkdir ../CM10_SOURCE/vendor/toshiba/tostab03
    cp -r tostab03_vendor_cm10/* ../CM10_SOURCE/vendor/toshiba/tostab03
    You also need to run a script to download some prebuilt CyanogenMod vendor files. Run the following code:

    Code:
    cd <src>/vendor/cm
    ./get-prebuilts
    • Downloading my build scripts
    I've made a few scripts to make my life easier and save myself a few keystrokes. You can download them here. Extract these files to your <src> folder. Here's what they do:

    rebuild.sh

    First, this script creates a list of "proprietary" files to be copied to the device after the build. I don't really use this setup correctly, which I should probably fix in the future. Right now, I'm running a script to tell the build system to copy all the files in <src>/vendor/toshiba/tostab03/proprietary to the system directory after building. This is a convenient way for me to add prebuilt binaries just by dropping them in that folder, however, it's not really what the vendor folder was designed for. I may change this in the future, but it's not a high priority for me.

    Then, it sets up the build environment and starts the build. This is a handy script to run anytime you want to test a change you've made in the device and/or vendor trees.

    flashboot.sh

    This script uses fastboot to flash the compiled boot image to the device. It's handy to use when you've made changes to the boot image but don't want to re-flash the entire ROM.

    install_update.sh

    This script uses adb to delete the update archive from the external sd, copy the new one over, and reboot into recovery mode so you can install the ROM.


    Note: You may have to set permissions on the scripts to allow them to be executed after extracting them. To do this, right-click the script file and click "Properties." On the "Permissions" tab, check the box that says "Allow executing file as program."
    • Building the ROM
    You're finally ready to build the ROM. This should be self-explanatory after the last step, but to build the ROM, just run rebuild.sh from the <src> folder. This step will take the longest. I have a Core i5-2400 with 16gb of RAM and an SSD, and it still takes me more than an hour to do a clean build. Don't worry, the consecutive builds should only take a couple minutes. However, I recommend running a clean build every few days (or whenever you run into major issues). Sometimes the build system doesn't pick up changes you've made, and a clean build is the best way to make sure your ROM is up to date with your code. You can run a clean build by running make clean from the <src> folder, then running the rebuild.sh script again.

    Note: The rebuild.sh script contains the following command: brunch cm_tostab03-userdebug -j8. Just like the command for downloading the source, the "-j8" argument defines the number of threads that are used. You can change this to optimize the script for your system. A guideline that I use (can't remember where I read it) is to use twice the number of cores in your CPU.
    • Testing the ROM
    Now that you've (hopefully) successfully built the ROM, it's time to test it out. The ROM is located at <src>/out/target/product/tostab03/cm_tostab03-ota-eng.gandhi.zip and there is an optimized version at <src>/out/target/product/tostab03/cm-10-<date>-UNOFFICIAL-tostab03.zip. If you're familiar with flashing ROMs already, which hopefully you are, you can copy these to your SD card and flash them in ClockworkMod Recovery. You can also use the install_update.sh script to copy it over.

    III. Debugging

    This section is going to be fairly short, but hopefully it will be helpful as a starting point for debugging issues in the ROM.


    • logcat
    logcat is the single most useful utility in debugging issues. It outputs the contents of the Android system log. To use it, just run adb shell logcat or adb shell logcat > <dev>/logs/logcat.log to record the log to a file that you can search with a text editor.
    • dmesg
    The dmesg command outputs the content of the kernel message buffer. These messages are slightly more cryptic than logcat, but can be helpful in figuring out driver and module issues.
    • logwrapper
    The logwrapper command is useful when debugging services and libraries. If you add /system/bin/logwrapper to the beginning of a service definition in the init.antares.rc file, it will log more messages and output to the system log, which can then be read with logcat.
    • strace
    strace is similar to logwrapper, but it outputs the messages to a file. The syntax goes like this:

    Code:
    /system/xbin/strace -tt -o/data/local/tmp/<service>.log /system/bin/<service> arg1 arg2
    Then the log can be read by viewing /data/local/tmp/<service>.log. strace is also very cryptic, but it has helped me to find missing libraries and other things.


    -------------------------------------------------------------------------------------------------------------------------------------


    Thanks for reading, and I hope this guide has been enlightening in your journey into ROM development! If you find any mistakes or confusing sections, feel free to reply with your suggestions for changes!
    Last edited by tybar; 09-12-2012 at 10:08 AM. Reason: added suggestions from HeWhoWas

  2. Ads


  3. #2
    Developer

    Member #
    3341
    Join Date
    Sep 2011
    Posts
    262
    Liked
    147 times
    Okay, I'm done. Please let me know if this guide helps you!

  4. #3
    Thrive Conveyor
    Member #
    3387
    Join Date
    Sep 2011
    Location
    Surprise, AZ
    Posts
    383
    Liked
    35 times
    This sounds like fun, but I find it easy to imagine that my old 32bit windows xp home edition, DELL 4600 Pentium 4, 3.02 hyperthreading Northwood Processor with 4gb of PC2700 RAM is not the workhorse needed to do a project like this, huh?

    I have done much to keep my 10 year old computer running and it works great for simple tasks, but I have been too cheap to invest in a modern computer since I have found a way to get mine to do all the basic tasks I use it for.

    I have the ability to dualboot and plenty of hard drive space. Just for the heck of it I have tried about 8 different versions of linux distro's including ubuntu 12.04, but I never had any real use for it outside of just learning and experimenting with a new technology. I have had success at dual booting stuff...

    So I have to ask, if my only real experience is messing with my personal pc (as described above), rooting a few android devices, flashing some roms... is this a project I'm likely to have any success with? Besides my own personal knowledge limitations, is my pc even capable of doing these tasks with some assurance of success?

    Regardless of me and my own little world, Thank You for taking the time to do this and trying to teach us how to do this type of work...

    "feed a man a fish, he eats for a day. teach a man to fish, he eats for life." I like your style for putting this out there. Since android is open source, you truly never know when the next eager beaver is going to come up with something great to add to the collective knowledge for the system..

    I would love to pull this stuff off with some level of success.
    Last edited by dandroid7; 08-29-2012 at 10:42 PM.
    THRiVE 16gb
    CM10 Jellybean 4.1.2 (built from source with pio_masaki's trees and kernel)
    TWRP Recovery (built by pio_masaki)
    GL2SD
    128gb Lexar 400x UHS-i Class 10 SDXC Card

  5. #4
    Thrive Informant
    Member #
    5165
    Join Date
    Nov 2011
    Posts
    47
    Liked
    7 times
    Looks like a good guide. I have done everything up to building without a problem. I will probably run a build this weekend and see if it works for me (Linux Mint 13). Mine isn't exactly a robust computer, spent more money on everyone else's machines than my own, but it will get the job done.

    I'll let you know how it goes.

  6. #5
    Thrive Conveyor
    Member #
    3387
    Join Date
    Sep 2011
    Location
    Surprise, AZ
    Posts
    383
    Liked
    35 times
    so, to keep things simple I did the windows installer for ubuntu 12.04 rather than doing the live cd as i have done in the past...I now have ubuntu 12.04 running on my system as dual boot again.

    do you know if the WUBI (windows ubuntu installer) installs the 32 bit version by default?

    I noticed you reference using 64bit stuff in your instructions in Section 1 - ADB, FASTBOOT, AND REPO section above. What needs to be done differently if one is running 32bit and not 64bit ubuntu 12.04?
    Last edited by dandroid7; 08-30-2012 at 04:09 PM.
    THRiVE 16gb
    CM10 Jellybean 4.1.2 (built from source with pio_masaki's trees and kernel)
    TWRP Recovery (built by pio_masaki)
    GL2SD
    128gb Lexar 400x UHS-i Class 10 SDXC Card

  7. #6
    Developer

    Member #
    3341
    Join Date
    Sep 2011
    Posts
    262
    Liked
    147 times
    Quote Originally Posted by dandroid7 View Post
    So I have to ask, if my only real experience is messing with my personal pc (as described above), rooting a few android devices, flashing some roms... is this a project I'm likely to have any success with? Besides my own personal knowledge limitations, is my pc even capable of doing these tasks with some assurance of success?
    I wouldn't let that stop you. Basically you're going to have to be very patient with the first build. Just let it run overnight or something. Your computer can do it, it will just take a while. If you have the patience, go for it! Also, that was my only experience before I began, well, developing. It helped me a little knowing a few computer languages, but honestly it's more about problem-solving skills and enjoying a good challenge.

    Quote Originally Posted by dandroid7 View Post
    so, to keep things simple I did the windows installer for ubuntu 12.04 rather than doing the live cd as i have done in the past...I now have ubuntu 12.04 running on my system as dual boot again.

    do you know if the WUBI (windows ubuntu installer) installs the 32 bit version by default?

    I noticed you reference using 64bit stuff in your instructions in Section 1 - ADB, FASTBOOT, AND REPO section above. What needs to be done differently if one is running 32bit and not 64bit ubuntu 12.04?
    I actually think those are 32-bit binaries. Truth is, I can't remember where I got them and I don't have a 32-bit machine to test them on. They should work. If not, let me know and I'll find the right tools. I think the WUBI defaults to 64-bit if your processor supports it. I'm basing that on the screenshots here.

  8. #7
    Thrive Informant
    Member #
    14664
    Join Date
    May 2012
    Posts
    34
    Liked
    1 times
    Note to everyone: Do not try and symlink the device and vendor files like I did. It does not work and will produce non-obvious errors that lead you to run around in circles until you try it without the links.

    Tybar - You also need to run /vendor/cm/get-prebuilts.sh prior to running your rebuild.sh script, otherwise you get errors relating to ROMManager.apk
    Last edited by HeWhoWas; 08-30-2012 at 07:24 PM.

  9. #8
    Thrive Informant
    Member #
    14664
    Join Date
    May 2012
    Posts
    34
    Liked
    1 times
    Quote Originally Posted by dandroid7 View Post
    so, to keep things simple I did the windows installer for ubuntu 12.04 rather than doing the live cd as i have done in the past...I now have ubuntu 12.04 running on my system as dual boot again.

    do you know if the WUBI (windows ubuntu installer) installs the 32 bit version by default?

    I noticed you reference using 64bit stuff in your instructions in Section 1 - ADB, FASTBOOT, AND REPO section above. What needs to be done differently if one is running 32bit and not 64bit ubuntu 12.04?
    You cannot build JellyBean with Ubuntu x86. You must have the x64 edition. Also make sure that you have at least 30-40GB free on your build partition.

  10. #9
    Thrive Conveyor
    Member #
    3387
    Join Date
    Sep 2011
    Location
    Surprise, AZ
    Posts
    383
    Liked
    35 times
    Quote Originally Posted by HeWhoWas View Post
    You cannot build JellyBean with Ubuntu x86. You must have the x64 edition. Also make sure that you have at least 30-40GB free on your build partition.
    So it seems as if my antiquated computer will not work for this. If i understand the technology correctly, my pentium 4 processor is x86 based and therefore not capable of running the 64 bit version of ubuntu?

    In terminal, i have run "cat /proc/cpuinfo" and also "grep flags /proc/cpuinfo" and both seem to confirm i am running a 32 bit processor. In neither instance do I see an "lm" in the "flags" section which apparently indicates "long mode" which refers to 64bit processors.

    I guess the world will never know of the genius i was to become... i will now be forced to give up my career in developing due to this setback with my computer hardware. ;-) My dreams of changing the world one android device at a time has apparently been dashed on the rocky shores of reality. Maybe someday in the future i will step into the new milenium and get a better computer?
    Last edited by dandroid7; 08-30-2012 at 11:26 PM.
    HeWhoWas and jorge505 like this.
    THRiVE 16gb
    CM10 Jellybean 4.1.2 (built from source with pio_masaki's trees and kernel)
    TWRP Recovery (built by pio_masaki)
    GL2SD
    128gb Lexar 400x UHS-i Class 10 SDXC Card

  11. #10
    Thrive Informant
    Member #
    14664
    Join Date
    May 2012
    Posts
    34
    Liked
    1 times
    Quote Originally Posted by dandroid7 View Post
    So it seems as if my antiquated computer will not work for this. If i understand the technology correctly, my pentium 4 processor is x86 based and therefore not capable of running the 64 bit version of ubuntu?

    In terminal, i have run "cat /proc/cpuinfo" and also "grep flags /proc/cpuinfo" and both seem to confirm i am running a 32 bit processor. In neither instance do I see an "lm" in the "flags" section which apparently indicates "long mode" which refers to 64bit processors.

    I guess the world will never know of the genius i was to become... i will now be forced to give up my career in developing due to this setback with my computer hardware. ;-) My dreams of changing the world one android device at a time has apparently been dashed on the rocky shores of reality. Maybe someday in the future i will step into the new milenium and get a better computer?
    Unfortunately yes :-( You can pick up an uber cheap rig for around $100-$150 if you have the monitor/hdd/odd, etc that would handle it though. On the other hand, you appear to have a flair for the dramatic description so perhaps fiction novels would be worth a shot as well :-P
    Last edited by HeWhoWas; 08-31-2012 at 01:34 AM. Reason: Dolla Dolla.


 
Page 1 of 7 123 ... LastLast


Remove Ads

Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

build cm10 for emulator
,
build cm10 from source
,
build cm10 with ics prebuilt kernel
,
cm10 hdmi setup
,

cm10 repo

,

compile cm10

,

compile cm10 from source

,

compile cm10 from source ubuntu 12.04

,

cyanogenmod build environment

,
environment for cm10
,
git-repo cm10
,

how to build cm 10

,
setting environment for build cyanogenmod
,
setting up cm10.2 development environment
,
ubuntu compile cm10.1
Click on a term to search our site for related topics.