How to regenerate bionic/libc/common/kernel headers for linux kernel v2.6.30

by Elvis Dowson » Thu, 23 Jul 2009 20:35:50 GMT


Sponsored Links
 i,
I'm working on trying to port android to linux-omap-2.6.30
kernel version. I've managed to successfully compile the kernel image.
When performing the port to a new kernel version, the bionic/libc
headers also require an update to linux kernel 2.6.30.

I was wondering if someone would be able to validate the changes and
modifications that I have made so far, and suggest some better fixes,
for example, I've had to disable boot animation, to get the
compilation to proceed, due to a linker error. Since this is a first
iteration, at this port, I thought it was acceptable just to try to
see how far it goes. I haven't tested it yet, but was wondering if
someone would be interested in trying this out in parallel, and get
android 1.5 SDK running on android-2.6.30 kernel version.

The reason for attempting this is to update the kernel version for the
gumstix overo, to better take advantage of the power management
functionality currently under development in kevin hilman's linux-omap-
pm pm branch.

Best regards,

Elvis

Technote android-2.6.30-001: How to regenerate bionic/libc/common/
kernel headers for linux kernel v2.6.30

Overview

This document describes how to update the android/bionic/libc/kernel
headers to linux kernel v2.6.30.

Procedure

Step 01.00: Backup the existing android/bionic/libc folder.

You will need the following header files from the existing v2.6.29
linux kernel headers at a later step:

android-alarm.h
android-pmem.h
android_power.h
ashmem.h
binder.h
msm_adsp.h
msm_audio.h
msm_mdp.h
keychord.h

Step 02.00: Clean up the existing android/bionic/libc/kernel folder.

Delete the contents of the following folders

android/bionic/libc/kernel/arch-arm
android/bionic/libc/kernel/arch-x86
android/bionic/libc/kernel/common

Step 03.00: Copy the required linux kernel v2.6.30 headers to the
android/bionic/libc/kernel/original folder.

[TODO: Insert steps on how to clone linux-omap-2.6 git repository and
switch to the omap-2.6.30 branch].

Copy the contents of the following folder to the specific target
location:

linux-omap-2.6/include/asm-generic to android/bionic/libc/kernel/
original/
linux-omap-2.6/include/linux to android/bionic/libc/kernel/original/
linux-omap-2.6/include/mtd to android/bionic/libc/kernel/original/

Step 04.00: Generate the clean linux headers.

Run the tools/update_all.py script to generate the clean linux
headers.

$ cd android/bionic/libc/kernel
$ tools/update_all.py

This will generate the headers into the android/bionic/libc/kernel/
common folder.

Step 05.00: Copy the following headers from the backup v2.6.29 bionic/
libc/kernel/common/linux folder to the new android/bionic/libc/kernel/
common/linux folder.

android-alarm.h
android-pmem.h
android_power.h
ashmem.h
binder.h
msm_adsp.h
msm_audio.h
msm_mdp.h
keychord.h

Step 06.00: Copy the architecture-specific headers.

Copy the contents of the architecture-specific asm folders to the
following target location:

linux-omap-2.6/arch/arm/include/asm to android/bionic/libc/kernel/arch-
arm/
linux-omap-2.6/arch/x86/include/asm to android/bionic/libc/kernel/arch-
x86/

Step 07.00: Delete the contents of the android/out folder.


Step 08.00: Build the android sdk.

$ cd android
$ make -j4

Step 09.00: Apply the following patches for the errors that pop up
during the build process.


Fixes for errors that can come up during compilation




Other Threads

1. Faster "Canvas.drawLine()" for rectangular lines?

Hello,

I'm developing a SurfaceView based, vector-styled game, so I'm using
Canvas.drawLine(startX, startY, stopX, stopY, Paint) very often. All
those lines are rectangular (startX=stopX or startY=stopY).
The TraceViewer shows me, that more than 50% of time are used to draw
those lines (about 100 per frame).

I read that drawLine is pretty slow on Android but I didn't find any
suggestions for an alternative.
What could be a faster method for this special case? I wouldn't need
the Bresenham algorithm for example, which drawLine will use I guess.

Any suggestions?
(Besides 'use openGL', as it's too late for that)

Regards, F Heft

PS: If anyone's interested: The game still runs with a sufficient
frame rate, but I want to improve wherever I can :)
--~--~---------~--~----~------------~-------~--~----~

2. how to add a line drawing to ListView?

When I try extending the View class to a subclass that will underline
portions of the text drawn by ListView, the code compiles okay but
results in a runtime exception apparently due to an improper class
cast.  Does anyone see what I've done wrong or have suggestions about
getting access to the Canvas of ListView items so portions of text can
be underlined?

Here is the code, which is the Efficient Adapter View/List example
from ApiDemos with an added UnderlinedView class.

- - -

/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.apis.view;

import android.app.ListActivity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Demonstrates how to write an efficient list adapter. The adapter
used in this example binds
 * to an ImageView and to a TextView for each row in the list.
 *
 * To work efficiently the adapter implemented here uses two
techniques:
 * - It reuses the convertView passed to getView() to avoid inflating
View when it is not necessary
 * - It uses the ViewHolder pattern to avoid calling findViewById()
when it is not necessary
 *
 * The ViewHolder pattern consists in storing a data structure in the
tag of the view returned by
 * getView(). This data structures contains references to the views we
want to bind data to, thus
 * avoiding calls to findViewById() every time getView() is invoked.
 */
public class List14 extends ListActivity {

        private static class UnderlinedView extends View {
                public UnderlinedView(Context context) {
                        super(context);
                }
                public UnderlinedView(Context context, AttributeSet as) {
                        super(context, as);
                }
                public UnderlinedView(Context context, AttributeSet as, int i) {
                        super(context, as, i);
                }
            @Override
            protected void onDraw(Canvas canvas) {
                super.onDraw(canvas);

                // Would like to do some line drawing here (e.g., underlining
portions of text)
            }
        }

    private static class EfficientAdapter extends BaseAdapter {
        private LayoutInflater mInflater;
        private Bitmap mIcon1;
        private Bitmap mIcon2;

        public EfficientAdapter(Context context) {
            // Cache the LayoutInflate to avoid asking for a new one
each time.
            mInflater = LayoutInflater.from(context);

            // Icons bound to the rows.
            mIcon1 = BitmapFactory.decodeResource(context.getResources
(), R.drawable.icon48x48_1);
            mIcon2 = BitmapFactory.decodeResource(context.getResources
(), R.drawable.icon48x48_2);
        }

        /**
         * The number of items in the list is determined by the number
of speeches
         * in our array.
         *
         * @see android.widget.ListAdapter#getCount()
         */
        public int getCount() {
            return DATA.length;
        }

        /**
         * Since the data comes from an array, just returning the
index is
         * sufficent to get at the data. If we were using a more
complex data
         * structure, we would return whatever object represents one
row in the
         * list.
         *
         * @see android.widget.ListAdapter#getItem(int)
         */
        public Object getItem(int position) {
            return position;
        }

        /**
         * Use the array index as a unique id.
         *
         * @see android.widget.ListAdapter#getItemId(int)
         */
        public long getItemId(int position) {
            return position;
        }

        /**
         * Make a view to hold each row.
         *
         * @see android.widget.ListAdapter#getView(int,
android.view.View,
         *      android.view.ViewGroup)
         */
        public View getView(int position, View convertView, ViewGroup
parent) {
            // A ViewHolder keeps references to children views to
avoid unneccessary calls
            // to findViewById() on each row.
            ViewHolder holder;
            UnderlinedView underlinedView = (UnderlinedView)
convertView;

            // When convertView is not null, we can reuse it directly,
there is no need
            // to reinflate it. We only inflate a new View when the
convertView supplied
            // by ListView is null.
            if (convertView == null) {
                convertView = mInflater.inflate
(R.layout.list_item_icon_text, null);
                underlinedView = (UnderlinedView)convertView;

                // Creates a ViewHolder and store references to the
two children views
                // we want to bind data to.
                holder = new ViewHolder();
                holder.text = (TextView) underlinedView.findViewById
(R.id.text);
                holder.icon = (ImageView) underlinedView.findViewById
(R.id.icon);

                underlinedView.setTag(holder);
            } else {
                // Get the ViewHolder back to get fast access to the
TextView
                // and the ImageView.
                holder = (ViewHolder) underlinedView.getTag();
            }

            // Bind the data efficiently with the holder.
            holder.text.setText(DATA[position]);
            holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 :
mIcon2);

            return underlinedView;
        }

        static class ViewHolder {
            TextView text;
            ImageView icon;
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new EfficientAdapter(this));
    }

    private static final String[] DATA = {
            "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam",
            "Abondance", "Ackawi", "Acorn", "Adelost", "Affidelice au
Chablis",
            "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre",
            "... a lot more strings are defined in original ApiDemos
sample ...",
            "Yarra Valley Pyramid", "Yorkshire Blue", "Zamorano",
            "Zanetti Grana Padano", "Zanetti Parmigiano Reggiano"};
}

- - -

The stack trace from logcat suggests a problem with the class cast in
line 127, which is the cast after the row's XML inflation in getView:

                convertView = mInflater.inflate
(R.layout.list_item_icon_text, null);
                underlinedView = (UnderlinedView)convertView;



D/AndroidRuntime(  723): Shutting down VM

W/dalvikvm(  723): threadid=3: thread exiting with uncaught exception
(group=0x4000fe70)

E/AndroidRuntime(  723): Uncaught handler: thread main exiting due to
uncaught exception

E/AndroidRuntime(  723): java.lang.ClassCastException:
android.widget.LinearLayout

E/AndroidRuntime(  723):        at
com.example.android.apis.view.List14$EfficientAdapter.getView
(List14.java:127)

E/AndroidRuntime(  723):        at android.widget.AbsListView.obtainView
(AbsListView.java:1269)

E/AndroidRuntime(  723):        at android.widget.ListView.makeAndAddView
(ListView.java:1623)

E/AndroidRuntime(  723):        at android.widget.ListView.fillDown
(ListView.java:607)

E/AndroidRuntime(  723):        at android.widget.ListView.fillFromTop
(ListView.java:664)

E/AndroidRuntime(  723):        at android.widget.ListView.layoutChildren
(ListView.java:1481)

E/AndroidRuntime(  723):        at android.widget.AbsListView.onLayout
(AbsListView.java:1113)

E/AndroidRuntime(  723):        at android.view.View.layout(View.java:6133)

E/AndroidRuntime(  723):        at android.widget.FrameLayout.onLayout
(FrameLayout.java:333)

E/AndroidRuntime(  723):        at android.view.View.layout(View.java:6133)

E/AndroidRuntime(  723):        at android.widget.LinearLayout.setChildFrame
(LinearLayout.java:1119)

E/AndroidRuntime(  723):        at android.widget.LinearLayout.layoutVertical
(LinearLayout.java:998)

E/AndroidRuntime(  723):        at android.widget.LinearLayout.onLayout
(LinearLayout.java:918)

E/AndroidRuntime(  723):        at android.view.View.layout(View.java:6133)

E/AndroidRuntime(  723):        at android.widget.FrameLayout.onLayout
(FrameLayout.java:333)

E/AndroidRuntime(  723):        at android.view.View.layout(View.java:6133)

E/AndroidRuntime(  723):        at android.view.ViewRoot.performTraversals
(ViewRoot.java:929)

E/AndroidRuntime(  723):        at android.view.ViewRoot.handleMessage
(ViewRoot.java:1482)

E/AndroidRuntime(  723):        at android.os.Handler.dispatchMessage
(Handler.java:99)

E/AndroidRuntime(  723):        at android.os.Looper.loop(Looper.java:123)

E/AndroidRuntime(  723):        at android.app.ActivityThread.main
(ActivityThread.java:3948)

E/AndroidRuntime(  723):        at java.lang.reflect.Method.invokeNative
(Native Method)

E/AndroidRuntime(  723):        at java.lang.reflect.Method.invoke
(Method.java:521)

E/AndroidRuntime(  723):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)

E/AndroidRuntime(  723):        at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:540)

E/AndroidRuntime(  723):        at dalvik.system.NativeStart.main(Native
Method)

I/Process (  564): Sending signal. PID: 723 SIG: 3

- - -

Initially I tried posting this question to the Android Beginners group
(as I'm a Java novice), but got no responses.  Anyone here have any
suggestions?

Thanks and best regards,
Greg






--~--~---------~--~----~------------~-------~--~----~

3. Is there any UI can connect to SQLite database?

4. Linux kernel Include files

5. Android BUG....

6. what is the point of ProviderTestCase2?

7. Garbage Collector - best practice