Linux Tips Archives

How to Edit Android Kernels in Ubuntu

The Android kernel is derived from the Linux kernel. It relies on the core services of Linux, such as security, memory, network and process management. To make amendments to the Android core and include or unlock certain abilities, you must edit and compile your own Android kernel. The Ubuntu operating system is one of the best platforms to edit and compile Android kernels on, and it’s easy to install everything you need.

Instructions

  • 1

    Select “Accessories” from the main menu and click on “Terminal” to open the application. The Terminal is similar to the Windows Command Prompt.

  • 2

    Type the following in the Terminal and press “Enter” to install Java:

    sudo apt-get install sun-java5-jdk

    Use the password you use to log in to Ubuntu when you are asked for a password. This gives the application root privileges.

  • 3

    Run the following commands in the Terminal to install the rest of the tools required to edit Android kernels:

    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 valgrind

  • 4

    Create the required folder structure, get a copy of the Android repository script, and give full read and write access to the script by running these commands in the Terminal:

    cd /home/*your-user-name
    mkdir myandroid
    mkdir bin
    curl http://android.git.kernel.org/repo > ~/bin/repo
    chmod a+x ~/bin/repo

  • 5

    Go to the “myandroid” folder and download the Google tools and Android source, using the repository script you’ve downloaded earlier. Do this by running these commands in the Terminal:

    cd ~/myandroid
    ~/bin/repo init -u git://android.git.kernel.org/platform/manifest.git
    ~/bin/repo sync

  • 6

    Copy and paste the following command in the Terminal and press “Enter” to run it:

    echo “—–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/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
    aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
    cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
    gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
    2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
    QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
    hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
    C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
    LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+
    OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
    pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
    KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
    N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
    vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
    G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
    hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
    EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
    =Wi5D
    —–END PGP PUBLIC KEY BLOCK—–”> /tmp/android.gpg

  • 7

    Run the following commands in the Terminal to copy the key from the temporary file to the keyring and delete the temporary file:

    gpg –import < /tmp/android.gpg
    rm -rf /tmp/android.gpg

  • 8

    Open the Web browser and navigate to HTCDev’s Kernel Source Code page (see Resources). Click on the “Download” button next to the “HTC EVO Shift 4G (Sprint WWE) – MVNOCRC – 2.6.32 kernel source code” entry. Save the file on your desktop.

  • 9

    Run this command in the Terminal to create a new directory:

    mkdir ~/.EVO_Kernel_sources

  • 10

    Open Nautilus. Nautilus is similar to Windows Explorer. The Home Folder is displayed. Press “Ctrl” and “H” at the same time to see hidden folders. Click on the “EVO_Kernel_sources” folder you created earlier to open it.

  • 11

    Double-click on the source file you downloaded earlier to open the TAR archive. It contains a single folder; drag this folder from the archive to the “EVO_Kernel_sources” folder to extract it there.

  • 12

    Run these commands in the Terminal to create the folder structure for the Android build and create a link to the kernel source you just extracted:

    cd ~
    mkdir android
    cd android
    mkdir sources
    cd sources
    ln -s /home/*your_user_name*/.EVO_Kernel_sources/*Extracted_folder_name kernel

    Replace “your_user_name” with your real Ubuntu username and “Extracted_folder_name” with the name of the folder you extracted from the EVO Android source archive.

  • 13

    Connect the Android phone to your Ubuntu machine in data transfer mode using the USB cable. Run these commands in the Terminal to copy the Android main configuration file from the phone to the “/android/sources/kernel” folder:

    adb pull /proc/config.gz ~/android/sources/kernel/
    cd ~/android/sources/kernel/
    gunzip config.gz

  • 14

    Run these commands to edit the makefile of the Android Kernel and specify the tool-chain and compiler:

    cd ~/android/sources
    make clean
    export ARCH=arm
    export CROSS_COMPILE=arm-eabi-
    export PATH=$PATH:~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin

  • 15

    Run this command to start configuring the kernel options:

    make menuconfig

    Scroll to the bottom of the resulting window, select the “Load an Alternative Configuration File” option and press “Enter.” Enter this path to the config file in the box that pops up:

    /home/*your-user-name*/android/sources/kernel/config

    Press “Enter” again.

  • 16

    Select the make options from the menu to edit the Android kernel. It’s best to select only the “msm7k,” “ondemand” and “performance” as processor governors in the CPU Frequency scaling section. Check the “Kernel debugging” option in the Kernel Hacking section if your build is a test build. Enable the “Support for Host-side USB” and “USB Gadget Support” if you want to use USB devices. You can also add support for various network functions, such as IP tunneling and network privacy options, in the Networking Support section.

  • 17

    Close the configuration window and select “Yes” when prompted to save it. This action creates the hidden “.config” file inside the kernel directory.

  • 18

    Run these commands in the Terminal to insert the Wi-Fi module, and make and compile your custom Android kernel:

    make
    export KERNEL_DIR=~/android/sources/kernel
    cd ~/myandroid/system/wlan/ti/sta_dk_4_0_4_32/
    make clean
    make

 

Here is a workshop in Singapore on Android Apps

You can password protect a folder by adding a .htaccess file with the following lines:

Sometimes, when the password protected folder is a sub-directory and, the parent folder has a .htaccess file that uses the rewrite engine, you may get a 404 Page Not Found error when you browse the protected sub-folder. WordPress users will especially notice this when they try to password protect a sub-folder. One way to solve this issue is to add 2 lines to the beginning of the protected folder’s .htaccess file. So, the final file will look like this:

This should solve the page not found errors!

Incoming search terms:

  • magento password protect directory
  • password protect directory prestashop

Bandwidth limitation is still a problem for a lot of people who connect to the Internet.  Available bandwidth can be improved by installing Squid caching proxy server on the network with configuration parameters that will increase the byte hit rate, giving you about 30-60% more bandwidth.

Squid can be fine-tuned to satisfy a host of needs. The stable version has at least 249 configurable parameters. The heavily commented configuration file, usually found in /etc/squid.conf, is more than 4,600 lines long. This can be intimidating to even experienced administrators. All settings are to be modified in this file.

Convert Pdf Documents To Jpeg Images

If you want to convert your pdf document into a jpeg image, it is possible to use pdftoppm and after that ppmtojpeg.

First, choose your pdf document and use:

You will have one ppm image per pdf page. If you want only part of the document use -f int1 -l int2, int1 is the initial page and int2 is the final page.

Use the script to convert all ppm images into jpeg images:

You will have your pdf document into jpeg images.

Make Ubuntu sleep instead of hibernate

One of the few things you can’t easily configure in Ubuntu is the option to make the computer sleep instead of hibernate when idle for X minutes. Here’s how to do it:

1. Press Alt+F2.
2. Type: gconf-editor.
3. Press Enter.
4. Go to –> apps/gnome-power-manager/actions/critical_battery.
5. Change the value to whatever you wish. Possible values are hibernate, suspend, shutdown and nothing.

When you close the lid of your laptop and Ubuntu is running, the computer goes into Suspend mode. Same goes for chosing Hibernate from the shutdown menu, when the laptop goes into deep sleep and consumes less power. When resuming from these two states, Ubuntu will ask you for your password. If you’d like to get rid of this password field, you need to launch gconf-editor and navigate to apps > gnome-power-manager > lock. There you’ll find a checkbox for hibernate and one for suspend. Uncheck these and close the Configuration Editor. Next time you resume from Suspend and Hibernate, you won’t be prompted for a password.

You can still manually lock your screen before closing the lid by using Ctrl+Alt+L.

Regex to return only the file extension.

//Returns Only the File extension.

function get_file_extenstion($filename) {

if( !preg_match(‘/\./’, $filename) ) return ”;

return preg_replace(‘/^.*\./’, ”, $filename);

}

//Convert MM/DD/YYYY to YYYY-MM-DD. This format is useful if you want to insert into a MySQL date field.

//Returns File Name stripping off the characters after hyphen in a file name.

function file_hyphen_strip($filename){

return preg_replace(‘/\-[^-]*$/’, ”, $filename);

}

Incoming search terms:

  • titanium regular expression hypens

Notes on mod_rewrite for Apache

Apache’s mod_rewrite document, calls this module as “Swiss Army Knife of URL manipulation!”

 

mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs. Incoming URLs are checked against a series of rules. The rules contain a regular expression to detect a particular pattern. If the pattern is found in the URL, and the proper conditions are met, the pattern is replaced with a provided substitution string or action. This process continues until there are no more rules left or the process is explicitly told to stop.

 

Fig: mod_rewrite control flow.

 

Advantages

  1. mod_rewrite can be used to transform long and complex urls into user friendly or short urls.

    For eg. http://myrurl.php/customer.php?name=shan&id=4562&aadr=561

    Above url can be converted to a more user friendly one as,

    http://myurl.php/customer/shan

     

  2. Security enhancement.

    Consider the above example a potential hacker can try out different urls to hack into the system by giving different parameters and values passed to customer.php, using mod_rewrite we can prevent such threats.

     

    mod_rewrite can be enabled by uncommenting the line,

    LoadModule rewrite_module modules/mod\_rewrite.so

    in apache configuration file httpd.conf.

Page 1 of 212