labs.beatcraft.com

building procedure of ALSA integrated android-1.5r2 for bc9

Please refer following URL for how to set up open source android platform build and development environment.
http://source.android.com/download 
This article use android-1.5r2 branch, seem to most stable at end of June 2009.
Booting android require android enabled linux kernel, add some android specific kernel drivers.

Initialize repo specifying with android-1.5r2 branch.

$ mkdir android-1.5r2
$ cd android-1.5r2
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-1.5r2

Make local_manifest.xml with following content under android1.5r2/.repo/.

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project path="external/alsa-lib" name="platform/external/alsa-lib"/>
  <project path="hardware/alsa_sound" name="platform/hardware/alsa_sound"/>
</manifest>

Return to android-1.5r2 directory and get files by following command.

$ repo sync

alsa-utils(containing alsamixer, aplay etc.) is only exist in master branch.
So we don't include it in local_manifest.xml.~ If you need it, get it as follows and copy it to android-1.5r2/externel/.

$ git clone git://android.git.kernel.org/platform/external/alsa-util
$ cp -a alsa-utils android-1.5r2/externel/

adjustment of building sources

adjustment of ALSA

In order to use ALSA as audio hardware library, change android-1.5r2/build/target/board/generic/BoardConfig.mk as follows.

# config.mk
#
# Product-specific compile-time definitions.
#
# The generic product target doesn't have any hardware-specific pieces.
TARGET_NO_BOOTLOADER := true
TARGET_NO_KERNEL := true
TARGET_NO_RADIOIMAGE := true
HAVE_HTC_AUDIO_DRIVER := true
BOARD_USES_ALSA_AUDIO := true
#BOARD_USES_GENERIC_AUDIO := true&#12288;*comment out this line

If you want to build alsa-utils too, add following line.

BUILD_WITH_ALSA_UTILS := true

Edit android-1.5r2/external/alsa-lib/Android.mk as follows.
(When android boot by chroot, alsa interface is generated not under /dev/snd but under /dev. So we modify Android.mk to fit it.)~

--- Android.mk.orig     2009-07-09 07:05:41.000000000 -0700
+++ Android.mk  2009-07-09 07:05:48.000000000 -0700
@@ -55,7 +55,7 @@
       -fPIC -DPIC -D_POSIX_SOURCE ¥
       -DALSA_CONFIG_DIR=¥"/system/usr/share/alsa¥" ¥
       -DALSA_PLUGIN_DIR=¥"/system/usr/lib/alsa-lib¥" ¥
-       -DALSA_DEVICE_DIRECTORY=¥"/dev/snd/¥"
+       -DALSA_DEVICE_DIRECTORY=¥"/dev/¥"

 LOCAL_SRC_FILES := $(sort $(call all-c-files-under, src))

patch for battery state

If you build android open source platform without this modification, android won't boot.
Because android determine power state as low battery.
(cf. http://androidzaurus.seesaa.net/article/116995835.html)
Apply patch to following files and pretend to be full battery.

android-1.5r2/framework/base/services/java/com/android/server/BatteryService.java
android-1.5r2/framework/base/services/java/com/android/server/PowerManagerService.java
android-1.5r2/framework/base/services/java/com/android/server/SystemServer.java
android-1.5r2/framework/base/phone/com/android/internal/policy/impl/PhoneWindowManager.java

Download filedummy-battery.patch to android-1.5r2/ directory and apply patch as follows.

$ cd android-1.5r2/
$ patch -p1 < ../dummy-battery.patch

build

Execute make command at android-1.5r2/ to build.

$ make

After build finished, required files are generated under android-1.5r2/out/target/product/generic/.
But sound resource files haven't copied to appropriate directory.
So copy sound resource files to out/target/product/generic/system/media/audio/ by following procedure.

ogg sound resource files

Rename or copy AudioPackage2.mk to Android.mk at android-1.5r2/frameworks/base/data/sounds/.

$ cp AudioPackage2.mk Android.mk 


$ cd android-1.5r2/build/
$ source envsetup.sh 
$ cd android-1.5r2/frameworks/base/data/sounds/
$ mm 

ogg format sound resource files are copied under out/target/product/generic/system/media/audio/.

making android-root directory

When finished previous build procedure, deploy android userland files to bootable layout.

$ cd ~/
$ mkdir android-root
$ cp -a ~/android-1.5r2/out/target/product/generic/root/* ~/android-root/
$ cp -a ~/android-1.5r2/out/target/product/generic/system/* ~/android-root/system/

edit init.rc

setting ALSA

Add ALSA related settings before "on boot" settings in android-root/init.rc.

   setprop alsa.mixer.playback.master Master
   setprop alsa.mixer.capture.master Capture
   setprop alsa.mixer.playback.earpiece Master
   setprop alsa.mixer.capture.earpiece Capture
   setprop alsa.mixer.playback.headset Master
   setprop alsa.mixer.playback.speaker Master
   chmod 0777 /dev/pcmC0D0c
   chmod 0777 /dev/pcmC0D0p
   chmod 0777 /dev/controlC0
   chmod 0777 /dev/timer
   chown root audio /dev/controlC
   chown root audio /dev/pcmC0D0c
   chown root audio /dev/pcmC0D0p
   chown root audio /dev/timer

others

Comment out yaffs2 mount settings.

diff -u init.rc.orig init.rc
--- init.rc.orig	2009-03-31 12:50:16.000000000 +0900
+++ init.rc	2009-03-31 12:57:19.000000000 +0900
@@ -36,16 +36,16 @@ 

 # mount mtd partitions
     # Mount /system rw first to give the filesystem a chance to save a checkpoint
-    mount yaffs2 mtd@system /system 
-    mount yaffs2 mtd@system /system ro remount
+#    mount yaffs2 mtd@system /system 
+#    mount yaffs2 mtd@system /system ro remount 
&#12288;
     # We chown/chmod /data again so because mount is run as root + defaults
-    mount yaffs2 mtd@userdata /data nosuid nodev
+#    mount yaffs2 mtd@userdata /data nosuid nodev
     chown system system /data
     chmod 0771 /data

     # Same reason as /data above
-    mount yaffs2 mtd@cache /cache nosuid nodev
+#    mount yaffs2 mtd@cache /cache nosuid nodev
     chown system cache /cache
     chmod 0770 /cache

asound.conf asound.state

Copy two ALSA setting files (asound.conf and asound.state) to android-root/system/etc/.

asound.state

Following fileasound.state is generated under /etc/ of OpenEmbedded when build OpenEmbedded Linux environment for bc9 by gumstix-oe.

state.Gumstix {
   control.1 {
       comment.access 'read write'
       comment.type INTEGER
       comment.count 1
       comment.range '0 - 4'
       iface MIXER
       name 'Tone Control - Bass'
       value 0
   }
   control.2 {
       comment.access 'read write'
       comment.type INTEGER
       comment.count 1
       comment.range '0 - 2'
       iface MIXER
       name 'Tone Control - Treble'
       value 0
   }
   control.3 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'Headphone Playback Switch'
       value true
   }
   control.4 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name De-emphasis
       value false
   }
   control.5 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'DC Filter'
       value true
   }
   control.6 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'Hi-pass Filter'
       value true
   }
   control.7 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'ADC Filter'
       value true
   }
   control.8 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'Master Playback Switch'
       value true
   }
   control.9 {
       comment.access 'read write'
       comment.type INTEGER
       comment.count 2
       comment.range '0 - 63'
       iface MIXER
       name 'Master Playback Volume'
       value.0 63
       value.1 63
   }
   control.10 {
       comment.access 'read write'
       comment.type ENUMERATED
       comment.count 2
       comment.item.0 Mic
       comment.item.1 CD
       comment.item.2 Video
       comment.item.3 Aux
       comment.item.4 Line
       comment.item.5 Mix
       comment.item.6 'Mix Mono'
       comment.item.7 Phone
       iface MIXER
       name 'Capture Source'
       value.0 Mic
       value.1 Mic
   }
   control.11 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'Capture Switch'
       value true
   }
   control.12 {
       comment.access 'read write'
       comment.type INTEGER
       comment.count 2
       comment.range '0 - 15'
       iface MIXER
       name 'Capture Volume'
       value.0 15
       value.1 15
   }
   control.13 {
       comment.access 'read write'
       comment.type BOOLEAN
       comment.count 1
       iface MIXER
       name 'Loudness (bass boost)'
       value false
   }
}

asound.conf

Following fileasound.conf is made from asound.state above to set all controls correctly.

ctl.AndroidPlayback {
	type hw
	card 0
}

ctl.AndroidRecord {
	type hw
	card 0
}

pcm.AndroidPlayback {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'	   value 0           } 
			{ name 'Tone Control - Treble'	   value 0           } 
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'		   value true	     }
			{ name 'ADC Filter'		   value true	     }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidPlayback_Speaker_normal {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}
pcm.AndroidPlayback_Speaker {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidPlayback_Headset {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidPlayback_Speaker_incall {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidPlayback_Headset_incall {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidPlayback_Earpiece_incall {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidPlayback_Bluetooth {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

pcm.AndroidRecord_Microphone {
	type hooks
	slave.pcm {
		type hw
		card 0
		device 0
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{ name 'Tone Control - Bass'       value 0	     }
			{ name 'Tone Control - Treble'     value 0	     }
			{ name 'Headphone Playback Switch' value true	     }
			{ name 'De-emphasis'		   value false	     }
			{ name 'DC Filter'		   value true	     }
			{ name 'Hi-pass Filter'	           value true	     }
			{ name 'ADC Filter'		   value true        }
			{ name 'Master Playback Switch'	   value true	     }
			{ name 'Master Playback Volume'	   value [ 55 55 ]   }
			{ name 'Capture Source'		   value [ Mic Mic ] }
			{ name 'Capture Switch'		   value true	     }
			{ name 'Capture Volume'		   value [ 15 15 ]   }
			{ name 'Loudness (bass boost)'	   value false	     }
		]
	}
}

vold

On android sdcard is mount by vold.
Make setting file. vold is executed according to the setting file.
android-root/system/etc/vold.conf
Format should be as follows.

## vold configuration file for bc9
volume_sdcard {
  media_path     /devices/platform/pxa2xx-mci.0/mmc_host/mmc0
  media_type     mmc
  mount_point    /sdcard
  ums_path       /devices/platform/usb_mass_storage/lun0
}

By setting this, first partition of microSD is mounted and it can be used as media files storage.

button layout

Button layout of bc9 is set as follows.
(from above)

  • HOME (ENDCALL)
  • MENU
  • BACK

bc9 has 3 buttons and these buttons work as F1, F2, F3 key of PC101 keyboard.
Assign F1 to ENDCALL, F2 to MENU, F3 to BACK.
Home button is available when you set ENDCALL behavior as "Go to Home" by android's Spare Parts application.


Edit android-root/system/usr/keylayout/qwerty.kl as follows.

--- qwerty.kl-orig      2009-07-02 20:28:21.000000000 +0900
+++ qwerty.kl   2009-07-02 20:29:42.000000000 +0900
@@ -11,18 +11,18 @@ key 10    9
 key 11    0
 key 158   BACK              WAKE_DROPPED
 key 230   SOFT_RIGHT        WAKE
-key 60    SOFT_RIGHT        WAKE
+key 60    MENU              WAKE
 key 107   ENDCALL           WAKE_DROPPED
 key 62    ENDCALL           WAKE_DROPPED
 key 229   MENU              WAKE_DROPPED
 key 139   MENU              WAKE_DROPPED
-key 59    MENU              WAKE_DROPPED
+key 59    ENDCALL           WAKE
 key 127   SEARCH            WAKE_DROPPED
 key 217   SEARCH            WAKE_DROPPED
 key 228   POUND
 key 227   STAR
 key 231   CALL              WAKE_DROPPED
-key 61    CALL              WAKE_DROPPED
+key 61    BACK              WAKE
 key 232   DPAD_CENTER       WAKE_DROPPED
 key 108   DPAD_DOWN         WAKE_DROPPED
 key 103   DPAD_UP           WAKE_DROPPED

Screen Timeout

After battery state patch applied, android can't resume when Screen Timeout made android into sleep mode.
In order to avoid this situation, Screen Timeout must be disabled on android's setting application.

  • [Menu] - [Settings] - [Sound & display] - [Screen timeout] - [Never timeout]

device_provisioned

Device provisioning process affect even to open source android platform.
By executing following command, the device is activated.

# cd /data/data/com.android.providers.settings/databases
# sqlite3 settings.db
sqlite> insert into "secure" values(NULL,"device_provisioned", "1");
sqlite> .exit

Once the device is activated, key lock dialog is added to home screen of android
and flight/silent mode selection are added to Power off confirmation dialog.
Not activated device has a few problem.

  • HOME key doesn't work.
  • Key lock dialog doesn't appear on home screen.

This is the end of ALSA integrated android-1.5r2 build procedure.

reference URL


Attach file: fileasound.conf 2286 download [Information] fileasound.state 2249 download [Information] filedummy-battery.patch 2541 download [Information]

Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes
Last-modified: 2009-10-23 (Fri) 07:15:31 (5655d)