Booting the target with boot.img generated by Android

by kanagesh radhakrishnan » Thu, 24 Sep 2009 05:12:28 GMT


Sponsored Links
 Hello All,

I am working with Android on a custom PXA310 based platform.  I am
facing issues while launching the Linux kernel and Android from
boot.img that is generated as part of Android build.  I have
summarized two scenarios below.

Case 1 (NOT WORKING)
-----------------------------------------

I am attempting to use boot.img built by Android to launch the Linux
kernel and Android

* Build the Linux kernel to generate arch/arm/boot/zImage
* The kernel has been built with
          -> CONFIG_BLK_DEV_INITRD=y and CONFIG_INITRAMFS_SOURCE not set
          ->CONFIG_CMDLINE set to onsole=ttyS0,38400 mem=128M* Copy the Linux kernel into Android sources under vendor/hw/platform/kernel
* Ensure that ARGET_NO_KERNELis set to false in
vendor/hw/platform/BoardConfig.mk
* Build Android.  This generates boot.img and recovery.img with the
prebuilt kernel
* Program boot.img, recovery.img to NAND flash on target platform
* On booting, Bootloader finds the default boot kernel or recovery
kernel (depending on the command in BCB)
* However, kernel boot fails while attempting to find a root file system (RFS)
* This is because the Linux kernel has no knowledge of where RFS
exists (we need to pass oot=option at kernel boot time? Or is it
some kernel config setting??)

CASE 2 (WORKING)
----------------------------------
I don't use the boot.img with this scenario.  In this scenario, I am
building Android's ramdisk (the contents of ramdisk.img) statically
with the Linux kernel.

* Build Android.  Copy the contents of ramdisk.img (from Android
folder out/target/hw/platform/root) to kernel sources to a folder
named 'root'
* Build the Linux kernel to generate arch/arm/boot/zImage
* The kernel has been built with
       -> CONFIG_BLK_DEV_INITRD=y and CONFIG_INITRAMFS_SOURCE=oot       -> CONFIG_CMDLINE is set to onsole=ttyS0,38400 mem=128M* Program this Linux kernel to NAND Flash on target platform
* On booting:
* Bootloader launches this kernel
        -> mounts the ramdisk provided as INITRAMFS, runs Android init
        -> mounts system.img and userdata.img programmed in NAND flash
        -> launches Android

Versions of Software being used are as follows:
Linux Kernel - Sources based on linux-2.6.28
Android - Sources based on Android source with tag 'android-sdk-1.5_r1'

On going through the build logs for Kernel and Android, I have
determined that the way boot.img is built is different from the way
the Linux kernel builds the kernel binary with CONFIG_INITRAMFS_SOURCE
set to point to a RAM disk.

Has anyone got the boot.img to launch the kernel and Android
successfully?  Any pointers on where I need to look or what parameters
I need to pass to the kernel to mount the ramdisk while using boot.img
would be extremely helpful.

Thank you for your time.

Regards,
Kanagesh

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

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



Other Threads

1. Inspecting the contents of an Intent

How do I know what extras an Intent contains when it returns from an
activity result?

For example, I have used an Intent.ACTION_GET_CONTENT to pick an image
from the gallery. When the result is returned, I can get the URI of
the image from intent.getData().toString(). In another scenario, I use
a MediaStore.ACTION_IMAGE_CAPTURE to get a new photo. When this result
returns, I know (from looking at other people's code) that you can get
the image itself from data.getExtras().get("data");

But how can I get the contentUri of this new photo?

A more relevant question, is how can I inspect the Intent so that I
know what extras and what data it contains? There seems to be a
differing combination depending on what the original Intent was.

Many thanks for any suggestions.
--~--~---------~--~----~------------~-------~--~----~

2. Code review request for ImageCache

I'm hoping I can get some opinions on my implementation of an
ImageCache using SoftReferences and  AsyncTask.  The task of the
ImageCache is to load Bitmaps as they are requested.  From the outside
the Bitmaps are requested using the get method which takes the Uri of
the Bitmap to load, and the ImageView which will eventually be updated
with the Bitmap.
A single thread waits for the requests or jobs as I call them to be
added to a job list.

I have to admit, I'm not the most knowledgable when it comes to
threads, but I think I got the
blocking calls correct.  Hopefully the formatting isn't to bad.


The following call initiates the cache and leaves it waiting for jobs

ImageCache.getInstance().executeLoadImagesTask( context );

a Bitmap is retrieved with the following call

Bitmap bm = ImageCache.getInstance().get( _thumbUri.toString(),
_imgVw );

if the image isn't initially in the cache, a default Bitmap is
returned, then a job is added to the job list.  This job contains the
Uri to the Bitmap to load and the ImageView to update.


public class ImageCache
{
        private static final String LOG_TAG = "ImageCache";
        private static final boolean LOGD = true;

        private static ImageCache _instance = null;
        private final HashMap<String, SoftReference<Bitmap>> _cache;

        private Context _ctx;
        private static Bitmap defaultBitmap;
        private Object _lock;
        private ArrayList<ImageJob> jobs =  new ArrayList<ImageJob>();

        public static ImageCache getInstance()
        {
                if ( _instance == null )
                {
                        _instance = new ImageCache();
                }

                return _instance;
        }

        private ImageCache()
        {
                _lock = new Object();
                _cache = new HashMap<String, SoftReference<Bitmap>>();
        }

        public void executeLoadImagesTask( Context ctx )
        {
                _ctx = ctx;
        defaultBitmap = BitmapFactory.decodeResource( _ctx.getResources
(), R.drawable.camera_icon );
                new LoadImagesTask().execute(null);
        }

        public void put( String key, Bitmap bitmap )
        {
                _cache.put( key, new SoftReference<Bitmap>(bitmap) );
        }

        public void clear()
        {
                _cache.clear();
        }

        public Bitmap get( String imguri, UriImageView viewToUpdate )
        {

                Bitmap bm = null;
                SoftReference<Bitmap> reference = _cache.get(imguri);

                if ( reference != null )
                {
                        bm = reference.get();
                }

                if ( bm == null )
                {
                        bm = defaultBitmap;
                        postJob( new ImageJob( imguri, viewToUpdate ) );
                }

                return bm;
        }


        /**
         * Called after the bitmap has been retrieved from the
         * sdcard
         *
         * @param jobs
         */
        public void addImage( ImageJob... jobs )
        {
                ImageJob job = jobs[0];
                final UriImageView view = job.getViewToUpdate();
                final Bitmap bm = job.getBitmap();
                final Uri imguri = job.getImageUri();

                put( imguri.toString(), bm );

                view.post( new Runnable() {

                        public void run()
                        {
                                view.setImage(imguri, bm);
                        }

                });
        }

        private void dbg( String msg )
        {
                if (LOGD) Log.d( LOG_TAG, msg );
        }


        private void postJob( final ImageJob job )
        {
            dbg( "Thread: " + Thread.currentThread().getName() + "
posting job " + job.getImageUri() );
            synchronized(_lock)
            {
                jobs.add(job);
                _lock.notify();
            }
        }

        private class ImageJob
        {
                private Uri _imageUri;
                private UriImageView _viewToUpdate;
                private Bitmap _bm;

                public ImageJob( Uri imageUri, UriImageView viewToUpdate )
                {
                        _imageUri = imageUri;
                        _viewToUpdate = viewToUpdate;
                }

                public ImageJob( String imageUri, UriImageView viewToUpdate )
                {
                        this( Uri.parse( imageUri ), viewToUpdate );
                }

                public Uri getImageUri()
                {
                        return _imageUri;
                }

                public UriImageView getViewToUpdate()
                {
                        return _viewToUpdate;
                }

                public void setBitmap( Bitmap bm )
                {
                        _bm = bm;
                }

                public Bitmap getBitmap()
                {
                        return _bm;
                }
        }

        private class LoadImagesTask extends AsyncTask<Object, ImageJob,
Integer>
        {
                @Override
                protected Integer doInBackground(Object... params)
                {
                        Thread.currentThread().setName( "LoadImagesTask" );

                        while( true )
                        {
                                int jobsize = 0;

                                synchronized( _lock )
                                {
                                        jobsize = jobs.size();
                                }

                                if ( jobsize > 0 )
                                {
                                        synchronized( _lock )
                                        {
                                                ImageJob job = jobs.remove(0);
                                                dbg( "performing image job " + 
job.getImageUri() );

                                                try
                                                {
                                                    job.setBitmap( 
ImgUtils.buildBitmap(_ctx, job.getImageUri(),
4) );
                                                    onProgressUpdate( job );
                                                }
                                                catch (IOException e)
                                                {
                                                        e.printStackTrace();
                                                }
                                        }
                                }
                                else
                                {
                                        try
                                        {
                                                synchronized( _lock )
                                                {
                                                        dbg( "Thread: " + 
Thread.currentThread().getName() + " waiting
for jobs" );
                                                        _lock.wait();
                                                        dbg( "Thread: " + 
Thread.currentThread().getName() + " got a
job" );
                                                }
                                        }
                                        catch (InterruptedException e)
                                        {
                                                e.printStackTrace();
                                        }
                                }
                        }
                }

            @Override
            public void onProgressUpdate(ImageJob... job)
            {
                addImage( job );
            }

            @Override
            public void onPostExecute(Integer imagesLoaded)
            {
                dbg( "loaded " + imagesLoaded + " images" );
            }

        }
}


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

3. how to select item from arrayadapter

4. Issue (bug) reports because of custom ROMS, varying configurations, etc.

5. Intercepting SQLite's file reads / writes, so we can encrypt the storage

6. Application closes when I try to convert String to Integer

7. How to contact comment author at the AM?