This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Cross-compile PC-ble-driver for arm7-32bit architecture on x86-64bit linux host

Hi All,

 

       We have tested the DFU(nrf52840) from a central to the target device over the BLE. In which a central device attached to the PC(x86-64bit Linux) via a Serial USB. We run this test using nrfuti on linux machine and it's work. Now we want to create the same environment for the gateway which is based on arm7-32bit architecture. We successfully installed the nrfutil on arm32 arch, but we stuck when run the DFU command because pc-ble-driver shard object not created for x86_32.

" raise RuntimeError("Could not load shared library {} : '{}'.".format(shlib_path, error))
RuntimeError: Could not load shared library /usr/lib/python3.5/site-packages/pc_ble_driver_py/lib/linux/x86_32/libpc_ble_driver_shared_sd_api_v3.so : '/usr/lib/python3.5/site-packages/pc_ble_driver_py/lib/linux/x86_32/libpc_ble_driver_shared_sd_api_v3.so: cannot open shared object file: No such file or directory'. "

    We tried to follow the steps given at https://github.com/NordicSemiconductor/pc-ble-driver#Compiling-pc-ble-driver-from-source, but facing an error when we run a command

$ vcpkg install asio catch2 spdlog
Error: Invalid vcpkg root directory /home/kashif/Downloads/pc-ble-driver-master/build/home/kashif/vcpkg: No such file or directory

Questions:

  1. Does the steps mentioned in above link, will help to cross-compile the pc-ble-driver for arm-32bit arch.
  2. if no, then can you please share what steps need to be followed for cross-compilation.

Thank You,

K.Khan

Parents
  • Hi, you can try to compile asio, catch2 and spdlog from source instead of using the vcpkg package manager.

    I wrote a guide in this Devzone post: https://devzone.nordicsemi.com/f/nordic-q-a/47329/connection-3b-armv8-and-nrf-52840-dongle/188449#188449

    Unfortunately the guide is a bit old now and things have changed, so I'm not sure if it work right out of the box, but at least you get the idea of how you can compile the necessary libraries from source.

  • Hi,

        I have compiled the necessary libraries from source as mentioned in your post and build using cmake command, But it's compiled for the native 64-bit compiler. I want to compile it for arm32 bit . Could you please tell me where and what changes need to be done for cross-compilation. I have attached the build debugs, Please have a look.

    kashif@kashif-VirtualBox:~/pc-ble-driver/build$ cmake -G Ninja ..
    -- NRF_BLE_DRIVER_VERSION not specified, setting it to 0.0.0
    -- CONNECTIVITY_VERSION not specified, setting it to 0.0.0
    -- The C compiler identification is GNU 6.5.0
    -- The CXX compiler identification is GNU 7.5.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Architecture not set, using native 64-bit toolchain.
    -- Building with build type: .
    -- Found Git: /usr/bin/git (found version "2.30.0") 
    -- Check if the system is big endian
    -- Searching 16 bit integer
    -- Looking for sys/types.h
    -- Looking for sys/types.h - found
    -- Looking for stdint.h
    -- Looking for stdint.h - found
    -- Looking for stddef.h
    -- Looking for stddef.h - found
    -- Check size of unsigned short
    -- Check size of unsigned short - done
    -- Using unsigned short
    -- Check if the system is big endian - little endian
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Check if compiler accepts -pthread
    -- Check if compiler accepts -pthread - yes
    -- Found Threads: TRUE  
    -- Compiled tests are installed in directory "bin"
    -- Compiled examples are installed in directory "bin"
    -- Did not find clang-tidy, target tidy is disabled.
    -- If clang-tidy is installed, make sure run-clang-tidy.py and clang-tidy is in PATH
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/kashif/pc-ble-driver/build
    

      

    Thank You!

    K.Khan

  • Hi, I think it is easiest to build the libraries and compile everything on the ARM core. Then you don't need to cross-compile. Can you try that first? Thanks

  • Hi All,

        we are trying to cross-compile the pc-ble-driver for the arm-32bit architecture. But unable to achieve the target yet. Made some changes in cmake configurations of required libraries like spdl, but getting errors as mentioned below. Can anyone, please let me know how can we complete the cross-compilation?

    Thank You!

    K.Khan

    kashif@kashif-VirtualBox:~/spdlog/build$ cmake ../spdlog \
    > -DCMAKE_TOOLCHAIN_FILE=/home/kashif/spdlog/spdl-cross-compile-config.cmake \
    > ..
    -- The CXX compiler identification is GNU 7.3.1
    -- Check for working CXX compiler: /home/kashif/Downloads/toolchain/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-g++
    -- Check for working CXX compiler: /home/kashif/Downloads/toolchain/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-g++ -- broken
    CMake Error at /usr/local/share/cmake-3.14/Modules/CMakeTestCXXCompiler.cmake:53 (message):
      The C++ compiler
    
        "/home/kashif/Downloads/toolchain/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-g++"
    
      is not able to compile a simple test program.
    
      It fails with the following output:
    
        Change Dir: /home/kashif/spdlog/build/CMakeFiles/CMakeTmp
        
        Run Build Command(s):/usr/bin/make cmTC_2cdfc/fast 
        /usr/bin/make -f CMakeFiles/cmTC_2cdfc.dir/build.make CMakeFiles/cmTC_2cdfc.dir/build
        make[1]: Entering directory '/home/kashif/spdlog/build/CMakeFiles/CMakeTmp'
        Building CXX object CMakeFiles/cmTC_2cdfc.dir/testCXXCompiler.cxx.obj
        /home/kashif/Downloads/toolchain/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-g++     -o CMakeFiles/cmTC_2cdfc.dir/testCXXCompiler.cxx.obj -c /home/kashif/spdlog/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
        Linking CXX executable cmTC_2cdfc
        /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2cdfc.dir/link.txt --verbose=1
        /home/kashif/Downloads/toolchain/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-g++       CMakeFiles/cmTC_2cdfc.dir/testCXXCompiler.cxx.obj  -o cmTC_2cdfc 
        /home/kashif/Downloads/toolchain/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
        exit.c:(.text.exit+0x2c): undefined reference to `_exit'
        collect2: error: ld returned 1 exit status
        CMakeFiles/cmTC_2cdfc.dir/build.make:86: recipe for target 'cmTC_2cdfc' failed
        make[1]: *** [cmTC_2cdfc] Error 1
        make[1]: Leaving directory '/home/kashif/spdlog/build/CMakeFiles/CMakeTmp'
        Makefile:121: recipe for target 'cmTC_2cdfc/fast' failed
        make: *** [cmTC_2cdfc/fast] Error 2
        
    
      
    
      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:13 (project)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/kashif/spdlog/build/CMakeFiles/CMakeOutput.log".
    See also "/home/kashif/spdlog/build/CMakeFiles/CMakeError.log".
    

  • Hi All,

        We have cross-compiled the PC-ble-driver and it's dependencies for the Arm-32 architect. We copied the shared object files like "libpc_ble_driver_shared_sd_api_v3.so" to the target arm device in the corresponding x86_32 directory and then run the dfu command. But it's  showing an error as mentioned below:

     # nrfutil -v -v -v -v dfu ble -ic NRF52 -pkg WSCB_NordicFW_IAR_DFU_TEST_MOTE.z
    ip -p /dev/ttyACM0 -n "DfuTarg"
    2021-01-27 15:44:47,525 Shared library: /usr/lib/python3.5/site-packages/pc_ble_driver_py/lib/linux/x86_32/libpc_ble_driver_shared_sd_api_v3.so
    2021-01-27 15:44:47,527 Swig module name: pc_ble_driver_sd_api_v3
    Traceback (most recent call last):
      File "/usr/bin/nrfutil", line 11, in <module>
        load_entry_point('nrfutil==5.2.0', 'console_scripts', 'nrfutil')()
      File "/usr/lib/python3.5/site-packages/click/core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python3.5/site-packages/click/core.py", line 782, in main
        rv = self.invoke(ctx)
      File "/usr/lib/python3.5/site-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3.5/site-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/lib/python3.5/site-packages/click/core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "/usr/lib/python3.5/site-packages/nordicsemi/__main__.py", line 1106, in ble
        ble_driver_init(conn_ic_id)
      File "/usr/lib/python3.5/site-packages/nordicsemi/__main__.py", line 70, in ble_driver_init
        from pc_ble_driver_py.ble_driver    import BLEDriver, Flasher
      File "/usr/lib/python3.5/site-packages/pc_ble_driver_py/ble_driver.py", line 112, in <module>
        driver = importlib.import_module(SWIG_MODULE_NAME)
      File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named 'pc_ble_driver_sd_api_v3'

    Can anyone please, let me know if I am missing something and, What's this error indicates ?

    Thank You!

    K.Khan

Reply
  • Hi All,

        We have cross-compiled the PC-ble-driver and it's dependencies for the Arm-32 architect. We copied the shared object files like "libpc_ble_driver_shared_sd_api_v3.so" to the target arm device in the corresponding x86_32 directory and then run the dfu command. But it's  showing an error as mentioned below:

     # nrfutil -v -v -v -v dfu ble -ic NRF52 -pkg WSCB_NordicFW_IAR_DFU_TEST_MOTE.z
    ip -p /dev/ttyACM0 -n "DfuTarg"
    2021-01-27 15:44:47,525 Shared library: /usr/lib/python3.5/site-packages/pc_ble_driver_py/lib/linux/x86_32/libpc_ble_driver_shared_sd_api_v3.so
    2021-01-27 15:44:47,527 Swig module name: pc_ble_driver_sd_api_v3
    Traceback (most recent call last):
      File "/usr/bin/nrfutil", line 11, in <module>
        load_entry_point('nrfutil==5.2.0', 'console_scripts', 'nrfutil')()
      File "/usr/lib/python3.5/site-packages/click/core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python3.5/site-packages/click/core.py", line 782, in main
        rv = self.invoke(ctx)
      File "/usr/lib/python3.5/site-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3.5/site-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/lib/python3.5/site-packages/click/core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "/usr/lib/python3.5/site-packages/nordicsemi/__main__.py", line 1106, in ble
        ble_driver_init(conn_ic_id)
      File "/usr/lib/python3.5/site-packages/nordicsemi/__main__.py", line 70, in ble_driver_init
        from pc_ble_driver_py.ble_driver    import BLEDriver, Flasher
      File "/usr/lib/python3.5/site-packages/pc_ble_driver_py/ble_driver.py", line 112, in <module>
        driver = importlib.import_module(SWIG_MODULE_NAME)
      File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named 'pc_ble_driver_sd_api_v3'

    Can anyone please, let me know if I am missing something and, What's this error indicates ?

    Thank You!

    K.Khan

Children
No Data
Related