Failure of the BMA4xx driver to compile

This is NOT a runtime error it's a compile time error (application). Failing at stage [154/159] Linking C executable zephyr\zephyr_pre0.elf

Having started by following the "nRF Connect SDK hands-on, series" with Ali Aljaaani.  I got his examples working OK but when I try to replace one of the sensors with the BMA400, via the bma4xx driver I get a compilation error.

Ther only call to the driver is:

	if (!device_is_ready(dev)) {
		printk("\nError: Device \"%s\" is not ready; "
		       "check the driver initialization logs for errors.\n",
		       dev->name);
		return NULL;
	}

Overlay file:

bma400: bma400@14 {
//        compatible = "bosch,bma4xx";   // BMA4xx Driver fails 
        compatible = "bosch,bma280";	// BMA280 Driver compiles OK
        status = "okay";
        reg = < 0x14 >;
    };
};

If I point to the BMA280 driver it compiles correctly and produces the expected result:

*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***

Error: Device "bme688@76" is not ready; check the driver initialization logs for errors.

Error: Device "bmi270@68" is not ready; check the driver initialization logs for errors.

Error: Device "bma400@14" is not ready; check the driver initialization logs for errors.

I can only assume there is a bug in one of the files in: "C:\ncs\v2.7.0\zephyr\drivers\sensor\bosch\bma4xx"

I am using toolchain/SDK 2.7.0 and my target is a 52832-dk board, no hardware sensors.

chris

test_case_bma4xx.zip

*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***

Error: Device "bme688@76" is not ready; check the driver initialization logs for errors.

Error: Device "bmi270@68" is not ready; check the driver initialization logs for errors.

Error: Device "bma400@14" is not ready; check the driver initialization logs for errors.



Building test_case_bma4xx
C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir m:/nrf-projects/test_case_bma4xx/build m:/nrf-projects/test_case_bma4xx --pristine --board nrf52dk/nrf52832 -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=m:/nrf-projects/test_pcb;m:/nrf-projects/eeprom;m:/nrf-projects/eeprom_samp;m:/nrf-projects/peripheral_lbs;m:/nrf-projects/test_case_bma4xx"

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: M:/nrf-projects/test_case_bma4xx
-- CMake version: 3.21.0
-- Found Python3: C:/ncs/toolchains/ce3b5ff664/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: C:/ncs/v2.7.0/zephyr/.cache
-- Zephyr version: 3.6.99 (C:/ncs/v2.7.0/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52dk, qualifiers: nrf52832
-- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/ce3b5ff664/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: C:/ncs/v2.7.0/zephyr/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts
-- Found devicetree overlay: M:/nrf-projects/test_case_bma4xx/boards/nrf52dk_nrf52832.overlay
-- Generated zephyr.dts: M:/nrf-projects/test_case_bma4xx/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: M:/nrf-projects/test_case_bma4xx/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: M:/nrf-projects/test_case_bma4xx/build/zephyr/dts.cmake
Parsing M:/nrf-projects/test_case_bma4xx/Kconfig
Loaded configuration 'C:/ncs/v2.7.0/zephyr/boards/nordic/nrf52dk/nrf52dk_nrf52832_defconfig'
Merged configuration 'M:/nrf-projects/test_case_bma4xx/prj.conf'
Configuration saved to 'M:/nrf-projects/test_case_bma4xx/build/zephyr/.config'
Kconfig header saved to 'M:/nrf-projects/test_case_bma4xx/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38") 
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Warning at C:/ncs/v2.7.0/zephyr/CMakeLists.txt:2027 (message):
  __ASSERT() statements are globally ENABLED


-- Configuring done
-- Generating done
-- Build files have been written to: M:/nrf-projects/test_case_bma4xx/build
-- west build: building application
[4/159] Generating include/generated/version.h
-- Zephyr version: 3.6.99 (C:/ncs/v2.7.0/zephyr), build: v3.6.99-ncs2
[154/159] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map M:/nrf-projects/test_case_bma4xx/build/zephyr/zephyr_pre0.map 
cmd.exe /C "cd . && C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=M:/nrf-projects/test_case_bma4xx/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a  zephyr/lib/libc/picolibc/liblib__libc__picolibc.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/soc/soc/nrf52832/libsoc__nordic.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/i2c/libdrivers__i2c.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/sensor/bosch/bme680/libdrivers__sensor__bosch__bme680.a  zephyr/drivers/sensor/bosch/bmi270/libdrivers__sensor__bosch__bmi270.a  zephyr/drivers/sensor/nordic/temp/libdrivers__sensor__nordic__temp.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/lib/dk_buttons_and_leds/lib..__nrf__lib__dk_buttons_and_leds.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/segger/libmodules__segger.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp"  -LM:/nrf-projects/test_case_bma4xx/build/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -mtp=soft  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  -DPICOLIBC_LONG_LONG_PRINTF_SCANF  --specs=picolibc.specs  -lc  -lgcc && cmd.exe /C "cd /D M:\nrf-projects\test_case_bma4xx\build\zephyr && C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.exe -E true""
c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(sensor_data_collector.c.obj): in function `sensor_data_collector':
M:/nrf-projects/test_case_bma4xx/src/sensor_data_collector.c:90: undefined reference to `__device_dts_ord_105'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.EXE' --build 'm:\nrf-projects\test_case_bma4xx\build'

 *  The terminal process terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

  • Hi Thanks,

    I may have tracked down the issue after trawling through the build directory I discovered that there had been no attempt to compile the driver so the cause of the error was no "bma4xx.obj" file.  The error only showed at link time...

    It appear that two new CONFIG entries are required for this driver but not the previous Bosch drivers.

    CONFIG_SENSOR_ASYNC_API=y
    CONFIG_BMA4XX=y

    As I'm at work I can only try this on the testcase I submitted which now compiles.  I will try in the full code this evening.

    This is not mentioned here, maybe it should be!

    docs.nordicsemi.com/.../bosch_bma4xx-i2c.html

    Hope this helps other users.

    Chris

  • Hello,

    This is common error '': undefined reference to `__device_dts_ord_105'' when driver is not enabled for the sensors in the prj.conf file.

    Try adding CONFIG_BMA400=y and CONFIG_BMA400_I2C=y in the prj.conf file and run the sample again.

  • Hi,

    Yes: per my reply above I think it was the: CONFIG_SENSOR_ASYNC_API=y, line that was the main missing link.

    After digging around in the driver files I found this in the: bma4xx/Kconfig file:

    	depends on DT_HAS_BOSCH_BMA4XX_ENABLED
    	depends on SENSOR_ASYNC_API

    Thanks

    Chris

  • Hi,

    Update:  I have now managed to compile with the BMA4xx driver, but have now run into issues using the sensor.

    BOOT WITH BOTH SENSOR COMMANDS DISABLED
    
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    Found bma400@14
    Sensor Reporting!
    AX: 256.000032; AY: 0.023725; AZ: -1.037648;[00:00:00.406,311] <dbg> bma4xx: bma4xx_chip_init: chip_id is 0x90
    [00:00:00.413,146] <wrn> bma4xx: Driver tested for BMA422. Check for unintended operation.
    
    BOOT WITH SENSOR_SAMPLE_FETCH ENABLED
    
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    Found bma400@14
    [00:00:00.435,974] <err> os: ***** USAGE FAULT *****
    [00:00:00.441,802] <err> os:   Illegal use of the EPSR
    [00:00:00.447,845] <err> os: r0/a1:  0x00009170  r1/a2:  0x0000003b  r2/a3:  0x00000000
    [00:00:00.456,817] <err> os: r3/a4:  0x00000000 r12/ip:  0x00002335 r14/lr:  0x00000693
    [00:00:00.465,820] <err> os:  xpsr:  0x00000000
    [00:00:00.471,221] <err> os: Faulting instruction address (r15/pc): 0x00000000
    [00:00:00.479,400] <err> os: >>> ZEPHYR FATAL ERROR 35: Unknown error on CPU 0
    [00:00:00.487,548] <err> os: Current thread: 0x20000278 (unknown)
    [00:00:00.494,567] <err> os: Halting system
    [00:00:00.407,775] <dbg> bma4xx: bma4xx_chip_init: chip_id is 0x90
    [00:00:00.414,611] <wrn> bma4xx: Driver tested for BMA422. Check for unintended operation.
    
    BOOT WITH SENSOR_CHANNEL_GET ENABLED
    
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    Found bma400@14
    [00:00:00.437,408] <err> os: ***** USAGE FAULT *****
    [00:00:00.443,237] <err> os:   Illegal use of the EPSR
    [00:00:00.449,279] <err> os: r0/a1:  0x00009174  r1/a2:  0x00000003  r2/a3:  0x20001ea0
    [00:00:00.458,282] <err> os: r3/a4:  0x00000000 r12/ip:  0x00002339 r14/lr:  0x00000695
    [00:00:00.467,285] <err> os:  xpsr:  0x00000000
    [00:00:00.472,686] <err> os: Faulting instruction address (r15/pc): 0x00000000
    [00:00:00.480,865] <err> os: >>> ZEPHYR FATAL ERROR 35: Unknown error on CPU 0
    [00:00:00.489,044] <err> os: Current thread: 0x20000278 (unknown)
    [00:00:00.496,063] <err> os: Halting system
    [00:00:00.410,308] <dbg> bma4xx: bma4xx_chip_init: chip_id is 0x90
    [00:00:00.417,144] <wrn> bma4xx: Driver tested for BMA422. Check for unintended operation.
    
    BOOT WITH BOTH SENSOR COMMANDS DISABLED
    
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    Found bma400@14
    Sensor Reporting!
    AX: 256.000032; AY: 0.023725; AZ: -1.037648;

    Above output is from 4 boots with different configurations of the sensor.... lines enabled.  In all 4 cases the chip is identified ID:90, and Found bma400@14. which is correct.

    So neither "sensor_sample_fetch" or "sensor_channel_get" work with the bma4xx driver, both get fatal errors.

    I have created a sample test case, attached. I have removed the build directory to reduce size.

    I was building on nRF52840dk-nRF52840 development board, nRF-connect 2.7.0 I have a BMA400 connected to the standard i2c0 pins, p0.26 and p0.27.

    5875.bma4xx_example.zip

  • Hello,

    Can you try with latest version of NCS (V3.0.2)?

Related