Zephyr building blocks

From Wiki at Neela Nurseries
Revision as of 23:42, 10 August 2021 by Ted (talk | contribs) (^ Setting Up Revisit: adding "chain of search" notes to reach Thing Plus board supporting SDK.)
Jump to: navigation, search

2021-08-05 Thursday

- OVERVIEW -
Zephyr RTOS explorations and building blocks

^ USART references

"Hello world" example build command:

 west build -b circuitdojo_feather_nrf9160ns samples/hello_world -p

Programming command:

 newtmgr -c serial image upload build/zephyr/app_update.bin


^ LIS2DH example project build errors

Build errors when attempting to compile LIS2DH sensor example with circuitdojo board as target board:

[192/197] Linking C executable zephyr/zephyr_prebuilt.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:         32 KB        48 KB     66.67%
            SRAM:        5520 B        64 KB      8.42%
        IDT_LIST:          40 B         2 KB      1.95%
[197/197] Linking C executable zephyr/zephyr.elf
[24/159] Building C object CMakeFiles/app.dir/src/main.c.obj
FAILED: CMakeFiles/app.dir/src/main.c.obj 
ccache /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBUILD_VERSION=v2.4.0-ncs2 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DNRF9160_XXAA -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include -Izephyr/include/generated -I/home/ted/projects/embedded/ncs/v1.4.1/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/ted/projects/embedded/ncs/v1.4.1/nrf/include -I/home/ted/projects/embedded/ncs/v1.4.1/modules/hal/cmsis/CMSIS/Core/Include -I/home/ted/projects/embedded/ncs/v1.4.1/modules/hal/nordic/nrfx -I/home/ted/projects/embedded/ncs/v1.4.1/modules/hal/nordic/nrfx/drivers/include -I/home/ted/projects/embedded/ncs/v1.4.1/modules/hal/nordic/nrfx/mdk -I/home/ted/projects/embedded/ncs/v1.4.1/modules/hal/nordic/. -isystem /home/ted/projects/embedded/ncs/v1.4.1/zephyr/lib/libc/minimal/include -isystem /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/include -isystem /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/include-fixed -Os -imacros /home/ted/projects/embedded/ncs/v1.4.1/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros /home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/ted/projects/embedded/ncs/v1.4.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/ted/projects/embedded/ncs/v1.4.1=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj   -c /home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c
In file included from /home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/arch/arm/aarch32/arch.h:20,
                 from /home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/arch/cpu.h:19,
                 from /home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/kernel_includes.h:38,
                 from /home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/kernel.h:17,
                 from /home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/zephyr.h:18,
                 from /home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c:8:
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c: In function 'main':
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:297:40: error: 'DT_N_INST_0_st_lis2dh_P_label' undeclared (first use in this function)
  297 | #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
      |                                        ^~~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:1911:38: note: in definition of macro 'DT_CAT'
 1911 | #define DT_CAT(node_id, prop_suffix) node_id##prop_suffix
      |                                      ^~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:496:27: note: in expansion of macro 'DT_PROP'
  496 | #define DT_LABEL(node_id) DT_PROP(node_id, label)
      |                           ^~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c:53:51: note: in expansion of macro 'DT_LABEL'
   53 |  const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
      |                                                   ^~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/sys/util_internal.h:105:26: note: in expansion of macro 'UTIL_PRIMITIVE_CAT'
  105 | #define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__)
      |                          ^~~~~~~~~~~~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:297:31: note: in expansion of macro 'UTIL_CAT'
  297 | #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
      |                               ^~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c:53:60: note: in expansion of macro 'DT_INST'
   53 |  const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
      |                                                            ^~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:297:40: note: each undeclared identifier is reported only once for each function it appears in
  297 | #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
      |                                        ^~~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:1911:38: note: in definition of macro 'DT_CAT'
 1911 | #define DT_CAT(node_id, prop_suffix) node_id##prop_suffix
      |                                      ^~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:496:27: note: in expansion of macro 'DT_PROP'
  496 | #define DT_LABEL(node_id) DT_PROP(node_id, label)
      |                           ^~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c:53:51: note: in expansion of macro 'DT_LABEL'
   53 |  const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
      |                                                   ^~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/sys/util_internal.h:105:26: note: in expansion of macro 'UTIL_PRIMITIVE_CAT'
  105 | #define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__)
      |                          ^~~~~~~~~~~~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/include/devicetree.h:297:31: note: in expansion of macro 'UTIL_CAT'
  297 | #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
      |                               ^~~~~~~~
/home/ted/projects/embedded/ncs/v1.4.1/zephyr/samples/sensor/lis2dh/src/main.c:53:60: note: in expansion of macro 'DT_INST'
   53 |  const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
      |                                                            ^~~~~~~
[29/159] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/ted/projects/embedded/ncs/v1.4.1/build
ted@localhost:~/projects/embedded/ncs/v1.4.1$ 


Search for DT_N_INST:

ted@indulkana:~/projects/embedded/ncs/v1.4.1$ grep -nr 'DT_N_INST[^_]' ./*
./zephyr/include/devicetree.h:297:#define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
./zephyr/include/devicetree.h:1245:		 UTIL_CAT(DT_N_INST, DT_DASH(compat, NUM_OKAY)))


^ LIS2DH example code

ted@localhost:~/projects/embedded/ncs/v1.4.1$ grep -nr st_lis2dh ./*
./zephyr/drivers/sensor/lis2dh/lis2dh_spi.c:11:#define DT_DRV_COMPAT st_lis2dh
./zephyr/drivers/sensor/lis2dh/lis2dh_i2c.c:11:#define DT_DRV_COMPAT st_lis2dh
./zephyr/drivers/sensor/lis2dh/lis2dh_trigger.c:7:#define DT_DRV_COMPAT st_lis2dh
./zephyr/drivers/sensor/lis2dh/lis2dh.c:7:#define DT_DRV_COMPAT st_lis2dh
./zephyr/samples/shields/x_nucleo_iks01a2/src/main.c:22:	const struct device *lsm303agr_a = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
./zephyr/samples/sensor/lsm303dlhc/src/main.c:42:						DT_LABEL(DT_INST(0, st_lis2dh)));
./zephyr/samples/sensor/lsm303dlhc/src/main.c:48:				DT_LABEL(DT_INST(0, st_lis2dh)));
Binary file ./zephyr/samples/sensor/lis2dh/src/.main.c.swp matches
./zephyr/samples/sensor/lis2dh/src/main.c:53:	const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
./zephyr/samples/sensor/lis2dh/src/main.c:57:		       DT_LABEL(DT_INST(0, st_lis2dh)));


^ Setting Up Revisit

This link from Zephyr's documentation home page / home site a good and detailed overview of the Zephyr RTOS project:

Detailed steps to install Zephyr's needed build tools and Zephyr SDK:

Board support for CircuitDojo nRF9160 Thing Plus is not available in either Nordic's ncs v1.4.1 SDK nor Zephyr's SDK which comes as part of Zephyr 2.6.0. Steps to locating an SDK which include board support and files for the Thing Plus include navigating the following URLs:

Link (3) Jared Wolff does not spell out nor provide a direct link to an SDK supporting the nRF9160 Thing Plus.


^ References Related and Supporting

./zephyr/doc/guides/dts/howtos.rst:710:   #define I2C_DEV_INST		DT_INST(0, vnd_i2c_device)
./zephyr/doc/guides/dts/howtos.rst:735:   #define SPI_DEV_INST		DT_INST(0, vnd_spi_device)

# nRF91 Series > nRF9160 > Production Programming > Updating the modem
# https://developer.arm.com/ip-products/processors/cortex-m/cortex-m33