bluetoothembedded-linuxandroid-bluetoothninjagn

Compiling fluoride bluetooth stack for embedded linux


Has anyone been able to compile fluoride bluetooth stack separately for an embedded linux device?
There is a guide at https://android.googlesource.com/platform/system/bt/+/181144a50114c824cfe3cdfd695c11a074673a5e/README.md, but following these instructions gn gen fails without getting the common-mk folder and modding some build files so there are no missing variables, folders etc.

I have been able to generate Ninja files, but when building, there are missing gtest and modp_b64 headers. After getting them from Google's source search, Ninja seems to be able to run a bit without errors, but ultimately fails with:

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.

All the errors and missing files are coming from third_party/libchrome
Any help would be much appreciated.


Solution

  • I followed instructions at https://cs.android.com/android/platform/superproject/+/master:system/bt/README.md

    In addition to instructions there, I had to resolve issues in the build script manually. I was able to compile the bluetooth stack successfully in Ubuntu 21.04

    Used sed command. Change to your fluoride directory as appropriate.

    for file in $(grep -r -l "//bt"); do sed -i 's/\/\/bt/\/home\/udara\/fluoride\/bt/g' $file; done
    
    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
    
    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/
    
    # 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
    
    <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