Monday, May 31, 2010

LG GW620 proximity sensor

Today I'm gonna write about the android based LG GW620 and its proximity sensor and how to enable it with a aosp cupcake build.
The proprietary LG firmware uses a modified framework, which in turn calls a custom function in libhardware_legacy.so to enable the proximity sensor.

The App "Sensor Dump" shows the sensor as GP2AP002, but no values are shown.

The driver for this device is defined in LG's kernel source in drivers/input/misc/prox_sharp.c.

To enable this sensor, just do a
echo 1 > /sys/devices/platform/i2c-gpio.6/i2c-adapter/i2c-6/6-0044/enable
(for example in an init script)

Now "Sensor Dump" finally shows us some values!

I suppose LG's firmware deactivates the proximity sensor when the phone is sleeping, but I have not looked into this and how this could be archieved with cupcake aosp.

Sunday, May 30, 2010

Internals of the LG GW620 RIL protocol

Hey everyone!

Today I'm gonna talk a bit about my findings with the proprietary RIL implementation in the GW620.
It consists of the files bin/rild, lib/libril.so lib/libril-qc-1.so. The rild daemon has not changend much, so we could use the plain rild from cupcake, but it will enable debugging output, when you
write "1" to /data/nv/QCRilLog_flag.

I have comiled the android framwork from plain cupcake android source, and it works quite well.
I can send SMS, receive SMS, get GPRS and UMTS (but UMTS status is not showed - it looks like GPRS), and I can receive calls (I had to modify the Phone app, because the GW620 has no "call" button to answer the call).

But I can't dial out.
I have tracked the process of Dialing from the PhoneApp/PhoneUtils -> framework/GSMPhone -> framework/CallTracker -> framework/gsm/RIL. It really helped to enable the DBG-flag in all those source files.

So when I dial, the DIAL command is send to the RIL socket /dev/socket/rild and no answer is received. In the radio log, I get the line
E/RILC ( 1002): invalid command block for token 133 request DIAL
from the qc ril implementation, so something of the format changed?
(See my other blog entry to enable verbose logging)

Later on we get a
D/MyRILJ ( 1193): WAKE_LOCK_TIMEOUT mReqPending=0 mRequestList=1
D/MyRILJ ( 1193): 0: [133] DIAL
in the log, because the the framework waits for an answer to our DIAL request, but gets no response.

I actually can dial out, by running the command
radiooptions 8 [numberToCall] from the commandline. This program is part of the android tree and usese /dev/socket/rild-debug to communicate with the rild daemon.

So I will have to look at the source code to figure out, how they changed the formatting of the DIAL request. I'll keep you updated!

EDIT:

To enable HSDPA status:
--- a/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
@@ -78,7 +78,8 @@ final class ServiceStateTracker extends Handler
static final int DATA_ACCESS_GPRS = 1;
static final int DATA_ACCESS_EDGE = 2;
static final int DATA_ACCESS_UMTS = 3;
-
+ static final int DATA_ACCESS_HSDPA = 7;
+
static final int MAX_NUM_DATA_STATE_READS = 15;
static final int DATA_STATE_POLL_SLEEP_MS = 100;

@@ -901,6 +902,9 @@ final class ServiceStateTracker extends Handler
case DATA_ACCESS_UMTS:
ret = "UMTS";
break;
+ case DATA_ACCESS_HSDPA:
+ ret = "HSDPA";
+ break;
}

return ret;

To use menu key to receive calls:
--- a/src/com/android/phone/InCallScreen.java
+++ b/src/com/android/phone/InCallScreen.java
@@ -1233,6 +1233,8 @@ public class InCallScreen extends Activity
enableTouchLock(false);
resetTouchLockTimer();
return true;
+ } else {
+ handleCallKey(); /* we have no call key, so use menu */
}
break;

To enable dialing out we have to add two options to the packet, which we send through /dev/socket/rild. The first is called "whichLine" and the second comes from "isEmergency". Their default in LG's code is zero.
--- a/telephony/java/com/android/internal/telephony/gsm/RIL.java
+++ b/telephony/java/com/android/internal/telephony/gsm/RIL.java
@@ -740,10 +742,12 @@ public final class RIL extends BaseCommands implements CommandsInterface
public void
dial (String address, int clirMode, Message result)
{
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result);

rr.mp.writeString(address);
rr.mp.writeInt(clirMode);
+ rr.mp.writeInt(0); /* whichLine */
+ rr.mp.writeInt(0); /* isEmergencyCall */

if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

Thursday, May 27, 2010

Enable logcat on the GW620

To see something more, we have to log lower priority events to, so do a

echo 2 >/sys/kernel/logger/log_main/priority
echo 2 >/sys/kernel/logger/log_events/priority
echo 2 >/sys/kernel/logger/log_radio/priority

for reference, see kernel/drivers/misc/logger.c

Monday, May 17, 2010

GW620 proprietary files

Files on the /system for germany/vodafone V10e image (android 1.5), which are not generated by
a compile from source.
I have used strings and readelf -d to find out, what those remaining files are for.

Fonts:
  • fonts/{SJGothicFull.ttf SJSans-Bold.ttf SJSans.ttf}
Sounds:
  • media/audio/notifications/F1_New_Call.ogg - set in system/build.prop as ro.config.notification_sound
  • sounds/lgeAT/Startup.wav the bootup sound (during Android logo)
Keylayout:
  • usr/keychars/eve_qwerty.kcm.bin binary map for Keycode to character?
  • usr/keylayout/eve_qwerty.kl ASCII file for keymapping and which keys can wake up from keypad lock!
  • both are used in libui, see source code at frameworks/base/libs/ui

OMADM:
  • etc/omadm/omadmclient_v12.xml
Frameworks:
  • framework/com.android.syncml.shared.jar ?
  • framework/com.google.android.gtalkservice.jar ?
  • framework/com.google.android.maps.jar Google maps
  • framework/lge-res.apk -> images for the "keypad unlock" and more..?
Apps:
  • xbin/btlifc ??? Something about RFCOM links against libbluetooth.so, no further reference in the rest of the image
  • bin/akmd2 - software to process and adjust compass/accelerometer events
  • bin/AT ??? opens /dev/smd0
  • bin/{rft rft.sh} - RF test script - so maybe not needed at all
  • bin/BCM4325D0_004.001.007.0168.0169.hcd: this is no executable and referenced by libbluedroid.so and libril-qc-1.so, maybe some firmware for the BCM4325 chip, which includes wifi, bluetooth and FM
  • bin/brcm_chg_bd_addr: what is a BD address?
  • bin/brcm_dutMode enable DUT (=test) mode for BCM4325 (?)
  • bin/btld daemon for some bluetooth?
  • bin/eta Something with "ATS agent", touchscreen testing maybe? reference to ro.build.hiddenmenu and /dev/graphics/fb0
  • bin/lgesystemd references to Factory Reset...?
  • diag_klog
  • fsck_msdos
  • hci_qcomm_init
  • loc_api_app
  • mm-adspsvc-test
  • mm-jpeg-dec-test
  • mm-jpeg-enc-test
  • mm-qcamera-test
  • mm-vdec-omxh264-test
  • mm-vdec-omxmp4-test
  • mm-venc-omx-test
  • port-bridge
  • qemu-props
  • qmuxd
  • set_grp_id
  • su - standard unix util to get root
  • test_diag

Libs: (in lib/)
  • modules/wireless.ko
  • libhgl.so - qualcomm/ati opengl ES library
  • libmmcamera.so - qcom camera driver (dlopend by libcamera.so)
  • libmm-qcamera-tgt.so - qcom camera driver (dlopend by libcamera.so)
  • libmmjpeg.so needed by libmmcamera.so
  • hw/copybit.eve.so - hal driver for the screen/framebuffer
  • hw/lights.eve.so - backlight and leds
  • hw/lights.goldfish.so - same for emulator?
  • libamcm.so
  • libAMMediaFileSplitter.so
  • libampostprocess.so
  • libAMVideoDecoder.so
  • libarcplatform.so
  • libautohan_jni.so
  • libbcmwl.so
  • libcameraservice.so
  • libcamera.so
  • libcm.so
  • libcommondefs.so
  • libdiag.so
  • libDioHWR.so
  • libdsm.so
  • libdss.so
  • libfotajni.so
  • libgps.so
  • libgsdi_exp.so
  • libgstk_exp.so
  • libjbedvm.so
  • liblgdrm.so
  • liblgeat.so
  • liblgerft.so
  • libloc_api.so
  • libmm-adspsvc.so
  • libmmgsdilib.so
  • libmm-omxcore.so main lib for codecs for decoding
  • libmvs.so
  • libnv.so
  • liboem_rapi.so
  • libOmxCore.so lib for codecs
  • libOmxH264Dec.so codec
  • libOmxMpeg4Dec.so codec
  • libOmxVidEnc.so codec
  • liboncrpc.so
  • libpdapi.so
  • libpdsm_atl.so
  • libping_mdm.so
  • libqmi.so
  • libqueue.so
  • libril_log.so
  • libril-qc-1.so main lib for radio
  • libsnd.so
  • libspeech.so
  • libuim.so
  • libunishape.so
  • libvdmengine.so - something with syncml and OMA DM
  • libvdmfumo.so
  • libwbxml_syncml_jni.so
  • libwbxml_syncml.so
  • libwmdrmpd.so
  • libwms.so
  • libwmsts.so
  • libwnndict.so
  • libWnnEngDic.so
  • libWnnJpnDic.so
  • libxt9_jni.so
Help is needed to identify the remaining files!
(I have omitted the files under 3rd_party/ArcSoft/{Camera DivXReg MediaGallery MediaPlayer VideoEditor})

LG GW620 - Compiling the system

  1. Get the mango.cupcake branch from codeaurora:
    repo init -u git://codeaurora.org/platform/manifest.git -b mango.cupcake

  2. Extract the LG-Source and copy it into that directory you just checked out.

  3. I have replaced msm7201a-perf_defconfig by eve_defconfig in vendor/qcom/msm7201a_surf/AndroidBoard.mk


  4. We have to fix some include paths and change vendor/lge/hardware/wifi/dhd/Android.mk and vendor/lge/hardware/wifi/wl/Android.mkby adding $(LOCAL_PATH)/../../../../../kernel/include to LOCAL_C_INCLUDES.


  5. And I needed to comment out line 845 of file vendor/lge/hardware/sensors/sensors_ak8973.c, which read
    sSensors[ID_P].proximity.distance = event.value;


  6. In the file vendor/qcom/msm7201a_surf/boot/eve/Android.mk, comment out the last line wich reads
    include $(BUILD_RAW_STATIC_LIBRARY).
    This keeps libboot_board_surf from building.


  7. In the file bootable/bootloader/legacy/nandwrite/Android.mk and bootable/bootloader/legacy/usbloader/Android.mk comment out the line
    include $(BUILD_RAW_EXECUTABLE)
    because those two depend on libboot_board_surf. I'm not quite sure what they do.


  8. In the file vendor/qcom/msm7201a_surf/boot/tools/Android.mk, comment out the two lines that say
    include $(BUILD_SYSTEM)/base_rules.mk
    That change keeps appsboot.mbn and appsboothd.mbn from building, which depend on usbloader.
  9. [Skip this step for now] Copy qcom propertiary libraries, by mkdir -p out/target/product/msm7201a_surf/obj/lib and then copy libloc_api.so, libdiag.so, libOmxCore.so, libmmcamera.so, libcamera.so from a stock image into that directory.





For building, updating or rebuilding, always use the next three commands (they set up the environment) (the last command is one line)

  • . build/envsetup.sh
  • choosecombo 1 1 msm7201a_surf eng
  • LGE_MODEL=eve make -j3 BOARD_HAVE_BLUETOOTH=true BRCM_BT_USE_BTL_IF=true WPA_BUILD_SUPPLICANT=true


Be aware, that there are many files missing or changed from the full image that comes installed to you phone. Especially init scripts, configuration files and propertiary binaries as for the radio ship must be copied over to out/target/product/msm7201a_surf/system and the system.img regenerated. I'm also not sure, how much you can trust the boot.img as the bootloader was not compiled. (but I think its not in boot.img).


I could not test the images created herefrom, because my GW620 got a hardware error berfore and I had to send it to support. Missing files under system/ are:
system/usr/keylayout/eve_qwerty.kl
system/usr/keychars/eve_qwerty.kcm.bin
system/fonts/SJSans-Bold.ttf
system/fonts/SJGothicFull.ttf
system/fonts/SJSans.ttf
system/sounds/lgeAT/1kHz_0dB_L128k.mp3
system/sounds/lgeAT/NoSignal_LR_128k.mp3
system/sounds/lgeAT/MultiSine_20-20kHz-0dBp_128k.mp3
system/sounds/lgeAT/1kHz_0dB_R_128k.mp3
system/sounds/lgeAT/PowerOn.mp3
system/sounds/lgeAT/Startup.wav
system/sounds/lgeAT/1kHz_0dB_LR_128k.mp3
system/sounds/Aging.mp3
system/xbin/btlifc
system/framework/com.google.android.maps.jar
system/framework/lge-res.apk
system/framework/com.android.syncml.shared.jar
system/framework/com.google.android.gtalkservice.jar
system/app/SimChecker.apk
system/app/GoogleSettingsProvider.apk
system/app/ArcVideoEditor.apk
system/app/Memo.apk
system/app/Email.apk
system/app/DivxRegistration.apk
system/app/ArcMMP.apk
system/app/WapService.apk
system/app/Quickoffice.apk
system/app/lgecamera.apk
system/app/MediaUploader.apk
system/app/GmailProvider.apk
system/app/NetworkLocation.apk
system/app/DrmDataMngr.apk
system/app/LGSystemProvider.apk
system/app/XIM.apk
system/app/ChargingTest.apk
system/app/checkin.apk
system/app/SyncMLProvider.apk
system/app/ExternalMemoryTest.apk
system/app/Homecube.apk
system/app/Street.apk
system/app/Homeselector.apk
system/app/ApiDemos.apk
system/app/Gmail.apk
system/app/gtalkservice.apk
system/app/ArcMediaGallery.apk
system/app/Linkbook.apk
system/app/DrmService.apk
system/app/SetupWizard.apk
system/app/orangephorowidget.apk
system/app/Calculator.apk
system/app/RingsExtended.apk
system/app/GooglePartnerSetup.apk
system/app/Talk.apk
system/app/YouTube.apk
system/app/PowerOff.apk
system/app/GoogleApps.apk
system/app/ELTTest.apk
system/app/ArcWorkshop.apk
system/app/Maps.apk
system/app/FavoriteContacts.apk
system/app/My_e-mail_Android.apk
system/app/LGSetupWizard.apk
system/app/Vending.apk
system/app/LgeFmRadio.apk
system/app/HiddenMenu.apk
system/media/audio/ringtones/WhistlingWizard.mp3
system/media/audio/ringtones/Airport.mp3
system/media/audio/ringtones/ThisTime.mp3
system/media/audio/ringtones/Crystal.mp3
system/media/audio/ringtones/CallingTrip.mp3
system/media/audio/notifications/F1_New_Call.ogg
system/media/lgdrm/developcert.cer
system/media/lgdrm/DRMCERTTYPE.TXT
system/etc/wl/nvram.txt
system/etc/omadm/omadmclient_v12.xml
system/etc/gps.conf
system/etc/flex/settings.db
system/etc/flex/flex.xml
system/etc/flex/NOTICE.html.gz
system/etc/LGE_favorites-400x240.xml
system/etc/favorites-400x240.xml
system/etc/favorites-320x240.xml
system/etc/email/hiddenesp.db
system/etc/favorites.xml
system/etc/permissions/com.android.syncml.shared.xml
system/etc/permissions/com.google.android.gtalkservice.xml
system/etc/permissions/com.google.android.maps.xml
system/lib/libmm-omxcore.so
system/lib/libWnnJpnDic.so
system/lib/libdsm.so
system/lib/libpdapi.so
system/lib/libgstk_exp.so
system/lib/libvdmengine.so
system/lib/libAMVideoDecoder.so
system/lib/libmmcamera.so
system/lib/libOmxMpeg4Dec.so
system/lib/libOmxH264Dec.so
system/lib/libbcmwl.so
system/lib/libOmxCore.so
system/lib/libcamera.so
system/lib/libautohan_jni.so
system/lib/libcm.so
system/lib/libcommondefs.so
system/lib/liblgerft.so
system/lib/libspeech.so
system/lib/libamcm.so
system/lib/hw/lights.eve.so
system/lib/hw/copybit.eve.so
system/lib/hw/lights.goldfish.so
system/lib/modules/wireless.ko
system/lib/libvdmfumo.so
system/lib/libwmsts.so
system/lib/libmm-qcamera-tgt.so
system/lib/libwbxml_syncml.so
system/lib/libAMMediaFileSplitter.so
system/lib/libpdsm_atl.so
system/lib/liblgdrm.so
system/lib/libwmdrmpd.so
system/lib/libarcplatform.so
system/lib/libwbxml_syncml_jni.so
system/lib/libwms.so
system/lib/liboem_rapi.so
system/lib/libmvs.so
system/lib/libsnd.so
system/lib/liboncrpc.so
system/lib/libril-qc-1.so
system/lib/libWnnEngDic.so
system/lib/libril_log.so
system/lib/libDioHWR.so
system/lib/libmmgsdilib.so
system/lib/libqueue.so
system/lib/libqmi.so
system/lib/libmmjpeg.so
system/lib/liblgeat.so
system/lib/libxt9_jni.so
system/lib/libnv.so
system/lib/libwnndict.so
system/lib/libuim.so
system/lib/libfotajni.so
system/lib/libping_mdm.so
system/lib/libhgl.so
system/lib/libunishape.so
system/lib/libgsdi_exp.so
system/lib/libmm-adspsvc.so
system/lib/libgps.so
system/lib/libdss.so
system/lib/libdiag.so
system/lib/libampostprocess.so
system/lib/libloc_api.so
system/lib/libOmxVidEnc.so
system/lib/libjbedvm.so
system/3rd_party/ArcSoft/*
system/bin/qemu-props
system/bin/set_grp_id
system/bin/eta
system/bin/rft.sh
system/bin/rft
system/bin/AT
system/bin/su
system/bin/mm-jpeg-enc-test
system/bin/fsck_msdos
system/bin/mm-vdec-omxh264-test
system/bin/mm-qcamera-test
system/bin/lgesystemd
system/bin/test_diag
system/bin/port-bridge
system/bin/qmuxd
system/bin/btld
system/bin/mm-venc-omx-test
system/bin/hci_qcomm_init
system/bin/mm-jpeg-dec-test
system/bin/brcm_chg_bd_addr
system/bin/loc_api_app
system/bin/diag_klog
system/bin/akmd2
system/bin/brcm_dutMode
system/bin/mm-vdec-omxmp4-test
system/bin/mm-adspsvc-test
system/bin/BCM4325D0_004.001.007.0168.0169.hcd