Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Page 1 of 2 12 LastLast
Results 1 to 25 of 47
Like Tree1Likes
  1. Thread Author  Thread Author    #1  

    Default [How-To] compile the Nexus S kernel from source

    android.git.kernel.org Git - kernel/samsung.git/summary

    If you're reading this, you're probably like me and love to mess with things until they break. Then fix them, and do it again. The Nexus S may not have an SDcard slot, and it may not be HSPA+, but if you like to hack and twist your phone into the shape you want, it's the phone to have.

    But where to start? That's what this post is all about -- getting a development computer up and running to build the Kernel source. There's lots of ways to get going, but we're going to stick to what Google recommends, and what has worked for me. If you're a bit more advanced, by all means change what you like, it's all about choice.

    The OS
    You're going to need a 64bit version of Linux. I recommend Ubuntu 10.10. Download it and install it on your development computer. Take the time to read some guides and get everything working, especially all your Internet tools and plug-ins. You'll need them. Once you have it set up, it's time to start development.

    You'll need some tools first.
    Sun/Oracle Java 6

    Code:
    sudo add-apt-repository ppa:sun-java-community-team/sun-java6
    sudo apt-get update
    sudo apt-get install sun-java6-jdk
    Next are the 32 bit headers

    Code:
    sudo apt-get install ia32-libs
    Next, some compilation tools

    Enable the multiverse repo (UbuntuGeek has a great tutorial, as well as many others. Bookmark it) and open your terminal. At the prompt, type:
    Code:
    sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
    this may take a while, it's a lot to download.

    Next, we want to install valgrind, for the inevitable bug tracking that we'll have to do:
    Code:
    sudo apt-get install valgrind
    Last edited by Jerry Hildenbrand; 01-21-2011 at 08:58 PM. Reason: new method due to changes in source
    ಠ_ಠ
    제리
    Thanked by 2:
    alicklee likes this.
  2. Thread Author  Thread Author    #2  

    Default

    Next, we need to set up our machine to pull and keep files up to date with Google's git repo. It's easier to do than you think:
    Code:
    $ cd ~
    $ mkdir bin
    Now make sure your ~/bin directory is in your PATH. Open your .bashrc file and add the following line at the end of the file:
    Code:
    PATH=$PATH:/home/*YOUR-USER-NAME*/bin
    export PATH
    Of course, substitute your user name above.

    Now download the repo script, and set permissions:
    Code:
    $ curl http://android.git.kernel.org/repo >~/bin/repo
    $ chmod a+x ~/bin/repo
    We need somewhere to put the files. Personally, I hate this naming convention, but that's what Android uses so we're going to use it too.
    Code:
    $ mkdir mydroid 
    $ cd mydroid 
    $ repo init -u git://android.git.kernel.org/platform/manifest.git
    When asked for your name and email, don't be shy. Open source is about sharing. Be sure to use a Gmail address, you'll need it if you ever contribute back.
    ಠ_ಠ
    제리
    Thanked by 2:
  3. Thread Author  Thread Author    #3  

    Default

    The long part is next -- getting all the code. It's really easy, but takes forever.

    Code:
    $ cd ~/mydroid
    $ repo sync
    Go make a sandwich, or take a walk, anything to pass the time it takes to download several Gigabytes of data from often slow servers. When it's done downloading, we're almost finished, we only have to import Google's gpg keys.

    Code:
    $ gpg --import
    then copy and paste the following into your terminal:
    Code:
    -----BEGIN PGP PUBLIC KEY BLOCK-----
    Version: GnuPG v1.4.2.2 (GNU/Linux)
    
    mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV 
    lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
    8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD 
    u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z 
    wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq 
    /HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
    jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
    MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
    b/aF/ygc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gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
    =Wi5D 
    -----END PGP PUBLIC KEY BLOCK-----
    Control + D will import and save it.

    That's it -- you're now ready to build both Android (AOSP), and custom kernels.
    Last edited by Jerry Hildenbrand; 12-14-2010 at 08:14 PM.
    ಠ_ಠ
    제리
    Thanked by 2:
  4. Thread Author  Thread Author    #4  

    Default

    Downloading the Nexus S kernel source

    As of today, the above isn't going to get you the Nexus S kernel source. That's easy to fix:

    Code:
    $ cd ~/mydroid
    $ git clone git://android.git.kernel.org/kernel/samsung.git
    Now you can go into that directory in your Android source tree:

    Code:
    $ cd ~/mydroid/samsung
    Now the building. Copy and paste these lines into your terminal. BE SURE TO EDIT YOUR EXPORT COMMAND WITH THE CORRECT PATH!

    Code:
    export PATH=$PATH:/home/<your username>/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/
    make ARCH=arm clean
    make ARCH=arm herring_defconfig
    make -j4 ARCH=arm CROSS_COMPILE=arm-eabi-
    This builds the kernel, as well as the wireless module. It takes a few minutes, depending on your computer. If it hasn't stopped and spit out an error, it's not done
    You find your kernel at:
    ~/mydroid/samsung/arch/arm/boot/zImage
    The wlan module is at:
    ~/mydroid/samsung/drivers/net/wireless/bcm4329/bcm4329.ko

    Next you need to package it up to test. I can't get a zImage to boot via fastboot on the NS, so you'll have to pack up a boot image. Download the attached file, and extract it. Put fastboot in your SDK/tools folder (if you don't have it) and place the unpack-bootimg.pl script and the mkbootimg binary into a folder in your home called NS-bootwork. Copy your zImage in there, too.

    Now pull the boot image from your phone, either via adb or from a terminal app:
    Code:
    cat /dev/mtd/mtd2 > /sdcard/boot.img
    Copy the boot.img from your Nexus S to your NS-bootwork folder, then it's time for more term c/p
    Code:
    cd ~/NS-bootwork
    ./unpack-bootimg.pl boot.img
    cd boot.img-ramdisk/
    find . | cpio -o -H newc | gzip > /home/<your username>/NS-bootwork/boot.img-ramdisk/ramdisk-repack.cpio.gz
    cd ..
    ./mkbootimg --kernel zImage --ramdisk /home/<your username>/NS-bootwork/boot.img-ramdisk/ramdisk-repack.cpio.gz --base 0x30000000 --pagesize 4096 -o newtestboot.img
    thanks to whoever originally created the unpack Perl script. If it was you, or you know who did, for the love of God let me know so I can thank them.

    Now to test it
    Take the newtestboot.img you just made, and put it in your SDK/tools folder. Shut your phone off, connect it to your computer, then hold volume up + power to enter fastboot. From the terminal (told you i love it)

    Code:
    cd ~/android-sdk-linux_86/tools
    sudo fastboot boot newtestboot.img
    <password>
    If it boots, you won't have Wifi because we haven't pushed the kernel module over yet. But take the time to open settings>about phone and admire your own kernel showing there. Smoke a cig, have a beer, whatever you need to do to celebrate. If it doesn't boot, just pull the battery and reboot. We only told the phone to boot this one time from your new image, and the next boot will have you back where you started.

    If it works well and you want to keep it, you need to put the bcm4329.ko (the kernel module) into /system/modules/. This will break wifi for any kernel except the one you have built, so only do it when you're ready to get final.

    Then just like before, we're going to use fastboot to copy it over, except this time we flash it permanently.
    Code:
    sudo fastboot flash boot newtestboot.img
    <password>
    If you wanna play around with the boot image, and don;t feel like building your own kernel, there's one right here: NS-kernel_build.tar.bz2

    Good luck!

    Putting this here so i don't lose it (courtesy of Swetland -- a mighty Googler)
    baseaddr 0x30000000
    pagesize 4096
    Attached Files Attached Files
    Last edited by Jerry Hildenbrand; 01-21-2011 at 08:56 PM.
    ಠ_ಠ
    제리
  5. Thread Author  Thread Author    #5  

    Default

    Quote Originally Posted by ragnarokx View Post
    Very interesting posts! I wish I was at a skill level to be able to use this stuff - maybe one day
    If you can copy paste, you can learn. And trust me, when you hit about phone and see your kernel running the show, it feels good
    ಠ_ಠ
    제리
  6. #6  
    serpico's Avatar

    Posts
    187 Posts
    Global Posts
    502 Global Posts

    Default

    I just want the skill to understand all this! Lol I always wanted to learn but hit hurdles when learning to code and quit.
  7. Thread Author  Thread Author    #7  

    Default

    Quote Originally Posted by Jon View Post
    I just want the skill to understand all this! Lol I always wanted to learn but hit hurdles when learning to code and quit.
    Jump on in. This stuff looks harder on paper (or lcd lol) than it really is. If enough of us get together, we can have a blast with this!
    ಠ_ಠ
    제리
  8. #8  

    Default what is it for

    Hey Jerry, I would love to do this, always wanted too. However I was wondering how we could use this? Do we have to have a Nexus S to make it useful, or can we do something with an existing phone, like an OG Droid for example...
    Thanks
  9. Thread Author  Thread Author    #9  

    Default

    Quote Originally Posted by bigbuss786 View Post
    Hey Jerry, I would love to do this, always wanted too. However I was wondering how we could use this? Do we have to have a Nexus S to make it useful, or can we do something with an existing phone, like an OG Droid for example...
    Thanks
    The first three posts (getting the computer set up) is exactly the same. I just stuck it here, because the Nexus S is what I'm going to be working with mostly.

    Go through the first 3 posts, then grab you some kernel source for your OG Droid. You'll be able to find some already overclocked and ready to go. Building it is the same process as we'll go through here -- the only difference will be your source code and packaging it for the phone (which we'll cover later)
    ಠ_ಠ
    제리
  10. #10  

    Default

    Quote Originally Posted by gbhil View Post
    If you can copy paste, you can learn. And trust me, when you hit about phone and see your kernel running the show, it feels good
    Alrighty then, I'll give it a shot. Time to dust off that old spare Macbook and get some dual boot action going! If only the source code for the Epic 2.2 kernel was out..
  11. #11  
    Darkshneider's Avatar

    Posts
    226 Posts
    ROM
    Stock

    Default

    Would be nice to work it into the Epic...
  12. #12  
    serpico's Avatar

    Posts
    187 Posts
    Global Posts
    502 Global Posts

    Default

    I've got an old Dell maybe two lol that I could put to use. Guess my nexus one will be similar as well.
  13. #13  
    jdkoreclipse's Avatar
    Banned

    Posts
    253 Posts
    ROM
    My roms (link in sig)

    Default

    One of the Samsung kernel Dev's last name is kang...what an awesome name

    Sent from my HTC Incredible using Tapatalk
  14. #14  
    bdotto14's Avatar

    Posts
    52 Posts
    Global Posts
    55 Global Posts
    ROM
    CyanogenMod 7.0.3

    Default

    I got an error message when I tried the command to get the JDK.

    E: Unable to locate package sun-java-5-jdk

    not sure why I got the error, I am on Ubuntu 10.10 because I couldn't get wireless to work with the suggested version of Ubuntu. Any help would be greatly appreciated
  15. #15  
    beezy's Avatar

    Posts
    2,457 Posts
    Global Posts
    2,458 Global Posts
    ROM
    Extra Crispy

    Default

    Just to help out cause you know I've had so much fun learning.
    After
    chmod a+x ~/bin/repo

    Might want to tell everyone to reboot or open new terminal,if not they will probably get bash repo errors.
    If i can think or run into anything else ill add what i find.
  16. #16  

    Default

    Thanks for this very illuminating article. Is there a conclusion to it somewhere. I set everything up but am unable to build. I get quite a few errors and make never ends.

    Thanks for any and all help

    The errors I get start with :
    ============================================
    PLATFORM_VERSION_CODENAME=AOSP
    PLATFORM_VERSION=AOSP
    TARGET_PRODUCT=full_crespo
    TARGET_BUILD_VARIANT=userdebug
    TARGET_SIMULATOR=false
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=arm
    TARGET_ARCH_VARIANT=armv7-a-neon
    HOST_ARCH=x86
    HOST_OS=linux
    HOST_BUILD_TYPE=release
    BUILD_ID=OPENMASTER

    build/core/binary.mk:323: target `out/target/product/crespo/obj/STATIC_LIBRARIES/libc_common_intermediates/arch-arm/syscalls/eventfd.o' given more than once in the same rule.
    find: `frameworks/base/frameworks/base/docs/html': No such file or directory
    find: `out/target/common/docs/gen': No such file or directory
    find: `frameworks/base/frameworks/base/docs/html': No such file or directory
    find: `out/target/common/docs/gen': No such file or directory
  17. #17  

    Default

    Quote Originally Posted by tl1720 View Post
    Thanks for this very illuminating article. Is there a conclusion to it somewhere. I set everything up but am unable to build. I get quite a few errors and make never ends.

    Thanks for any and all help

    The errors I get start with :
    ============================================
    PLATFORM_VERSION_CODENAME=AOSP
    PLATFORM_VERSION=AOSP
    TARGET_PRODUCT=full_crespo
    TARGET_BUILD_VARIANT=userdebug
    TARGET_SIMULATOR=false
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=arm
    TARGET_ARCH_VARIANT=armv7-a-neon
    HOST_ARCH=x86
    HOST_OS=linux
    HOST_BUILD_TYPE=release
    BUILD_ID=OPENMASTER

    build/core/binary.mk:323: target `out/target/product/crespo/obj/STATIC_LIBRARIES/libc_common_intermediates/arch-arm/syscalls/eventfd.o' given more than once in the same rule.
    find: `frameworks/base/frameworks/base/docs/html': No such file or directory
    find: `out/target/common/docs/gen': No such file or directory
    find: `frameworks/base/frameworks/base/docs/html': No such file or directory
    find: `out/target/common/docs/gen': No such file or directory
    I am also trying to figure out how to build this. Is there a config.gz in proc? There doesn't seem to be one in mine. My only problem is I don't know what the kernel configuration should be.

    Edit - It looks like you are trying to build the AOSP, not the kernel. I think this thread was about building the kernel??
  18. #18  

    Default Thanks

    I intended to build the kernel. Guess i got something wrong. Can someone please point out the steps to build the kernel after the environment is set up.

    Thanks
  19. Thread Author  Thread Author    #19  

    Default

    sorry guys. Google has changed the entire procedure, and while I can hack my way through it and make it work, I'm waiting on them to update their page with the new requirements and method.

    In the meantime, anyone interested should subscribe to the android-kernel mailing list and the android-building mailing list to take part in the discussion.

    It's likely going to be as easy as installing Sun-Java-6 and using the same methods --
    pull config from /proc
    make menuconfig
    make

    but I can;t say for sure what the recommended methods will be until we get them
    ಠ_ಠ
    제리
  20. #20  

    Default Thanks for the update

    Just in case it helps - apparently they have added the requirement of building on a 64 bit environ and Sun java 6. I created my set up on a 64 bit 10.04 which
    apparently is Google'w own build environment.

    Thanks for all the help.
  21. #21  

    Default

    Quote Originally Posted by gbhil View Post
    sorry guys. Google has changed the entire procedure, and while I can hack my way through it and make it work, I'm waiting on them to update their page with the new requirements and method.

    In the meantime, anyone interested should subscribe to the android-kernel mailing list and the android-building mailing list to take part in the discussion.

    It's likely going to be as easy as installing Sun-Java-6 and using the same methods --
    pull config from /proc
    make menuconfig
    make

    but I can;t say for sure what the recommended methods will be until we get them
    The config file does not exist in proc. See https://groups.google.com/d/topic/an...8zM/discussion to how to build. My problem is I get a access denied error when it tries to use the toolchain.
  22. #22  

    Default

    Quote Originally Posted by tl1720 View Post
    Just in case it helps - apparently they have added the requirement of building on a 64 bit environ and Sun java 6. I created my set up on a 64 bit 10.04 which
    apparently is Google'w own build environment.

    Thanks for all the help.
    Gingerbread requires a 64 bit environment and sun-java 6 as you noted above.

    So in short

    2.2 = 32 bit and sun java 5
    2.3 = 64 bit and sun java 6

    It's unreal how out of date their documentation is. Talking about costing a lot of people time and/or money.
  23. #23  

    Default

    This is something I am stuck for last 10 days. That is the source not compiling for gingerbread. This is all on 64 bit Ubuntu with Java 6.
  24. #24  

    Default

    I have at last successfully build gingerbread. I had followed the
    instructions at source.android.com and I was never able to compile the
    source.

    The reason was that I had the master branch as I did not mention -b
    gingerbread when I initialized repo using repo init.

    Then today I came across the post at
    Gingerbread is baked - Android Building | Google Groups
    by Jean-Baptiste M. "JBQ" Queru

    It gives the details about how you can switch from on branch to
    another. After I followed these instructions to switch to gingerbread
    then my make command worked like charm.

    Also you should follow find: `frameworks/base/frameworks/base/docs&#39;: No such file or directory - Android Building | Google Groups
    before running make command.

    Now the next step is using the result. Which is still something I
    don't know. So if someone can tell how to use the result of the
    compile then I will be very thankful to him.

    I believe I have to use system.img in some way. Also note that I want
    to use it in emulator I don't have an android phone with me.

    Regards,
    Asif
  25. Thread Author  Thread Author    #25  

    Default

    First two posts updated, with my own directions. Tired of waiting on Google.

    If the final instructions differ or work better, I'll update.
    ಠ_ಠ
    제리
    Thanked by 2:
Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions