This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

To identify, adjust sleep period of sample app threads?

Hello Devzone Community,

My name is Ted, and I am continuing my effort to configure a Zephyr based, Nordic aws_iot sample app based firmware to run and support nRF9160 lowest specified power consumption. I am in the process of putting all application threads to sleep, so that Zephyr's idle thread can put the application processor into a low power sleep mode. Nordic Power Profiler waveforms of measured current draw, however, indicate that I've failed in this. Some part of the overall firmware binary appears to be yet running. Lowest average current I achieve is ~190 microamps.

My Devzone account doesn't permit me to upload photos, but here is a link to two captures from Nordic's power profile which I took earlier today.  My apology that I must include an external link here and not the images directly:

wiki.neelanurseries.com/.../20220311

The first one shows a general pattern of current regularly spiking from a few microamps to around three milliamps.  The zoomed capture shows the ten millisecond spikes, a more distinct fast spike and a more blunted longer duration one.

These are taken during a 45 second period when all my application threads are sleeping -- for 45 seconds -- and LTE modem is turned off, and GPIOs to hardware enable points of our board are also turned off, effectively powering down the hardware outside the nRF9160.

From these waveforms I observe that some ARM processor activity appears to be consuming current every ten milliseconds. But though I have put my app threads into a nearly minute long sleep period, and have searched for the sleep periods set on aws_iot sample app threads, I cannot see any firmware configured device or service that is configured to run every ten milliseconds.

This work is based on Nordic's aws_iot sample app, as it appears in ncs v1.6.1. The sample app creates three or four Zephyr threads. Zephyr itself creates a  thread for `int main()` and an idle thread. Work of my own adds a few more threads at run time. These latest threads I can readily put to sleep for minutes or even hours, with a call to k_sleep() in a given thread's effective main function.

I have enabled Zephyr's thread_analyzer feature, and can observe simple reporting at run time of the threads of this firmware. Here is a typical Zephyr output I can see via a serial connection, and using a simple CLI to invoke a handful of commands:

Excerpt 1: Zephyr thread summary report

```1) 'thread_accelerometer' stack size 2048 bytes, stack used 960 bytes, 46%
2) 'thread_dev_work' stack size 3072 bytes, stack used 1504 bytes, 48%
3) 'thread_simple_cli' stack size 4096 bytes, stack used 1768 bytes, 43%
4) 'thread_led' stack size 512 bytes, stack used 136 bytes, 26%
5) 'download_client' stack size 4096 bytes, stack used 104 bytes, 2%
6) 'at_cmd_socket_thread' stack size 1472 bytes, stack used 688 bytes, 46%
7) 'time_thread' stack size 1024 bytes, stack used 728 bytes, 71%
8) 'connection_poll_thread' stack size 3072 bytes, stack used 296 bytes, 9%
9) '0x20015ab0' stack size 1024 bytes, stack used 168 bytes, 16%
10) 'sysworkq' stack size 2048 bytes, stack used 168 bytes, 8%
11) 'idle 00' stack size 320 bytes, stack used 56 bytes, 17%```


Here I modify the report to annotate each thread's origin, which affects how easily or not I can adjust a thread's sleep time:

Excerpt 2:

```1) 'thread_accelerometer' . . . home authored application
2) 'thread_dev_work' . . . home authored application
3) 'thread_simple_cli' . . . home authored application
4) 'thread_led' . . . home authored application
5) 'download_client' . . . aws_iot sample app
6) 'at_cmd_socket_thread' . . . aws_iot sample app
7) 'time_thread' . . . aws_iot sample app
8) 'connection_poll_thread' . . . aws_iot sample app
9) '0x20015ab0' . . . ?, not known
10) 'sysworkq' . . . Zephyr 2.6.0
11) 'idle 00' . . . Zephyr 2.6.0```


So far I have been able to track down in Zephyr's dwt.h library header file that the time thread has a default sleep period of 3600 seconds. Tracing thread 'at_cmd_socket_thread' which is implemented in ncs/nrf/subsys/net/lib/aws_iot/src/aws_iot.c I cannot tell what this thread's effective sleep period is.

Question (1): Can a Devzone team member or community member help me identify where this thread's sleep time is realized?

I have yet to find the implementation details for thread 'download_client', 'connection_poll_thread' and '0x20015ab0'. The last of these threads I have concern for. It is not named, and so I cannot be sure whether it is a Zephyr construct or a Nordic sample app construct. This unnamed thread has shown in the thread analyzer report since I enabled Zephyr's analyzer.


Question (2): is static code analysis the only way to learn "who" in the Zephyr and other source codes is creating the unnamed thread?

Until I can identify the unnamed thread, I won't know whether I can cleanly properly adjust its sleep period. If it is a kernel thread, my app space firmware won't automatically have privileges to make any changes to a kernel thread. I believe there are some extra steps to be able to do so, if that is even possible.

I recognize also that I cannot simply change sleep times of the aws_iot sample app threads, and expect celular level and MQTT client-broker connections to continue to function. I'll need to study and find a way to cleanly close connections before putting such threads to sleep.

Thanks ahead of time to all who can shed some light and help on these deep sleep and nRF9160 power saving questions!

- Ted

Parents
  • Hello Didrik,

    Reporting now findings with the latest low power hello_world code you send.  The project zipped in file hello_world_low_power.zip results for me in the same erroneous, cyclic 'endless loop' cmake build behavior which I described first time a couple of days ago.  I have unzipped and attempted to build this project four times, in two different ways, on two different Ubuntu 20.04 based work stations.

    My first try was to unzip hello_world_low_power in an extent ncs v1.6.1 workspace.  I've often called this my 'west workspace'.  The yaml file which directs `west` how to populate this workspace is:

    manifest:
      remotes:
        - name: nrfconnect
          url-base: https://github.com/nrfconnect
      projects:
        - name: nrf
          repo-path: sdk-nrf
          remote: nrfconnect
          revision: v1.6.1
          import: true 
      self:
        # This repository should be cloned to 
        path: aws-iot-stand-alone
    

    The projects you zipped and have shared with me do not have any manifest file, so I assumed they would build against ncs v1.6.1.  I find no reference in these modified hello_world projects to any particular ncs version.  You mention however that 1462.hello_world.zip unintentionally was or is built against ncs version 1.9.1.  I think that's today's latest stable ncs.  v1.9.1 is definitely a newer release than the nrf-connect SDK code I am presently using.

    The second way I attempt my builds is to create a fresh ncs folder, add my west.yml file there, and run `west init -l hello_world_low_power` in the ncs folder, and then cd into the hello_world_low_power project folder and `west update` there.  There's no obvious reason I can see this would make a difference, but I wanted to be sure I wasn't gumming up any works by re-using my existing ncs workspace.  ( I have successfully used the same ncs workspace for multiple projects, taking care to know that each one depends on the same ncs and third party git repos. )

    The two work hosts on which I'm developing have mostly identical toolchain elements.  I am likely missing some key elements of toolchain description but here are the primary tools I use and think about in my nRF9160 Zephyr application based work:

    Excerpt 1 - host 2 toolchain, Nordic Semi + Zephyr + arm-none-eabi-gcc:

    ted@dev-host-2:~/projects/zephyr-based$ west --version
    West version: v0.12.0
    
    ted@dev-host-2:~/projects/zephyr-based$ cmake --version
    cmake version 3.23.0
    
    CMake suite maintained and supported by Kitware (kitware.com/cmake).
    ted@dev-host-2:~/projects/zephyr-based$ dtc --version
    Version: DTC 1.5.0
    
    ted@dev-host-2:/opt/gcc-arm-none-eabi-10.3-2021.10/bin$ ./arm-none-eabi-gcc --version
    arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
    Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    Excerpt 2 - host 1 toolchain, Nordic Semi ncs 1.6.1 + Zephyr + crosstool-NG compiler:

    Ubuntu 20.04 LTS - Dell tower FG
    
    ted@localhost:~/projects/zephyr-based/z4-sandbox-kionix-work$ west --version
    West version: v0.11.0
    
    ted@localhost:~/projects/zephyr-based/z4-sandbox-kionix-work$ cmake --version
    cmake version 3.21.1
    
    CMake suite maintained and supported by Kitware (kitware.com/cmake).
    
    ted@localhost:~/projects/zephyr-based/z4-sandbox-kionix-work$ dtc --version
    Version: DTC 1.5.0
    
    ted@localhost:/opt/zephyr-sdk-0.13.0/arm-zephyr-eabi/bin$ ./arm-zephyr-eabi-gcc --version
    arm-zephyr-eabi-gcc (crosstool-NG 1.24.0.378_e011758) 10.3.0
    Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    The first hello_world.zip project, which lacked the setting of symbol `CONFIG_NRF_MODEM_LIB=y` prj.conf, and also did not include a child_image subdirectory builds and runs on both hosts.  I can build this sample app simply unzipping it within my existing ncs west workspace.  The two later low power hello_world apps fail to build, but without producing any cmake or other error messages. To recap the build time failure is that cmake or a subordinate tool in the build process keeps cycling back to the start of project processing.

    Do you have any suggestion where further I can look in cmake's output to determine what's misguiding the build process?  This 'cmake endless loop' error so far is specific to the two latest modified projects you share in this Devzone thread.  The error travels with the projects from one host to a second, with a similar but not identical build environment.  This leads me to believe there is some edge case error somewhere in the project.  I will however keep in mind that I may have set up my tools with an edge case fault on each of my favored workstations.

    What I can and will do at this point is return to the working hello_word app, and manually add the prj.conf NRF_MODEM_LIB symbol, try building, and then manually add the child_image folder and Kconfig modifier file for Secure Partition Manager project there.  Those are the two key changes I see you make in the second hello_world and later.

    Kindly inform me and our audience if there are additional toolchain details I should include, to decipher from where this endless loop build arises.

    Thanks again Didrik, and stay safe . . .

    - Ted

  • Hi again Didrik,

    As I attempt to amend the first hello_world project you posted in this thread, I find that adding to prj.conf the symbol setting `CONFIG_NRF_MODEM_LIB=y` causes for me the build error:

    Excerpt - cmake build time snippet:

    $ west build -b nrf9160dk_nrf9160ns
    [0/14] Performing build step for 'spm_subimage'
    ninja: no work to do. 
    [2/12] Building C object modules/nrf/lib/nrf_modem_lib/CMakeFiles/..__nrf__lib__nrf_modem_lib.dir/nrf91_sockets.c.obj
    FAILED: modules/nrf/lib/nrf_modem_lib/CMakeFiles/..__nrf__lib__nrf_modem_lib.dir/nrf91_sockets.c.obj 
    ccache /opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.6.0-rc1-ncs1 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DNRF9160_XXAA -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/ted/projects/zephyr-based/zephyr/include -I/home/ted/projects/zephyr-based/hello-world-0311/build/zephyr/include/generated -I/home/ted/projects/zephyr-based/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/ted/projects/zephyr-based/nrf/include -I/home/ted/projects/zephyr-based/modules/hal/cmsis/CMSIS/Core/Include -I/home/ted/projects/zephyr-based/modules/hal/nordic/nrfx -I/home/ted/projects/zephyr-based/modules/hal/nordic/nrfx/drivers/include -I/home/ted/projects/zephyr-based/modules/hal/nordic/nrfx/mdk -I/home/ted/projects/zephyr-based/zephyr/modules/hal_nordic/nrfx/. -I/home/ted/projects/zephyr-based/modules/debug/segger/SEGGER -I/home/ted/projects/zephyr-based/modules/debug/segger/Config -I/home/ted/projects/zephyr-based/zephyr/modules/segger/. -I/home/ted/projects/zephyr-based/nrfxlib/nrf_modem/include -isystem /home/ted/projects/zephyr-based/zephyr/lib/libc/minimal/include -isystem /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/include -isystem /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/include-fixed -Os -imacros /home/ted/projects/zephyr-based/hello-world-0311/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros /home/ted/projects/zephyr-based/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/ted/projects/zephyr-based/hello-world-0311=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/ted/projects/zephyr-based/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/ted/projects/zephyr-based=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT modules/nrf/lib/nrf_modem_lib/CMakeFiles/..__nrf__lib__nrf_modem_lib.dir/nrf91_sockets.c.obj -MF modules/nrf/lib/nrf_modem_lib/CMakeFiles/..__nrf__lib__nrf_modem_lib.dir/nrf91_sockets.c.obj.d -o modules/nrf/lib/nrf_modem_lib/CMakeFiles/..__nrf__lib__nrf_modem_lib.dir/nrf91_sockets.c.obj -c /home/ted/projects/zephyr-based/nrf/lib/nrf_modem_lib/nrf91_sockets.c
    /home/ted/projects/zephyr-based/nrf/lib/nrf_modem_lib/nrf91_sockets.c:21:10: fatal error: sockets_internal.h: No such file or directory
       21 | #include <sockets_internal.h>
          |          ^~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    ninja: build stopped: subcommand failed.

    When I change working directory from hello_world up to ../zephyr and search for this header file, I find it located in `subsys/net/lib/sockets`.  So from my ncs top level dir the path and file are `ncs/zephyr/subsys/net/lib/sockets/sockets_internal.h`.

    I have attempted to add this path to hello_world's build with a stanza in CMakeLists.txt, a line of the form:

    include_directories($ENV{ZEPHYR_BASE}/subsys/net/lib/sockets)

    As well I have tried some related paths with fewer path elements.  None of these has solved the missing header file error, nor had any visible impact on the -I options reported during build, and visible as part of line 4 in the build snippet above.

    Question 1 - have you a west.yaml file for your latest hello_world_low_power project, which you can share?

    Question 2 - are there one or more other Kconfig symbols, e.g. CONFIG_NETWORKING which I may need to enable?

    My effort here is to build the hello_world sample app, with nRF Modem lib enabled but not explicitly called by the sample, so that I can confirm our nRF9160DK kit can draw as little as 3 microamps.  I'm presently copying my own west.yml file.  This manifest file works for ncs v1.6.1 sample apps and a couple ncs based projects of my own.  I am however unsure if my west.yml sets up the same libraries as you have when you build and run your hello_world app versions.

    Attempting to build and prove your project draws 3uA, so I may adopt its key configurations to my team's work and achieve the same result there.  Will continue researches here to overcome these build time errors.

    - Ted

  • I have not seen this kind of loop before. I have also given the hello_world_low_pwer .zip to a colleague of mine with a Linux computer, and for him the project builds just fine.

    However, he did tell me that he have seen such loops when a project has been moved from one location to another. So you could try to delete the build folder and the .vscode folder and see if that helps.

    However, in the low power projects, and the current meassurement blogpost, there should be compiled versions of the programs as well. So you should be able to use them to meassure the current consumption even though you can't build the projects.

    Or, you could create your own project by applying the same changes:

    1. Enable CONFIG_NRF_MODEM_LIB (which also requires CONFIG_NETWORKING, CONFIG_NET_SOCKETS and CONFIG_HEAP_MEM_POOL_SIZE)

    2. Disable CONFIG_SERIAL in both the application and in any child images (CONFIG_NRF_MODEM_LIB requires that you build the application for the non-secure domain, so you need the SPM to start your application). If you do not, you risk the child image starting the UART, and the application not turning it off.

    3. Ensure that the application doesn't do anything, so that the idle thread puts the device to sleep.

  • Hello Didrik,

    When you hear back findings on the Linux / Ubuntu command line based build, please let me know.  I am actually not using VSCode.  So far `west` and the other `west` orchestrated command line  tools are working well for me. Past experience with integrated development environments has been useful on some points, but always more difficult in terms of understanding compile time settings.  IDEs nearly always seem to hide configuration settings of project `make` and more recently cmake files.

    Thank you also for including `merged.hex` in the example app archives.  Failing to reach a successful build outcome I could still test the specific board for which those pre-compiled binaries are built.

    Regarding the enumerated changes in your reply, yes, I more or less learned those through some trial and error and searching the hello_world / ncs workspace' Kconfig settings.  I am finding `west build -t menuconfig` to be helpful and educational, though I don't know that I will move much beyond scratching the surface of this programming realm.

    Question 1 - Curious, each of your 'hello_world' examples compiles for you with only the prj.conf symbols I find in the zipped archives, correct?  Last night's exercise to revisit and combine elements of two of the example zips you sent provides a good lesson.  But if the zips compile for you, is it that you are building in VSCode, and VSCode holds some project settings outside of your shared, zipped sources?

    Question 2 - does your hello_world `west` manifest file pull in any different set of ncs or third party git repositories, with respect to the west.yml file I posted here a day or two ago?

    Question 3 - I have our nRF9160DK board connect to PPK II as shown in measuring current in Ampere Meter mode.  My first current measurements are around 46 nano-amperes, which seems too low to be real.  In particular, I kept the `while (1) { printk(...); k_msleep(1000); } code block in main() routine, expecting to see a current spike at about one Hertz.  I don't see that.  Is a standard USB-C cable from computer providing 5VDC to the development board?

    When I flash and run the hello_world app, I see the following Zephyr start up messages arrive over the board-powering USB-C cable:

    *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
    Flash regions           Domain          Permissions
    00 01 0x00000 0x10000   Secure          rwxl
    02 31 0x10000 0x100000  Non-Secure      rwxl
    
    Non-secure callable region 0 placed in flash region 1 with size 32.
    
    SRAM region             Domain          Permissions
    00 07 0x00000 0x10000   Secure          rwxl
    08 31 0x10000 0x40000   Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC0             Non-Secure      OK
    03 NRF_RTC1             Non-Secure      OK
    04 NRF_NVMC             Non-Secure      OK
    05 NRF_UARTE1           Non-Secure      OK
    06 NRF_UARTE2           Secure          SKIP
    07 NRF_TWIM2            Non-Secure      OK
    08 NRF_SPIM3            Non-Secure      OK
    09 NRF_TIMER0           Non-Secure      OK
    10 NRF_TIMER1           Non-Secure      OK
    11 NRF_TIMER2           Non-Secure      OK
    12 NRF_SAADC            Non-Secure      OK
    13 NRF_PWM0             Non-Secure      OK
    14 NRF_PWM1             Non-Secure      OK
    15 NRF_PWM2             Non-Secure      OK
    16 NRF_PWM3             Non-Secure      OK
    17 NRF_WDT              Non-Secure      OK
    18 NRF_IPC              Non-Secure      OK
    19 NRF_VMC              Non-Secure      OK
    20 NRF_FPU              Non-Secure      OK
    21 NRF_EGU1             Non-Secure      OK
    22 NRF_EGU2             Non-Secure      OK
    23 NRF_DPPIC            Non-Secure      OK
    24 NRF_REGULATORS       Non-Secure      OK
    25 NRF_PDM              Non-Secure      OK
    26 NRF_I2S              Non-Secure      OK
    27 NRF_GPIOTE1          Non-Secure      OK
    
    SPM: NS image at 0x10000
    SPM: NS MSP at 0x200179e8
    SPM: NS reset vector at 0x124dd
    SPM: prepare to jump to Non-Secure image.
    

    But I never see the "hello world" or "printk" messages themselves.  Am I correct that I should see these messages?

    When the 9160 DK is powered, the Linux station enumerates three /dev/ttyACMx devices:  ttyACM0, ttyACM1, ttyACM2.  I see no terminal messages on ACM1 nor ACM2.

    My terminal program is configured for no hardware flow control, no software flow control, and baud of 115200.  I ought to see at least the starting "hello world" message, yes?

    Ah wait, I may need to strike my last question. With UARTs and high speed clocks turned off I will not see any "hello world" message, correct?  As a sanity check then that firmware is actually running, I would want some alternate heartbeat test such as flashing an LED?

    - Ted

  • tedhavelka said:

    Question 1 - Curious, each of your 'hello_world' examples compiles for you with only the prj.conf symbols I find in the zipped archives, correct?  Last night's exercise to revisit and combine elements of two of the example zips you sent provides a good lesson.  But if the zips compile for you, is it that you are building in VSCode, and VSCode holds some project settings outside of your shared, zipped sources?

    Question 2 - does your hello_world `west` manifest file pull in any different set of ncs or third party git repositories, with respect to the west.yml file I posted here a day or two ago?

    I use the Toolchain Manager to manager my NCS installations, and don't keep a sepparate West workspace for each application. So, when I open a terminal through the Toolchain Manager, it will create an environment where West/CMake finds the right version of the toolchain, etc. Perhaps the most important effect for this conversation is that it sets ZEPHYR_BASE to point to my NCS 1.6.0 installation (there shouldn't be any . Similarly, I have configured VS Code to use my 1.6.0 installation (you can see the settings in the .vscode folder).

    But there shouldn't be any "magic" happening. As long as West finds your 1.6.0 installation, I would have expected it to work.

    tedhavelka said:
    Question 3 - I have our nRF9160DK board connect to PPK II as shown in measuring current in Ampere Meter mode.  My first current measurements are around 46 nano-amperes, which seems too low to be real.  In particular, I kept the `while (1) { printk(...); k_msleep(1000); } code block in main() routine, expecting to see a current spike at about one Hertz.  I don't see that.  Is a standard USB-C cable from computer providing 5VDC to the development board?

    It might be that the printk is turned into a no-op when the console is disabled (which it will be because we disabled it's only backend). But I agree that 46 nA is a bit too good. What DK version do you have?

    If your DK didn't come with a jumper on the "nRF current meassurement" header, you need to cut a solder bridge connecting the two pins: https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/prepare_board.html

    tedhavelka said:
    Ah wait, I may need to strike my last question. With UARTs and high speed clocks turned off I will not see any "hello world" message, correct?  As a sanity check then that firmware is actually running, I would want some alternate heartbeat test such as flashing an LED?

    Yes, without the UART, you will not see messages over UART Slight smile

    I'll try to be optimistic and provide another sample project. This time the blinky sample, with the same changes as I made to the hello_world sample. When I meassure it on my 1.0.0 DK with a PPK2 in source meter mode, I get a total average of ~3.8 uA, and ~2.7 uA in the idle periods.

    The compiled .hex file is included as well.

    blinky_low_power.zip

  • Hello Didrik,

    On 2022-04-05 Didrik asked:  What DK version do you have?

    A white rectangular sticker on the non-component side of my nRF9160DK reads:

    PCA10090

    1.0.0

    2021.11

    960048580

    Contains FCC ID:  xxxxx . . .

    Contains IC:  24529-NRF9160

    Just downloaded and unzipped your latest, number four nRF9160 low power sample app, "blinky_low_power.zip".  I tried to compile again with `west build -b nrf9160dk_nrf9160ns` and again have that cyclic build error where cmake cannot get past what looks to be Kconfig processing.

    All the same, I'd actually gotten the same blinky app code merged in with my prior modified version of the very first intended low power sample you sent / shared in this Devzone post.  So my "doubting Thomas" streak is sated that I am indeed able to modify the low power app -- something I cannot see at any terminal with UART and high speed clocks suspended -- and I can now share back with you the code which builds on my host and runs on my hardware.

    Question - with PPK II connected to "nRF Current Measurement" jumper, is it true that I am measuring the current consumed only and only by the nRF9160 SiP on the nRF9160DK development kit?

    I thought I had seen mention of this point in an earlier reply of yours, Didrik, but I could not find it reviewing all our exchanges in this Devzone ticket.

    Thank you and will keep you posted on progress I make with 9160DK current measurements on my side.

    - Ted

  • tedhavelka said:
    Question - with PPK II connected to "nRF Current Measurement" jumper, is it true that I am measuring the current consumed only and only by the nRF9160 SiP on the nRF9160DK development kit?

    Yes, the "nRF Current Measurement" header will only give you the current drawn by the nRF9160. The GPIO pins are powered through a sepparate source.

Reply
  • tedhavelka said:
    Question - with PPK II connected to "nRF Current Measurement" jumper, is it true that I am measuring the current consumed only and only by the nRF9160 SiP on the nRF9160DK development kit?

    Yes, the "nRF Current Measurement" header will only give you the current drawn by the nRF9160. The GPIO pins are powered through a sepparate source.

Children
  • Thank you Didrik,

    Your mention of the separate power supply, I believe nRF9160 datasheet names it VDD_GPIO or similar, reminds me of a related question:  what is or are the correct Zephyr 2.6.0 GPIO configuration to assign to nRF9160 general purpose I/O port pins,

    (a)  when I/O pin acts as a chip select line to external device, which itself is powered off (at ground state)

    (b)  when I/O pin in wake mode receives interrupts from external device,

    To be clear, during active wake times of nRF9160 + external circuit + firmware, I will configure I/O pins for their normal input or output uses, and set pull-ups and pull-downs as needed.  But to enter deep sleep mode and avoid unintended "bleed" currents to and from nRF9160 GPIOs, I expect I must in some cases change pin configurations at run time or "on the fly".  Is my understanding in this correct?

    Kindly tell me whether this question group is best to open in a new Devzone ticket.

    I ask this I/O config question, due to modest progress with my team's custom 9160-based board.  My latest efforts to modify project firmware to emulate the settings and action of your low power hello_world have gotten me to sub-one-hundred uA current draw.  It is true my custom board differs from the nRF9160DK kit.  In particular, I can only measure total board current, I don't have a break out solder bridge or test points pair to look only at nRF9160 VDD current use.  But this measure-all-board-current is good.  I need to bring total board current down to very close to nRF9160 advertised lowest current for battery life requirements.

    The code I run is also still different code with respect to attached low-power code samples.  In my firmware project I've commented out everything I may reasonably disable.  Given custom board however I wrote and use custom board files (dts, yaml).  These depart from your shared hello_world sample apps.

    So I am trying to adapt my firmware as near as possible to your hello_world configuration settings and run time functionality.  I no longer see any periodic ~25Hz to ~33Hz current pulsing, just small steady current in tens of microamps.  I suspect GPIO mis-configuration.

    As always thank you, Didrik.  Once I solve our low current conundrums I will share a practical summary of steps taken plus what works.

    - Ted

    ( p.s.:  I have tested three different Zephyr GPIO pin configurations, which I set in code sequence to enter my custom firmware into deep sleep mode.  These configurations include (1) GPIO_INPUT with weak pull-down enabled, (2) GPIO_OUTPUT with output set low, (3) GPIO_DISCONNECTED.  These settings I apply to pins which are connected to external sensors, FETs, memory which are themselves at that point powered down.  I actually see more current consumption on our custom board when I attempt these settings, than when making no explicit GPIO configuration at all. Strange.  I am now working through one and a few pins' settings at a time and building a table of current measurement results, to narrow down whether one or a few pins are contributing the additional currents.  But there are many combinations of configurations possible, and pins to configure, which motivate my latest questions! )

  • tedhavelka said:
    I no longer see any periodic ~25Hz to ~33Hz current pulsing

    That's great!

    tedhavelka said:
    Kindly tell me whether this question group is best to open in a new Devzone ticket

    They are a bit outside of my area of expertise and given that we found the rouge thread (and you no longer see the current pulsing), I think those questions are best answered in a new ticket.

    tedhavelka said:
    As always thank you, Didrik

    You're welcome.

    Best regards,

    Didrik

  • Hello Didrik,

    Regarding nRF9160 GPIO settings I will open a new Devzone ticket.  Thank you for helping me to track down the rogue thread, a run-time result of ncs v1.6.1 aws_iot sample app calling at_configure() ncs API routine in its main.c source file.

    By the way I notice that in ncs v1.9.1 aws_iot main.c there is no longer any call anywhere to at_configure().

    As for the attached low power examples, I only want to note that I've yet to obtain approximate 3uA deep sleep current readings.  The first of the five versions of attached hello_world I could build and run, but draws about 3mA on nRF9160DK board rev 1.0.0 (known issue there you note and link to an errata sheet).  The later attached projects I cannot build.  A modified version I tried to adapt, and eventually in Devzone post 86265 draws too little current for me to trust, about 46nA.  Have further testing to perform, and I may open a new ticket on the low power sample app question too.

    Thank you again for the detailed help and your patience Didrik.  Stay safe,

    - Ted

  • Hello Didrik,

    Will you please mark this Devzone post as answered?  I strayed from the original threads question at points, but the answers for tracking down the mystery thread in my aws_iot sample based app are here.  Plus the related Zephyr thread debugging questions have also been answered.  Following Håkon's instructions for gdb server and gdb in each their own terminal window provides me run time inspection of Zephyr 2.6.0 threads in a custom app.

    Thanks,

    - Ted

  • tedhavelka said:
    Thank you for helping me to track down the rogue thread, a run-time result of ncs v1.6.1 aws_iot sample app calling at_configure() ncs API routine in its main.c source file.

    No, the at_configure() isn't involved. The problem is the at_host library, which runs in the background and don't interract directly with the application.

    tedhavelka said:
    By the way I notice that in ncs v1.9.1 aws_iot main.c there is no longer any call anywhere to at_configure()

    Yes, we have reworked the AT command interface, so the at_cmd() and at_notif() libraries no longer is needed.

    Instead, you can use the AT command interface in the modem_lib directly: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/nrfxlib/nrf_modem/doc/at_interface.html

    tedhavelka said:
    Will you please mark this Devzone post as answered?

    I'll see if I can find some usefull answers to mark as verified.

    Best regards,

    Didrik

Related