Connection refused on nrf9160dk

Hello, I’ve been trying to use the golioth-firmware-sdk to connect to my project and later have FOTA. It took me a while to configure the project to work with the sdk and it was a bit custom so I’ll explain what I did.

In the early stages of development my project began from the mqtt_sample from nrf connect sdk. The key thing about it is that it used the west.yml from C:/ncs/v2.6.0/nrf. Meaning it doesn’t have a yml file for the project. In order to add the golioth-firmware-sdk I added the following lines to the yml in the projects section:

- name: golioth
      path: modules/lib/golioth
      revision: v0.14.0
      url: https://github.com/golioth/golioth-firmware-sdk.git

After west update I also went into its directory (C:/ncs/v2.6.0/modules/lib/golioth) and ran: git submodule update --init --recursive.

The last thing before I explain the current issue is that it couldn’t create an eventfd before so I had to increase CONFIG_EVENTFD_MAX=3

“it” is the following lines from the sample:

golioth_client = golioth_client_create(&client_config);
        golioth_client_register_event_callback(golioth_client, on_golioth_event, NULL);

I put them right when I connect to the network (via cellular). I tried setting the config to both PSK and TAG while configuring it according to the docs. Everything else is set to default. Now when I run the code I get the following errors again and again:

<err> golioth_coap_client_zephyr: Failed to connect to socket: -111
[00:00:03.172,729] <err> golioth_coap_client_zephyr: Failed to connect: -111
[00:00:03.172,729] <wrn> golioth_coap_client_zephyr: Failed to connect: -111

Lmk if you have any further questions and thank you in advance

EDIT: I’ve also tried v2.5.2 now and it didn’t fix the problem. Though the connection refused message is surprisingly quick

Hey @justavishay ,

Thanks for posting! I have a few questions for you listed below:

• Is the device connected to the network before you attempt to connect to Golioth Cloud?
• Can you post the entire yml file you are using?
• Can you try to use our hello Zephyr example and see if the issue persists? It is easier to debug potential Golioth-related problems that way.

Hello,
This is a co-worker who is working with the original poster.
We now have a problem when following the tutorial of “Hello Zephyr example”.
Everything works as expected, until the last step of flashing the device.
The correct credentials have been put in and verified, but after successfully building the project, and trying the west flash command, it gives us this error:
‘FATAL ERROR: one or more Python dependencies were missing; see the getting started guide for details on how to fix’.

As for your other questions:

  1. yes
  2. I’m attaching the yml file.
# The west manifest file (west.yml) for the nRF Connect SDK (NCS).
#
# The per-workspace west configuration file, ncs/.west/config,
# specifies the location of this manifest file like this:
#
#     [manifest]
#     path = nrf
#
# See the west documentation for more information:
#
# https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/west/index.html

manifest:
  version: "0.13"

  # "remotes" is a list of locations where git repositories are cloned
  # and fetched from.
  remotes:
    # nRF Connect SDK GitHub organization.
    # NCS repositories are hosted here.
    - name: ncs
      url-base: https://github.com/nrfconnect
    # Third-party repository sources:
    - name: zephyrproject
      url-base: https://github.com/zephyrproject-rtos
    - name: throwtheswitch
      url-base: https://github.com/ThrowTheSwitch
    - name: armmbed
      url-base: https://github.com/ARMmbed
    - name: nordicsemi
      url-base: https://github.com/NordicSemiconductor
    - name: dragoon
      url-base: https://projecttools.nordicsemi.no/bitbucket/scm/drgn
    - name: memfault
      url-base: https://github.com/memfault
    - name: ant-nrfconnect
      url-base: https://github.com/ant-nrfconnect
    - name: babblesim
      url-base: https://github.com/BabbleSim
    - name: bosch
      url-base: https://github.com/boschsensortec

  # If not otherwise specified, the projects below should be obtained
  # from the ncs remote.
  defaults:
    remote: ncs

  group-filter: [-nrf-802154, -dragoon, -find-my, -ant, -babblesim, -sidewalk, -bsec, +optional]

  # "projects" is a list of git repositories which make up the NCS
  # source code.
  #
  # For 'userdata' fields in the projects area, please refer to:
  # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/dm_code_base.html
  projects:

    # The Zephyr RTOS fork in the NCS, along with the subset of its
    # modules which NCS imports directly.
    #
    # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/introduction/index.html
    # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html
    - name: zephyr
      repo-path: sdk-zephyr
      revision: v3.5.99-ncs1
      import:
        # In addition to the zephyr repository itself, NCS also
        # imports the contents of zephyr/west.yml at the above
        # revision. Only the projects explicitly named in the
        # following allowlist are imported.
        #
        # Note that the zephyr west extensions (like 'build', 'flash',
        # 'debug', etc.) are automatically provided by this import, so
        # there's no need to add a redundant west-commands: key for
        # the zephyr project.
        #
        # Please keep this list sorted alphabetically.
        name-allowlist:
          - TraceRecorderSource
          - canopennode
          - chre
          - cmsis
          - cmsis-dsp
          - cmsis-nn
          - edtt
          - fatfs
          - golioth
          - hal_nordic
          - hal_st # required for ST sensors (unrelated to STM32 MCUs)
          - hal_wurthelektronik
          - liblc3
          - libmetal
          - littlefs
          - loramac-node
          - lvgl
          - lz4
          - mipi-sys-t
          - nanopb
          - net-tools
          - nrf_hw_models
          - open-amp
          - picolibc
          - segger
          - tinycrypt
          - tf-m-tests
          - uoscore-uedhoc
          - zcbor
          - zscilib

    # NCS repositories.
    #
    # Some of these are also Zephyr modules which have NCS-specific
    # changes.
    - name: hostap
      repo-path: sdk-hostap
      path: modules/lib/hostap
      revision: dda5457ad2cfce99e333980c7764c8d480ae4010
      userdata:
        ncs:
          upstream-url: https://w1.fi/cgit/hostap/
          upstream-sha: e792f38db8471f35ee94f109a4093dece8f78c6a
          compare-by-default: true
    - name: wfa-qt-control-app
      repo-path: sdk-wi-fiquicktrack-controlappc
      path: modules/lib/wfa-qt-control-app
      revision: d649bd1342215e089d4211757186705cda179013
      userdata:
        ncs:
          upstream-url: https://github.com/Wi-FiQuickTrack/Wi-FiQuickTrack-ControlAppC
          upstream-sha: 1225729e8d84075f03bf9fc51eee85d84dfb0091
          compare-by-default: true
    - name: mcuboot
      repo-path: sdk-mcuboot
      revision: v2.0.99-ncs1
      path: bootloader/mcuboot
    - name: qcbor
      url: https://github.com/laurencelundblade/QCBOR
      revision: 751d36583a9ce1a640900c57e13c9b6b8f3a2ba2
      path: modules/tee/tf-m/qcbor
    - name: mbedtls
      path: modules/crypto/mbedtls
      repo-path: sdk-mbedtls
      revision: v3.5.2-ncs1
    - name: nrfxlib
      repo-path: sdk-nrfxlib
      path: nrfxlib
      revision: v2.6.0
    - name: trusted-firmware-m
      repo-path: sdk-trusted-firmware-m
      path: modules/tee/tf-m/trusted-firmware-m
      revision: v2.0.0-ncs1
    - name: psa-arch-tests
      repo-path: sdk-psa-arch-tests
      path: modules/tee/tf-m/psa-arch-tests
      revision: 94a349db22cd0e44136c281724ffc71b6e7391c3
    - name: matter
      repo-path: sdk-connectedhomeip
      path: modules/lib/matter
      revision: v2.6.0
      submodules:
        - name: nlio
          path: third_party/nlio/repo
        - name: nlassert
          path: third_party/nlassert/repo
        - name: nlunit-test
          path: third_party/nlunit-test/repo
        - name: pigweed
          path: third_party/pigweed/repo
        - name: jsoncpp
          path: third_party/jsoncpp/repo
      userdata:
        ncs:
          upstream-url: https://github.com/project-chip/connectedhomeip
          upstream-sha: 8f66f4215bc0708efc8cc73bda80620e67d8955f
          compare-by-default: false
    - name: nrf-802154
      repo-path: sdk-nrf-802154
      path: nrf-802154
      revision: v2.6.0
      groups:
        - nrf-802154
    - name: dragoon
      # Only for internal Nordic development
      repo-path: dragoon.git
      remote: dragoon
      revision: 36f0e50e876848fb02fd9f82cc32e57b91b15ced
      submodules: true
      groups:
        - dragoon
    - name: cjson
      repo-path: sdk-cjson
      path: modules/lib/cjson
      revision: c6af068b7f05207b28d68880740e4b9ec1e4b50a
      userdata:
        ncs:
          upstream-url: https://github.com/DaveGamble/cJSON
          upstream-sha: d2735278ed1c2e4556f53a7a782063b31331dbf7
          compare-by-default: false
    - name: sidewalk
      repo-path: sdk-sidewalk
      revision: v2.6.0
      groups:
        - sidewalk
    - name: find-my
      repo-path: sdk-find-my
      revision: v2.6.0
      groups:
        - find-my
    - name: azure-sdk-for-c
      repo-path: azure-sdk-for-c
      path: modules/lib/azure-sdk-for-c
      revision: 308c171cb4b5eed266649012a68406487ec81fb2
      userdata:
        ncs:
          upstream-url: https://github.com/Azure/azure-sdk-for-c
          upstream-sha: adc56bc6138a28b5490bce339a31a2581a072092
          compare-by-default: false
    - name: golioth
      path: modules/lib/golioth
      revision: v0.14.0
      url: https://github.com/golioth/golioth-firmware-sdk.git
      # import: west-external.yml
    - name: cirrus
      repo-path: sdk-mcu-drivers
      path: modules/hal/cirrus-logic
      revision: 3873a08377d93a479105a75ac390d3bbcd31d690
      userdata:
        ncs:
          upstream-url: https://github.com/CirrusLogic/mcu-drivers
          upstream-sha: 1be6ca7253133a21a1e9fe0fbb4656e17d63a936
          compare-by-default: false
    - name: openthread
      repo-path: sdk-openthread
      path: modules/lib/openthread
      revision: b9dcdbca4edd348e924d7579a2bada48bf085645
      userdata:
        ncs:
          upstream-url: https://github.com/openthread/openthread
          upstream-sha: c6eaeda5a1c1c5dbb24dce7e027340cb8893a77b
          compare-by-default: false

    # Other third-party repositories.
    - name: cmock
      path: test/cmock
      submodules: true
      revision: f65066f15d8248e6dcb778efb8739904a4512087
      remote: throwtheswitch
    - name: memfault-firmware-sdk
      path: modules/lib/memfault-firmware-sdk
      revision: 1.6.0
      remote: memfault
    - name: ant
      repo-path: sdk-ant
      revision: fcfcd1bc801b0ad2ef08117c7a681514729a5c4b
      remote: ant-nrfconnect
      groups:
        - ant
    - name: bsim
      repo-path: bsim_west
      remote: babblesim
      revision: 384a091445c57b44ac8cbd18ebd245b47c71db94
      import:
        path-prefix: tools
    - name: bme68x
      repo-path: Bosch-BME68x-Library
      remote: bosch
      path: modules/lib/bme68x
      revision: v1.1.40407
      groups:
        - bsec
    - name: bsec
      repo-path: Bosch-BSEC2-Library
      remote: bosch
      path: modules/lib/bsec
      revision: v1.5.2400
      groups:
        - bsec


  # West-related configuration for the nrf repository.
  self:
    # This repository should be cloned to ncs/nrf.
    path: nrf
    # This line configures west extensions.
    west-commands: scripts/west-commands.yml

Hey @miki.dovlekaev2510.w,

error with west flash is Zephyr related and from the message: ‘FATAL ERROR: one or more Python dependencies were missing; see the getting started guide for details on how to fix it looks like you are missing dependencies from the scripts/requirements.txt file.

You can install them by executing:

pip install -r zephyr/scripts/requirements.txt

Additionaly, you might also need to execute:

pip3 install -r nrf/scripts/requirements.txt
pip3 install -r bootloader/mcuboot/scripts/requirements.txt

as stated in Installing the nRF Connect SDK guide.

Hey marko,
We did just that and it worked. We flashes the hello sample and also the update_fw sample and both worked fine. Meaning it’s obviously a issue with our project’s configuration.
I’m now trying to create a new project and make the hello sample code work to see what configurations I’m missing.
I’ve began by copying the main.c and the net_connect.c into the main.c in my project and hardcode the credentials. After that I’ve copied the prj.conf and nrf9160dk_nrf9160_ns.conf into my prj.conf. And lastly I’ve added the Kconfig.defconfig into my Kconfig.
It’s still not working and I get the following errors:

MCUBoot bootloader key file: C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/bootloader/mcuboot/root-ec-p256.pem
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/justa/Documents/rotal/Modem-Nordic-New/application/build_1/mcuboot
=== child image mcuboot -  end ===

CMake Warning at C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/nrf/modules/mcuboot/CMakeLists.txt:320 (message):
 

         ---------------------------------------------------------
         --- WARNING: Using default MCUBoot key, it should not ---
         --- be used for production.                           ---
         ---------------------------------------------------------
         



CMake Warning at C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/nrf/cmake/partition_manager.cmake:79 (message):
 

         ---------------------------------------------------------------------
         --- WARNING: Using a bootloader without pm_static.yml.            ---
         --- There are cases where a deployed product can consist of       ---
         --- multiple images, and only a subset of these images can be     ---
         --- upgraded through a firmware update mechanism. In such cases,  ---
         --- the upgradable images must have partitions that are static    ---
         --- and are matching the partition map used by the bootloader     ---
         --- programmed onto the device.                                   ---
         ---------------------------------------------------------------------
         

Call Stack (most recent call first):
 C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/zephyr/cmake/modules/kernel.cmake:247 (include)
 C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
 C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
 C:/Users/justa/Documents/rotal/Modem-Nordic-New/external/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
 CMakeLists.txt:2 (find_package)


Dropping partition 'nrf_modem_lib_trace' since its size is 0.
Dropping partition 'nonsecure_storage' since it is empty.
-- Configuring incomplete, errors occurred!
See also "C:/Users/justa/Documents/rotal/Modem-Nordic-New/application/build_1/CMakeFiles/CMakeOutput.log".
See also "C:/Users/justa/Documents/rotal/Modem-Nordic-New/application/build_1/CMakeFiles/CMakeError.log".
FAILED: build.ninja 
C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe --regenerate-during-build -SC:\Users\justa\Documents\rotal\Modem-Nordic-New\application -BC:\Users\justa\Documents\rotal\Modem-Nordic-New\application\build_1
ninja: error: rebuilding 'build.ninja': subcommand failed
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\Users\justa\Documents\rotal\Modem-Nordic-New\application\build_1'

What else is missing? I couldn’t find any more configuration files in the sample and it’s a bit weird that it’s not stated in the documentation or at least I couldn’t find them

Hey @justavishay,

It’s great that you were able to set up the build environment and that the hello and the fw_update samples are working.

Unfortunately, you are still experiencing issues related to project setup when trying to build a standalone application, which are hard to debug over the forum.

The best course of action is to start with our reference design template application, where all dependencies are downloaded in the deps folder, where the build system is correctly set up and the project instructions are straightforward and easy to follow.

Hey marko,
As per your advice I went to the reference design template application but instead of using it for a project I decided to copy the prf.conf. I had to change a couple of settings of course but now it’s working in my own project! From here I can slowly bring files from my original project into this one.
So thank you very much for your help!