【问题标题】:Compiling fluoride bluetooth stack for embedded linux为嵌入式linux编译氟化物蓝牙堆栈
【发布时间】:2020-06-18 08:51:03
【问题描述】:

有没有人能够为嵌入式 linux 设备单独编译氟化物蓝牙堆栈?
https://android.googlesource.com/platform/system/bt/+/181144a50114c824cfe3cdfd695c11a074673a5e/README.md 有一个指南,但按照这些说明 gn gen 失败,没有获取 common-mk 文件夹并修改一些构建文件,因此没有丢失的变量、文件夹等。

我已经能够生成 Ninja 文件,但是在构建时,缺少 gtest 和 modp_b64 标头。从 Google 的源搜索中获取它们后,Ninja 似乎能够运行一点而没有错误,但最终失败:

In file included from ../../third_party/libchrome/base/message_loop/message_loop.h:18:
../../third_party/libchrome/base/message_loop/message_loop_current.h:209:3: error: static_assert failed due to requirement 'std::is_same<MessagePumpForUI, MessagePumpLibevent>::value' "MessageLoopCurrentForUI::WatchFileDescriptor is not supported when MessagePumpForUI is not a MessagePumpLibevent."
  static_assert(std::is_same<MessagePumpForUI, MessagePumpLibevent>::value,
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/libchrome/base/message_loop/message_loop_current.h:214:28: error: no type named 'Mode' in 'base::MessagePumpGlib'; did you mean 'MessagePumpLibevent::Mode'?
                           MessagePumpForUI::Mode mode,
                           ^~~~~~~~~~~~~~~~~~~~~~
                           MessagePumpLibevent::Mode
../../third_party/libchrome/base/message_loop/watchable_io_message_pump_posix.h:55:8: note: 'MessagePumpLibevent::Mode' declared here
  enum Mode {
       ^
In file included from ../../third_party/libchrome/base/run_loop.cc:10:
In file included from ../../third_party/libchrome/base/message_loop/message_loop.h:18:
../../third_party/libchrome/base/message_loop/message_loop_current.h:215:28: error: no type named 'FdWatchController' in 'base::MessagePumpGlib'; did you mean 'MessagePumpLibevent::FdWatchController'?
                           MessagePumpForUI::FdWatchController* controller,
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           MessagePumpLibevent::FdWatchController
../../third_party/libchrome/base/message_loop/message_pump_libevent.h:28:9: note: 'MessagePumpLibevent::FdWatchController' declared here
  class FdWatchController : public FdWatchControllerInterface {
        ^
In file included from ../../third_party/libchrome/base/run_loop.cc:10:
In file included from ../../third_party/libchrome/base/message_loop/message_loop.h:18:
../../third_party/libchrome/base/message_loop/message_loop_current.h:216:28: error: no type named 'FdWatcher' in 'base::MessagePumpGlib'; did you mean 'MessagePumpLibevent::FdWatcher'?
                           MessagePumpForUI::FdWatcher* delegate);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                           MessagePumpLibevent::FdWatcher
../../third_party/libchrome/base/message_loop/watchable_io_message_pump_posix.h:17:9: note: 'MessagePumpLibevent::FdWatcher' declared here
  class FdWatcher {
        ^
4 errors generated.

所有错误和丢失的文件都来自third_party/libchrome
任何帮助将不胜感激。

【问题讨论】:

    标签: bluetooth embedded-linux android-bluetooth ninja gn


    【解决方案1】:

    出现 common-mk 问题的原因是在编写指令和现在之间,libchrome 添加了一个 BUILD.gn 文件 - 因此它正在被使用,而不是按预期使用 build/secondary/third-party/libchrome 中的替代文件。要修复这部分构建,只需删除 third-party/libchrome/BUILD.gn - 应该避免需要大量构建摆弄。

    第二部分是因为libchrome的配置。删除提到的文件后,您需要修改 build/secondary/third-party/libchrome/BUILD.gn 以将以下内容添加到 source_set 中(如在上游所做的那样),还要为下游用户添加到 libchrome_config

     defines = [
        "__ANDROID_HOST__=1",
     ]
    

    这会影响构建配置,因此它不会尝试使用 glib。

    我在构建这个方面的最佳工作是在这里,尽管我还没有让它完全工作。 https://github.com/rpavlik/fluoride我做这个主要是作为一个实验,请随时从我离开的地方继续。

    【讨论】:

      【解决方案2】:

      我按照https://cs.android.com/android/platform/superproject/+/master:system/bt/README.md的说明进行操作

      除了那里的说明之外,我还必须手动解决构建脚本中的问题。我能够在 Ubuntu 21.04 中成功编译蓝牙堆栈

      • 在构建文件中将 //bt 替换为 /home/udara/fluoride/bt

      使用sed 命令。根据需要切换到您的氟化物目录。

      for file in $(grep -r -l "//bt"); do sed -i 's/\/\/bt/\/home\/udara\/fluoride\/bt/g' $file; done
      
      • bootstrap.py生成的common-mk符号链接复制到fluoride目录。
      • 并将//common-mk 替换为/home/udara/fluoride/common-mk
      for file in $(grep -r -l "//common-mk"); do sed -i 's/\/\/common-mk/\/home\/udara\/fluoride\/common-mk/g' $file; done
      
      • 安装了一些缺少的依赖项
      sudo apt install llvm
      sudo apt install libc++abi-dev
      
      • 已将/home/udara/fluoride/bt/output/out/Default/gen/ABS_PATH/home/udara/fluoride/bt/gd/dumpsys/bundler/bundler_generated.h 复制到/home/udara/fluoride/bt/gd/dumpsys/
      cp /home/udara/fluoride/bt/output/out/Default/gen/ABS_PATH/home/udara/fluoride/bt/gd/dumpsys/bundler/bundler_generated.h /home/udara/fluoride/bt/gd/dumpsys/
      
      • bt 目录中创建了名为output 的目录。
      • 设置环境变量
      # this is set by bootstrap.py
      export STAGING_DIR=/home/udara/fluoride/staging
      
      # you have to manually set this
      export OUTPUT_DIR=/home/udara/fluoride/bt/output
      
      • 然后用
      • 编译蓝牙堆栈
      ./build.py --output ${OUTPUT_DIR} --platform-dir ${STAGING_DIR} --clang
      
      • 将以下行添加到/etc/dbus-1/system.d/bluetooth.conf
      <policy>
          ...
          <allow own="org.chromium.bluetooth"/>
          <allow own="org.chromium.bluetooth.Manager"/>
      </policy>
      
      • 最后用氟化物运行
      cd /home/udara/fluoride/bt/output/debug
      sudo ./btadapterd --hci=0 INIT_gd_hci=true
      

      【讨论】:

        猜你喜欢
        • 2019-11-13
        • 1970-01-01
        • 2023-02-18
        • 2013-01-05
        • 1970-01-01
        • 2013-04-28
        • 2013-12-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多