ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2012年2月23日 星期四

android 內含 ? kernel 的 build script。
會參考

create my kernel defconfig file

kernel config 中增加一個新的 defconfig.

defconfig 的內容還是會經過所有 Kconfig 的檢驗,所以最好是用 make menuconfig 產生 .config 後,
再 copy 到 arch/XXX/configs/ 下

要注意,檔名結尾一定要是 _defconfig,因為 makefile 是用 *_defconfig 來找所有 config file。



以增加一個 boot splash logo option 為例:

在 drivers/video/logo/Kconfig 增加一個 entry: config LOGO_TOB bool "tob" default n
然後 drivers/video/logo/Makefile 增加: obj-$(CONFIG_LOGO_TOB) += logo_tob_clut224.o
然後做好 logo_tob_clut224.ppm

這邊要注意一下,Makefile 是依照filename 最後的 clut224, mono, vga16 等字樣,
用不同的 convert program 轉成 c

make 確認 OK 後,就可以把 .config copy 到 arch/arm/configs/imx_tob_defconfig

還有 log.c 要把新增加的 splash screen 的 symbol 加進去 ,還有 header 要加上新的 symbol 宣告。
最後測試: make distclean && make imx_tob_defconfig && make uImage

2012年2月22日 星期三

property_get, set 在 /system/core/libcutils/properties.c

裡面implement 三種方法,分別依有否定義
  1. HAVE_LIBC_SYSTEM_PROPERTIES
  2. HAVE_SYSTEM_PROPERTY_SERVER
而有不同。
兒這些定義非別定義在:
/system/core/include/arch/....

裡面, linux-arm, linux-x86 .. 分別使用不同的定義。

linux-arm 使用 HAVE_LIBC_SYSTEM_PROPERTIES..


Service Socket 定義在 bionic: ./bionic/libc/include/sys/_system_properties.h:#define PROP_SERVICE_NAME "property_service" Service 啟動在 /system/core/init/property_service.c:

property_set 是由 property server (listen socket) 提供。
property_get 由 libc 的 system_property_xxx 提供,直接由一塊記憶體中讀取。<br>

2012年2月15日 星期三

Unhandled fault: external abort on non-linefetch (0x1018) at 0x2b7d0054 -- imx android

from :
http://imxcommunity.org/profiles/blogs/what-is-the-error-message-unhandled-fault-external-abort-on-non

他說:
It is not the error message, it just means Freescale MMCodec had been used, such information was generated by MMCodec in liscense checking.

真糟。

驗證的方法就是follow 他的說明,把 codec 都關掉: To disable the FSL codec, in init.rc, set the followed parameters to 0 # fsl omx graphic manager media framework property setprop media.omxgm.enable-player 0 setprop media.omxgm.enable-record 0 setprop media.omxgm.enable-scan 0
結果 這個 unhandled exception 真的都沒出現了。

2012年2月14日 星期二

D-Link HSPDA Dongle - DWN-156

會先出現 cd rom,然後要切 modeswitch,才會出現 serial port。
在 windows 上會出現三個 serial port (其中一個是 USB Modem):
  1. D-Link HSPDA DataCard Diagnostics Interface
  2. D-Link HSPDA DataCard NMEA Device
  3. D-Link HSPDA DataCard Propertiery USB Modem

這又是一個 有 usb cdrom 模式的 3g dongle。
剛插入系統,會是 cd rom。
要先 switch 到 modem 後,才會出現 usb serial。

剛插入時,vid , pid 是:
New USB device found, idVendor=07d1, idProduct=a804
mount 再 umount 後,vid, pid 是:
New USB device found, idVendor=07d1, idProduct=7e11
但是這時後也沒有出現 usb serial port。



大概用兩個步驟:
  1. usb-modeswitch, 切換到 modem mode
  2. 手動 load usb-serial ,指定 vid, pid

usb-modeswitch:

debian 已經有安裝,但是 /etc/usb_modeswitch.d/ 下面沒有 07d1:a804 的設定檔,
所以要寫 /etc/usb_modeswitch.d/ 下的 vid:pid 檔:
sudo vi /etc/usb_modeswitch.d/07d1:a804 ######################################################## # D-Link DWM-156 HSUPA 3.75G USB Modem DefaultVendor= 0x07d1 DefaultProduct=0xa804 TargetVendor= 0x07d1 TargetProduct= 0x7e11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000" CheckSuccess=20 寫好就可以用 usb_modeswitch 來切了..

先插入 dwn-156, dmesg 內容是: [25387.281621] usb 2-1.1.4.2: new high speed USB device using ehci_hcd and address 19 [25387.391940] usb 2-1.1.4.2: New USB device found, idVendor=07d1, idProduct=a804 [25387.391946] usb 2-1.1.4.2: New USB device strings: Mfr=3, Product=2, SerialNumber=4 [25387.391950] usb 2-1.1.4.2: Product: D-Link WCDMA Technologies MSM [25387.391954] usb 2-1.1.4.2: Manufacturer: D-Link,Incorporated [25387.391957] usb 2-1.1.4.2: SerialNumber: MF112DDLKD010000 [25387.392114] usb 2-1.1.4.2: configuration #1 chosen from 1 choice [25387.394534] scsi16 : SCSI emulation for USB Mass Storage devices [25387.394655] usb-storage: device found at 19 [25387.394659] usb-storage: waiting for device to settle before scanning [25392.392130] usb-storage: device scan complete [25392.392810] scsi 16:0:0:0: CD-ROM HSPA USB SCSI CD-ROM 2.31 PQ: 0 ANSI: 2 [25392.397282] sr1: scsi-1 drive [25392.397481] sr 16:0:0:0: Attached scsi CD-ROM sr1 [25392.397632] sr 16:0:0:0: Attached scsi generic sg4 type 5 用 usb_modeswitch 來切換 mode: $ sudo usb_modeswitch -c /etc/usb_modeswitch.d/07d1:a804 Looking for target devices ... No devices in target mode or class found Looking for default devices ... Found devices in default mode or class (1) Accessing device 022 on bus 002 ... Using endpoints 0x01 (out) and 0x81 (in) Using endpoints 0x01 (out) and 0x81 (in) Inquiring device details; driver will be detached ... Looking for active driver ... OK, driver found ("usb-storage") OK, driver "usb-storage" detached SCSI inquiry data (for identification) ------------------------- Vendor String: HSPA Model String: USB SCSI CD-ROM Revision String: 2.31 ------------------------- USB description data (for identification) ------------------------- Manufacturer: D-Link,Incorporated Product: D-Link WCDMA Technologies MSM Serial No.: MF112DDLKD010000 ------------------------- Setting up communication with interface 0 ... Using endpoint 0x01 for message sending ... Trying to send message 1 to endpoint 0x01 ... OK, message successfully sent Resetting response endpoint 0x81 Resetting message endpoint 0x01 Checking for mode switch (max. 20 times, once per second) ... Waiting for original device to vanish ... Waiting for original device to vanish ... Original device can't be accessed anymore. Good. Searching for target devices ... Found correct target device Mode switch succeeded. Bye.
看一下 dmesg: [38715.226573] usb 2-1.1.4.2: new high speed USB device using ehci_hcd and address 23 [38715.337316] usb 2-1.1.4.2: New USB device found, idVendor=07d1, idProduct=7e11 [38715.337321] usb 2-1.1.4.2: New USB device strings: Mfr=3, Product=2, SerialNumber=4 [38715.337324] usb 2-1.1.4.2: Product: D-Link WCDMA Technologies MSM [38715.337327] usb 2-1.1.4.2: Manufacturer: D-Link,Incorporated [38715.337329] usb 2-1.1.4.2: SerialNumber: MF112DDLKD010000 [38715.337460] usb 2-1.1.4.2: configuration #1 chosen from 1 choice
已經切換了。

然後動 load usb-serial module,指定 vid,pid sudo modprobe usbserial vendor=0x07d1 product=0x7e11
dmesg 可以看到 ttyUSB 出現: [38715.339951] usbserial_generic 2-1.1.4.2:1.0: generic converter detected [38715.340069] usb 2-1.1.4.2: generic converter now attached to ttyUSB0 [38715.340178] usbserial_generic 2-1.1.4.2:1.1: generic converter detected [38715.340280] usb 2-1.1.4.2: generic converter now attached to ttyUSB1 [38715.340537] scsi20 : SCSI emulation for USB Mass Storage devices [38715.340695] usb-storage: device found at 23 [38715.340699] usb-storage: waiting for device to settle before scanning [38715.340788] usbserial_generic 2-1.1.4.2:1.3: generic converter detected [38715.340889] usb 2-1.1.4.2: generic converter now attached to ttyUSB2 [38720.337127] usb-storage: device scan complete

這時候,在 panel 的 network widget 就可以看到 "Chungwha Telecom..",
打勾 就可以連上了。



ref: http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=817&sid=e08d0632f3a91e6379a0367bd258809c

2012年2月9日 星期四

Android Set System Time.

/framework/base/libs/utils/SystemClock.cpp:
#if HAVE_ANDROID_OS fd = open("/dev/alarm", O_RDWR); if(fd < 0) { LOGW("Unable to open alarm driver: %s\n", strerror(errno)); return -1; } ts.tv_sec = tv.tv_sec; ts.tv_nsec = tv.tv_usec * 1000; res = ioctl(fd, ANDROID_ALARM_SET_RTC, &ts); if(res < 0) { LOGW("Unable to set rtc to %ld: %s\n", tv.tv_sec, strerror(errno)); ret = -1; } close(fd); #else if (settimeofday(&tv, NULL) != 0) { LOGW("Unable to set clock to %d.%d: %s\n", (int) tv.tv_sec, (int) tv.tv_usec, strerror(errno)); ret = -1; } #endif 可以看到 Android 設定系統時間,用 ioctl,不能直接 call settimeofday.

settimeofday ,系統時間會改,但是 RTC 不會改, 所以 system reboot 後,時間還是沒變更。




手動設會有 D/SystemClock( 2399): Setting time of day to sec=31622433 D/ ( 2269): enter Cmd: L D/dalvikvm( 2269): GC_CONCURRENT freed 1061K, 45% free 2224K/3971K, external 3688K/4325K, paused 3ms+3ms D/AlarmManagerService( 2269): Kernel timezone updated to -540 minutes west of GMT

Time Sync with GPS

Time Sync with GPS
  1. 設定 enable/disable 放在 Settings.system 中
  2. 應該由 Location Service 讀取內容,負責動作。
Location Service 和 hardware gps 的分層負責就因人而異了。

可以增加 interface (?),讓 service 告知 gps driver 收到 gps time nmea data 時,set system time。
也可以 service 自己作,當取得 nmea time data 時,依照 Setting 內容決定。

要sync system time 的時機:
  1. 改 Auto Sync 設定時
  2. GPS lock 時
所以要寫在兩個地方,互相 check 對方。

但是要確認 gps driver , check lock 的時間,要比 server 啟動, check system setting 的後面才行。
否則就會不同步。



直接把 GPS NMEA Channel cat 出來.. (只列出 GPRMC)..並且修改 location data.. (所以 checksum 是錯的) $GPRMC,080058.000,A,2502.9061,N,14122.4832,E,0.00,0.00,090212,,,A*6x $GPRMC,080100.000,A,2502.9061,N,14122.4832,E,0.00,0.00,090212,,,A*6x $GPRMC,080101.000,A,2502.9061,N,14122.4832,E,0.00,0.00,090212,,,A*6x $GPRMC,080102.000,A,2502.9061,N,14122.4832,E,0.00,0.00,090212,,,A*6x GPRMC format : (http://aprs.gids.nl/nmea/#rmc)
eg1. $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62
eg2. $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68


           225446       Time of fix 22:54:46 UTC
           A            Navigation receiver warning A = OK, V = warning
           4916.45,N    Latitude 49 deg. 16.45 min North
           12311.12,W   Longitude 123 deg. 11.12 min West
           000.5        Speed over ground, Knots
           054.7        Course Made Good, True
           191194       Date of fix  19 November 1994
           020.3,E      Magnetic variation 20.3 deg East
           *68          mandatory checksum
GPS FIX 的資料是在 $GPGGA - Global Positioning System Fix Data (http://aprs.gids.nl/nmea/)
eg2. $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx

hhmmss.ss = UTC of position 
llll.ll = latitude of position
a = N or S
yyyyy.yy = Longitude of position
a = E or W 
x = GPS Quality indicator (0=no fix, 1=GPS fix, 2=Dif. GPS fix) 
xx = number of satellites in use 
x.x = horizontal dilution of precision 
x.x = Antenna altitude above mean-sea-level
M = units of antenna altitude, meters 
x.x = Geoidal separation
M = units of geoidal separation, meters 
x.x = Age of Differential GPS data (seconds) 
xxxx = Differential reference station ID 
其中 'GPS Quality indicator' 就是 FIX 的狀態..
實際的資料: (pull-out gps antenna): $GPGGA,000935.066,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*4C $GPGGA,000936.064,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*4D $GPGGA,000938.066,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*41 $GPGGA,000940.075,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*4C $GPGGA,000941.065,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*4C

2012年2月8日 星期三

moveTaskToFront, moveTaskToBack ..

要作一個 toggle 功能的 hot-key: 按一下開啟,按一下關閉。

關閉還不能真的關,只能把他擺到後面..

所以用 moveTaskToBack, moveTaskToFront 來作。

Hotkey 的implement 在 PhoneWindow.java

所以在 onKeyDown( ) 的 case 特殊 Key,作 public class PhoneWindow extends Window implements MenuBuilder.Callback { String packageName = "com.android.calculator2"; String className = "com.android.calculator2.Calculator"; ActivityManager am = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE); List>ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(20); for(int i=0;i<taskInfo.size();i++) { Log.d("current task:", "CURRENT Activity ::" + taskInfo.get(i).topActivity.getClassName() + ", id: " + taskInfo.get(i).id); Log.d("Package Name:", " " + taskInfo.get(i).topActivity.getPackageName()); if(taskInfo.get(i).topActivity.getPackageName().equals(packageName) == true){ Log.d(TAG,"Found!" + packageName + " in " + i); if(i!=0) { try { ActivityManagerNative.getDefault().moveTaskToFront(taskInfo.get(i).id); }catch (RemoteException e) { Log.d(TAG,"Failed !! moveTaskToFront"); } }else{ try { ActivityManagerNative.getDefault().moveTaskToBack(taskInfo.get(i).id); } catch (RemoteException e) { Log.d(TAG,"Failed !! moveTaskToBack"); } Log.d(TAG,"Calc is on top"); } return true; } } // calculator not launched. Log.d(TAG," " + packageName + " not running"); Intent intent = new Intent(); intent.setClassName(packageName,className); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { getContext().startActivity(intent); }catch( ActivityNotFoundException e){ Log.d(TAG,"Activity Not Found"); } } .. 找特定 packagename,如果是 0 (top), move to back.
如果不是 0 (background), move to front

如果找不掉 -- startActivity 啟動他

用 eclipse 的 hierarchy viewr 可以看到這個動作。

但是某 app,本身就具有 "避免重複啟動" , back , home key, keeps running in background 功能。
在 move to front 後,沒有動作。
看 hierarachy view ,好像沒有取得 focus。

所以只好改成:
if on top ==> move to back
if not top ==> startActivity



這要動作。系統要拿掉 GET_TASKS, moveTaskToFront, moveTaskToBack 的 permission check

2012年2月7日 星期二

ViewRoot 的 getpermission 用到 ActivityManagerNative: return ActivityManagerNative.getDefault().checkPermission( permission, Binder.getCallingPid(), Binder.getCallingUid());

getTopActivity & GET_TASKS permission check

要知道目前 最前面的 activity 是什麼,可以用: import java.util.List; import android.app.ActivityManager; ... ActivityManager am = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1); Log.d("current task:", "CURRENT Activity ::" + taskInfo.get(0).topActivity.getClassName()); Log.d("Package Name:", " " + taskInfo.get(0).topActivity.getPackageName());
但是 getRunningTasks( ) 需要 GET_TASKS 權限 android.permission.GET_TASKS

getRunningTasks( ) 實際上是 call IActivityManager 的 getTasks(): public List<RunningTaskInfo> getRunningTasks(int maxNum, int flags, IThumbnailReceiver receiver) throws SecurityException { try { return ActivityManagerNative.getDefault().getTasks(maxNum, flags, receiver); } catch (RemoteException e) { // System dead, we will be dead too soon! return null; } }


配合 Hotkey 的動作,如果要作到:依照目前操作的 程式,決定 Hotkey 要 launch 的程式,就要改 framework 裡,hotkey 的 code。

因為這段 code 實際上是在每一個 vm 中 run 的,
所以,要是 這個 package 沒有 GET_TASKS 權限, framework 的 getRunningTasks 就會 fail。

只好.... bypass GET_TASKS 的 permission check!!

修改 ActivityManagerService.java: public List getTask(int maxNum .... ... if (checkCallingPermission(android.Manifest.permission.GET_TASKS) != PackageManager.PERMISSION_GRANTED) { .. 把這段 check comment 掉..



ref:
  1. http://qtcstation.com/2011/01/getting-info-about-your-currently-running-activities/

2012年2月6日 星期一

shortcut - Camera

CAMERA 按鍵在 android framework 中,要長按才會啟動,

順便可以看一下 LongPress 的 detection: if (event.getRepeatCount() == 0) { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { dispatcher.performedLongPress(event); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); sendCloseSystemWindows(); Broadcast an intent that the Camera button was longpressed Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); intent.putExtra(Intent.EXTRA_KEY_EVENT, event); getContext().sendOrderedBroadcast(intent, null); } 大概就是... 第一次 down event (repeat()=0) 時,call startTracking( ) 叫 Input manager(?) tracking 這個 key。
這樣 input manager 就會持續嗔測 CAMERA Key, timeout 時 再送一個 down event,並且 event.isLongPress() 會是 1



在 ViewRoot.java 有關 CAMERA Key 的一段 code: private void dispatchKey(KeyEvent event, boolean sendDone) { //noinspection ConstantConditions if (false && event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_CAMERA) { if (Config.LOGD) Log.d("keydisp", "==================================================="); if (Config.LOGD) Log.d("keydisp", "Focused view Hierarchy is:"); debug(); if (Config.LOGD) Log.d("keydisp", "==================================================="); } } .... 如果把 false 拿掉,會印出有趣的 debug message,,,
D/keydisp ( 2642): =================================================== D/keydisp ( 2642): Focused view Hierarchy is: D/View ( 2642): + com.android.internal.policy.impl.PhoneWindow$DecorView@2ac72cc0 D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/Debug ( 2642): Contents of WM.LayoutParams{(0,0)(fillxfill) ty=1 fl=#790303 fmt=-2 wanim=0x1030001}: D/Debug ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } D/Debug ( 2642): WindowManager.LayoutParams={title=com.android.deskclock/com.android.deskclock.DeskClock} D/View ( 2642): flags={} D/View ( 2642): privateFlags={IS_ROOT_NAMESPACE HAS_BOUNDS DRAWN} D/View ( 2642): { D/View ( 2642): + android.widget.FrameLayout@2ac73900 (id=16908290) D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/View ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } D/View ( 2642): flags={} remain 0 unprocessed. D/View ( 2642): privateFlags={HAS_BOUNDS DRAWN} D/View ( 2642): { D/View ( 2642): + android.widget.FrameLayout@2ac74548 D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/View ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } D/View ( 2642): flags={} D/View ( 2642): privateFlags={HAS_BOUNDS DRAWN} D/View ( 2642): { D/View ( 2642): + android.widget.LinearLayout@2ac74bc0 (id=2131492882) D/View ( 2642): frame={0, 0, 800, 480} scroll={0, 0} D/View ( 2642): padding={0, 38, 0, 0} D/View ( 2642): mMeasureWidth=800 mMeasureHeight=480 D/View ( 2642): ViewGroup.LayoutParams={ width=match-parent, height=match-parent } 可以出來,目前的 Focuse App 是 com.android.deskclock/com.android.deskclock.DeskClock

2012年2月3日 星期五

Task :
A task is a collection of activities that users interact with when performing a certain job. 
http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html 所以task 是一堆 activity 的集合。
Application 是 apk.
application 裡面是一堆 component (Activity, Service, BroadcastReceiver...)。
當這個 application 的 component 被叫起來時, android 就會啟動這個 application。
做出 Launcher 長壓 HOME Key 的動作:
列出 N 個 recent task,按下後開啟該 task。

或先測試一下這用 "長按 HOME" 來切換 task 的方式,和不合用。
再作決定。


HomeLongPress 在 PhoneWindowManager.java Runnable mHomeLongPress = new Runnable() { public void run() { mHomePressed = false; performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); showRecentAppsDialog(); } };
的 showRecentAppsDialog: void showRecentAppsDialog() { if (mRecentAppsDialog == null) { mRecentAppsDialog = new RecentApplicationsDialog(mContext); } mRecentAppsDialog.show(); }
所以實做就是在 RecentApplicationDialog( )


2012年2月2日 星期四

3g modem, rild & pppd

init.rc 啟動 rild 和 pppd: service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so socket rild stream 660 root radio socket rild-debug stream 660 radio system socket rild-ppp stream 660 radio system user root group radio cache inet misc audio service pppd_gprs /etc/init.gprs-pppd user root group radio cache inet misc disabled oneshot rild 的部份是直接 run rild (實際是去 run libreference-ril.so 的 Init)

rild 負責 modem 的初始化,語音撥撥號,接聽,modem 連線狀態維護 (連線中, operator, signal strength.. etc)。
pppd 則負責 ppp protocol,並形成 ppp0 這個 network interface

pppd 是 run script : /etc/init.gprs-pppd: PPPD_PID= /system/bin/setprop "net.gprs.ppp-exit" "" /system/bin/log -t pppd "Starting pppd" #/system/xbin/pppd $* # pppd was put into /system/bin instead of /system/xbin after SDK1.6 if ls /dev/ttyUSB0 > /dev/null 2>&1; then /system/bin/pppd connect 'chat -f "/etc/3gdata.conf"' /dev/ttyUSB3 115200 mru 1280 mtu 1280 nodetach debug dump defaultroute usepeerdns novj novjccomp noipdefault ipcp-accept-local ipcp-accept-remote connect-delay 5000 linkname ppp0 else /system/bin/pppd ttyACM0 921600 nodetach noauth noipdefault defaultroute usepeerdns linkname ppp0 connect "chat -v '' AT OK ATD*99***1# CONNECT" debug fi PPPD_EXIT=$? PPPD_PID=$! /system/bin/log -t pppd "pppd exited with $PPPD_EXIT" /system/bin/setprop "net.gprs.ppp-exit" "$PPPD_EXIT" .. 這個 file 在 /system/core/rootfs/etc/

script 是啟動 pppd ,在參數指定連接的動作,使用 chat: connect 'chat -f "/etc/3gdata.conf" ' 這樣寫是要 chat 使用 3gdata.conf 作 連線參數。
connect "chat -v ''AT OK ATD*99***1# CONNECT" 這樣寫是使用簡單是 chat 設定,所以直接寫出來。

chat 是一種 send - reply 對應的程式,會依照config 送 string,並且依照 config 檢查回應的string。

pppd 的 help 中,connet 的說明是: connect <p> Invoke shell command <p> to set up the serial line 就是另外 run script 'p' 來作建立連線的動作 (撥號)。

啟動 pppd 還要給的就是 pppd 對應的 3g modem data port number,一般會是 /dev/ttyUSB?

3g modem 會提供很多 ttyUSB port,每個有不同的功能
  1. AT Command 語音撥號
  2. ppp 資料
  3. AT Command 系統狀態
每一個廠家的port 對應都不一樣,所以要告訴 pppd 對哪一個 port 動作。

同理,撥號也一樣,如果撥號和 ppp 通訊在同一個,就可以寫在 這裡,叫 pppd 撥號。
如果 撥號 和 ppp 通訊在不同的 port,就不能請 pppd 做了 (也就沒有 connect 這個 參數)



port 是 支援 3g modem 時最麻煩的東西。
不同的 modem 有不同的 port 指定。
不僅 pppd 要知道對哪一個 port 動作, rild 也要知道。

舊版的 android,是把 port number 直接寫在 init.rc 的 啟動命令參數,所以要同時支持多個 3g modem 是不可能的。

新版修改了 rild reference-ril,會由 3g modem 的 vid, pid 知道是哪一個 modem,然後有一個內建的 table,決定 port。
所以只要有在 vid. pid table 中的 3g modem, rild 都可以正確動作。

* 但是這樣只有作半套...
pppd 的 port 還是由 init.rc 寫死,所以沒辦法依照 vid.pid 來決定。

iMX51 的 DDR D0-D31 driving strength setting

  1. IOMUXC_SW_PAD_CTL_GRP_DRAM_B0 (08A4) : DRAM_D0-- D7
  2. IOMUXC_SW_PAD_CTL_GRP_DRAM_B1 (08AC) : DRAM_D8-- D15
  3. IOMUXC_SW_PAD_CTL_GRP_DRAM_B2 (08B8) : DRAM_D16- D23
  4. IOMUXC_SW_PAD_CTL_GRP_DRAM_B4 (082C) : DRAM_D25- D31
最後 bit 2.1 是 driving strength
  1. 0.0 : Low
  2. 0.1 : Medium
  3. 1.0 : High
  4. 1.1 : Max
memory 的相關設定都是在 bootloader 做的,所以是在 board/freescale/imx51_bbg/flash_header.S MXC_DCD_ITEM(11,4, IOMUXC_BASE_ADDR + 0x8a4, 0x004) MXC_DCD_ITEM(12,4, IOMUXC_BASE_ADDR + 0x8ac, 0x004) MXC_DCD_ITEM(13,4, IOMUXC_BASE_ADDR + 0x8b8, 0x004) MXC_DCD_ITEM(14,4, IOMUXC_BASE_ADDR + 0x82c, 0x004) 都改最小的話,就是 0x000

標籤

網誌存檔