移植交換芯片SDK到Linux系統

需求

把88E6131交換芯片的sdk移植到現有嵌入式linux系統中,使得以後能通過上層函數在對交換芯片進行配置操作(如lan配置)。

 

已知條件:

*有交換芯片的文檔,sdk源碼,例子,無針對現有系統的直接解決方案.

 

實現方法概述:

* 編譯SDK之後會生成一個qdDriver.o文件。

* 自己寫一個main函數,gcc的時候把這個.o文件也作爲編譯目標之一。最後編譯出來的就是一個linkmain函數與sdk的目標文件。

* 這個目標文件跑在Linux的用戶層。軟件工程師要在這裏面實現2個接口(mii_read/mii_write)。這樣用戶層的SDK就能對硬件寄存器進行操作了。


對接口的實現方法:

 

在內核層面,利用linuxdevice_attr (),在文件系統中增加設備屬性。

 

 

讓內核加載交換芯片驅動時生成設備屬性文件:

 

 

編譯內核之後,操作系統的/sys/device/2:10/reg_io即爲增加的設備屬性文件。

可對此文件可進行讀寫操作,以達到讀寫交換芯片寄存器的作用。

 

 

在用戶層面,寫兩個函數來對上面的設備屬性文件進行讀寫操作,把這兩個函數作爲mii接口,編譯到SDK中即可。

 

 

 

附錄:對88E6131的SDK代碼移植的步驟具體注意事項

 

<!--@page { size: 8.5in 11in; margin: 0.79in }P { margin-bottom: 0.08in }-->

Build qdDrv.o for Linux

-----------------------------------

 

1. Extract the given ZIP file into$HOME/DSDT_2.x directory(directory can be changed)

in Linux system (verified with RedHat7.3)

2. Edit setenv file in$HOME/DSDT_2.x/tools

3. Modify the following variablesaccording to your setup.

declare -x USER_BASE=$HOME/DSDT_2.x

declare -x PROJ_NAME=qdDrv

4. run "source setenv"

5. Change directory to$HOME/DSDT_2.x/src

6. run "make"

  1. qdDrv.o and qdDrv.map will becreated in $HOME/DSDT_2.x/Library.

 

PRACTICE NOTE:

following above is not enough tomake compilation success. You need to do following things:

  1. make sure that /bin/sh is pointingto /bin/bash

  2. the commands in ./tools/setenvdoesn't really set global environment, so need to port it insrc/makefile manually

  3. need to specify the platformCompiler and Linker as shown below:

make -C srcCC="$(OPENWRT_DIR)/staging_dir/toolchain-mips_gcc4.1.2/bin/mips-linux-uclibc-gcc"LD="$(OPENWRT_DIR)/staging_dir/toolchain-mips_gcc4.1.2/bin/mips-linux-uclibc-ld"

  1. DSDT_2.8b/tools/makelnx.defs maynot using the correct -march parameters.

 

 

So after changes of following files,build can be successful:

build_dir/mips/cpe_mgmt-CPE_MGMT-B001/DSDT_2.8b/src/makefile

build_dir/mips/cpe_mgmt-CPE_MGMT-B001/DSDT_2.8b/Makefile

build_dir/mips/cpe_mgmt-CPE_MGMT-B001/DSDT_2.8b/tools/makelnx.defs

build_dir/mips/cpe_mgmt-CPE_MGMT-B001/DSDT_2.8b/sample/mskefile

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章