心血來潮突然想用最新的compiler 來編譯 autoboot
下載了 mips-sde-elf-gcc 之後
( MIPS 的 sde 已經結束,交由 codesourcery 繼續 )
( 有 mips-elf 及 mips-linux 2種版本)
主要是 Link system 不一樣 ( ABI ?)
簡單說
mips-elf 是針對 bare-metal system ,沒有OS 的 compiler,
link 的時候要指定 linker script ( -T scriptfile )
而 mips-linux 就是針對 linux 的啦
CodeSourcery 的 compiler 不需要 cygwin
但是跟 cygwin 相容,可以在 cygwin 下使用。
這點很重要,因為大部份的 makefile 都是給 X-nix 的
裝好後( 選add to PATH) 試著編譯
出現 no input file 訊息
用舊的 sde-gcc 同樣的命令則無問題
表示 codesourcery 沒設定好
因為 cygwin 下,路徑名是 Linux 式的而非 Windows Path
所以要下
export CYGPATH=cygpath ( ref. Starter Guide)
或
export CYGPATH=xxxx\bin\cygpath
這樣CS 就會呼叫 cygpath 這個utility 來調整路徑
調整好後繼續編譯,在link的時候出現
cannot find -lc
這是因為找不到 library libc.a
設定好 config file 中的 LIBPATH 指到CS目錄下的lib
然後 -lc 換成 -lgcc (因為CS下沒有 libc.a 只有 libgcc.a )
就可以了
或者 -lc 拿掉,不指定 library,也可以過...
2個重點
1. export CYGPATH=cygpath
2. c library link problem
接下來分享並紀錄一下 gcc 的一些參數
-l statically link library, -lc 就是 libc.a -lgcc 就是 libgcc.a
-L lib link directory
-EL use little endian lib
-T specify linker script
-Wa,xxxx pass xxx option to assembler, -Wa 後面加逗號就是 pass 給assembler 的參數
編譯完後的 booter.rec.elf 檔比原來大很多 (345k vs 224k)
可能是library的關係?
但是booter.rec 大小差不多。
note: 編譯中有出現一個問題
用新的 gcc ( 4.5.2 ) vs 3.4.4
在nand.c 會出現error
static NandDevice nand_devices[] =
{
{ //Toshiba TC58DVM92A1FT00
.description("Toshiba 8-bit Flash"),
.model("TC58DVM92A1FT00"),
.maker(0x98),
.device_id(0x76),
.data_width(8),
.page_size(528),
.spare_area_size(16),
.page_count(32),
.block_count(4096),
.cs_dont_care(0),
.sequential_read(1)
},
{ //Samsung K9F1216U0A-YCB0
.description("Samsung 16-bit Flash"),
.model("K9F1216U0A-YCB0"),
.maker(0xEC),
.device_id(0x56),
.data_width(16),
.page_size(528),
.spare_area_size(16),
.page_count(32),
.block_count(4096),
.cs_dont_care(1),
.sequential_read(0)
},
...
};
typedef struct
{
char* description;
char* model;
int maker;
int device_id;
int data_width;
int page_size;
int spare_area_size;
int page_count;
int block_count;
int cs_dont_care;
int sequential_read;
} NandDevice;
其中
.description("Toshiba 8-bit Flash"), 會出現錯誤
改成
.description = "Toshiba 8-bit Flash", 就 ok了
.description = {"Toshiba 8-bit Flash" }, 的話會出現 near initialization warning
全部的 .data(XXX) 改成 .data = "XXX" 就可以過了
.data(XXX) initialize 的語法好像是 gcc 以前獨有的
可以參考
http://tigcc.ticalc.org/doc/gnuexts.html
C99 的initialization 有大改,而gcc 4 應該是符合 C99 所以 old code cannot compile
2011年6月30日 星期四
2011年6月21日 星期二
WINCE Battery Driver
在尋找電源相關問題時 ( 懷疑進入battery mode, not AC mode )
對 Battery Driver 有了更深的了解
http://blog.csdn.net/pk666666/archive/2010/12/17/6082762.aspx
是很好的文章
對 Battery Driver 有了更深的了解
http://blog.csdn.net/pk666666/archive/2010/12/17/6082762.aspx
是很好的文章
一.概述
Windows CE电池驱动属于分层驱动,由MDD层和PDD层组成。驱动示例代码位于%_WINCEROOT%\Public\Common\Oak\Drivers\Battdrvr。其中battdrvr.c是MDD层代码,sbattif.c是PDD层代码。MDD层代码微软已经搭好架构,一般不需要修改,我们要实现的是PDD层的代码。
在Au1200 BSP中 sbattiff.c 被 battpdd.c 取代
二.MDD层
电池驱动对外接口函数没有“BAT_”前缀,因为HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery\Flags注册表项设置了DEVFLAGS_NAKEDENTRIES属性,表示“Init”代替“BAT_Init”,这样修改注册表“Prefix”项的值时不需要修改驱动代码。
DEVFLAGS_NAKEDENTRIES 重要,其值為 8
在 battdrvr.reg 中
; These registry entries load the battery driver. The IClass value must match
; the BATTERY_DRIVER_CLASS definition in battery.h -- this is how the system
; knows which device is the battery driver. Note that we are using
; DEVFLAGS_NAKEDENTRIES with this driver. This tells the device manager
; to instantiate the device with the prefix named in the registry but to look
; for DLL entry points without the prefix. For example, it will look for Init
; instead of BAT_Init. This allows the prefix to be changed in the registry (if
; desired) without editing the driver code.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery]
"Prefix"="BAT"
"Dll"="battdrvr.dll"
"Flags"=dword:8 ; DEVFLAGS_NAKEDENTRIES
"Order"=dword:0
"IClass"="{DD176277-CD34-4980-91EE-67DBEF3D8913}"
2011年6月16日 星期四
NDIS Performance Test
HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > WindowsNT > CurrentVersion > NetworkCards
http://msdn.microsoft.com/en-us/library/aa463155.aspx
http://msdn.microsoft.com/en-us/library/ms894400.aspx
http://msdn.microsoft.com/en-us/library/aa463155.aspx
http://msdn.microsoft.com/en-us/library/ms894400.aspx
2011年5月31日 星期二
KITLOutputDebugString
WINCE 6 & 7 沒有 e_to_k.h
以下參考
Kitl 中output debug message的function : KITLOutputDebugString( ),
定义在
PUBLIC\COMMON\OAK\INC\e_to_k.h:
#define KITLOutputDebugString EdbgOutputDebugString
而 EdbgOutputDebugString, implement在
PLATFORM\COMMON\BOOT\BLCOMMON\format.c
就是一般的format printing,最终输出是呼叫 OEMWriteDebugByte( )。
这个function 就要每个platform 自己implement了,所以是在OAL中:
OAL\debug.c
这个对底层的string output function 就像一般的embedded system, putchar( )一样,
用最基本的polling 方式output string:
while(TX_NOT_EMPTY);
TX = outchar;
.但是为了怕有时候用来作output的serial port有其它用途 (通常不会友好结果 ),所以整个 OEMWriteDebugByte( ) 内部用#ifdef 包围起来。
OAL\debug.c 内含
• InitDebug
• ReadDebug
• WriteDebug
InitDebug 在对应的hardware (UART) 的 PowerOn, BSPPowerOn function 中呼叫。
所以要改变debug output channel,要修改 oal\debug 的这几个function,还要将InitDebug( )放到该channel hardware 启动的地方,和 BSP PowerOn 的地方。
定义在
PUBLIC\COMMON\OAK\INC\e_to_k.h:
#define KITLOutputDebugString EdbgOutputDebugString
而 EdbgOutputDebugString, implement在
PLATFORM\COMMON\BOOT\BLCOMMON\format.c
就是一般的format printing,最终输出是呼叫 OEMWriteDebugByte( )。
这个function 就要每个platform 自己implement了,所以是在OAL中:
OAL\debug.c
这个对底层的string output function 就像一般的embedded system, putchar( )一样,
用最基本的polling 方式output string:
while(TX_NOT_EMPTY);
TX = outchar;
.但是为了怕有时候用来作output的serial port有其它用途 (通常不会友好结果 ),所以整个 OEMWriteDebugByte( ) 内部用#ifdef 包围起来。
OAL\debug.c 内含
• InitDebug
• ReadDebug
• WriteDebug
InitDebug 在对应的hardware (UART) 的 PowerOn, BSPPowerOn function 中呼叫。
所以要改变debug output channel,要修改 oal\debug 的这几个function,还要将InitDebug( )放到该channel hardware 启动的地方,和 BSP PowerOn 的地方。
http://microsoft-personal-operating-systems.hostweb.com/TopicMessages/microsoft.public.windowsce.platbuilder/2010043/1/Default.aspx
http://www.cnblogs.com/we-hjb/archive/2008/10/16/1312236.html
http://www.cnblogs.com/we-hjb/archive/2008/10/16/1312236.html
2011年5月29日 星期日
Improve NDIS Driver speed
接到了一個任務 要加快網路的速度
目前的速度 2Mbps 太慢
找到了一篇
http://msdn.microsoft.com/en-us/library/aa447432.aspx
http://msdn.microsoft.com/en-us/library/ms892554.aspx
目前的速度 2Mbps 太慢
找到了一篇
http://msdn.microsoft.com/en-us/library/aa447432.aspx
http://msdn.microsoft.com/en-us/library/ms892554.aspx
2011年5月25日 星期三
Windows 7 High CPU usage
http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/system-interrupts-huge-cpu-usage/2197c025-b0b8-43f2-854b-72e576373607?page=2
http://www.msfn.org/board/topic/140263-how-to-get-the-cause-of-high-cpu-usage-by-dpc-interrupt/
http://msdn.microsoft.com/en-us/performance/default
http://msdn.microsoft.com/en-us/library/ff191077.aspx
後來找到有人用 Windows SDK 中的 Windows Performance Toolkit 來分析 deferred procedure calls and interrupt activity (DPCs and ISRs).
Windows SDK WDK 中有很多好東西及工具
如 WPT ( Windows Performance Toolkit)
App Verifier
Debugging Tools for Windows (dbghelp.dll dbgengine.dll )
PREfast
還有
Network Monitor 3.4
Process Explorer
http://www.msfn.org/board/topic/140263-how-to-get-the-cause-of-high-cpu-usage-by-dpc-interrupt/
http://msdn.microsoft.com/en-us/performance/default
http://msdn.microsoft.com/en-us/library/ff191077.aspx
後來找到有人用 Windows SDK 中的 Windows Performance Toolkit 來分析 deferred procedure calls and interrupt activity (DPCs and ISRs).
Windows SDK WDK 中有很多好東西及工具
如 WPT ( Windows Performance Toolkit)
App Verifier
Debugging Tools for Windows (dbghelp.dll dbgengine.dll )
PREfast
還有
Network Monitor 3.4
Process Explorer
2011年5月24日 星期二
USB Driver DLL load
在設定好registry 之後 還是沒有load到我寫的driver
感覺好像是沒有 USBDeviceAttach 這個函式。
但是我明明就有 implement , 而且也注意到了 .cpp 和 .c 的不同( function name decoration)
後來再做更詳細的確認,確定是 GetProcAddress( USBDeviceAttach ) 失敗( 但LoadLibrary 成功)
我想應該是此function 沒有 export 吧,果然。
加上 __declspec( dllexport ) (在此會跟 usbdi.h 的宣告衝突) 或
在 .def 裏加上 EXPORTS USBDeviceAttach 就解決了。
GetProcAddress 原來需要函式 為 exported 。否則找不到。
DllEntry
還有,PB很多driver 都是用 DllEntry 當入口,但是在 source 必須指定好 DLLENTRY
為 DllEntry 不然還是用 DllMain 較保險
補充:
DllEntry 和 DllMain 的差別
參考 http://msdn.microsoft.com/en-us/library/aa909718(v=winembedded.60).aspx
_DllMainCRTStartup (Preferred C runtime entry point for DLL) --> DllMain
_DllEntryCRTStartup( Basic C runtime entry point for DLL) --> DllEntry
預設 DLLENTRY MACRO 是 DllMain
_DllEntryCRTStartup 和 _DllMainCRTStartup 主要的差別是 _DllEntryCRTStartup 不會處理
Exception Handling 和 call _pRawDllMain (MFC 和ATL需要)
所以如果你用DllEntry 的話 DLLENTRY 也要設成 _DllEntryCRTStartup 或 DllEntry
感覺好像是沒有 USBDeviceAttach 這個函式。
但是我明明就有 implement , 而且也注意到了 .cpp 和 .c 的不同( function name decoration)
後來再做更詳細的確認,確定是 GetProcAddress( USBDeviceAttach ) 失敗( 但LoadLibrary 成功)
我想應該是此function 沒有 export 吧,果然。
加上 __declspec( dllexport ) (在此會跟 usbdi.h 的宣告衝突) 或
在 .def 裏加上 EXPORTS USBDeviceAttach 就解決了。
GetProcAddress 原來需要函式 為 exported 。否則找不到。
DllEntry
還有,PB很多driver 都是用 DllEntry 當入口,但是在 source 必須指定好 DLLENTRY
為 DllEntry 不然還是用 DllMain 較保險
補充:
DllEntry 和 DllMain 的差別
參考 http://msdn.microsoft.com/en-us/library/aa909718(v=winembedded.60).aspx
_DllMainCRTStartup (Preferred C runtime entry point for DLL) --> DllMain
_DllEntryCRTStartup( Basic C runtime entry point for DLL) --> DllEntry
預設 DLLENTRY MACRO 是 DllMain
_DllEntryCRTStartup 和 _DllMainCRTStartup 主要的差別是 _DllEntryCRTStartup 不會處理
Exception Handling 和 call _pRawDllMain (MFC 和ATL需要)
所以如果你用DllEntry 的話 DLLENTRY 也要設成 _DllEntryCRTStartup 或 DllEntry
訂閱:
文章 (Atom)