我想交叉編譯android的Openvswitch。 我按照這裏的指示https://docs.google.com/document/pub?id=1k5jAkz_R475Ohj0OaJdWwSpAw6mmR2Mp_Ggr8_yrXsY。交叉編譯openvswitch爲Android
內核版本
我已經下載併成功建成之後從https://source.android.com/source/building-kernels.html在指令的Galaxy Nexus的OMAP內核。 內核位於我的桌面上的/ home/zoe/AOSP/omap文件夾中。內核是3.0.72版本。
我已經下載了Android NDK r5b,以便使用toolchain arm-eabi-4.4.0的交叉編譯器。
OpenVswitch版本
我試了很多版本。 1.7.0,1.9.3,2.0.0,但他們都給我同樣的錯誤(openvswitch.ko undefined!)。
初始化enviornment
首先我運行下面的命令
export ANDROID_NDK_ROOT=/home/zoe/android-ndk-r5b
export ANDROID_KERNEL=/home/zoe/AOSP/omap
然後我設置通路,以便交叉編譯器,可以發現:
export PATH=$PATH:/home/zoe/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin
cd openvswitch-2.0.0
然後我生成配置文件:
./boot.sh
然後,我運行配置:
./configure --host=arm-eabi CC=arm-eabi-gcc CPPFLAGS="-I$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include/" CFLAGS="-nostdlib" LDFLAGS="-Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/" LIBS="-lc " ovs_cv_use_linker_sections=no --with-l26=$ANDROID_KERNEL KARCH=arm --with-rundir=/data/local/var
當我在openvswitch文件夾做ARCH=arm CROSS_COMPILE=arm-eabi- make
,在構建模塊第2階段我得到許多錯誤和警告說,openvswitch.ko未定義:
錯誤消息
Building modules, stage 2.
MODPOST 1 modules
WARNING: "register_netdevice" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_destroy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmalloc_caches" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__kmalloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_gso_segment" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "register_pernet_device" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "del_timer" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strlen" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "rcu_barrier" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "genl_unregister_family" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "autoremove_wake_function" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ip_local_out" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "get_random_bytes" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netdev_rx_handler_register" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "rtnl_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_copy_and_csum_dev" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dst_release" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock_bh" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_clone" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_get_by_name" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_find_next_bit_le" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "register_netdevice_notifier" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__alloc_percpu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "inet_proto_csum_replace4" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "sock_create_kern" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "mutex_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "call_rcu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "crc32c" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kthread_create_on_node" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "jiffies" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "free_percpu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "unregister_netdevice_notifier" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_trim" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strcmp" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netif_rx" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__pskb_pull_tail" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__init_waitqueue_head" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nr_cpu_ids" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_memcpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "wait_for_completion" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__memzero" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nlmsg_notify" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memset" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "net_namespace_list" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_checksum" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "random32" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock_irqrestore" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "jiffies_to_msecs" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "printk" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ethtool_op_get_link" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kthread_stop" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memcmp" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "unregister_pernet_device" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ipv6_ext_hdr" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__skb_warn_lro_forwarding" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_find" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "free_netdev" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strncpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_put" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock_irq" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "strlcpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_free" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "warn_slowpath_null" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_push" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "mutex_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_get_by_index_rcu" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__skb_get_rxhash" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "sk_free" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netlink_unicast" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__rcu_read_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "add_timer" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "genl_register_family_with_ops" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_pull" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "init_net" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_get" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ksize" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__do_div64" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "boot_tvec_bases" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "local_bh_disable" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__secpath_destroy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_alloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__nla_reserve" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__alloc_skb" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "sk_release_kernel" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netlink_broadcast" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_unlock_bh" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_parse" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "cpu_possible_mask" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netdev_rx_handler_unregister" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_checksum_help" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "schedule" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kfree_skb" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock_irq" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "local_bh_enable" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "alloc_netdev_mqs" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "eth_type_trans" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__bug" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "wake_up_process" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "pskb_expand_head" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ether_setup" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_alloc_trace" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__per_cpu_offset" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_raw_spin_lock_irqsave" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nf_conntrack_destroy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_pull_rcsum" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kmem_cache_create" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "unregister_netdevice_queue" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ip_route_output_flow" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "ktime_get_ts" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__wake_up" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "net_ratelimit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "netlink_set_err" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_free" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kthread_should_stop" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_set_promiscuity" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kfree" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memcpy" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "prepare_to_wait" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "kernel_bind" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "genl_register_mc_group" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_alloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "finish_wait" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_set_bit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "nla_reserve" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "complete" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_test_and_set_bit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "memmove" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "csum_partial" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "consume_skb" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "dev_queue_xmit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__rcu_read_lock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "_clear_bit" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_put" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "skb_copy_bits" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "inet_get_local_port_range" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "rtnl_unlock" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__ip_select_ident" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "__nla_put" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
WARNING: "flex_array_prealloc" [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.ko] undefined!
CC /home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.o
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:8: error: variable '__this_module' has initializer but incomplete type
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:9: error: unknown field 'name' specified in initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:9: warning: excess elements in struct initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:9: warning: (near initialization for '__this_module')
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:10: error: unknown field 'init' specified in initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:10: warning: excess elements in struct initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:10: warning: (near initialization for '__this_module')
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: error: unknown field 'arch' specified in initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: error: 'MODULE_ARCH_INIT' undeclared here (not in a function)
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: warning: excess elements in struct initializer
/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.c:14: warning: (near initialization for '__this_module')
make[5]: *** [/home/zoe/openvswitch-2.0.0/datapath/linux/openvswitch.mod.o] Error 1
make[4]: *** [modules] Error 2
make[4]: Leaving directory `/home/zoe/AOSP/omap'
make[3]: *** [default] Error 2
make[3]: Leaving directory `/home/zoe/openvswitch-2.0.0/datapath/linux'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/zoe/openvswitch-2.0.0/datapath'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/zoe/openvswitch-2.0.0'
make: *** [all] Error 2
我不明白髮生了什麼事情錯了。我無法在網上找到解決方案。
謝謝。
你解決了你的問題! –
我沒有解決3.4之前的內核版本的問題。 openvswitch.ko已經存在於3.4及更高版本的android內核中。但是,您應該通過運行make config來激活它。 Kitkat及其後的所有Android版本的內核版本> = 3.4。 –