2011年6月30日 星期四

CodeSourcery g++

心血來潮突然想用最新的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月21日 星期二

WINCE Battery Driver

在尋找電源相關問題時 ( 懷疑進入battery mode, not AC mode )
對 Battery Driver 有了更深的了解

http://blog.csdn.net/pk666666/archive/2010/12/17/6082762.aspx
是很好的文章



                              Windows CE 5.0电池驱动剖析
一.概述
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