ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2012年4月16日 星期一

Android System Shutdown -- code trace

在 frameworks/base/core/java/com/android/internal/app 有一個 ShutdownThread.java

這邊有說明一下 shutdown process:
  1. http://kobablog.wordpress.com/2011/07/16/shutdown-sequence-of-android/
  2. http://hi.baidu.com/jsxhxcq/blog/item/0933ae618376f0e8f6365451.html

使用標準的 shutdown process的話,app 還可以收到 shutdown message:
http://stackoverflow.com/questions/5076410/how-to-know-device-is-power-off

copy 一下 回答的部份:
public static final String ACTION_SHUTDOWN Since: API Level 4 Broadcast Action: Device is shutting down. This is broadcast when the device is being shut down (completely turned off, not sleeping). Once the broadcast is complete, the final shutdown will proceed and all unsaved data lost. Apps will not normally need to handle this, since the foreground activity will be paused as well. This is a protected intent that can only be sent by the system. Constant Value: "android.intent.action.ACTION_SHUTDOWN" This would appear to be it? I just Googled your command and it was on the Standard Broadcast Actions list. :
ref: http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN

my hero mantain log - 恢復 official 2.1

因為改了 font,竟然導致 開機 fail -- 開到 hTC ...就停了

這時候連上 PC,沒有動作,裝了 HTC Sync 後才有 (猜是 usb pid/vid)。

然後值行 download 下來的 RUU.exe ,竟然可以動 (猜是 HTC sync 有連上 adb)。
RUU 執行,說明是 .4,要升(?) 級到 .1 (?),回答OK後,自己進入 HBOOT,
update ok 後,自動重新開機,回到官方 2.1。

開機都開完後,關機,
按著 HOME Key 開機,結果出現 紅色三角。
接著按 Volume UP + Power,嘗試進入 recovery,...
出現:
Android ststem recovery < 2e >
follow instruction,reboot system。

插入 SIM card 開機,enable 3G data --- 出現 OTA, 升級到 .4 的通知。

確認,自己 reboot,然後是 progress 圈圈....
等一陣子後,就是.4 版了。


之後 SD card 正常使用,Google Acccount 設定後,Market 可以用,install facebook, google+ 都 OK。
google map 與定位也 OK (但是功能和畫面不太一樣)。

應該算是正常使用了。

所以接下來就是作 backup. 和 root(?).



開機時按著 "HOME" 就是進入 Recovery Mode。
bootloader load 會是 recovery image。

上面的紅色三角+驚嘆號 就是 HTC 官方的 recovery image。
所以手機要先root,然後把 燒rom 用的 recovery image copy 到 recovery partition,
覆蓋掉原來的

手機mantain : 一些 hero rom 與更新bookmark

官方:

很有趣,從 RUU 中找出 rom : http://www.diypda.com/forum.php?mod=viewthread&tid=140722

01 的,官方2.1rom, recook: http://www.mobile01.com/topicdetail.php?f=566&t=1693403&p=103

01 上RUU (不知道是不是最新) : http://www.mobile01.com/topicdetail.php?f=566&t=1674071

非官方, 2.2, 2.3:

原始 XDA 大概是在: http://forum.xda-developers.com/showthread.php?t=932377

elelinux 中文版說明: http://gphonefans.net/thread-28341-1-1.html

同樣是 elelinux,大陸人的說明 (有點亂,但是有一點評側) : http://bbs.hiapk.com/thread-1864963-1-1.html

中文輸入法: http://devilmen.blogspot.com/2011/01/cedime-for-android.html

01 的,結果好像都不怎麼 OK : http://www.mobile01.com/topicdetail.php?f=566&t=2234395&p=1

01 的另一篇,教刷機:http://www.mobile01.com/topicdetail.php?f=566&t=1989203&p=1

xda 上的另一個 rom - zero: http://forum.xda-developers.com/showthread.php?t=1406532&page=11

兩種 rom : http://blog.xuite.net/diecorroder/withclaire/39127279-%5BHERO+ROM%5D+HERO+2.2+%E6%95%88%E8%83%BD453%E5%88%86!+Tegro+2.1+%2F+Floyo+1.01+%2F+FROYO_2.2_v2.1+3%E6%AC%BEROM%E7%B0%A1%E5%96%AE%E6%B8%AC%E8%A9%A6!+

01 的,2.2 (3?) : http://www.mobile01.com/topicdetail.php?f=566&t=2141479&p=1

刷 elelinux 後的感想:http://synn-solis.blogspot.com/2010/11/android-hero.html

2012年4月10日 星期二

u-boot boot code -- alter path of boot

boot code trace
cpu/arm_cortexa8/cpu.S 就像是以前 ads 的 startup.S

一開始就是 arm 的 interrupt vector。
後面就是 code.

從 reset 開始。
然後call cpu_init_crit (low level init ?)。
之後就是 relocate。
-- 因為 iMX51 的 bootrom 已經把DDR config 好,並且把 uboot load 到 DDR,所以不用作 reloacate 了。

設定 stack:
sp = _TEXT_BASE - #CONFIG_SYS_MALLOC_LEN - #CONFIG_SYS_GBL_DATA_SIZE - 12

clear bbs: __bss_start -- __bss_end 的區域都填 0

run board_mmu_init.
這段code 要參考 Reference Manual Chapter 2 : Memory Map. 對照 Physical Address 的內容 (其實註解已經寫得很清楚)
/* Actual Virtual Size Attributes Function */ /* Base Base MB cached? buffered? access permissions */ /* xxx00000 xxx00000 */ X_ARM_MMU_SECTION(0x000, 0x200, 0x1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* ROM */ X_ARM_MMU_SECTION(0x1FF, 0x1FF, 0x001, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* IRAM */ X_ARM_MMU_SECTION(0x300, 0x300, 0x100, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* GPU */ X_ARM_MMU_SECTION(0x400, 0x400, 0x200, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* IPUv3D */ X_ARM_MMU_SECTION(0x600, 0x600, 0x300, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* periperals */ X_ARM_MMU_SECTION(0x900, 0x000, 0x1FF, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */ X_ARM_MMU_SECTION(0x900, 0x900, 0x200, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */ X_ARM_MMU_SECTION(0x900, 0xE00, 0x200, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM 0:128M*/ X_ARM_MMU_SECTION(0xB80, 0xB80, 0x10, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CS1 EIM control*/ X_ARM_MMU_SECTION(0xCC0, 0xCC0, 0x040, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CS4/5/NAND Flash buffer */
其中 X_ARM_MMU_SECTION 的內容,跟 MMU 的spec 一樣,一個 entry 是 1M ,所以: #define X_ARM_MMU_SECTION(abase, vbase, size, cache, buff, access) \ { \ int i; int j = abase; int k = vbase; \ for (i = size; i > 0 ; i--, j++, k++) \ ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access); \ }
根據 size 以 1M 為單位,把所有的 table entry 都設完。
-- 因為 MMU 的 translation 是把bit20~31 拿去作 translate。所以單位是 1M (0~19 bit).

  1. 關於 mmu section translation 可以google 一下:https://www.google.com.tw/search?q=arm%20mmu%20section%20translation&um=1&ie=UTF-8&hl=zh-TW&tbm=isch&source=og&sa=N&tab=wi&ei=3NSDT_-eJaz0mAWizJW4Bw&biw=1366&bih=630&sei=-dSDT8-LEMycmQXnquSyBw

這 code 跟 spec 的圖結合在一起: union ARM_MMU_FIRST_LEVEL_DESCRIPTOR { unsigned long word; struct ARM_MMU_FIRST_LEVEL_FAULT fault; struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table; struct ARM_MMU_FIRST_LEVEL_SECTION section; struct ARM_MMU_FIRST_LEVEL_RESERVED reserved; }; 是 UNION.
ref : ARM processor MMU -- level one descriptor 的圖。

之後就可以啟動 MMU。

然後執行 start_armboot()。



start_armboot()準備 gd_t (globale_data) 的空間,然後用類似 linux init 的方式 call init function (這裡是手動): for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { hang (); } } init_fnc_t *init_sequence[] = { #if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ #endif board_init, /* basic board dependent setup */ #if defined(CONFIG_USE_IRQ) interrupt_init, /* set up exceptions */ #endif timer_init, /* initialize timer */ env_init, /* initialize environment */ init_baudrate, /* initialze baudrate settings */ serial_init, /* serial communications setup */ console_init_f, /* stage 1 init of console */ display_banner, /* say that we are here */ #if defined(CONFIG_DISPLAY_CPUINFO) print_cpuinfo, /* display cpu info (and speed) */ #endif #if defined(CONFIG_DISPLAY_BOARDINFO) checkboard, /* display board info */ #endif #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) init_func_i2c, #endif dram_init, /* configure available RAM banks */ #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI) arm_pci_init, #endif display_dram_config, NULL, }; 之後就是一個一個個別 hardware function 的 init... (?為什摩不在 init_sequence[] 裡作?)

然後 call check_recovery_mode()
最後是 main_loop().



check_recovery_mode( ) 就是偵測 hardware pin,然後call setup_recovery_env( )。
單純操作 env: void setup_recovery_env(void) { char *env, *boot_args, *boot_cmd; int bootdev = get_boot_device(); boot_cmd = supported_reco_envs[bootdev].cmd; boot_args = supported_reco_envs[bootdev].args; if (boot_cmd == NULL) { printf("Unsupported bootup device for recovery\n"); return; } printf("setup env for recovery..\n"); env = getenv("bootargs_android_recovery"); /* Set env to recovery mode */ /* Only set recovery env when these env not exist, give user a * chance to change their recovery env */ if (!env) setenv("bootargs_android_recovery", boot_args); env = getenv("bootcmd_android_recovery"); if (!env) setenv("bootcmd_android_recovery", boot_cmd); setenv("bootcmd", "run bootcmd_android_recovery"); }
就是改 bootcmd 為 "run bootcmd_android_recoery"。
這樣之後的 boot process,去 run bootcmd ,就會 run bootcmd_android_recovery.

2012年4月9日 星期一

bluez a2dp sink test

首先是這一篇:http://blog.cyphermox.net/2012/03/call-for-testing-bluez-a2dp-and-hsphfp.html

這樣看起來 bluez 好像可以 support A2DP Sink。
所以稍微查一下,
最後是照著這一篇:http://linuxtoy.org/archives/ubuntu-bluetooth-guide.html

用 blueman pair 後才成功。



需要 paluseaudio。

先修改 /etc/bluetooth/audio.conf,在 [General] 後面加上 Enable=SourceL
重新啟動 bluetooth: service bluetooth restart 之後就可以用 blueman (Debian 需要aptitude額外安裝),Bluetooth Manager的 device 作 search,
Blueman 可以選擇 connect to 的 function ,選 "Audio Source"。
一樣,作 pair, trust,connect 後,在 手機上可以看到 已經和 NB 作 媒體音訊 的連接了。

之後手機就可以播放。

手機連接 A2DP 後,在音量控制部份,會多出一個 entry: Device : Capture : 手機名稱(PulseAudio Mixer)


ref:
  1. 圖文並茂版:http://ceworkbench.wordpress.com/2011/03/21/configuring-linux-as-an-a2dp-audio-sink/
  2. dbus command: http://blog.csdn.net/mayouyang/article/details/5940805



不使用 blueman ,手動的部份,參考 ref 2 的後半,還有 http://ceworkbench.wordpress.com/2011/03/21/configuring-linux-as-an-a2dp-audio-sink/

一般的問題都是用 pactl list 找不到 手機 的 source card。
這個 ref 可以看到是用 bluetooth device address 為名。

依照說明,開啟 d-feet,在 device address 的 AudioSource method connect() 按下後,
執行 pactl list | grep Name: 可以看到兩個 entry: Name: bluez_source.5C_B5_24_XX_XX_XX Name: bluez_card.5C_B5_24_XX_XX_XX 這個就是手機連線後,新增加的 sound card 裝置。

follow 說明 load module-loopback 給定對應的 source, sink name ,就可以正確播出聲音了。

.. 我的 pactl list | grep Name: 有關 audio 的是: Name: alsa_output.pci-0000_02_00.1.hdmi-stereo Name: alsa_output.pci-0000_00_1b.0.analog-stereo Name: alsa_output.pci-0000_02_00.1.hdmi-stereo.monitor Name: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor Name: alsa_input.pci-0000_00_1b.0.analog-stereo Name: bluez_source.5C_B5_24_XX_XX_XX Name: alsa_card.pci-0000_02_00.1 Name: alsa_card.pci-0000_00_1b.0 Name: bluez_card.5C_B5_24_XX_XX_XX 所以 load loopback module 的 command 是: pactl load-module module-loopback source=bluez_source.5C_B5_24_XX_XX_XX sink=alsa_output.pci-0000_00_1b.0.analog-stereo
這個command 回 return 一個數字,是 modue 的 index,在 unload-module 時要用。
例如,return 20 的話,unload loopback module 時,要用: pactl unload-module 20


這個blog有詳細的 bluetooth, bluez 解說:
http://blog.sina.com.cn/s/articlelist_1613727600_2_1.html

2012年4月6日 星期五

bluez test tool - l2test, l2ping

bluez 有一些 bluetooth 測試的 tool:
像 ping 一樣動作的 l2ping: 先用 hcitool scan 掃一下 附近 device 的 Address 用 l2ping XX:XX:XX:XX:XX:XX 就像網路的 ping 一樣,會回報回應時間。

也有類似 iperf 一樣的 持續 send, rec 的 client -- server mode testing program:
l2test
Usage: l2test [options] [bdaddr] Modes: -r listen and receive -w listen and send -d listen and dump incoming data -x listen, then send, then dump incoming data -t listen, then send and receive at the same time -q connect, then send and receive at the same time -s connect and send -u connect and receive -n connect and be silent -y connect, then send, then dump incoming data -c connect, disconnect, connect, ... -m multiple connects -p trigger dedicated bonding -z information request Options: [-b bytes] [-i device] [-P psm] [-I imtu] [-O omtu] [-L seconds] enable SO_LINGER [-W seconds] enable deferred setup [-B filename] use data packets from file [-N num] send num frames (default = infinite) [-C num] send num frames before delay (default = 1) [-D milliseconds] delay after sending num frames (default = 0) [-X mode] select retransmission/flow-control mode [-F fcs] use CRC16 check (default = 1) [-Q num] Max Transmit value (default = 3) [-Z size] Transmission Window size (default = 63) [-R] reliable mode [-G] use connectionless channel (datagram) [-U] use sock stream [-A] request authentication [-E] request encryption [-S] secure connection [-M] become master [-T] enable timestamps 實際使用:
Server 的 command: l2test -I 2000 -r
Client 的 command: l2test -O 2000 -s XX:XX:XX:XX:XX:XX

ref:
  1. http://www.jeremythompson.uklinux.net/RH8-0/bluezhowto.pdf

2012年4月2日 星期一

NB A2DP to device ..

00:19:0E:A0:2F:44 2be 用 nb 連 A2DP 的 Sink,播放聲音給他。

好像就是配對成功,
然後 在自己的 HOME 下新增這個 .asoundrc pcm.bluetooth { type bluetooth device 00:19:0E:A0:2F:44 } pcm.!default { type plug slave.pcm "bluetooth" } 那個 device 的 MAC 就是 A2DP speaker 的 MAC。
然後用 movie player 撥就可以
-- 用 VLC 撥,聲音還是在 nb 這邊。

在 VLC -- preference -- Audio 這邊,要選 ALSA 裝置 -- default。


ref:
  1. http://forum.xbmc.org/showthread.php?tid=103503

標籤

網誌存檔