ATLFlight/cmake_hexagon

Linking .so files

raunaqbhirangi opened this issue · 8 comments

I'm trying to use the libsensor_imu.so file with my app. My QURT_BUNDLE function looks something like this.

QURT_BUNDLE(APP_NAME imu_tester
IDL_FILE imu_interface.idl
DSP_SOURCES
adsp_proc/libsensor_imu.so
APPS_SOURCES
apps_proc/imu_tester.cpp
APPS_INCS
-I../include
APPS_COMPILER arm-linux-gnueabihf-g++
)

It gives me the following errors
CMake Error: CMake can not determine linker language for target: imu_tester
CMake Error: Cannot determine link language for target "imu_tester".

Alternatively, I tried this.

QURT_BUNDLE(APP_NAME imu_tester
IDL_FILE imu_interface.idl
APPS_SOURCES
apps_proc/imu_tester.cpp
APPS_INCS
-I../include
APPS_COMPILER arm-linux-gnueabihf-g++
DSP_LINK_LIBS adsp_proc/libsensor_imu.so
)

I got the following error, which I assume is from the C file being compiled using a C++ compiler.

imu_interface_stub.c:177:55: error: invalid conversion from 'void_' to 'heap' [-fpermissive]
pn = malloc(size + sizeof(_heap) - sizeof(uint64_t));

There were a lot of other errors which followed this.

Hi

The libsensor_imu,so is a shared library for the apps processor. May I know the use-case for using the libsensor_imu.so? If you are using px4 framework, you should be able get the IMU data by subscribing to the respective orb topic( i forgot the name of it ). The main purpose of the libsensor_imu.so is when one is not using px4 framework.

For the current supported version, the platfrom SDK( qrlSDK ) has /usr/include/sensor-imu/SensorImu.hpp API. This can be used to get the Raw IMU data. For this to work you need to do the following:

  • create you app and call into the API's of the SensorIMU.hpp
  • compile and link the app against the libsensor_imu.so

To run you need to do the following:

  • run "imu_app -s 2" ( use -h option for help ) make sure there is the main app of px4 is not running.
    --- this will create a server on the adsp and initializes the mpu driver.
  • run your apps proc app. This should get the data using the API.

Also there is a tester program called sensor_imu_tester you can run it to see if you are getting the imu data from adsp. This will also need the "imu_app" running first.

There is plan to get the imu data when px4's main app is running. This is something we want to support but there is not ETA yet.

Thanks
Rama

@raunaqbhirangi

In the posix build of the XXX_stub.c file, you have to set the following flags:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes -Wno-missing-declarations")

The generated stub file causes certain compiler warnings.

@rkintada :
I am trying to write and test code outside the px4 framework.

I created my app with the help of the SensorIMU.hpp API. I'm however very unclear on the directory structure. I tried to implement it based on what I saw in the HelloWorld and dspal tester apps. I also want to know how I should compile and link the app against libsensor_imu.so using QURT_BUNDLE.

Where do I find the sensor_imu_tester program?

@mcharleb :
Which file is that exactly?

@raunaqbhirangi The sensor_imu_tester app is already on the platform and is in the path. run as follows:
%>sensor_imu_tester 10

Regarding the usage for the API, there is some documentation in the user guide document at:
http://support.intrinsyc.com/documents/124

In the particular case, there is not need for the use of QURT bundle as the SensorIMU.hpp/libsensor_imu.so warps all the idl and qurt compilation. As long you have the arm-cross compilation setup, you should be able to compile the code as follows:

EAGLE_ADDON_SRC ?= /opt/eagle_addon/flight_controller/
EAGLE_ADDON ?= ${EAGLE_ADDON_SRC}/krait/libs
EAGLE_INCS ?= ${EAGLE_ADDON_SRC}/krait/inc
sensor_imu_test: sensor_imu_test.cpp
${CXX} -o sensor_imu_test -D__STDC_FORMAT_MACROS -I${EAGLE_INCS} -L${EAGLE_ADDON} sensor_imu_test.cpp -lpthread -lrt -lsensor_imu

@raunaqbhirangi sorry for bold face code.. it may be a typo somewhere in my text.

Rama.

@rkintada Fixed the formatting.

Hi,

So I could get the IMU data with the help of qrlSDK. I am now trying to use the csr_gps_api.h for GPS data using Hexagon SDK.

When I put LINK_LIBS csr_gps under the QURT_LIB, I get the error--
Fatal: cannot recognize namespec -lcsr_gps

Also, I am not sure what argument I should pass to the csr_gps_init(const char *) function from the csr_gps_api.h. I'm using a Snapdragon Flight.