- 建一個BSP_ 開頭的目錄在\PLATFORM\COMMON\SRC\SOC\pxa310_mrvl_v1下
- 將檔案copy到上述的目錄
- 從你要改的檔的source 找出TARGETNAME
- 用3的name 去search PUBLIC, PLATFORM 下的sources
- -> 如果PUBLIC 下有就要再去找用的sources是不是有另外別人用(用這一個的sources 再跑一次3,4 steps)
- -> 如果PLATFORM 下有就要改它的sources 去link 到你會產生的lib而不是public的
- -> 如果兩個都沒有, 去search PUBLIC\COMMON\CESYSGEN\makefile, 如果有…表示wince 有用到這個lib
- 在project root 下, 下sysgen_captuer <targetname>, 會產生一個或多個sources.xxxx, 選source.<targetname>
- create a DLL floador 在(上層1), 將1 copy 進去rename 成sources
- 改(上層3的source) targetname = bsp_xxxxx
- 改includes 或cpp 想辦法讓它build 過
10.22.2008
如何將public code 移到platform下
9.12.2008
* how is it programmed in code?
* every status maps to what signaling?
UfnMdd_Start() @publiccommonoakdriversusbfncontrollermddUfnmdd.cpp ->
ZyUSBOTG_ULPI::NewStateAction() @platformzylonite_mhlvsrdriverotg_upliUsbotg_lupi.cpp
*what's Device A&B? -> A = Host, need to offer Vbus , B = peripheral
No device attached: D+ and D- float to 0V if not driven
FS device attached: D+ floats to 4.54V and D- floats to 0V if not driven
LS device attached: D+ floats to 0V and D- floats to 4.54V if not driven
*pull-down resistance
when A/B-device is idle or acting as Host, D+ -> pull low (R 14.25k -24.8k) D- -> pull low (R 14.25k -24.8k)
when A/B-device is acting as a peripheral, D+ disable pull-down(floating) and D-> pull-down, A prevent B-device's D- floating if the B-device becomes unplugged and B is the same that of A-device.
During the interval of packet transmission, A/B-device is allowed to disable D+ and D- pull-down resistor
*pull-up resistance
A/B-device is operating as Peripheral, D+ -> pull-up
During the interval of packet transmission, A/B-device is allowed to disable D+ pull-up resistor
*if one side is not OTG device, how does the protocol go?
J state -> idle state -> D+>D-(differential 1) for FS, D+<D-(differential 0) for LSK state -> D+<D-(differential 0) for FS, D+>D-(differential 1) for LS
*What's Host Negotiation protocol(HNP)?
- A-device sends a SetFeature(b_hnp_enable) command.
- A-device suspend bus.
- B-device signals a disconnect to the A-device.(if B-device want to use bus)
- A-device interrupts this disconnect.(if A-device enable to switch)
- A-device turns on pull-up resistor on D+.
A) A-device finishes using bus and stops all bus activity, (i.e. suspends the bus).
A) A-device 用完bus 然後停止所有的bus 的運作,(例如suspends the bus)
B) B-device detects that bus is idle for more than TA_AIDL_BDIS min and begins HNP by turning off pull-up on D+. This allows the bus to discharge to the SE0 state. If the bus was operating in HS mode, the B-device will first enter the full-speed mode and turn on its D+ pull-up resistor for at least TB_FS_BDIS min before turning off its pull up to start the HNP sequence.
B) B-device 偵測到bus idle 超過 TA-AIDL_BDIS min 之後開始 HNP , 透過關掉 D+的pull-up。 這麼做可以讓bus 進入 SE0 state(D+ and D- go low). 如果 bus 正在運作在 HS mode, B-device 會先進入 FS mode 並開啟 D+ pull-up 阻抗至少 TB_FS_BDIS min ,在關掉pull-up 阻抗去開始NHP程序之前.
Note: After B-device enters the FS mode and turns on its pull-up resistor; it waits to see if the data line goes high. If the data line does not go high within TWTRSTHS (from Table 7-14 in USB 2.0 specification [USB2.0]), then the B-device shall start its HS chirp. Otherwise, if the D+ line does go high for at least TB_FS_BDIS min, then the B-device may start HNP.
注意: 在B-device 進入 FS mode 並開啟 pull-up 阻抗之後; 它會等並看看是否資料線是hi. 如果資料線沒有go high 至少 TWTRSTHS(在USB 2.0 的Table 7-14有提到), B-device 可能會開始它的 HS chirp。否則,如果D+ line 有go high 至少 TB_FS_BDIS min, 則B-device 開始 NHP.
C) The A-device detects the SE0 on the bus and recognizes this as a request from the B-device to become Host. The A-device responds by turning on its D+ pull-up within TA_BDIS_ACON max of first detecting the SE0 on the bus.
C) A-device 偵測到 SE0 並了解這個是 B-device 要變成 Host 的要求。A-device 回應,透過開啟 D+ pull-up 要在第一次偵測到 SE0 的 TA_BDIS_ACON 的最大值之間。
D) After waiting long enough to insure that the D+ line cannot be high due to the residual effect of the B-device pull-up, (see Section 5.1.9), the B-device sees that the D+ line is high and D- line is low, (i.e. J state). This indicates that the A-device has recognized the HNP request from the B-device. At this point, the B-device becomes Host and asserts bus reset to start using the bus. The B-device must assert the bus reset (SE0) within TB_ACON_BSE0 max of the time that the A-device turns on its pull-up.
D) 在等待一段長時間來確定 D+ 線不會是 hi 之後(由於B-device pull-up 的殘餘的影響 Section 5.1.9) , B-device 會看到D+>D-(例如 J State)。這說明了A-device 已經辦識到 HNP 的要求來自B-device。在這個時候, B-device 變成 Host 並reset bus 來開始使用bus. B-device 必須告知 bus reset (SE0) 在 TB_ACON_BES0的最大值之間, 這個時間是A-device 開啟它的pull-up 的時候。
E) When the B-device completes using the bus, it stops all bus activity. (Optionally, the B-device may turn on its D+ pull-up when a FS idle condition is detected on the bus.)
E) 當B-device 用完bus 時, 它停止所有bus 上的運作(B-device 可能會開啟 D+ pull-up 當偵測到 FS idle 在bus 上)
F) A-device detects lack of bus activity for more than TA_BIDL_ADIS min and turns off its D+ pull-up. Alternatively, if the A-device has no further need to communicate with the B-device, the A-device may turn off VBUS and end the session.
F) A-device 偵測到busy 沒有活動超過 TA_BIDL_ADIS min 然後就關掉 D+ pull-up. 如果A-device 沒有更進一步的需要來跟B-device 溝通的話,A-device 關掉Vbus 然後結束 session.
G) B-device turns on its pull-up.
G) B-device 開啟 pull-up.
H) After waiting long enough to insure that the D+ line cannot be high due to the residual effect of the A-device pull-up, (see Section 5.1.9), the A-device sees that the D+ line is high (and D- line is low)indicating that the B-device is signaling a connect and is ready to respond as a Peripheral. At this point, the A-device becomes Host and asserts bus reset to start using the bus.
H) 在等待一段長時間來確定 D+ 線不會是 hi 之後(由於A-device pull-up 的殘餘的影響 Section 5.1.9) , A-device 會看到D+ -> hi, (D- -> low)。這說明了B-device 正在連接並且準備好回應如同一個 Peripheral. 在這個時候, A-device 變成 Host 並reset bus 來開始使用bus.
9.10.2008
9.01.2008
8.25.2008
Windows Embedded CE 6.0 是如何啟動的?
As writer said, the most interesting thing in Embedded system is how the Kernel start. This article gives us insights into kernel and start process.
Windows Embedded CE 6.0 是如何啟動的?
posted by Kurt Kennett, Senior Development Lead, Windows CE OS Core
作業系統程式,如同我的其中一個同事最近才了解的,就只是一個"程式"而已。它沒有存在任何魔法或高深的知識。事實上,一個作業系統程式跟其它程式比起來也只是有較好的結構及設計而已。當你再懷疑時,它就已經是了。愈來愈多的人需要了解及維護一套能支援除錯的作業系統程式的核心。這些人藉由不斷的進步及換工作去尋找新的挑戰來持續學習這樣的核心程式。但這些人當中,如果只有一個人了解作業系統的運作方式,那將是多麼大的風險。
在工作上,我追過作業系統的流程,其中最有趣的部份是它如何啟動。雖然初始化在設計裡是最後一步(最不重要?),但同時卻也揭開,使用原理的最根本的基礎。試想一個平台要啟動,從一開始什麼都沒有,就只有一棵能執行指令(有時甚至連記憶體也沒能使用)的CPU,到能夠將一個平台從原點帶到完全功能的系統,一個不只是只會利用硬體的系統,而還要能夠讓硬體之間有個共通協定的系統。
在這篇文章我要仔細的討論Winodows CE 6.0 kernel是如何啟動的,以及Microsoft 的 kernel 與 OEM 的程式之間的關係。透過這樣的了解,希望有更多的人有個較好的 IDEA,Microsoft "如何"及"為什麼"這樣設計。
一開始,讓我們快速的複習一下 operation system software 是如何被建立的。Microsoft tool chain 發行了.EXE 以及/或者 .DLL 程式檔。這兩個檔案格式都是"Portable Executable"或叫做"PE"格式。他們在許多方面幾乎是一樣的:
- 他們都是Common Object File Format(COFF) 格式
- 他們都有輸入表格及輸出表格(EXE的輸出表格通常是空白的)
- 他們都有個entry pointer(就是程式從哪執行),它是被定義在他們的headers裡
PE 檔還有一個額外的特性就是它可以被安置以至於它能"execute in place"。意思就是說如果 file data 被放在特定的 virtual address,那麼檔案裡的 program code 的部份不需做任何改變就能知道其它code 和data 的正確位址。舉例來說,假設 Microsoft linker program 將 Kernel program 放在 virtual address 0x80000000,然後將它與 code (function entry point) 的關聯也放在 EXE file ,那麼其它的code 就可以透過address(定址?)跳到這一個code。如果 function foo()是在位址0x80001000 然後裡面的一條 code call function bar() 在位址 0x80005000 ,那麼就會有個從 foo() call 到 0x80005000 的h指令,直接存在程式碼裡。虛線只是代表 function code 的開始和結束。
你可見上面的例子,如果 kernel EXE 檔被設計放在位址 0x80000000 但卻被載入在位址 0x8050000,那麼程式裡的指令就會不正確。
當一個 EXE 或 DLL 程式檔在被載入到對應的實際載入位址時需要做一些改變,這樣的改變的程序就叫做 "fixed up" 。(改變的)記錄會被放在一個標準的、允許程式檔被 fixed up 的 EXE 檔裡。然而,直到 fixup 程序完成,EXE 檔的 function 位址會一直是錯的。為了避免這樣的情況,Windows CE kernel EXE 檔會事先 fixed up 好,然後才載入到特定的位址。有個程式叫做 ROMIMAGE ,當它再 build operation system image file (NK.BIN)時,實際上就對 kernel EXE 及一些被使用的 DLLs 做事前的處理並將它們 fix up。
Windows CE images 有一個很重要的結構,叫做 “Table Of Contents”, 或 TOC,它是由 ROMIMAGE 建立並放在 image 檔裡。TOC 包含了operating system image 檔的 pointers 及 metadata。然後在靠近 image 檔一開始的地方,放個 marker - "CECE" (0x44424442)。在這個 maker 之後就是TOC的位址。如此 bootloader 或其它程式可以找到關於這個 image 的資訊。除了透過 marker 可以知道 TOC 的位址外,OAL 還必需定義一個公用的 symbol 叫做 'pTOC' (依照 'C' 命名規則),當 ROMIMAGE 再準備 image 檔時,它會找 pTOC 並填入 TOC 的 virtual address。在編譯時,NK.EXE 的 pTOC 變數必須是 0xFFFFFFFF。當 ROMIMAGE 再準備 NK.BIN OS system imgae 時,ROMIMAGE 會做下列事 (除了其它工作以外):
- 載入 NK.EXE 並 fix it up
- 建立 TOC 並在 image 檔裡找個位址放(當 os image 被載入時,是在 virtual memory裡)
- 在 NK.EXE 裡找 'pTOC' 變數並確定值為 0xFFFFFFFF。
- 將TOC的位址值(2)設給pTOC
這個方式,當 NK.EXE 開始時它會參考這個變數來知道 TOC 在哪裡。透過使用TOC,程式可以找到 operating system image 的其它部份。
NK 0x80070000 0x02000000 RAMIMAGE
RAM 0x82070000 0x01E7F000 RAM
這些 entryies 告訴 ROMIMAGE 要做什麼。它會知道將 OS image 檔放在 0x80070000,以及可以從0x82070000 開始 讀/寫 memory。依照這個資訊,它可以將一些 modules 像是 NK.EXE 和 KERNEL.DLL 放進virtual memory, 然後產生一個TOC並且將TOC 放入image裡。 為了幫助kernel 啟動,TOC 也包含 RAM 位址的資訊。更詳細的資訊有關 image 檔如何放在memory裡,顯示如下:
為了實際讓 operating system 運作起來,bootloader 需要:
2.找 "CECE" marker
3.使用 TOC pointer,就是在找到TOC之後
4.在TOC裡找"NK.EXE" 檔的起始點
5. 掃描這個EXE檔的entry point(它是標準的PE格式檔)
6.跳到與這個entry point 相符合的位址
- 設定 virtual memory並且啟動它
- 收集一些資訊,這些資訊是 KERNEL.DLL 會用來跑系統的資訊
- 使用 pTOC 來找 TOC 以知道 KERNEL.DLL 在 operatinhg system image 的哪裡
- 找 KERNEL.DLL 的 entry point
- 在呼叫他自己的entry 時把在搜集到的重要資訊(2)給 KNERNEL.DLL
- 所有的 caches disabled
- RAMIMAGE 和 RAM 的區域的 entry ,就是在 CONFIG.BIB 檔明確說到的 ,是可定址和讀取的在實際位址
- Virtual memory是在預先定義的狀態(CPU 基本上是執行在 physical address 模式)
- 在virtual memory裡,它有自己的位置(它將會執行指令的地方)
- 在physical memory裡,它有自己的位置(它正在執行指令的地方)
- OEMAddressTable 的 virtual address (當 ROMIMAGE 建立 NK.EXE 並隨後 fixed up 所決定的位置)
The OEMAddressTable has triads of DWORDS making up a line in a table, with the following format:
<region virtual start> <region physical start> <region size in MB>
<region virtual start> <region physical start> <region size in MB>
...
- 備份 pTOC
- OEMAddressTable 位址。
- OEMInitGlobals() function 的位址
- PFN_InitDebugSerial(), PFN_WriteDebugByte(), PFN_ReadDebugByte()
- PFN_SetRealTime(), PFN_GetRealTime(), PFN_SetAlarmTime()
- PFN_Ioctl()
這些 function 的指標都指到 OEM 關連的 functions 像是 OEMInitDebugSerial 及 OEMIoctl,這些 function 都存在 NK.EXE 裡。許多其它 functions 也會被列出來,好讓 KERNEL.DLL 可以做一些必需要做的事情,針對某種特定的平台。這些 functions 也會用很明顯的名字寫在 MSDN 裡。
- Architecture-specific 設定
- Architecture-neutral 設定
- Platform-specific 設定 (特定 CPU 和 BSP 的初始化)
- 設定 hard required page table 及保留 VM 給 kernel page tables
- 在 Page Tables 裡更新 cache 的資訊
- 清除 Transition Lookaside Buffer (TLB)
- 設定 architecture-specific 匯流排及元件 (相關的 chips,處理器等)
- 將 memory (M) 的值,寫到暫存器(R)裡
- 比較 (R) 和另一個有同樣值的暫存器 (R2)
- 如果 (R) 和 (R2) 不相等,則離開
- 將另一個暫存器 (R3)值,寫到 memory (M) 的位址
- 執行的 threads 有個特別地要求
- thread 的 time-slice 到期 (由 timer interrupt event 來通知) 然後換另一個 thread 開始跑
- 另一種中斷發生,這個中斷需要執行高優先權的 thread
- 初始化 Kernel Debug Output (透過呼叫 OEMInitDEbugSerial(),這個 function point 是在 OEMGlobals structer)
- 丟個message("Windows CE Kernel Version xxxx") 到 debug output
- 從變數選項選擇 kernel processor type
- 列舉可用的記憶體(選擇性的呼叫 OEMEnumExtensionDRAM())
- 初始化 kernel 裡不可缺的部份(這個部份有使用 Interlocked API, 它的設定在上面有討論過)
- 初始化 heap 結構
- 初始化 process 和 thread tracking 結構
- 完成任何動作在 multi-threading 開啟之前
- 初始化系統 loader
- 初始化 paging pool
- 初始化系統 logging
- 初始化系統 debugger
8.24.2008
8.19.2008
A visit with Microsoft Research: A look at tomorrow’s health solutions today
在Chanel 10 ,報導了三個有趣的 Microsoft Research
第一個 project 是電腦看人類的人際關系:
當兩個人比較接近或是他們的動作傾向是一夥,在銀幕上就會將兩個人連成一線。電腦也可以知道現在誰看著誰之類的。
(透過這個東西分析之後,是不是就可以很容易知道誰跟誰是一國的?哪裡形成一個小圈圈?但電腦知道這個資訊有什麼用呢?)
第二個 project 就人怎麼看電腦:
透過個sencer 可以知道人的眼睛都底是看銀幕的那裡。
第三個就是 Surface: 不過是用投影的,所以也就可以用任何的地方當Surface。而且也可放實體鍵盤。當需要多人討論時,是不會錯的工具。
8.18.2008
8.10.2008
- 16/22 -> 72% driver ready to test
System part:
處理器&記憶體模組(Tommy):ask about the items (Jession) -> ask Tommy, can we do it? and confirm Tommy liu -> need to add codeSDRAM:waiting for PE(tommy, liu) demo電話模組:know how to test (Jession) -> 之星 handle it -> ready 2 test -> he can't test w/o SIM card, don't sure how to get IMEItypedef struct simlocalinfo_tag {
DWORD cbSize;
DWORD dwParams;
DWORD dwLAC;
DWORD dwCellId;
TCHAR lpszNumName[MAXLEN_OPERATOR_NUMERIC];
TCHAR lpszIMEI[MAXLEN_IMEI];
BYTE rgbNMR[MAXLEN_NMR];
BYTE rgbBCCH[MAXLEN_BCCH * MAXNUM_BCCH];
DWORD dwNumBCCH;
} SIMLOCALINFO, *LPSIMLOCALINFO;??
lpszIMEI[MAXLEN_IMEI]
Indicates International Mobile Equipment Identifier (IMEI) of the phone.充電電源 (清偉):know how to test (Jession) -> Kerror have to modify his driver and provide API to AP -> 清偉 give me deviceIOControl call or GetACLineStatus() and GetBatteryLifePercent() @BQ24070.c照相機模組 (Vision, Ivan):pending -> the same as 869, there is a AP for camera test, ready 2 testScan (政揚):only 1D -> request sample code to 之星 -> offer a AP path for Diag lanuch -> wait FA to test藍芽模組(柏豪):ready to test, wait for AP無線網路模組 (柏豪):know how to test (Jession) -> as the old one, ready to test電流測試 (Sammy):know how to test (Jession) -> there is a tool for PC to test ,and is supposed to done already, ready to testRTC (Jassion):know how to test (Jession) -> the driver is not ready yet, wait for driver -> wait for gigi(shanghi)'s code for 869 -> add code form 869, ready to test重置:doing nothing in driver
Interface part: 8/18(Zhi-Xing)信號燈:ready 4 test, wait 4 AP螢幕顯示:ready 4 test, wait 4 AP背光:ready 4 test, wait 4 AP觸控螢幕:ready 4 test, wait 4 AP閃光燈:ask PM to confirm this function -> there is a flash light in EDA, how to drive it (vison or Bear) -> Bear add a iocontrol in cammera, wait him back to TW -> 2 ways to turn on Flash light:1. commend 2. GPIO.. haven't decide to use which one yet按鍵/ 鍵盤:ready 4 test, wait 4 AP震動:ready 4 test, wait 4 AP喇叭/耳機:confirm it's work in driver -> driver seems no ready, who's in charge of?(Vincent)錄放音:confirm to APIR 測試:ready 4 test, wait 4 APMicro SD測試:to confirm how to test R/W/E action (who?) -> just check detect MicroSD is okay, ready 2 test
7.30.2008
How can I do?
one way can do, to merge code before check in.
- to update my code base
- get the lasest code on Source Safe and make sure it can be builded through the end
- merge my code which im developoing to the new code base and make sure it can be builded through the end
- check out the code what I want to merge
- merge 2 to my new code base and make sure it can be builded throough the end
- check in
7.22.2008
Build code hanging
"Microsoft (R) Program Maintenance Utility Version Test Version
Copyright
(C) Microsoft Corporation. All rights reserved.
Windows CE Version
(Release) (Built on Mar 1 2004 21:46:39)
makefile.def: Invoked with
predefined settings:
TARGETNAME: dummy
TARGETTYPE: dummy
RELEASETYPE:
TARGETLIBS:
SOURCELIBS:
makefile.def: Including
D:\WM612_AKU1.2_19958\public\common\oak\misc\Sources.default
makefile.def:
BUILDROOT is D:\WM612_AKU1.2_19958\public\ossvcs\cesysgen
0 Please add
_COMMONPUBROOT and __PROJROOT to your tree's cesysgen\sources file.
makefile.def: Including .\sources.
makefile.def: Including
D:\WM612_AKU1.2_19958\public\common\oak\misc\Sources.CE
makefile.def:
Including D:\WM612_AKU1.2_19958public\wpc\oak\misc\makefile.inc
Directory:
D:\WM612_AKU1.2_19958\PUBLIC\OSSVCS\CESYSGEN
TARGETNAME: dummy
RELEASETYPE is not defined. Using DEFAULT.
makefile.def: Including
D:\WM612_AKU1.2_19958\public\common\oak\misc\sources.ReleaseType_DEFAULT
輸入錯誤: 副檔名".js" 沒有對應的 Script 引擎。
NMAKE : fatal error U1077: 'cscript' :
return code '0x1'
Stop."
the problem is cuased from UltraEdit. It sets the Script file for UltraEdit using and change the seting of builder.
Solution is from Sammy.
Understanding Makefile is useful.
Image Update Device Side Features
*Normal boot kernel starts&loads OS components to located in the kernel partition to point(OS can read from the system partition) At this point: nothing is located in the kernel partition until the run-time image is booted.
*Device update IPL knows where the master boot record(MBR). active partition is stored in the MBR. IPL loads the contents of active partition(kernel partition) to RAM(NAND,NOR), or jumps to startup address if the artition is NOR XIP kernel.
*during an update to the kernel partition to system partitionpackage mechanism donwloads (update packages) to (device's persistent user store)
UpdateBin- checks signature on the packages,
- validates the package contents,
- verifies versions,
- sets a flash update flag(update is available)
- rebbots the system. at reboot, IPL notes the flag and invokes ULDR.
*when ULDR is booted and runing from RAM, ULDR searches the validated packages in the user store (contains file system drivers).
begins update process one package at a time package information is recorded in the file system for useing by Update Validator on future updates. the update progress is tracked to allow for roll-forward updates in case a power failure occurs during the update.
*when all package contents have been applied and complete, the package can be removed from the user store or marked as completed. the flash update flag is cleared the device is rebooted.
Image Download Application
1. downloading the new disk image to device replacing the existing disk image.
2. downloading packages to the device in the Update Loader context. packages can be applied to the image by the ULDR.
*when a device boots, IPL jumps to the ULDR
the primary run-time image(pressing a switch/ software flag is set(packages need to be applied).
*when IPL jumps to the ULDR, ULDR run an update application to apply the available updates to the image , reboot the device, and updating the image
*because Image Download Application can downlade packages in the ULDR context, it is useful for the development enviroment or for failsafe image recovery.
*because the Impage Update model replaces the old boot loader model,