From 398d1962f42a576a8178ad267ee8e723f0155a2e Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Mon, 20 Nov 2023 10:51:02 +0100 Subject: [PATCH 01/22] doc: add colorization formatter for devicetree Signed-off-by: Stephan Linz --- doc/bridle/roles.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/bridle/roles.txt b/doc/bridle/roles.txt index 1456ccc290..b87106e20d 100644 --- a/doc/bridle/roles.txt +++ b/doc/bridle/roles.txt @@ -107,6 +107,10 @@ :language: rst :class: highlight +.. role:: devicetree(code) + :language: devicetree + :class: highlight + .. conditional raw outputs .. role:: raw-html(raw) From 36f407214dc9d44cc2c3c400d6130200650fd4ed Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Mon, 20 Nov 2023 10:51:48 +0100 Subject: [PATCH 02/22] boards: rpi_pico: enable SoC reset controller Signed-off-by: Stephan Linz --- boards/extensions/rpi_pico/doc/index.rst | 3 +++ boards/extensions/rpi_pico/rpipico_r3.dtsi | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/boards/extensions/rpi_pico/doc/index.rst b/boards/extensions/rpi_pico/doc/index.rst index 90dd916942..6ae048ad7c 100644 --- a/boards/extensions/rpi_pico/doc/index.rst +++ b/boards/extensions/rpi_pico/doc/index.rst @@ -20,3 +20,6 @@ List of extensions - :code:`rpipico_serial: &pico_serial {};` - :code:`rpipico_spi: &pico_spi {};` - :code:`rpipico_i2c: &pico_i2c {};` + +- enable the RP2040 SoC reset controller bindet as + :dtcompatible:`raspberrypi,pico-reset` diff --git a/boards/extensions/rpi_pico/rpipico_r3.dtsi b/boards/extensions/rpi_pico/rpipico_r3.dtsi index 1feac459b4..2edd54aed1 100644 --- a/boards/extensions/rpi_pico/rpipico_r3.dtsi +++ b/boards/extensions/rpi_pico/rpipico_r3.dtsi @@ -8,3 +8,7 @@ rpipico_serial: &pico_serial {}; rpipico_spi: &pico_spi {}; rpipico_i2c: &pico_i2c {}; + +&reset { + status = "okay"; +}; From a85ac1ebcbffa4da1e6dda547eafa2d5daaeccd0 Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Mon, 20 Nov 2023 12:44:14 +0100 Subject: [PATCH 03/22] samples: helloshell: test: disable GPIO on QEMU All QEMU targets doesn't yet support GPIO functions out of the box, thus we have to disable related driver and shell setup. Signed-off-by: Stephan Linz --- samples/helloshell/boards/qemu_arc_em.conf | 2 ++ samples/helloshell/boards/qemu_arc_hs.conf | 2 ++ samples/helloshell/boards/qemu_cortex_a53.conf | 2 ++ samples/helloshell/boards/qemu_cortex_a9.conf | 2 ++ samples/helloshell/boards/qemu_cortex_r5.conf | 2 ++ samples/helloshell/boards/qemu_kvm_arm64.conf | 2 ++ samples/helloshell/boards/qemu_leon3.conf | 2 ++ samples/helloshell/boards/qemu_malta.conf | 2 ++ samples/helloshell/boards/qemu_malta_be.conf | 2 ++ samples/helloshell/boards/qemu_nios2.conf | 2 ++ samples/helloshell/boards/qemu_riscv32.conf | 2 ++ samples/helloshell/boards/qemu_riscv32e.conf | 2 ++ samples/helloshell/boards/qemu_riscv64.conf | 2 ++ samples/helloshell/boards/qemu_x86.conf | 2 ++ samples/helloshell/boards/qemu_x86_64.conf | 2 ++ samples/helloshell/boards/qemu_xtensa.conf | 2 ++ 16 files changed, 32 insertions(+) diff --git a/samples/helloshell/boards/qemu_arc_em.conf b/samples/helloshell/boards/qemu_arc_em.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_arc_em.conf +++ b/samples/helloshell/boards/qemu_arc_em.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_arc_hs.conf b/samples/helloshell/boards/qemu_arc_hs.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_arc_hs.conf +++ b/samples/helloshell/boards/qemu_arc_hs.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_cortex_a53.conf b/samples/helloshell/boards/qemu_cortex_a53.conf index e498c2ea60..13eb045fb5 100644 --- a/samples/helloshell/boards/qemu_cortex_a53.conf +++ b/samples/helloshell/boards/qemu_cortex_a53.conf @@ -4,5 +4,7 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n CONFIG_LED=n CONFIG_LED_SHELL=n diff --git a/samples/helloshell/boards/qemu_cortex_a9.conf b/samples/helloshell/boards/qemu_cortex_a9.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_cortex_a9.conf +++ b/samples/helloshell/boards/qemu_cortex_a9.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_cortex_r5.conf b/samples/helloshell/boards/qemu_cortex_r5.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_cortex_r5.conf +++ b/samples/helloshell/boards/qemu_cortex_r5.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_kvm_arm64.conf b/samples/helloshell/boards/qemu_kvm_arm64.conf index e498c2ea60..13eb045fb5 100644 --- a/samples/helloshell/boards/qemu_kvm_arm64.conf +++ b/samples/helloshell/boards/qemu_kvm_arm64.conf @@ -4,5 +4,7 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n CONFIG_LED=n CONFIG_LED_SHELL=n diff --git a/samples/helloshell/boards/qemu_leon3.conf b/samples/helloshell/boards/qemu_leon3.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_leon3.conf +++ b/samples/helloshell/boards/qemu_leon3.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_malta.conf b/samples/helloshell/boards/qemu_malta.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_malta.conf +++ b/samples/helloshell/boards/qemu_malta.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_malta_be.conf b/samples/helloshell/boards/qemu_malta_be.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_malta_be.conf +++ b/samples/helloshell/boards/qemu_malta_be.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_nios2.conf b/samples/helloshell/boards/qemu_nios2.conf index 5dcb6ed61c..a7217f33e8 100644 --- a/samples/helloshell/boards/qemu_nios2.conf +++ b/samples/helloshell/boards/qemu_nios2.conf @@ -4,6 +4,8 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n # disable components to avoid FLASH overflow on RODATA allocation CONFIG_SENSOR=n diff --git a/samples/helloshell/boards/qemu_riscv32.conf b/samples/helloshell/boards/qemu_riscv32.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_riscv32.conf +++ b/samples/helloshell/boards/qemu_riscv32.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_riscv32e.conf b/samples/helloshell/boards/qemu_riscv32e.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_riscv32e.conf +++ b/samples/helloshell/boards/qemu_riscv32e.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_riscv64.conf b/samples/helloshell/boards/qemu_riscv64.conf index e498c2ea60..13eb045fb5 100644 --- a/samples/helloshell/boards/qemu_riscv64.conf +++ b/samples/helloshell/boards/qemu_riscv64.conf @@ -4,5 +4,7 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n CONFIG_LED=n CONFIG_LED_SHELL=n diff --git a/samples/helloshell/boards/qemu_x86.conf b/samples/helloshell/boards/qemu_x86.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_x86.conf +++ b/samples/helloshell/boards/qemu_x86.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n diff --git a/samples/helloshell/boards/qemu_x86_64.conf b/samples/helloshell/boards/qemu_x86_64.conf index e498c2ea60..13eb045fb5 100644 --- a/samples/helloshell/boards/qemu_x86_64.conf +++ b/samples/helloshell/boards/qemu_x86_64.conf @@ -4,5 +4,7 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n CONFIG_LED=n CONFIG_LED_SHELL=n diff --git a/samples/helloshell/boards/qemu_xtensa.conf b/samples/helloshell/boards/qemu_xtensa.conf index a66efa47b5..5d62cf6df0 100644 --- a/samples/helloshell/boards/qemu_xtensa.conf +++ b/samples/helloshell/boards/qemu_xtensa.conf @@ -4,3 +4,5 @@ # disable unsupported components or components with issues CONFIG_FLASH=n CONFIG_FLASH_SHELL=n +CONFIG_GPIO=n +CONFIG_GPIO_SHELL=n From 82879b18223a2470a695689688d6378f25b597cb Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Mon, 20 Nov 2023 13:13:35 +0100 Subject: [PATCH 04/22] ci: git: hot fix: disable Kconfig compliance check See bug issue #159. That have to revert as soon as possible. Signed-off-by: Stephan Linz --- .github/workflows/qa-compliance.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/qa-compliance.yml b/.github/workflows/qa-compliance.yml index 881f88e31b..b307df4d68 100644 --- a/.github/workflows/qa-compliance.yml +++ b/.github/workflows/qa-compliance.yml @@ -84,6 +84,8 @@ jobs: ls -la git log --pretty=oneline | head -n 10 # -m Checkpatch \ + # Hot fix, disable KconfigBasic, see bug issue #159 + # -m KconfigBasic \ ${BRIDLE_BASE}/scripts/ci/check_compliance.py \ --annotate \ -m Codeowners \ @@ -91,7 +93,6 @@ jobs: -m Gitlint \ -m YAMLLint \ -m Devicetree \ - -m KconfigBasic \ -m Pylint \ -m Identity \ -m Nits \ From 7d6593519a43a57b3f7785e6c331a55dfedf9b5b Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Tue, 31 Oct 2023 09:13:03 +0100 Subject: [PATCH 05/22] manifest: support u-blox portable C API Provides a new sub-manifest to add the u-blox portable C API library as 'modules/lib/ubxlib' inside the build workspace. Signed-off-by: Stephan Linz --- submanifests/ubxlib.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 submanifests/ubxlib.yml diff --git a/submanifests/ubxlib.yml b/submanifests/ubxlib.yml new file mode 100644 index 0000000000..bb9d29b7ee --- /dev/null +++ b/submanifests/ubxlib.yml @@ -0,0 +1,35 @@ +# The west submanifest file for ubxlib. +# +# Copyright (c) 2023 TiaC Systems +# +# SPDX-License-Identifier: Apache-2.0 + +manifest: + version: "0.13" + + # If not otherwise specified, the projects below should be obtained + # from the u-blox remote. + defaults: + remote: u-blox + + # "remotes" is a list of locations where git repositories are cloned + # and fetched from. + remotes: + - name: u-blox + url-base: https://github.com/u-blox + + # "projects" is a list of git repositories which make up the TIAC + # source code. Please add items below based on alphabetical order. + projects: + + # + # TODO: create fork in the TIAC organization! + # + # The fork in the TIAC organization of the portable C libraries which + # provides the u-blox modules API for microcontroller and RTOS SDKs. + # It depends on the Zephyr subset module 'mbedtls'. + - name: ubxlib + path: modules/lib/ubxlib + remote: u-blox + repo-path: ubxlib + revision: master From 650cdb662901feaad637053bddee2b79f160cd83 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Tue, 7 Nov 2023 13:30:24 +0100 Subject: [PATCH 06/22] manifest: Also pull in submodules for ubxlib Signed-off-by: Sarah Renkhoff --- submanifests/ubxlib.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/submanifests/ubxlib.yml b/submanifests/ubxlib.yml index bb9d29b7ee..a5a38b68bc 100644 --- a/submanifests/ubxlib.yml +++ b/submanifests/ubxlib.yml @@ -33,3 +33,4 @@ manifest: remote: u-blox repo-path: ubxlib revision: master + submodules: true From 6938c5fc8a42d3d557ba8dc61de7c37f97424832 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 6 Nov 2023 14:00:04 +0100 Subject: [PATCH 07/22] manifest: Point ubxlib manifest at forked repo Signed-off-by: Sarah Renkhoff --- submanifests/ubxlib.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/submanifests/ubxlib.yml b/submanifests/ubxlib.yml index a5a38b68bc..72caa3f543 100644 --- a/submanifests/ubxlib.yml +++ b/submanifests/ubxlib.yml @@ -8,29 +8,26 @@ manifest: version: "0.13" # If not otherwise specified, the projects below should be obtained - # from the u-blox remote. + # from the tiacsys remote. defaults: - remote: u-blox + remote: tiacsys # "remotes" is a list of locations where git repositories are cloned # and fetched from. remotes: - - name: u-blox - url-base: https://github.com/u-blox + - name: tiacsys + url-base: https://github.com/tiacsys # "projects" is a list of git repositories which make up the TIAC # source code. Please add items below based on alphabetical order. projects: - # - # TODO: create fork in the TIAC organization! - # # The fork in the TIAC organization of the portable C libraries which # provides the u-blox modules API for microcontroller and RTOS SDKs. # It depends on the Zephyr subset module 'mbedtls'. - name: ubxlib path: modules/lib/ubxlib - remote: u-blox + remote: tiacsys repo-path: ubxlib - revision: master + revision: tiacsys/master submodules: true From d7206d0b574a68af89da0ccb8b80752ed4d41c14 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 6 Nov 2023 14:00:53 +0100 Subject: [PATCH 08/22] ubxlib: Copy original Kconfig and CMakeLists.txt from upstream Signed-off-by: Sarah Renkhoff --- modules/ubxlib/CMakeLists.txt | 157 ++++++++++++++++++++++++++++++++++ modules/ubxlib/Kconfig | 70 +++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 modules/ubxlib/CMakeLists.txt create mode 100644 modules/ubxlib/Kconfig diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt new file mode 100644 index 0000000000..a35a1ced61 --- /dev/null +++ b/modules/ubxlib/CMakeLists.txt @@ -0,0 +1,157 @@ +# This CMake file will select the ubxlib source and include directories +# to include in the Zephyr application based on Kconfig. Use menuconfig +# to view the available options. +# +# TODO: Instead of compiling the files directly with the app this cmake +# file should create an ubxlib library instead. +if(CONFIG_UBXLIB) + +get_filename_component(UBXLIB_BASE ../../../ ABSOLUTE) +set(ENV{UBXLIB_BASE} ${UBXLIB_BASE}) + +# Add environment variables passed-in via U_FLAGS +if (DEFINED ENV{U_FLAGS}) + separate_arguments(U_FLAGS NATIVE_COMMAND "$ENV{U_FLAGS}") + target_compile_options(app PRIVATE ${U_FLAGS}) + message("ubxlib: added ${U_FLAGS} due to environment variable U_FLAGS.") +endif() + +# Set the features for ubxlib.cmake +if (NOT DEFINED UBXLIB_FEATURES) + list(APPEND UBXLIB_FEATURES u_lib) + if (CONFIG_UBXLIB_SHORTRANGE) + list(APPEND UBXLIB_FEATURES short_range) + endif() + if (CONFIG_UBXLIB_CELL) + list(APPEND UBXLIB_FEATURES cell) + endif() + if (CONFIG_UBXLIB_GNSS) + list(APPEND UBXLIB_FEATURES gnss) + endif() + if (CONFIG_UBXLIB_GEODESIC) + list(APPEND UBXLIB_FEATURES geodesic) + endif() +endif() + +message("UBXLIB_FEATURES will be \"${UBXLIB_FEATURES}\"") + +if (CONFIG_ARCH_POSIX) + # When compiling for Zephyr on Linux, need to force + # compilation of 32-bit objects when we call ubxlib.cmake + set(UBXLIB_COMPILE_OPTIONS "-m32") +endif() + +# From this line we will get back: +# - UBXLIB_SRC +# - UBXLIB_INC +# - UBXLIB_PRIVATE_INC +# - UBXLIB_TEST_SRC +# - UBXLIB_TEST_INC +# - UBXLIB_COMPILE_OPTIONS +# and optionally: +# - UBXLIB_EXTRA_LIBS +include(${UBXLIB_BASE}/port/ubxlib.cmake) + +# Set ubxlib source files +target_sources(app PRIVATE + ${UBXLIB_SRC} + src/u_port.c + src/u_port_debug.c + src/u_port_os.c + src/u_port_gpio.c + src/u_port_uart.c + src/u_port_i2c.c + src/u_port_spi.c + src/u_port_private.c + ${UBXLIB_BASE}/port/clib/u_port_clib_mktime64.c + ${UBXLIB_BASE}/port/platform/common/mbedtls/u_port_crypto.c +) + +if (CONFIG_UBXLIB_OPEN_CPU_BLE) + target_sources(app PRIVATE src/u_port_gatt.c) +endif() + +# Set the include directories +zephyr_include_directories( + ${UBXLIB_INC} + ${UBXLIB_PRIVATE_INC} + cfg + src + ${UBXLIB_BASE}/port/clib + ${ZEPHYR_BASE}/include/zephyr +) + +# Add any compile options that came out of ubxlib.cmake +target_compile_options(app PRIVATE ${UBXLIB_COMPILE_OPTIONS}) + +# Add test source & include dirs if selected +if (CONFIG_UBXLIB_TEST) + target_compile_definitions(app PRIVATE UNITY_INCLUDE_CONFIG_H) + + target_sources(app PRIVATE + ${UBXLIB_TEST_SRC} + ) + + zephyr_include_directories( + ${UBXLIB_PRIVATE_INC} + ${UBXLIB_TEST_INC} + ) + + # we need to build https://github.com/ThrowTheSwitch/unity + # Path resolution order: + # 1. environment variable UNITY_PATH + # 2. if ubxlib is imported by zephyr west, it will be at + # ${ZEPHYR_BASE}/../modules/test/cmock/vendor/unity + # 3. if the nRF Connect SDK is inside our workspace, it will be at + # ${ZEPHYR_BASE}/../test/cmock/vendor/unity + # 4. otherwise the platform itself must build and include it + if (DEFINED $ENV{UNITY_PATH}) + set(UNITY_PATH $ENV{UNITY_PATH}) + elseif (EXISTS "${ZEPHYR_BASE}/../modules/test/unity") + # this is the location if west fetched unity for us + set(UNITY_PATH "${ZEPHYR_BASE}/../modules/test/unity") + elseif (EXISTS "${ZEPHYR_BASE}/../test/cmock/vendor/unity") + #this is where the nRF Connect SDK puts unity + set(UNITY_PATH "${ZEPHYR_BASE}/../test/cmock/vendor/unity") + endif() + + if (DEFINED UNITY_PATH) + message("Unity from ${UNITY_PATH} will be used") + target_sources(app PRIVATE + ${UNITY_PATH}/src/unity.c + ) + zephyr_include_directories( + ${UNITY_PATH}/src + ) + else() + message("Assuming that the platform will bring in Unity") + endif() +endif() + +if (CONFIG_MINIMAL_LIBC) + target_sources(app PRIVATE + ${UBXLIB_BASE}/port/clib/u_port_clib_isblank.c + ${UBXLIB_BASE}/port/clib/u_port_clib_mktime.c + ${UBXLIB_BASE}/port/clib/u_port_setjmp.S + src/u_port_clib.c + ) +endif() + +if (CONFIG_UBXLIB_EDM_STREAM_DEBUG) + target_compile_definitions(app PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG) +endif() + +if (CONFIG_UBXLIB_EDM_STREAM_DEBUG_COLOR) + target_compile_definitions(app PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG_COLOR) +endif() + +if (CONFIG_UBXLIB_EDM_STREAM_DEBUG_DUMP_DATA) + target_compile_definitions(app PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG_DUMP_DATA) +endif() + + +if (UBXLIB_EXTRA_LIBS) + target_link_libraries(app PRIVATE ${UBXLIB_EXTRA_LIBS}) +endif() + +endif() #CONFIG_UBXLIB diff --git a/modules/ubxlib/Kconfig b/modules/ubxlib/Kconfig new file mode 100644 index 0000000000..d96387a9fe --- /dev/null +++ b/modules/ubxlib/Kconfig @@ -0,0 +1,70 @@ +config UBXLIB + bool "u-blox ubxlib support" + default n + help + Enable ubxlib for use with u-blox modules + +if UBXLIB + +if !NRF_SECURITY +config UBXLIB_CRYPTO + bool "Crypto libraries required for some parts of ubxlib" + default y + select MBEDTLS + select MBEDTLS_MAC_SHA256_ENABLED + select MBEDTLS_CIPHER_AES_ENABLED + help + Bring in TLS libraries required by some parts of ubxlib +endif # !NRF_SECURITY + +config UBXLIB_CELL + bool "Cellular support" + default y + help + This will enable cell API + +config UBXLIB_GNSS + bool "GNSS support" + default y + help + This will enable GNSS API + +menuconfig UBXLIB_SHORTRANGE + bool "Short range support" + default y + help + This will enable BLE and Wifi API + +if UBXLIB_SHORTRANGE +config UBXLIB_OPEN_CPU_BLE + bool "Enable ubxlib OpenCPU BLE components" + default n + depends on BT + depends on BT_PERIPHERAL + depends on BT_CENTRAL + select BT_GATT_DYNAMIC_DB + select BT_GATT_CLIENT + help + This will enable BLE SPS + +menuconfig UBXLIB_EDM_STREAM_DEBUG + bool "Enable logging of EDM stream events" + default n +if UBXLIB_EDM_STREAM_DEBUG +config UBXLIB_EDM_STREAM_DEBUG_COLOR + bool "Enable ANSI color coding for EDM debug" + default y +config UBXLIB_EDM_STREAM_DEBUG_DUMP_DATA + bool "Dump EDM data" + default n +endif +endif + +config UBXLIB_TEST + bool "Compile the ubxlib tests" + select TEST + select IRQ_OFFLOAD # To be able to test semaphore from ISR + select CPLUSPLUS # Unity requires cpp + default n + +endif # UBXLIB \ No newline at end of file From 7343269779932e1479a026b18b855c6fde1ba2fa Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 6 Nov 2023 14:08:51 +0100 Subject: [PATCH 09/22] ubxlib: Correct paths to reflect actual module location Signed-off-by: Sarah Renkhoff --- modules/ubxlib/CMakeLists.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt index a35a1ced61..d7d0179b4b 100644 --- a/modules/ubxlib/CMakeLists.txt +++ b/modules/ubxlib/CMakeLists.txt @@ -6,7 +6,7 @@ # file should create an ubxlib library instead. if(CONFIG_UBXLIB) -get_filename_component(UBXLIB_BASE ../../../ ABSOLUTE) +set(UBXLIB_BASE ${ZEPHYR_CURRENT_MODULE_DIR}) set(ENV{UBXLIB_BASE} ${UBXLIB_BASE}) # Add environment variables passed-in via U_FLAGS @@ -55,14 +55,14 @@ include(${UBXLIB_BASE}/port/ubxlib.cmake) # Set ubxlib source files target_sources(app PRIVATE ${UBXLIB_SRC} - src/u_port.c - src/u_port_debug.c - src/u_port_os.c - src/u_port_gpio.c - src/u_port_uart.c - src/u_port_i2c.c - src/u_port_spi.c - src/u_port_private.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_debug.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_os.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_gpio.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_uart.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_i2c.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_spi.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_private.c ${UBXLIB_BASE}/port/clib/u_port_clib_mktime64.c ${UBXLIB_BASE}/port/platform/common/mbedtls/u_port_crypto.c ) @@ -75,8 +75,8 @@ endif() zephyr_include_directories( ${UBXLIB_INC} ${UBXLIB_PRIVATE_INC} - cfg - src + ${UBXLIB_BASE}/port/platform/zephyr/cfg + ${UBXLIB_BASE}/port/platform/zephyr/src ${UBXLIB_BASE}/port/clib ${ZEPHYR_BASE}/include/zephyr ) @@ -133,7 +133,7 @@ if (CONFIG_MINIMAL_LIBC) ${UBXLIB_BASE}/port/clib/u_port_clib_isblank.c ${UBXLIB_BASE}/port/clib/u_port_clib_mktime.c ${UBXLIB_BASE}/port/clib/u_port_setjmp.S - src/u_port_clib.c + ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_clib.c ) endif() From 5c41944c47de00e93312e16011f1f0ab7169d305 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 6 Nov 2023 14:10:37 +0100 Subject: [PATCH 10/22] ubxlib: Remove ubxlib specific tests from builds Signed-off-by: Sarah Renkhoff --- modules/ubxlib/CMakeLists.txt | 44 ----------------------------------- 1 file changed, 44 deletions(-) diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt index d7d0179b4b..665fab53ff 100644 --- a/modules/ubxlib/CMakeLists.txt +++ b/modules/ubxlib/CMakeLists.txt @@ -84,50 +84,6 @@ zephyr_include_directories( # Add any compile options that came out of ubxlib.cmake target_compile_options(app PRIVATE ${UBXLIB_COMPILE_OPTIONS}) -# Add test source & include dirs if selected -if (CONFIG_UBXLIB_TEST) - target_compile_definitions(app PRIVATE UNITY_INCLUDE_CONFIG_H) - - target_sources(app PRIVATE - ${UBXLIB_TEST_SRC} - ) - - zephyr_include_directories( - ${UBXLIB_PRIVATE_INC} - ${UBXLIB_TEST_INC} - ) - - # we need to build https://github.com/ThrowTheSwitch/unity - # Path resolution order: - # 1. environment variable UNITY_PATH - # 2. if ubxlib is imported by zephyr west, it will be at - # ${ZEPHYR_BASE}/../modules/test/cmock/vendor/unity - # 3. if the nRF Connect SDK is inside our workspace, it will be at - # ${ZEPHYR_BASE}/../test/cmock/vendor/unity - # 4. otherwise the platform itself must build and include it - if (DEFINED $ENV{UNITY_PATH}) - set(UNITY_PATH $ENV{UNITY_PATH}) - elseif (EXISTS "${ZEPHYR_BASE}/../modules/test/unity") - # this is the location if west fetched unity for us - set(UNITY_PATH "${ZEPHYR_BASE}/../modules/test/unity") - elseif (EXISTS "${ZEPHYR_BASE}/../test/cmock/vendor/unity") - #this is where the nRF Connect SDK puts unity - set(UNITY_PATH "${ZEPHYR_BASE}/../test/cmock/vendor/unity") - endif() - - if (DEFINED UNITY_PATH) - message("Unity from ${UNITY_PATH} will be used") - target_sources(app PRIVATE - ${UNITY_PATH}/src/unity.c - ) - zephyr_include_directories( - ${UNITY_PATH}/src - ) - else() - message("Assuming that the platform will bring in Unity") - endif() -endif() - if (CONFIG_MINIMAL_LIBC) target_sources(app PRIVATE ${UBXLIB_BASE}/port/clib/u_port_clib_isblank.c From 7c41ec0107cc26ad41cff396b4af318cd2a277b3 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Tue, 7 Nov 2023 13:31:06 +0100 Subject: [PATCH 11/22] ubxlib: Rewrite and simplify CMakeLists.txt * Create a Zephyr library instead of building directly into the application target * "Flattens" the build process by no longer calling into ubxlib.cmake * In rewriting, I trusted u-blox to get the distinction between UBXLIB_INC and UBXLIB_PRIVATE_INC right, even though in the original script both are simply thrown into zephyr_interface Signed-off-by: Sarah Renkhoff --- modules/ubxlib/CMakeLists.txt | 304 +++++++++++++++++++++++++--------- 1 file changed, 227 insertions(+), 77 deletions(-) diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt index 665fab53ff..ca8e283b67 100644 --- a/modules/ubxlib/CMakeLists.txt +++ b/modules/ubxlib/CMakeLists.txt @@ -1,60 +1,165 @@ -# This CMake file will select the ubxlib source and include directories -# to include in the Zephyr application based on Kconfig. Use menuconfig -# to view the available options. -# -# TODO: Instead of compiling the files directly with the app this cmake -# file should create an ubxlib library instead. +# Copyright (c) 2023 Sarah Renkhoff +# SPDX-License-Identifier: Apache-2.0 + if(CONFIG_UBXLIB) +# Paths we'll need set(UBXLIB_BASE ${ZEPHYR_CURRENT_MODULE_DIR}) -set(ENV{UBXLIB_BASE} ${UBXLIB_BASE}) +set(GEODESIC_DIR ${UBXLIB_BASE}/common/geofence/geographiclib) -# Add environment variables passed-in via U_FLAGS -if (DEFINED ENV{U_FLAGS}) - separate_arguments(U_FLAGS NATIVE_COMMAND "$ENV{U_FLAGS}") - target_compile_options(app PRIVATE ${U_FLAGS}) - message("ubxlib: added ${U_FLAGS} due to environment variable U_FLAGS.") -endif() +# Helper function to add an entire source dir +function(add_src_dir dir) +file(GLOB SRCS ${dir}/*.c) +list(APPEND UBXLIB_SRC ${SRCS}) +set(UBXLIB_SRC ${UBXLIB_SRC} PARENT_SCOPE) +endfunction() -# Set the features for ubxlib.cmake -if (NOT DEFINED UBXLIB_FEATURES) - list(APPEND UBXLIB_FEATURES u_lib) - if (CONFIG_UBXLIB_SHORTRANGE) - list(APPEND UBXLIB_FEATURES short_range) - endif() - if (CONFIG_UBXLIB_CELL) - list(APPEND UBXLIB_FEATURES cell) - endif() - if (CONFIG_UBXLIB_GNSS) - list(APPEND UBXLIB_FEATURES gnss) - endif() - if (CONFIG_UBXLIB_GEODESIC) - list(APPEND UBXLIB_FEATURES geodesic) - endif() -endif() +if(CONFIG_ARCH_POSIX) + # When compiling for Zephyr on Linux, need to force + # compilation of 32-bit objects when we call ubxlib.cmake + list(APPEND UBXLIB_COMPILE_OPTIONS "-m32") +endif() # CONFIG_ARCH_POSIX -message("UBXLIB_FEATURES will be \"${UBXLIB_FEATURES}\"") +# Additional library that may or may not be used +if (CONFIG_UBXLIB_GEODESIC) -if (CONFIG_ARCH_POSIX) - # When compiling for Zephyr on Linux, need to force - # compilation of 32-bit objects when we call ubxlib.cmake - set(UBXLIB_COMPILE_OPTIONS "-m32") -endif() + zephyr_library_named(ubxlib_geodesic) -# From this line we will get back: -# - UBXLIB_SRC -# - UBXLIB_INC -# - UBXLIB_PRIVATE_INC -# - UBXLIB_TEST_SRC -# - UBXLIB_TEST_INC -# - UBXLIB_COMPILE_OPTIONS -# and optionally: -# - UBXLIB_EXTRA_LIBS -include(${UBXLIB_BASE}/port/ubxlib.cmake) - -# Set ubxlib source files -target_sources(app PRIVATE - ${UBXLIB_SRC} + # Sources + file(GLOB GEODESIC_SRC ${GEODESIC_DIR}/src/*.cpp) + + # Specific configure and build instructions + set(GEOGRAPHICLIB_PRECISION 2) + configure_file( + ${GEODESIC_DIR}/include/GeographicLib/Config.h.in + ${GEODESIC_DIR}/include/GeographicLib/Config.h + @ONLY + ) + set_target_properties(ubxlib_geodesic PROPERTIES CXX_STANDARD 11) + + # Library specific include dirs + target_include_directories(ubxlib_geodesic PRIVATE + ${GEODESIC_DIR}/include + ${GEODESIC_DIR}/include/GeographicLib + ) + + # Extra compile options + list(APPEND UBXLIB_COMPILE_OPTIONS + -DGEOGRAPHICLIB_SHARED_LIB=0 + -DU_CFG_GEOFENCE_USE_GEODESIC + ) + target_compile_options(ubxlib_geodesic PRIVATE ${UBXLIB_COMPILE_OPTIONS}) + +endif() # CONFIG_UBXLIB_GEODESIC + +# The actual library we're building +zephyr_library_named(ubxlib) + +# Include paths that should be exposed to applications ("UBXLIB_INC") +zephyr_include_directories( + ${UBXLIB_BASE} + ${UBXLIB_BASE}/ble/api + ${UBXLIB_BASE}/cfg + ${UBXLIB_BASE}/cell/api + ${UBXLIB_BASE}/common/assert/api + ${UBXLIB_BASE}/common/at_client/api + ${UBXLIB_BASE}/common/error/api + ${UBXLIB_BASE}/common/device/api + ${UBXLIB_BASE}/common/dns/api + ${UBXLIB_BASE}/common/geofence/api + ${UBXLIB_BASE}/common/http_client/api + ${UBXLIB_BASE}/common/lib_common/api + ${UBXLIB_BASE}/common/location/api + ${UBXLIB_BASE}/common/mqtt_client/api + ${UBXLIB_BASE}/common/network/api + ${UBXLIB_BASE}/common/security/api + ${UBXLIB_BASE}/common/short_range/api + ${UBXLIB_BASE}/common/sock/api + ${UBXLIB_BASE}/common/spartn/api + ${UBXLIB_BASE}/common/type/api + ${UBXLIB_BASE}/common/ubx_protocol/api + ${UBXLIB_BASE}/common/utils/api + ${UBXLIB_BASE}/gnss/api + ${UBXLIB_BASE}/port/api + ${UBXLIB_BASE}/port/clib + ${UBXLIB_BASE}/port/platform/common/debug_utils/api + ${UBXLIB_BASE}/port/platform/zephyr/cfg + ${UBXLIB_BASE}/port/platform/zephyr/src + ${UBXLIB_BASE}/wifi/api + ${ZEPHYR_BASE}/include/zephyr + ) + +# Private include paths ("UBXLIB_PRIVATE_INC") +target_include_directories(ubxlib PRIVATE + ${UBXLIB_BASE}/ble/src + ${UBXLIB_BASE}/cell/src + ${UBXLIB_BASE}/common/assert/src + ${UBXLIB_BASE}/common/at_client/src + ${UBXLIB_BASE}/common/device/src + ${UBXLIB_BASE}/common/dns/src + ${UBXLIB_BASE}/common/geofence/src + ${UBXLIB_BASE}/common/http_client/src + ${UBXLIB_BASE}/common/location/src + ${UBXLIB_BASE}/common/mqtt_client/src + ${UBXLIB_BASE}/common/network/src + ${UBXLIB_BASE}/common/security/src + ${UBXLIB_BASE}/common/short_range/src + ${UBXLIB_BASE}/common/sock/src + ${UBXLIB_BASE}/common/spartn/src + ${UBXLIB_BASE}/common/ubx_protocol/src + ${UBXLIB_BASE}/common/utils/src + ${UBXLIB_BASE}/gnss/src + ${UBXLIB_BASE}/gnss/src/lib_mga + ${UBXLIB_BASE}/port/platform/common/debug_utils/src + ${UBXLIB_BASE}/port/platform/common/event_queue + ${UBXLIB_BASE}/port/platform/common/mutex_debug + ${UBXLIB_BASE}/port/platform/common/log_ram + ${UBXLIB_BASE}/wifi/src + ${ZEPHYR_BASE}/include/zephyr +) + +# Hacking this in directly for now, ultimately we don't want the mbedtls dependency anyway +target_include_directories(ubxlib PRIVATE + ${ZEPHYR_BASE}/../modules/crypto/mbedtls/include +) + +# Unconditional sources +add_src_dir(${UBXLIB_BASE}/common/assert/src) +add_src_dir(${UBXLIB_BASE}/common/at_client/src) +add_src_dir(${UBXLIB_BASE}/common/dns/src) +add_src_dir(${UBXLIB_BASE}/common/geofence/src) +add_src_dir(${UBXLIB_BASE}/common/http_client/src) +add_src_dir(${UBXLIB_BASE}/common/location/src) +add_src_dir(${UBXLIB_BASE}/common/lib_common/src) +add_src_dir(${UBXLIB_BASE}/common/mqtt_client/src) +add_src_dir(${UBXLIB_BASE}/common/security/src) +add_src_dir(${UBXLIB_BASE}/common/sock/src) +add_src_dir(${UBXLIB_BASE}/common/spartn/src) +add_src_dir(${UBXLIB_BASE}/common/ubx_protocol/src) +add_src_dir(${UBXLIB_BASE}/common/utils/src) +add_src_dir(${UBXLIB_BASE}/port/platform/common/debug_utils/src) +add_src_dir(${UBXLIB_BASE}/port/platform/common/event_queue) +add_src_dir(${UBXLIB_BASE}/port/platform/common/mutex_debug) +add_src_dir(${UBXLIB_BASE}/port/platform/common/log_ram) +list(APPEND UBXLIB_SRC + ${UBXLIB_BASE}/common/device/src/u_device.c + ${UBXLIB_BASE}/common/device/src/u_device_serial.c + ${UBXLIB_BASE}/common/device/src/u_device_shared.c + ${UBXLIB_BASE}/common/device/src/u_device_private.c + ${UBXLIB_BASE}/common/device/src/u_device_private_cell_stub.c + ${UBXLIB_BASE}/common/device/src/u_device_private_gnss_stub.c + ${UBXLIB_BASE}/common/device/src/u_device_private_short_range_stub.c + ${UBXLIB_BASE}/common/network/src/u_network.c + ${UBXLIB_BASE}/common/network/src/u_network_shared.c + ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod_stub.c + ${UBXLIB_BASE}/common/network/src/u_network_private_cell_stub.c + ${UBXLIB_BASE}/common/network/src/u_network_private_gnss_stub.c + ${UBXLIB_BASE}/common/network/src/u_network_private_wifi_stub.c + ${UBXLIB_BASE}/port/clib/u_port_clib_mktime64.c + ${UBXLIB_BASE}/port/platform/common/mbedtls/u_port_crypto.c + ${UBXLIB_BASE}/port/u_port_heap.c + ${UBXLIB_BASE}/port/u_port_timezone.c + ${UBXLIB_BASE}/port/u_port_resource.c ${UBXLIB_BASE}/port/platform/zephyr/src/u_port.c ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_debug.c ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_os.c @@ -63,51 +168,96 @@ target_sources(app PRIVATE ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_i2c.c ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_spi.c ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_private.c - ${UBXLIB_BASE}/port/clib/u_port_clib_mktime64.c - ${UBXLIB_BASE}/port/platform/common/mbedtls/u_port_crypto.c ) -if (CONFIG_UBXLIB_OPEN_CPU_BLE) - target_sources(app PRIVATE src/u_port_gatt.c) -endif() +# Conditional sources +if (CONFIG_UBXLIB_CELL) +add_src_dir(${UBXLIB_BASE}/cell/src) +list (APPEND UBXLIB_SRC + ${UBXLIB_BASE}/common/network/src/u_network_private_cell.c + ${UBXLIB_BASE}/common/device/src/u_device_private_cell.c + ) +else() + list(APPEND UBXLIB_SRC + ${UBXLIB_BASE}/common/device/src/u_device_private_cell_link.c + ${UBXLIB_BASE}/common/network/src/u_network_private_cell_link.c + ) +endif() # CONFIG_UBXLIB_CELL -# Set the include directories -zephyr_include_directories( - ${UBXLIB_INC} - ${UBXLIB_PRIVATE_INC} - ${UBXLIB_BASE}/port/platform/zephyr/cfg - ${UBXLIB_BASE}/port/platform/zephyr/src - ${UBXLIB_BASE}/port/clib - ${ZEPHYR_BASE}/include/zephyr +if (CONFIG_UBXLIB_GEODESIC) + target_include_directories(ubxlib PRIVATE + ${GEODESIC_DIR}/include + ${GEODESIC_DIR}/include/GeographicLib + ) + + zephyr_library_link_libraries( + ubxlib_geodesic + ) +endif() # CONFIG_UBXLIB_GEODESIC + +if (CONFIG_UBXLIB_GNSS) + add_src_dir(${UBXLIB_BASE}/gnss/src) + list(APPEND UBXLIB_SRC + ${UBXLIB_BASE}/gnss/src/lib_mga/u_lib_mga.c + ${UBXLIB_BASE}/common/network/src/u_network_private_gnss.c + ${UBXLIB_BASE}/common/device/src/u_device_private_gnss.c + ) +else() +list(APPEND UBXLIB_SRC +${UBXLIB_BASE}/common/device/src/u_device_private_gnss_link.c +${UBXLIB_BASE}/common/network/src/u_network_private_gnss_link.c ) +endif() # CONFIG_UBXLIB_GNSS + +if (CONFIG_UBXLIB_SHORTRANGE) + add_src_dir(${UBXLIB_BASE}/common/short_range/src) + add_src_dir(${UBXLIB_BASE}/ble/src) + add_src_dir(${UBXLIB_BASE}/wifi/src) + list(APPEND UBXLIB_SRC + ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod.c + ${UBXLIB_BASE}/common/network/src/u_network_private_ble_intmod.c + ${UBXLIB_BASE}/common/network/src/u_network_private_wifi.c + ${UBXLIB_BASE}/common/device/src/u_device_private_short_range.c + ) +else() + list(APPEND UBXLIB_SRC + ${UBXLIB_BASE}/common/device/src/u_device_private_short_range_link.c + ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod_link.c + ${UBXLIB_BASE}/common/network/src/u_network_private_wifi_link.c + ) +endif() # CONFIG_UBXLIB_SHORTRANGE -# Add any compile options that came out of ubxlib.cmake -target_compile_options(app PRIVATE ${UBXLIB_COMPILE_OPTIONS}) +if (CONFIG_UBXLIB_OPEN_CPU_BLE) + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_gatt.c) +endif() if (CONFIG_MINIMAL_LIBC) - target_sources(app PRIVATE + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/port/clib/u_port_clib_isblank.c ${UBXLIB_BASE}/port/clib/u_port_clib_mktime.c ${UBXLIB_BASE}/port/clib/u_port_setjmp.S ${UBXLIB_BASE}/port/platform/zephyr/src/u_port_clib.c ) -endif() +endif() # CONFIG_MINIMAL_LIBC + +# Finally add all the accumulated sources +zephyr_library_sources( + ${UBXLIB_SRC} +) + +# Any extra compile options and definitions +target_compile_options(ubxlib PRIVATE ${UBXLIB_COMPILE_OPTIONS}) if (CONFIG_UBXLIB_EDM_STREAM_DEBUG) - target_compile_definitions(app PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG) -endif() + target_compile_definitions(ubxlib PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG) +endif() # CONFIG_UBXLIB_EDM_STREAM_DEBUG if (CONFIG_UBXLIB_EDM_STREAM_DEBUG_COLOR) - target_compile_definitions(app PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG_COLOR) -endif() + target_compile_definitions(ubxlib PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG_COLOR) +endif() # CONFIG_UBXLIB_EDM_STREAM_DEBUG_COLOR if (CONFIG_UBXLIB_EDM_STREAM_DEBUG_DUMP_DATA) - target_compile_definitions(app PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG_DUMP_DATA) -endif() - - -if (UBXLIB_EXTRA_LIBS) - target_link_libraries(app PRIVATE ${UBXLIB_EXTRA_LIBS}) -endif() + target_compile_definitions(ubxlib PRIVATE U_CFG_SHORT_RANGE_EDM_STREAM_DEBUG_DUMP_DATA) +endif() # CONFIG_UBXLIB_EDM_STREAM_DEBUG_DUMP_DATA endif() #CONFIG_UBXLIB From 45a8590eaf3fd6f680f750d02fbb85b1f0f2867a Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Tue, 7 Nov 2023 14:10:50 +0100 Subject: [PATCH 12/22] ubxlib: Add missing Kconfig option Signed-off-by: Sarah Renkhoff --- modules/ubxlib/Kconfig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/ubxlib/Kconfig b/modules/ubxlib/Kconfig index d96387a9fe..345cb78c61 100644 --- a/modules/ubxlib/Kconfig +++ b/modules/ubxlib/Kconfig @@ -1,3 +1,8 @@ +# Copyright (c) 2021 Andreas Anderberg +# Copyright (c) 2022-2023 Rob Meades +# Copyright (c) 2023 Sarah Renkhoff +# SPDX-License-Identifier: Apache-2.0 + config UBXLIB bool "u-blox ubxlib support" default n @@ -23,6 +28,12 @@ config UBXLIB_CELL help This will enable cell API +config UBXLIB_GEODESIC + bool "Enable geodesic library for geofence support" + default n + help + This will enable geofence support + config UBXLIB_GNSS bool "GNSS support" default y @@ -67,4 +78,4 @@ config UBXLIB_TEST select CPLUSPLUS # Unity requires cpp default n -endif # UBXLIB \ No newline at end of file +endif # UBXLIB From c8d49a383b3e4990d2361e7be4be8d36d9a776e1 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Wed, 8 Nov 2023 06:55:45 +0100 Subject: [PATCH 13/22] ubxlib: Disable features by default Signed-off-by: Sarah Renkhoff --- modules/ubxlib/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ubxlib/Kconfig b/modules/ubxlib/Kconfig index 345cb78c61..093599925d 100644 --- a/modules/ubxlib/Kconfig +++ b/modules/ubxlib/Kconfig @@ -14,7 +14,7 @@ if UBXLIB if !NRF_SECURITY config UBXLIB_CRYPTO bool "Crypto libraries required for some parts of ubxlib" - default y + default n select MBEDTLS select MBEDTLS_MAC_SHA256_ENABLED select MBEDTLS_CIPHER_AES_ENABLED @@ -24,7 +24,7 @@ endif # !NRF_SECURITY config UBXLIB_CELL bool "Cellular support" - default y + default n help This will enable cell API @@ -36,13 +36,13 @@ config UBXLIB_GEODESIC config UBXLIB_GNSS bool "GNSS support" - default y + default n help This will enable GNSS API menuconfig UBXLIB_SHORTRANGE bool "Short range support" - default y + default n help This will enable BLE and Wifi API From 0476688fafe1d36fe81ba868ce7e592c4d6575cb Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 13 Nov 2023 10:27:20 +0100 Subject: [PATCH 14/22] ubxlib: Add Kconfig option to control ubxlib internal logging Also change the default from enabled to disabled Signed-off-by: Sarah Renkhoff --- modules/ubxlib/CMakeLists.txt | 4 ++++ modules/ubxlib/Kconfig | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt index ca8e283b67..c04a9abf8b 100644 --- a/modules/ubxlib/CMakeLists.txt +++ b/modules/ubxlib/CMakeLists.txt @@ -20,6 +20,10 @@ if(CONFIG_ARCH_POSIX) list(APPEND UBXLIB_COMPILE_OPTIONS "-m32") endif() # CONFIG_ARCH_POSIX +if (NOT CONFIG_UBXLIB_LOGGING) + list(APPEND UBXLIB_COMPILE_OPTIONS "-DU_CFG_ENABLE_LOGGING=0") +endif() # CONFIG_UBXLIB_LOGGING + # Additional library that may or may not be used if (CONFIG_UBXLIB_GEODESIC) diff --git a/modules/ubxlib/Kconfig b/modules/ubxlib/Kconfig index 093599925d..0655df98eb 100644 --- a/modules/ubxlib/Kconfig +++ b/modules/ubxlib/Kconfig @@ -78,4 +78,8 @@ config UBXLIB_TEST select CPLUSPLUS # Unity requires cpp default n +config UBXLIB_LOGGING + bool "Enable ubxlib logging" + default n + endif # UBXLIB From 2380a1865bec1e40c0afa67f3ab7763da66a4bf6 Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Fri, 17 Nov 2023 06:44:41 +0100 Subject: [PATCH 15/22] ubxlib: Fix white spaces and order of options Also add some more help messages into Kconfig. Signed-off-by: Stephan Linz --- modules/ubxlib/CMakeLists.txt | 47 ++++++++---- modules/ubxlib/Kconfig | 140 ++++++++++++++++++++-------------- 2 files changed, 114 insertions(+), 73 deletions(-) diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt index c04a9abf8b..4d83a38d38 100644 --- a/modules/ubxlib/CMakeLists.txt +++ b/modules/ubxlib/CMakeLists.txt @@ -15,8 +15,8 @@ set(UBXLIB_SRC ${UBXLIB_SRC} PARENT_SCOPE) endfunction() if(CONFIG_ARCH_POSIX) - # When compiling for Zephyr on Linux, need to force - # compilation of 32-bit objects when we call ubxlib.cmake + # When compiling for Zephyr on Linux, need to force + # compilation of 32-bit objects when we call ubxlib.cmake list(APPEND UBXLIB_COMPILE_OPTIONS "-m32") endif() # CONFIG_ARCH_POSIX @@ -91,7 +91,7 @@ zephyr_include_directories( ${UBXLIB_BASE}/port/platform/zephyr/src ${UBXLIB_BASE}/wifi/api ${ZEPHYR_BASE}/include/zephyr - ) +) # Private include paths ("UBXLIB_PRIVATE_INC") target_include_directories(ubxlib PRIVATE @@ -122,7 +122,8 @@ target_include_directories(ubxlib PRIVATE ${ZEPHYR_BASE}/include/zephyr ) -# Hacking this in directly for now, ultimately we don't want the mbedtls dependency anyway +# Hacking this in directly for now, ultimately +# we don't want the mbedtls dependency anyway! target_include_directories(ubxlib PRIVATE ${ZEPHYR_BASE}/../modules/crypto/mbedtls/include ) @@ -145,6 +146,7 @@ add_src_dir(${UBXLIB_BASE}/port/platform/common/debug_utils/src) add_src_dir(${UBXLIB_BASE}/port/platform/common/event_queue) add_src_dir(${UBXLIB_BASE}/port/platform/common/mutex_debug) add_src_dir(${UBXLIB_BASE}/port/platform/common/log_ram) + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device.c ${UBXLIB_BASE}/common/device/src/u_device_serial.c @@ -176,19 +178,25 @@ list(APPEND UBXLIB_SRC # Conditional sources if (CONFIG_UBXLIB_CELL) -add_src_dir(${UBXLIB_BASE}/cell/src) -list (APPEND UBXLIB_SRC + + add_src_dir(${UBXLIB_BASE}/cell/src) + + list (APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_private_cell.c ${UBXLIB_BASE}/common/device/src/u_device_private_cell.c - ) + ) + else() + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_private_cell_link.c ${UBXLIB_BASE}/common/network/src/u_network_private_cell_link.c ) + endif() # CONFIG_UBXLIB_CELL if (CONFIG_UBXLIB_GEODESIC) + target_include_directories(ubxlib PRIVATE ${GEODESIC_DIR}/include ${GEODESIC_DIR}/include/GeographicLib @@ -197,38 +205,49 @@ if (CONFIG_UBXLIB_GEODESIC) zephyr_library_link_libraries( ubxlib_geodesic ) + endif() # CONFIG_UBXLIB_GEODESIC if (CONFIG_UBXLIB_GNSS) + add_src_dir(${UBXLIB_BASE}/gnss/src) + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/gnss/src/lib_mga/u_lib_mga.c ${UBXLIB_BASE}/common/network/src/u_network_private_gnss.c ${UBXLIB_BASE}/common/device/src/u_device_private_gnss.c - ) + ) + else() -list(APPEND UBXLIB_SRC -${UBXLIB_BASE}/common/device/src/u_device_private_gnss_link.c -${UBXLIB_BASE}/common/network/src/u_network_private_gnss_link.c -) + + list(APPEND UBXLIB_SRC + ${UBXLIB_BASE}/common/device/src/u_device_private_gnss_link.c + ${UBXLIB_BASE}/common/network/src/u_network_private_gnss_link.c + ) + endif() # CONFIG_UBXLIB_GNSS if (CONFIG_UBXLIB_SHORTRANGE) + add_src_dir(${UBXLIB_BASE}/common/short_range/src) add_src_dir(${UBXLIB_BASE}/ble/src) add_src_dir(${UBXLIB_BASE}/wifi/src) + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod.c ${UBXLIB_BASE}/common/network/src/u_network_private_ble_intmod.c ${UBXLIB_BASE}/common/network/src/u_network_private_wifi.c ${UBXLIB_BASE}/common/device/src/u_device_private_short_range.c ) + else() + list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_private_short_range_link.c ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod_link.c ${UBXLIB_BASE}/common/network/src/u_network_private_wifi_link.c ) + endif() # CONFIG_UBXLIB_SHORTRANGE if (CONFIG_UBXLIB_OPEN_CPU_BLE) @@ -245,9 +264,7 @@ if (CONFIG_MINIMAL_LIBC) endif() # CONFIG_MINIMAL_LIBC # Finally add all the accumulated sources -zephyr_library_sources( - ${UBXLIB_SRC} -) +zephyr_library_sources(${UBXLIB_SRC}) # Any extra compile options and definitions target_compile_options(ubxlib PRIVATE ${UBXLIB_COMPILE_OPTIONS}) diff --git a/modules/ubxlib/Kconfig b/modules/ubxlib/Kconfig index 0655df98eb..5a69ab187b 100644 --- a/modules/ubxlib/Kconfig +++ b/modules/ubxlib/Kconfig @@ -4,82 +4,106 @@ # SPDX-License-Identifier: Apache-2.0 config UBXLIB - bool "u-blox ubxlib support" - default n - help - Enable ubxlib for use with u-blox modules + bool "u-blox ubxlib support" + default n + help + Enable ubxlib for use with u-blox modules if UBXLIB -if !NRF_SECURITY -config UBXLIB_CRYPTO - bool "Crypto libraries required for some parts of ubxlib" - default n - select MBEDTLS - select MBEDTLS_MAC_SHA256_ENABLED - select MBEDTLS_CIPHER_AES_ENABLED - help - Bring in TLS libraries required by some parts of ubxlib -endif # !NRF_SECURITY - config UBXLIB_CELL - bool "Cellular support" - default n - help - This will enable cell API - -config UBXLIB_GEODESIC - bool "Enable geodesic library for geofence support" - default n - help - This will enable geofence support + bool "Cellular support" + default n + help + This will enable cell API. config UBXLIB_GNSS - bool "GNSS support" - default n - help - This will enable GNSS API + bool "GNSS support" + default n + help + This will enable GNSS API. + +config UBXLIB_GEODESIC + bool "Enable geodesic library for geofence support" + default n + help + This will enable geofence support. menuconfig UBXLIB_SHORTRANGE - bool "Short range support" - default n - help - This will enable BLE and Wifi API + bool "Short range support" + default n + help + This will enable BLE and Wifi API. if UBXLIB_SHORTRANGE + config UBXLIB_OPEN_CPU_BLE - bool "Enable ubxlib OpenCPU BLE components" - default n - depends on BT - depends on BT_PERIPHERAL - depends on BT_CENTRAL - select BT_GATT_DYNAMIC_DB - select BT_GATT_CLIENT - help - This will enable BLE SPS + bool "Enable ubxlib OpenCPU BLE components" + default n + depends on BT + depends on BT_PERIPHERAL + depends on BT_CENTRAL + select BT_GATT_DYNAMIC_DB + select BT_GATT_CLIENT + help + This will enable BLE SPS menuconfig UBXLIB_EDM_STREAM_DEBUG - bool "Enable logging of EDM stream events" - default n + bool "Enable logging of EDM stream events" + default n + if UBXLIB_EDM_STREAM_DEBUG + config UBXLIB_EDM_STREAM_DEBUG_COLOR - bool "Enable ANSI color coding for EDM debug" - default y + bool "Enable ANSI color coding for EDM debug" + default y + config UBXLIB_EDM_STREAM_DEBUG_DUMP_DATA - bool "Dump EDM data" - default n -endif -endif + bool "Dump EDM data" + default n -config UBXLIB_TEST - bool "Compile the ubxlib tests" - select TEST - select IRQ_OFFLOAD # To be able to test semaphore from ISR - select CPLUSPLUS # Unity requires cpp - default n +endif # UBXLIB_EDM_STREAM_DEBUG + +endif # UBXLIB_SHORTRANGE + +if !NRF_SECURITY + +config UBXLIB_CRYPTO + bool "Crypto libraries required for some parts of ubxlib" + default n + select MBEDTLS + select MBEDTLS_MAC_SHA256_ENABLED + select MBEDTLS_CIPHER_AES_ENABLED + help + Bring in TLS libraries required by some parts of ubxlib. + +endif # !NRF_SECURITY config UBXLIB_LOGGING - bool "Enable ubxlib logging" - default n + bool "Enable ubxlib logging" + default n + help + The self contained ubxlib logging is only usefull for + development and a simple tool for dumping datagram + content and internal state changes. + + Note that the ubxlib logging is a complete standalone + implementation based on simple printf() wrapper and + has nothing to do with the Zephyr logging system! + +config UBXLIB_TEST + bool "Compile the ubxlib tests" + select TEST + select IRQ_OFFLOAD + select CPLUSPLUS + default n + help + The self contained ubxlib tests are only usefull for + development and depends on some special OS features, + such like C++ support for the Unity test framework and + the IRQ Offload to be able to test semaphore from ISR. + + Currently this option is featureless. The ubxlib tests + are not enabled for Zephyr. endif # UBXLIB From 14e6240f78630322680700fb4eb62bcda551ca2f Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Sat, 18 Nov 2023 00:31:10 +0100 Subject: [PATCH 16/22] ubxlib: Remove prefix to Zephyr public header folder Signed-off-by: Stephan Linz --- modules/ubxlib/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ubxlib/CMakeLists.txt b/modules/ubxlib/CMakeLists.txt index 4d83a38d38..079680256e 100644 --- a/modules/ubxlib/CMakeLists.txt +++ b/modules/ubxlib/CMakeLists.txt @@ -90,7 +90,7 @@ zephyr_include_directories( ${UBXLIB_BASE}/port/platform/zephyr/cfg ${UBXLIB_BASE}/port/platform/zephyr/src ${UBXLIB_BASE}/wifi/api - ${ZEPHYR_BASE}/include/zephyr + ${ZEPHYR_BASE}/include ) # Private include paths ("UBXLIB_PRIVATE_INC") @@ -119,7 +119,7 @@ target_include_directories(ubxlib PRIVATE ${UBXLIB_BASE}/port/platform/common/mutex_debug ${UBXLIB_BASE}/port/platform/common/log_ram ${UBXLIB_BASE}/wifi/src - ${ZEPHYR_BASE}/include/zephyr + ${ZEPHYR_BASE}/include ) # Hacking this in directly for now, ultimately From 8fc77e08462578ba22e2ad344d0e583cb718a1c4 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 13 Nov 2023 11:05:10 +0100 Subject: [PATCH 17/22] samples: ubx_gnss: Add sample for communicating with u-blox GNSS modules Signed-off-by: Sarah Renkhoff Signed-off-by: Stephan Linz --- samples/ubx_gnss/CMakeLists.txt | 14 ++++ samples/ubx_gnss/Kconfig | 14 ++++ samples/ubx_gnss/README.rst | 39 +++++++++++ samples/ubx_gnss/app.overlay | 10 +++ samples/ubx_gnss/prj.conf | 45 +++++++++++++ samples/ubx_gnss/src/main.c | 110 ++++++++++++++++++++++++++++++++ 6 files changed, 232 insertions(+) create mode 100644 samples/ubx_gnss/CMakeLists.txt create mode 100644 samples/ubx_gnss/Kconfig create mode 100644 samples/ubx_gnss/README.rst create mode 100644 samples/ubx_gnss/app.overlay create mode 100644 samples/ubx_gnss/prj.conf create mode 100644 samples/ubx_gnss/src/main.c diff --git a/samples/ubx_gnss/CMakeLists.txt b/samples/ubx_gnss/CMakeLists.txt new file mode 100644 index 0000000000..699fa41b3e --- /dev/null +++ b/samples/ubx_gnss/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2023 TiaC Systems +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +# Standard Bridle application boilerplate, includes Zephyr. +find_package(Bridle REQUIRED HINTS $ENV{BRIDLE_BASE}) +project("UBXLib Hello Shell" VERSION 0.1) + +assert(CONFIG_SHELL "Zephyr's embedded shell must be enabled") + +# Add your source file to the "app" target. This must come after +# the boilerplate code, which defines the target. +target_sources(app PRIVATE src/main.c) diff --git a/samples/ubx_gnss/Kconfig b/samples/ubx_gnss/Kconfig new file mode 100644 index 0000000000..a82d9c774d --- /dev/null +++ b/samples/ubx_gnss/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2023 Sarah Renkhoff +# SPDX-License-Identifier: Apache-2.0 + +menu "Ubxlib GNSS sample settings" + +module = MAIN +module-str = "main" +source "subsys/logging/Kconfig.template.log_config" + +endmenu + +menu "Zephyr Kernel" +source "Kconfig.zephyr" +endmenu diff --git a/samples/ubx_gnss/README.rst b/samples/ubx_gnss/README.rst new file mode 100644 index 0000000000..dbde68836e --- /dev/null +++ b/samples/ubx_gnss/README.rst @@ -0,0 +1,39 @@ +.. _ubx_gnss_sample: + +Ubxlib GNSS Sample +################## + +Overview +******** + +A sample application demonstrating how to integrate a u-blox GNSS device into a +zephyr application. + +Requirements +************ + +A u-blox GNSS device must be connected via UART, and a devicetree alias +`ubxlib-uart0` must exist and point towards this UART port. To fulfil this +requirement, you can add a simple devicetree overlay for your board such as + +.. code-block:: devicetree + + / { + aliases { + ubxlib-uart0 = &usart3; + }; + }; + +Building and Running +******************** + +ST Nucleo L496ZG +================ + +.. zephyr-app-commands:: + :zephyr-app: bridle/samples/ubx_gnss + :board: nucleo_l496zg + :build-dir: nucleo_l496zg-ubx_gnss + :west-args: -p + :goals: flash + :compact: diff --git a/samples/ubx_gnss/app.overlay b/samples/ubx_gnss/app.overlay new file mode 100644 index 0000000000..ba426657c2 --- /dev/null +++ b/samples/ubx_gnss/app.overlay @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2023 Sarah Renkhoff + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + aliases { + ubxlib-uart0 = &arduino_serial; + }; +}; diff --git a/samples/ubx_gnss/prj.conf b/samples/ubx_gnss/prj.conf new file mode 100644 index 0000000000..0a4c4fbe00 --- /dev/null +++ b/samples/ubx_gnss/prj.conf @@ -0,0 +1,45 @@ +# Copyright (c) 2022 Peter Lerup +# Copyright (c) 2023 Rob Meades +# Copyright (c) 2023 Sarah Renkhoff +# SPDX-License-Identifier: Apache-2.0 + +# Multi-threaded, with timer support in the kernel +CONFIG_MULTITHREADING=y +CONFIG_NUM_COOP_PRIORITIES=16 +CONFIG_NUM_METAIRQ_PRIORITIES=0 + +CONFIG_ERRNO=y +CONFIG_SCHED_DUMB=y +CONFIG_WAITQ_DUMB=y + +# Shell with printk +CONFIG_BOOT_BANNER=y +CONFIG_PRINTK=y +CONFIG_CBPRINTF_FP_SUPPORT=y +CONFIG_SHELL=y + +# Logging +CONFIG_LOG=y + +# Ubxlib +CONFIG_SERIAL=y +CONFIG_UBXLIB=y +CONFIG_UBXLIB_GNSS=y + +# Libc +CONFIG_MINIMAL_LIBC=y +CONFIG_MINIMAL_LIBC_MALLOC=n + +# Memory +CONFIG_MAIN_STACK_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +# Interrupt driven UART is set just to point out that is the +# case: it will be the default anyway, except for Zephyr Linux +# where the UART has, unfortunately, to be polled +CONFIG_UART_INTERRUPT_DRIVEN=y + +# Required for uPortTaskStackMinFree() to work (from Ubxlib) +CONFIG_INIT_STACKS=y +CONFIG_THREAD_STACK_INFO=y +CONFIG_THREAD_NAME=y diff --git a/samples/ubx_gnss/src/main.c b/samples/ubx_gnss/src/main.c new file mode 100644 index 0000000000..d2e79c0b5e --- /dev/null +++ b/samples/ubx_gnss/src/main.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2023 Sarah Renkhoff + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +#include +LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL); + +#include +#include + +static const uDeviceCfg_t device_config = { + .deviceType = U_DEVICE_TYPE_GNSS, + .deviceCfg = { + .cfgGnss = { + .moduleType = U_GNSS_MODULE_TYPE_M10, + .pinEnablePower = -1, + .pinDataReady = -1, + }, + }, + .transportType = U_DEVICE_TRANSPORT_TYPE_UART, + .transportCfg = { + .cfgUart = { + .uart = 0, + .baudRate = U_GNSS_UART_BAUD_RATE, + .pinTxd = -1, + .pinRxd = -1, + .pinCts = -1, + .pinRts = -1, + } + }, +}; + +uDeviceHandle_t gnss_device_handle = NULL; + +static int init(void) { + + uPortInit(); + uDeviceInit(); + + return 0; +} +SYS_INIT(init, APPLICATION, 90); + +static int cmd_pos_single(const struct shell *sh, size_t argc, char **argv, void *data) { + + if (gnss_device_handle == NULL) { + shell_print(sh, "Error: GNSS device is not ready"); + return -1; + } + + int32_t latitudeX1e7 = 0; + int32_t longitudeX1e7 = 0; + int32_t altitude_millimeters = 0; + int32_t radius_millimeters = 0; + int32_t speed_millimeters_per_second = 0; + int32_t space_vehicles_used = 0; + int64_t time_utc = 0; + + int64_t start_time_ms = k_uptime_get(); + + int ret = uGnssPosGet(gnss_device_handle, &latitudeX1e7, &longitudeX1e7, + &altitude_millimeters, &radius_millimeters, &speed_millimeters_per_second, + &space_vehicles_used, &time_utc, NULL); + + int64_t stop_time_ms = k_uptime_get(); + float time_to_fix_seconds = (stop_time_ms - start_time_ms) / 1000.0; + + if (ret != 0) { + shell_print(sh, "Error during uGnssPosGet: %d", ret); + return -1; + } + + float latitude = latitudeX1e7 / 1.e7; + float longitude = longitudeX1e7 / 1.e7; + float altitude_meters = altitude_millimeters / 1000.0; + float radius_meters = radius_millimeters / 1000.0; + + shell_print(sh, "Found position estimate after %.1fs: (lat, lon): (%f, %f), alt: %.2fm, radius: %.2fm (%d SV used)", + time_to_fix_seconds, latitude, longitude, altitude_meters, radius_meters, space_vehicles_used); + + return 0; +} +SHELL_STATIC_SUBCMD_SET_CREATE(gnss_sub, + SHELL_CMD(single, NULL, "Get a one-shot position estimate", cmd_pos_single), + SHELL_SUBCMD_SET_END +); +SHELL_CMD_REGISTER(gnss, &gnss_sub, "GNSS related commands", NULL); + +int main(void) { + + int ret = uDeviceOpen(&device_config, &gnss_device_handle); + + if (ret != 0) { + LOG_ERR("Error during uDeviceOpen: %d", ret); + return 0; + } + + LOG_INF("GNSS Device is ready!"); + + while(true) { + k_msleep(1000); + } + + return 0; +} From 8b8ae5acfa6408a6f2b0556e14df0bde3a158ec8 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 13 Nov 2023 11:19:14 +0100 Subject: [PATCH 18/22] samples: ubx_gnss: Move shell commands to separate file Signed-off-by: Sarah Renkhoff --- samples/ubx_gnss/CMakeLists.txt | 9 +++++- samples/ubx_gnss/src/main.c | 48 ++--------------------------- samples/ubx_gnss/src/main.h | 14 +++++++++ samples/ubx_gnss/src/shell.c | 54 +++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 47 deletions(-) create mode 100644 samples/ubx_gnss/src/main.h create mode 100644 samples/ubx_gnss/src/shell.c diff --git a/samples/ubx_gnss/CMakeLists.txt b/samples/ubx_gnss/CMakeLists.txt index 699fa41b3e..2480085858 100644 --- a/samples/ubx_gnss/CMakeLists.txt +++ b/samples/ubx_gnss/CMakeLists.txt @@ -11,4 +11,11 @@ assert(CONFIG_SHELL "Zephyr's embedded shell must be enabled") # Add your source file to the "app" target. This must come after # the boilerplate code, which defines the target. -target_sources(app PRIVATE src/main.c) +target_sources(app PRIVATE + src/main.c + src/shell.c +) + +target_include_directories(app PRIVATE + src +) diff --git a/samples/ubx_gnss/src/main.c b/samples/ubx_gnss/src/main.c index d2e79c0b5e..a07cf17d00 100644 --- a/samples/ubx_gnss/src/main.c +++ b/samples/ubx_gnss/src/main.c @@ -5,7 +5,8 @@ #include #include -#include + +#include #include LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL); @@ -46,51 +47,6 @@ static int init(void) { } SYS_INIT(init, APPLICATION, 90); -static int cmd_pos_single(const struct shell *sh, size_t argc, char **argv, void *data) { - - if (gnss_device_handle == NULL) { - shell_print(sh, "Error: GNSS device is not ready"); - return -1; - } - - int32_t latitudeX1e7 = 0; - int32_t longitudeX1e7 = 0; - int32_t altitude_millimeters = 0; - int32_t radius_millimeters = 0; - int32_t speed_millimeters_per_second = 0; - int32_t space_vehicles_used = 0; - int64_t time_utc = 0; - - int64_t start_time_ms = k_uptime_get(); - - int ret = uGnssPosGet(gnss_device_handle, &latitudeX1e7, &longitudeX1e7, - &altitude_millimeters, &radius_millimeters, &speed_millimeters_per_second, - &space_vehicles_used, &time_utc, NULL); - - int64_t stop_time_ms = k_uptime_get(); - float time_to_fix_seconds = (stop_time_ms - start_time_ms) / 1000.0; - - if (ret != 0) { - shell_print(sh, "Error during uGnssPosGet: %d", ret); - return -1; - } - - float latitude = latitudeX1e7 / 1.e7; - float longitude = longitudeX1e7 / 1.e7; - float altitude_meters = altitude_millimeters / 1000.0; - float radius_meters = radius_millimeters / 1000.0; - - shell_print(sh, "Found position estimate after %.1fs: (lat, lon): (%f, %f), alt: %.2fm, radius: %.2fm (%d SV used)", - time_to_fix_seconds, latitude, longitude, altitude_meters, radius_meters, space_vehicles_used); - - return 0; -} -SHELL_STATIC_SUBCMD_SET_CREATE(gnss_sub, - SHELL_CMD(single, NULL, "Get a one-shot position estimate", cmd_pos_single), - SHELL_SUBCMD_SET_END -); -SHELL_CMD_REGISTER(gnss, &gnss_sub, "GNSS related commands", NULL); - int main(void) { int ret = uDeviceOpen(&device_config, &gnss_device_handle); diff --git a/samples/ubx_gnss/src/main.h b/samples/ubx_gnss/src/main.h new file mode 100644 index 0000000000..3b3a825c75 --- /dev/null +++ b/samples/ubx_gnss/src/main.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2023 TiaC Systems + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef MAIN_H +#define MAIN_H + +#include +#include + +extern uDeviceHandle_t gnss_device_handle; + +#endif // MAIN_H diff --git a/samples/ubx_gnss/src/shell.c b/samples/ubx_gnss/src/shell.c new file mode 100644 index 0000000000..eaa5ab295e --- /dev/null +++ b/samples/ubx_gnss/src/shell.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 TiaC Systems + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include + +static int cmd_gnss_single(const struct shell *sh, size_t argc, char **argv, void *data) { + + if (gnss_device_handle == NULL) { + shell_print(sh, "Error: GNSS device is not ready"); + return -1; + } + + int32_t latitudeX1e7 = 0; + int32_t longitudeX1e7 = 0; + int32_t altitude_millimeters = 0; + int32_t radius_millimeters = 0; + int32_t speed_millimeters_per_second = 0; + int32_t space_vehicles_used = 0; + int64_t time_utc = 0; + + int64_t start_time_ms = k_uptime_get(); + + int ret = uGnssPosGet(gnss_device_handle, &latitudeX1e7, &longitudeX1e7, + &altitude_millimeters, &radius_millimeters, &speed_millimeters_per_second, + &space_vehicles_used, &time_utc, NULL); + + int64_t stop_time_ms = k_uptime_get(); + float time_to_fix_seconds = (stop_time_ms - start_time_ms) / 1000.0; + + if (ret != 0) { + shell_print(sh, "Error during uGnssPosGet: %d", ret); + return -1; + } + + float latitude = latitudeX1e7 / 1.e7; + float longitude = longitudeX1e7 / 1.e7; + float altitude_meters = altitude_millimeters / 1000.0; + float radius_meters = radius_millimeters / 1000.0; + + shell_print(sh, "Found position estimate after %.1fs: (lat, lon): (%f, %f), alt: %.2fm, radius: %.2fm (%d SV used)", + time_to_fix_seconds, latitude, longitude, altitude_meters, radius_meters, space_vehicles_used); + + return 0; +} + +SHELL_STATIC_SUBCMD_SET_CREATE(gnss_sub, + SHELL_CMD(single, NULL, "Get a one-shot position estimate", cmd_gnss_single), + SHELL_SUBCMD_SET_END +); +SHELL_CMD_REGISTER(gnss, &gnss_sub, "GNSS related commands", NULL); From 18c03dc6af4603684399453864e102012d494cbc Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 13 Nov 2023 11:47:47 +0100 Subject: [PATCH 19/22] samples: ubx_gnss: Add commands for streaming position estimates Signed-off-by: Sarah Renkhoff --- samples/ubx_gnss/prj.conf | 2 +- samples/ubx_gnss/src/shell.c | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/samples/ubx_gnss/prj.conf b/samples/ubx_gnss/prj.conf index 0a4c4fbe00..9de99a1c48 100644 --- a/samples/ubx_gnss/prj.conf +++ b/samples/ubx_gnss/prj.conf @@ -32,7 +32,7 @@ CONFIG_MINIMAL_LIBC_MALLOC=n # Memory CONFIG_MAIN_STACK_SIZE=8192 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=16384 # Interrupt driven UART is set just to point out that is the # case: it will be the default anyway, except for Zephyr Linux diff --git a/samples/ubx_gnss/src/shell.c b/samples/ubx_gnss/src/shell.c index eaa5ab295e..c461e4925d 100644 --- a/samples/ubx_gnss/src/shell.c +++ b/samples/ubx_gnss/src/shell.c @@ -7,6 +7,30 @@ #include +static void gnss_stream_callback(uDeviceHandle_t device_handle, + int32_t error_code, + int32_t latitudeX1e7, + int32_t longitudeX1e7, + int32_t altitude_millimeters, + int32_t radius_millimeters, + int32_t speed_millimeters_per_second, + int32_t space_vehicles_used, + int64_t time_utc) { + + if (error_code != 0) { + return; + } + + float latitude = latitudeX1e7 / 1.e7; + float longitude = longitudeX1e7 / 1.e7; + float altitude_meters = altitude_millimeters / 1000.0; + float radius_meters = radius_millimeters / 1000.0; + + printk("Found position estimate: (lat, lon): (%f, %f), alt: %.2fm, radius: %.2fm (%d SV used)\n", + latitude, longitude, altitude_meters, radius_meters, space_vehicles_used); + +} + static int cmd_gnss_single(const struct shell *sh, size_t argc, char **argv, void *data) { if (gnss_device_handle == NULL) { @@ -47,8 +71,39 @@ static int cmd_gnss_single(const struct shell *sh, size_t argc, char **argv, voi return 0; } +static int cmd_gnss_stream_start(const struct shell *sh, size_t argc, char **argv, void *data) { + + if (gnss_device_handle == NULL) { + shell_print(sh, "Error: GNSS device is not ready"); + return -1; + } + + uGnssPosGetStreamedStart(gnss_device_handle, 1000, gnss_stream_callback); + + return 0; +} + +static int cmd_gnss_stream_stop(const struct shell *sh, size_t argc, char **argv, void *data) { + + if (gnss_device_handle == NULL) { + shell_print(sh, "Error: GNSS device is not ready"); + return -1; + } + + uGnssPosGetStreamedStop(gnss_device_handle); + + return 0; +} + +SHELL_STATIC_SUBCMD_SET_CREATE(gnss_stream_sub, + SHELL_CMD(start, NULL, "Start streaming position estimates", cmd_gnss_stream_start), + SHELL_CMD(stop, NULL, "Stop streaming position estimates", cmd_gnss_stream_stop), + SHELL_SUBCMD_SET_END +); + SHELL_STATIC_SUBCMD_SET_CREATE(gnss_sub, SHELL_CMD(single, NULL, "Get a one-shot position estimate", cmd_gnss_single), + SHELL_CMD(stream, &gnss_stream_sub, "Start or stop streaming of position estimates", NULL), SHELL_SUBCMD_SET_END ); SHELL_CMD_REGISTER(gnss, &gnss_sub, "GNSS related commands", NULL); From 69769f8d59c9c2608dcaeb4ede48d67be9e70408 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 13 Nov 2023 13:07:09 +0100 Subject: [PATCH 20/22] samples: ubx_gnss: Add ability to reset the GNSS module Signed-off-by: Sarah Renkhoff Signed-off-by: Stephan Linz --- samples/ubx_gnss/app.overlay | 5 ++++ .../ubx_gnss/dts/bindings/reset-switch.yaml | 13 ++++++++++ samples/ubx_gnss/src/main.c | 25 +++++++++++++++++++ samples/ubx_gnss/src/main.h | 2 ++ samples/ubx_gnss/src/shell.c | 12 +++++++++ 5 files changed, 57 insertions(+) create mode 100644 samples/ubx_gnss/dts/bindings/reset-switch.yaml diff --git a/samples/ubx_gnss/app.overlay b/samples/ubx_gnss/app.overlay index ba426657c2..1ed27cce83 100644 --- a/samples/ubx_gnss/app.overlay +++ b/samples/ubx_gnss/app.overlay @@ -4,6 +4,11 @@ */ / { + reset_switch: reset_switch { + compatible = "reset-switch"; + gpios = <&arduino_header 8 GPIO_ACTIVE_LOW>; + }; + aliases { ubxlib-uart0 = &arduino_serial; }; diff --git a/samples/ubx_gnss/dts/bindings/reset-switch.yaml b/samples/ubx_gnss/dts/bindings/reset-switch.yaml new file mode 100644 index 0000000000..9400e3a4d4 --- /dev/null +++ b/samples/ubx_gnss/dts/bindings/reset-switch.yaml @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Sarah Renkhoff +# SPDX-License-Identifier: Apache-2.0 + +description: GPIO pin to cause a reset on an external device + +compatible: "reset-switch" + +properties: + gpios: + type: phandle-array + required: true + description: | + The GPIO pin connected to a reset switch. diff --git a/samples/ubx_gnss/src/main.c b/samples/ubx_gnss/src/main.c index a07cf17d00..754c4050f9 100644 --- a/samples/ubx_gnss/src/main.c +++ b/samples/ubx_gnss/src/main.c @@ -3,17 +3,29 @@ * SPDX-License-Identifier: Apache-2.0 */ +/* Zephyr includes */ #include #include +#include +#include +/* Application specific includes */ #include +/* Logging */ #include LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL); +/* ubxlib specific includes */ #include #include +#if !DT_NODE_EXISTS(DT_NODELABEL(reset_switch)) +#error No reset switch node found in devicetree, check overlay for your board +#endif + +static const struct gpio_dt_spec reset_switch = GPIO_DT_SPEC_GET(DT_NODELABEL(reset_switch), gpios); + static const uDeviceCfg_t device_config = { .deviceType = U_DEVICE_TYPE_GNSS, .deviceCfg = { @@ -43,10 +55,23 @@ static int init(void) { uPortInit(); uDeviceInit(); + gpio_pin_configure_dt(&reset_switch, GPIO_OUTPUT_INACTIVE); + return 0; } SYS_INIT(init, APPLICATION, 90); +void reset_gnss(void) { + + LOG_INF("Resetting GNSS module"); + + gpio_pin_set_dt(&reset_switch, 1); + k_msleep(200); + gpio_pin_set_dt(&reset_switch, 0); + + LOG_INF("Reset complete"); +} + int main(void) { int ret = uDeviceOpen(&device_config, &gnss_device_handle); diff --git a/samples/ubx_gnss/src/main.h b/samples/ubx_gnss/src/main.h index 3b3a825c75..598b1f1566 100644 --- a/samples/ubx_gnss/src/main.h +++ b/samples/ubx_gnss/src/main.h @@ -11,4 +11,6 @@ extern uDeviceHandle_t gnss_device_handle; +void reset_gnss(void); + #endif // MAIN_H diff --git a/samples/ubx_gnss/src/shell.c b/samples/ubx_gnss/src/shell.c index c461e4925d..3162fb3259 100644 --- a/samples/ubx_gnss/src/shell.c +++ b/samples/ubx_gnss/src/shell.c @@ -95,6 +95,17 @@ static int cmd_gnss_stream_stop(const struct shell *sh, size_t argc, char **argv return 0; } +static int cmd_gnss_reset(const struct shell *sh, size_t argc, char **argv, void *data) { + + if (gnss_device_handle == NULL) { + shell_print(sh, "Error: GNSS device is not ready"); + return -1; + } + + reset_gnss(); + return 0; +} + SHELL_STATIC_SUBCMD_SET_CREATE(gnss_stream_sub, SHELL_CMD(start, NULL, "Start streaming position estimates", cmd_gnss_stream_start), SHELL_CMD(stop, NULL, "Stop streaming position estimates", cmd_gnss_stream_stop), @@ -104,6 +115,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(gnss_stream_sub, SHELL_STATIC_SUBCMD_SET_CREATE(gnss_sub, SHELL_CMD(single, NULL, "Get a one-shot position estimate", cmd_gnss_single), SHELL_CMD(stream, &gnss_stream_sub, "Start or stop streaming of position estimates", NULL), + SHELL_CMD(reset, NULL, "Reset GNSS module", cmd_gnss_reset), SHELL_SUBCMD_SET_END ); SHELL_CMD_REGISTER(gnss, &gnss_sub, "GNSS related commands", NULL); From dc73ebc26354e892dc056a3e784276b789d8e497 Mon Sep 17 00:00:00 2001 From: Sarah Renkhoff Date: Mon, 13 Nov 2023 13:28:46 +0100 Subject: [PATCH 21/22] samples: ubx_gnss: Add command for testing TTFF Signed-off-by: Sarah Renkhoff Signed-off-by: Stephan Linz --- samples/ubx_gnss/src/main.c | 4 ---- samples/ubx_gnss/src/shell.c | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/samples/ubx_gnss/src/main.c b/samples/ubx_gnss/src/main.c index 754c4050f9..538f2a9c18 100644 --- a/samples/ubx_gnss/src/main.c +++ b/samples/ubx_gnss/src/main.c @@ -63,13 +63,9 @@ SYS_INIT(init, APPLICATION, 90); void reset_gnss(void) { - LOG_INF("Resetting GNSS module"); - gpio_pin_set_dt(&reset_switch, 1); k_msleep(200); gpio_pin_set_dt(&reset_switch, 0); - - LOG_INF("Reset complete"); } int main(void) { diff --git a/samples/ubx_gnss/src/shell.c b/samples/ubx_gnss/src/shell.c index 3162fb3259..f3a0ae5783 100644 --- a/samples/ubx_gnss/src/shell.c +++ b/samples/ubx_gnss/src/shell.c @@ -4,6 +4,7 @@ */ #include +#include #include @@ -106,6 +107,42 @@ static int cmd_gnss_reset(const struct shell *sh, size_t argc, char **argv, void return 0; } +static int cmd_gnss_ttff(const struct shell *sh, size_t argc, char **argv, void *data) { + + if (gnss_device_handle == NULL) { + shell_print(sh, "Error: GNSS device is not ready"); + return -1; + } + + int n_tests = 1; + if (argc > 1) { + n_tests = atoi(argv[1]); + } + + uint64_t durations_total_ms = 0; + for (int i = 0; i < n_tests; i++) { + + reset_gnss(); + uint64_t start_time_ms = k_uptime_get(); + int ret = uGnssPosGet(gnss_device_handle, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + if (ret != 0) { + shell_print(sh, "Error during uGnssPosGet: %d", ret); + return -1; + } + + uint64_t stop_time_ms = k_uptime_get(); + uint64_t duration_ms = stop_time_ms - start_time_ms; + shell_print(sh, "Run %d of %d: Acquired fix after %.2fs", i+1, n_tests, duration_ms / 1000.0); + durations_total_ms += duration_ms; + } + + float duration_avg_seconds = (durations_total_ms / 1000.0) / n_tests; + shell_print(sh, "---------------"); + shell_print(sh, "Avg. TTFF: %.2f", duration_avg_seconds); + + return 0; +} + SHELL_STATIC_SUBCMD_SET_CREATE(gnss_stream_sub, SHELL_CMD(start, NULL, "Start streaming position estimates", cmd_gnss_stream_start), SHELL_CMD(stop, NULL, "Stop streaming position estimates", cmd_gnss_stream_stop), @@ -116,6 +153,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(gnss_sub, SHELL_CMD(single, NULL, "Get a one-shot position estimate", cmd_gnss_single), SHELL_CMD(stream, &gnss_stream_sub, "Start or stop streaming of position estimates", NULL), SHELL_CMD(reset, NULL, "Reset GNSS module", cmd_gnss_reset), + SHELL_CMD(ttff, NULL, "Measure TTFF", cmd_gnss_ttff), SHELL_SUBCMD_SET_END ); SHELL_CMD_REGISTER(gnss, &gnss_sub, "GNSS related commands", NULL); From 4ef1cadc65ee4a17e89afb60c8c57ee5340a8107 Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Fri, 17 Nov 2023 07:36:04 +0100 Subject: [PATCH 22/22] samples: ubx_gnss: Improve documentation - add the reset GPIO line to requirements - show a full Devicetree sample for specific board - give a hint for standard configuration on top of an Arduino UNO R3 edge connector (D0, D1, D2) - add example console session - test on more boards: ST Nucleo L496ZG ST Nucleo F413ZH ST Nucleo F767ZI NXP MIMXRT1060-EVK Signed-off-by: Stephan Linz --- samples/ubx_gnss/README.rst | 148 +++++++++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 12 deletions(-) diff --git a/samples/ubx_gnss/README.rst b/samples/ubx_gnss/README.rst index dbde68836e..102224568f 100644 --- a/samples/ubx_gnss/README.rst +++ b/samples/ubx_gnss/README.rst @@ -6,29 +6,44 @@ Ubxlib GNSS Sample Overview ******** -A sample application demonstrating how to integrate a u-blox GNSS device into a -zephyr application. +A sample application demonstrating how to integrate a u-blox GNSS device into +a Zephyr application. Requirements ************ -A u-blox GNSS device must be connected via UART, and a devicetree alias -`ubxlib-uart0` must exist and point towards this UART port. To fulfil this -requirement, you can add a simple devicetree overlay for your board such as +A u-blox GNSS device must be connected via UART, and a Devicetree alias +:code:`ubxlib-uart0` must exist and point towards this UART port. Also +a single GPIO line for the module reset signal have to define. To fulfil +this requirement, you can add a simple Devicetree overlay for your board +as shown below. .. code-block:: devicetree - / { - aliases { - ubxlib-uart0 = &usart3; - }; - }; + / { + reset_switch: reset_switch { + compatible = "reset-switch"; + gpios = <&gpiof 15 GPIO_ACTIVE_LOW>; + }; + + aliases { + ubxlib-uart0 = &usart3; + }; + }; + +In default this sample application comes with a generic :code:`app.overlay` +that should be usable with all boards that provies an Arduino UNO R3 edge +connector. For :code:`ubxlib-uart0` the standard Arduino UART on D0 (RX) +and D1 (TX) will be used (`&arduino_serial`). The reset signal will be +controlled by D2 (GPIO) and is mapped to :code:`<&arduino_header 8 …>`. Building and Running ******************** -ST Nucleo L496ZG -================ +Build and flash for different boards +==================================== + +.. rubric:: ST Nucleo L496ZG .. zephyr-app-commands:: :zephyr-app: bridle/samples/ubx_gnss @@ -37,3 +52,112 @@ ST Nucleo L496ZG :west-args: -p :goals: flash :compact: + +.. rubric:: ST Nucleo F413ZH + +.. zephyr-app-commands:: + :zephyr-app: bridle/samples/ubx_gnss + :board: nucleo_f413zh + :build-dir: nucleo_f413zh-ubx_gnss + :west-args: -p + :goals: flash + :compact: + +.. rubric:: ST Nucleo F767ZI + +.. zephyr-app-commands:: + :zephyr-app: bridle/samples/ubx_gnss + :board: nucleo_f767zi + :build-dir: nucleo_f767zi-ubx_gnss + :west-args: -p + :goals: flash + :compact: + +.. rubric:: NXP MIMXRT1060-EVK + +.. zephyr-app-commands:: + :zephyr-app: bridle/samples/ubx_gnss + :board: mimxrt1060_evk + :build-dir: mimxrt1060_evk-ubx_gnss + :west-args: -p + :flash-args: -r pyocd + :goals: flash + :compact: + +Example console session +======================= + +After power-on or hard reset, the GNSS module will be initialized automatically: + + .. code-block:: console + + *** Booting Zephyr OS build … *** + [00:00:02.021,000] main: GNSS Device is ready! + uart:~$ _ + +There is a simple Shell command for some standard evaluation steps: + + .. code-block:: console + + uart:~$ gnss -h + gnss - GNSS related commands + Subcommands: + single :Get a one-shot position estimate + stream :Start or stop streaming of position estimates + reset :Reset GNSS module + ttff :Measure TTFF + uart:~$ _ + +Reset GNSS module: + + .. code-block:: console + + uart:~$ gnss reset + uart:~$ _ + + The on-module LED for PPS signaling goes off and comes back to blink + after TTFF. + +Measure TTFF: + + .. code-block:: console + + uart:~$ gnss ttff + Run 1 of 1: Acquired fix after 32.26s + --------------- + Avg. TTFF: 32.26 + uart:~$ _ + + The on-module LED for PPS signaling goes off and comes back to blink + after TTFF. + +Get a one-shot position estimate: + + .. code-block:: console + + uart:~$ gnss single + Found position estimate after 0.8s: (lat, lon): (50.922432, 11.600015), alt: 192.05m, radius: 1.48m (15 SV used) + uart:~$ _ + +Start or stop streaming of position estimates: + + .. code-block:: console + + uart:~$ gnss stream start + Found position estimate: (lat, lon): (50.922447, 11.600006), alt: 192.64m, radius: 1.45m (17 SV used) + Found position estimate: (lat, lon): (50.922451, 11.600005), alt: 192.53m, radius: 1.45m (18 SV used) + Found position estimate: (lat, lon): (50.922451, 11.600004), alt: 192.63m, radius: 1.45m (18 SV used) + Found position estimate: (lat, lon): (50.922455, 11.600004), alt: 192.71m, radius: 1.46m (17 SV used) + Found position estimate: (lat, lon): (50.922455, 11.600004), alt: 192.80m, radius: 1.46m (18 SV used) + Found position estimate: (lat, lon): (50.922455, 11.600004), alt: 192.96m, radius: 1.46m (18 SV used) + Found position estimate: (lat, lon): (50.922455, 11.600003), alt: 192.89m, radius: 1.46m (18 SV used) + Found position estimate: (lat, lon): (50.922459, 11.600002), alt: 192.79m, radius: 1.47m (17 SV used) + Found position estimate: (lat, lon): (50.922459, 11.600001), alt: 192.92m, radius: 1.47m (18 SV used) + Found position estimate: (lat, lon): (50.922462, 11.600000), alt: 192.89m, radius: 1.48m (17 SV used) + Found position estimate: (lat, lon): (50.922462, 11.599999), alt: 192.77m, radius: 1.48m (18 SV used) + Found position estimate: (lat, lon): (50.922466, 11.599998), alt: 192.69m, radius: 1.48m (18 SV used) + Found position estimate: (lat, lon): (50.922466, 11.599996), alt: 192.49m, radius: 1.50m (18 SV used) + Found position estimate: (lat, lon): (50.922470, 11.599995), alt: 192.22m, radius: 1.50m (18 SV used) + uart:~$ gnss stream stop + Found position estimate: (lat, lon): (50.922470, 11.599994), alt: 192.12m, radius: 1.50m (18 SV used) + uart:~$ _