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

Using math.h on nRF9160

I'm trying to build a custom version of the example SAADC code provided here:

https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c

and I'm trying to include math.h to use the log(x) function. The only code I've added does a small computation on one of the variables, but unfortunately, I'm getting errors during the linker phase that tell me that the log function is undefined. To fix this, I added the line:

target_link_libraries(app PUBLIC libm.a)

to the CMakeLists.txt. Now, I get an error that says:

/opt/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: error: zephyr/zephyr_prebuilt.elf uses VFP register arguments, /opt/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v8-m.main/nofp/libm.a(lib_a-w_log.o) does not

After that, I tried setting using every possible combination of the following flags:

In prj.conf:

CONFIG_FLOAT=<y/n>
CONFIG_FP_SOFTABI=<y/n>
CONFIG_FP_HARDABI=<y/n>

and in CMakeLists.txt:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=<soft/softfp/hard>")

with no success. Any advice would be much appreciated, as I'm not sure where to go from here.

Parents Reply Children
Related