主题 : 請問如何解決移植bridge-utils到Android的錯誤 复制链接 | 浏览器收藏 | 打印
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
楼主  发表于: 2011-11-02 17:01

 請問如何解決移植bridge-utils到Android的錯誤

如題,請各位先進幫幫手吧

首先我直接

yum install autoconf
yum install automake

1.arm-linux-gcc靜態編譯
先是使用 arm-linux的方式static編譯,
#autoconf
#./configure --host=arm-linux
make CC=arm-linux-gcc
後來發現brctl在android 沒有 作用

2.重編內核linux-2.6.36-android(友善版的)bridge部份
選擇briding support
產出bridge.ko
但是insmod bridge.ko

exports duplicate symbol br_should_route_hook(owned by kernel)
insmod:init_module '/system/...bridge.ko' failed (Exec format error)

3.只好重新移植Bridge-utils到android

改寫android.mk

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

BRCTL_BUILD :=true
ifneq ($TARGET_SIMULATOR),true)
   BRCTL_BUILD :=true
endif

ifndef L_CFLAGS
L_CFLAGS := -O2 -Wall -g -static
endif

INCLUDES_BRCTL :=-I/libbridge
INCLUDES_LIBBRIDGE :=-I/libbridge

COMMON_SOURCES := brctl/brctl_cmd.c brctl/brctl_disp.c
SOURCE_BRCTL := brctl/brctl.c  $(COMMON_SOURCES)

LIBBRIDGE_SOURCES := \
        libbridge/libbridge_devif.c \
        libbridge/libbridge_if.c \
        libbridge/libbridge_init.c \
        libbridge/libbridge_misc.c

ifeq ($(BRCTL_BUILD),true)
include $(CLEAR_VARS)
LOCAL_MODULE := libbridge
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LIBBRIDGE_SOURCES)
LOCAL_CFLAGS := $(L_CFLAGS)
LOCAL_C_INCLUDES := $(INCLUDES_LIBBRIDGE)
LOCAL_SHARED_LIBRARIES :=libc libcutils
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := brctl
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES :=libc libcutils
LOCAL_STATIC_LIBRARIES :=libbridge
LOCAL_CFLAGS := $(L_CFLAGS)
LOCAL_SRC_FILES := $(SOURCE_BRCTL)
LOCAL_C_INCLUDES := $(INCLUDES_LIBBRIDGE)
include $(BUILD_EXECUTABLE)
endif


#############################

make: Entering directory `/home/Android-2.3.4'
target thumb C: libbridge <= external/bridge-utils-1.5/libbridge/libbridge_devif.c
external/bridge-utils-1.5/libbridge/libbridge_devif.c:26:23: error: sys/fcntl.h: No such file or directory
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libbridge_intermediates/libbridge/libbridge_devif.o] Error 1
make: Leaving directory `/home/Android-2.3.4'

請各位先進幫幫手吧
[ 此帖被kazaya在2011-11-02 18:15重新编辑 ]
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2011-11-02 17:34
Android下没有sys/fcntl.h, 我想你可以直接用include <fcntl.h>.
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
2楼  发表于: 2011-11-02 18:46
不好意思,還是要尋求協助:

1.bridge-utils-1.5/libbridge/libbridge_devif.c 修改
-#include <sys/fcntl.h>
+#include <fcntl.h>
2.bridge-utils-1.5/libbridge/libbridge_if.c 修改
-#include <sys/fcntl.h>
+#include <fcntl.h>

重新編譯後,出現如下錯誤:
target thumb C: brctl <= external/bridge-utils-1.5/brctl/brctl.c
external/bridge-utils-1.5/brctl/brctl.c:25:23: error: libbridge.h: No such file or directory
external/bridge-utils-1.5/brctl/brctl.c:26:20: error: config.h: No such file or directory
In file included from external/bridge-utils-1.5/brctl/brctl.c:28:
external/bridge-utils-1.5/brctl/brctl.h:35: warning: 'struct timeval' declared inside parameter list
external/bridge-utils-1.5/brctl/brctl.h:35: warning: its scope is only this definition or declaration, which is probably not what you want
external/bridge-utils-1.5/brctl/brctl.h:37: warning: 'struct bridge_info' declared inside parameter list
external/bridge-utils-1.5/brctl/brctl.c: In function 'main':
external/bridge-utils-1.5/brctl/brctl.c:44: warning: missing initializer
external/bridge-utils-1.5/brctl/brctl.c:44: warning: (near initialization for 'options[2].has_arg')
external/bridge-utils-1.5/brctl/brctl.c:53: error: 'PACKAGE_NAME' undeclared (first use in this function)
external/bridge-utils-1.5/brctl/brctl.c:53: error: (Each undeclared identifier is reported only once
external/bridge-utils-1.5/brctl/brctl.c:53: error: for each function it appears in.)
external/bridge-utils-1.5/brctl/brctl.c:53: error: 'PACKAGE_VERSION' undeclared (first use in this function)
external/bridge-utils-1.5/brctl/brctl.c:63: warning: implicit declaration of function 'br_init'
make: *** [out/target/product/generic/obj/EXECUTABLES/brctl_intermediates/brctl/brctl.o] Error 1



後來我直接將libbridge.h及config.h
自/libbridge目錄複制過去,重新編譯還是出現錯誤:

target thumb C: brctl <= external/bridge-utils-1.5/brctl/brctl.c
In file included from external/bridge-utils-1.5/brctl/brctl.c:25:
external/bridge-utils-1.5/brctl/libbridge.h:42: error: field 'max_age' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:43: error: field 'hello_time' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:44: error: field 'forward_delay' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:45: error: field 'bridge_max_age' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:46: error: field 'bridge_hello_time' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:47: error: field 'bridge_forward_delay' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:52: error: field 'ageing_time' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:53: error: field 'hello_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:54: error: field 'tcn_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:55: error: field 'topology_change_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:56: error: field 'gc_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:64: error: field 'ageing_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:80: error: field 'message_age_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:81: error: field 'forward_delay_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/libbridge.h:82: error: field 'hold_timer_value' has incomplete type
external/bridge-utils-1.5/brctl/brctl.c: In function 'main':
external/bridge-utils-1.5/brctl/brctl.c:44: warning: missing initializer
external/bridge-utils-1.5/brctl/brctl.c:44: warning: (near initialization for 'options[2].has_arg')
make: *** [out/target/product/generic/obj/EXECUTABLES/brctl_intermediates/brctl/brctl.o] Error 1
make: Leaving directory `/home/Android-2.3.4'

.....
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2011-11-02 20:50
你确定
INCLUDES_BRCTL :=-I/libbridge
INCLUDES_LIBBRIDGE :=-I/libbridge
是对的?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
4楼  发表于: 2011-11-03 11:10
引用第3楼kasim于2011-11-02 20:50发表的  :
你确定
INCLUDES_BRCTL :=-I/libbridge
INCLUDES_LIBBRIDGE :=-I/libbridge
是对的?


已經改成如下:

INCLUDES_BRCTL : \
         $(LOCAL_PATH)/libbridge

INCLUDES_LIBBRIDGE := \
         $(LOCAL_PATH)/libbridge

錯誤還是一樣....

我只是要一個可以在android執行brctl
brctl addbr br0
ifconfig eth0 0.0.0.0
ifconfig ra0 0.0.0.0
brctl addif br0 eth0
brctl addif br0 ra0
ifconfig br0 192.168.1.231 netmask 255.255.255.0 up

最後,發現一個比較簡單的方式
移植busybox.....
我直接build好了....但是我不會複制到mini6410


下列網址下載:
http://busybox.net/downloads/
build busybox教學:
http://blog.sina.com.cn/s/blog_68d212e10100wc7y.html

但是我不會複制到mini6410

我是用採用linux (因為無法複制到USB隋身碟)
adb shell 連mini6410但是都是失敗....

[root@FC12 tools]# adb remount
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: device not found
[root@FC12 tools]

####
重新下載編譯adb
終於連上了

[root@FC12 platform-tools]# killall -9 adb
[root@FC12 platform-tools]# ./adb shell
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

[root@FC12 platform-tools]# ./adb push /home/busybox-1.17.2/_install/sbin/brctl /system/busybox/sbin/brctl
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
3162 KB/s (1801952 bytes in 0.556s)

但是

killall -9 adb
[root@FC12 platform-tools]# ./adb shell
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
/ # busybox brctl
brctl: applet not found

再試過:
[root@FC12 platform-tools]# ./adb push /home/busybox-1.17.2/_install/ /system/busybox/


但是我在insmod /system/lib/modules/ar6000.ko
結果mini6410 重新開機
目前正在查為什麼出錯....確定是kernel 2.6.36 開啟的ethernet bridge 與我insmod wifi module衝 突
但是如果不開啟ethernet bridge
brctl: bridge br0: Package not installed


請問各位先進有什麼方法解決?....
[ 此帖被kazaya在2011-11-03 18:39重新编辑 ]