Merging examples together

I have some bare metal experience on other processors, but I am new to Nordic and Zephyr. I was wondering if there are there any good source materials that show the best practices on merging samples? Specifically I would like to create a solution that uses both Peripheral_UART and ICM42605... Pedometer which sends data over BLE.

I've found some older stuff to reference, but before I dive into it I want to make sure I am using the modern/best/easiest way possible with the newest SDK's and VSCode. 

Parents
  • Hi,

    With the two samples you mentioned you may be able to just add them together. It does not look like they conflict in any way. Just merge the overlay and prj.conf files from zephyr/samples/sensor/icm42605 with the same files from peripheral_uart. And copy over the functions etc from the main.c and add the main() functions together.

    For future, more complicated merging, you should look out for conflicts in configs and peripheral instances. For example, if the samples are using spi1 and i2c1. Those can not both be enabled, so then you would for example use i2c2 instead.
    Conflicting configs will give a warning when building that the config was assigned a value, but ended up with a different one. Then you can look the config up in the Kconfig reference to see its dependencies.

  • I haven't made any headway finding the cause of the problems I outlined. I am betting someone with more experience can probably spot my error?

  • Sorry for the delay. Seems like you forgot to copy the contents of the overlay file from the icm42605 sample. In the boards folder.

  • Thanks! That sorted it out. After a pristine build I get two warnings. Should I be concerned about either?

    CMake Warning at C:/ncs/v2.4.2/zephyr/CMakeLists.txt:839 (message): cmake [Ln, 839, Col 1]

    if(NOT "${allow_empty}")
    839:  message(WARNING "No SOURCES given to Zephyr library: ${zephyr_lib}\nExcluding target from build.")


    CMake Warning at C:/ncs/v2.4.2/zephyr/CMakeLists.txt:1865 (message): cmake [Ln, 1865, Col 1]

    1865:  message(WARNING "__ASSERT() statements are globally ENABLED")

Reply
  • Thanks! That sorted it out. After a pristine build I get two warnings. Should I be concerned about either?

    CMake Warning at C:/ncs/v2.4.2/zephyr/CMakeLists.txt:839 (message): cmake [Ln, 839, Col 1]

    if(NOT "${allow_empty}")
    839:  message(WARNING "No SOURCES given to Zephyr library: ${zephyr_lib}\nExcluding target from build.")


    CMake Warning at C:/ncs/v2.4.2/zephyr/CMakeLists.txt:1865 (message): cmake [Ln, 1865, Col 1]

    1865:  message(WARNING "__ASSERT() statements are globally ENABLED")

Children
Related