移植交换芯片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

 

 

 

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值