[[labs.beatcraft.com]]~ #contents * building procedure of ALSA integrated android-1.5r2 for bc9 [#v4e936e9] 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 [#m50e883d] *** adjustment of ALSA [#d7c10840] 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 *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 [#ra39b62d] 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 this patch to android-1.5r2/ directory and apply patch as follows. Download &ref(dummy-battery.patch); to android-1.5r2/ directory and apply patch as follows. $ cd android-1.5r2/ $ patch -p1 < ../dummy-battery.patch ** build [#td9a9723] 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 [#ud1caab1] 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 [#e3d23780] 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 [#x7dc45fb] ***setting ALSA [#dbe71121] 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 [#gd356672] 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   # 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 [#lf590132] Copy two ALSA setting files (asound.conf and asound.state) to android-root/system/etc/.~ ***asound.state [#p995eaa6] Following &ref(asound.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 [#jd7ab206] Following &ref(asound.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 [#b981575b] 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 [#t151b9e9] 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 [#na5cac04] 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 [#v004c1a5] 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 [#j8dc33c0] -http://code.google.com/p/patch-hosting-for-android-x86-support/wiki/ALSA -http://d.hatena.ne.jp/bs-android/20090603/1244043649 -http://labs.embinux.org/index.php/Android_Porting_Guide_to_Beagle_Board -http://nemustech.blogspot.com/2009/04/android-on-s3c6410-target-board.html