Skip to content

Conversation

@gminn
Copy link
Member

@gminn gminn commented Apr 3, 2025

Summary

In cases where an upstream device uploads data to Memfault on behalf
of a downstream device, the project key is not required. This change
allows the project key to be optional in those cases. For the
NCS Memfault sources, this is when we are not using MDS or the
Memfault Zephyr HTTP client.

Test Plan

Confirmed that before this change, the build fails if the project key
is not set for a generic cortex-m application where Memfault is enabled:

west build -b qemu_cortex_m3
zephyr/samples/hello_world -- \
-DCONFIG_MEMFAULT=y \
-DCONFIG_MEMFAULT_NCS_FW_TYPE=\"test-app\" \
-DCONFIG_MEMFAULT_NCS_DEVICE_ID=\"my-test-device\"

Confirmed after this change, the build succeeds with this same build command.

Also confirmed that after this change, the build still fails if the project key
is not set for projects where MDS or the Memfault Zephyr HTTP client
are used:

west build -b nrf52840dk/nrf52840 \
nrf/samples/bluetooth/peripheral_mds
...
/Users/gminnehan/projects/memfault-sdk-nrf-workspace/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "Memfault Project Key not configured. Please visit https://goto.memfault.com/create-key/nrf "
 87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
    |                                    ^~~~~~~~~~~~~~
/Users/gminnehan/projects/memfault-sdk-nrf-workspace/nrf/modules/memfault-firmware-sdk/memfault_integration.c:40:1: note: in expansion of macro 'BUILD_ASSERT'
 40 | BUILD_ASSERT(sizeof(CONFIG_MEMFAULT_NCS_PROJECT_KEY) > 1,
    | ^~~~~~~~~~~~
west build -b thingy91/nrf9160/ns -p always \
nrf/applications/asset_tracker_v2 -- \
-DOVERLAY_CONFIG=overlay-memfault.conf
...
/Users/gminnehan/projects/memfault-sdk-nrf-workspace/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "Memfault Project Key not configured. Please visit https://goto.memfault.com/create-key/nrf91 "
 87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
    |                                    ^~~~~~~~~~~~~~
/Users/gminnehan/projects/memfault-sdk-nrf-workspace/nrf/modules/memfault-firmware-sdk/memfault_integration.c:40:1: note: in expansion of macro 'BUILD_ASSERT'
 40 | BUILD_ASSERT(sizeof(CONFIG_MEMFAULT_NCS_PROJECT_KEY) > 1,
    | ^~~~~~~~~~~~

and still succeeds when the project key is passed:

west build -b nrf52840dk/nrf52840 \
nrf/samples/bluetooth/peripheral_mds -- \
-DCONFIG_MEMFAULT_NCS_PROJECT_KEY=\"$(<~/.memfault-gilly-playground-proj-key)\"
west build -b thingy91/nrf9160/ns \
nrf/applications/asset_tracker_v2 -- \
-DCONFIG_MEMFAULT_NCS_PROJECT_KEY=\"$(<~/.memfault-gilly-playground-proj-key)\" \
-DOVERLAY_CONFIG=overlay-memfault.conf

Resolve: MCU-982

 ### Summary

 In cases where an upstream device uploads data to Memfault on behalf
 of a downstream device, the project key is not required. This change
 allows the project key to be optional in those cases, which for the
 NCS Memfault sources is when we are not using MDS or the Memfault
 Zephyr HTTP client.

 ### Test Plan

 Confirmed that before this change, the build fails if the project key
 is not set for a generic cortex-m application where Memfault is enabled:

 ```
 west build -b qemu_cortex_m3 -p always zephyr/samples/hello_world -- \
 -DCONFIG_MEMFAULT=y \
 -DCONFIG_MEMFAULT_NCS_FW_TYPE=\"test-app\" \
 -DCONFIG_MEMFAULT_NCS_DEVICE_ID=\"my-test-device\"
 ```

 Confirmed after this change, the build succeeds with this same build command.

 Also confirmed that after this change, the build still fails if the project key
 is not set for projects where MDS or the Memfault Zephyr HTTP client
 are used:

  ```
west build --pristine always --board nrf52840dk/nrf52840 \
nrf/samples/bluetooth/peripheral_mds
  ...
  /Users/gminnehan/projects/memfault-sdk-nrf-workspace/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "Memfault Project Key not configured. Please visit https://goto.memfault.com/create-key/nrf91 "
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                    ^~~~~~~~~~~~~~
/Users/gminnehan/projects/memfault-sdk-nrf-workspace/nrf/modules/memfault-firmware-sdk/memfault_integration.c:40:1: note: in expansion of macro 'BUILD_ASSERT'
   40 | BUILD_ASSERT(sizeof(CONFIG_MEMFAULT_NCS_PROJECT_KEY) > 1,
      | ^~~~~~~~~~~~
  ```

  ```
  west build -b thingy91/nrf9160/ns -p always \
  nrf/applications/asset_tracker_v2 -- \
  -DOVERLAY_CONFIG=overlay-memfault.conf
  ...
  /Users/gminnehan/projects/memfault-sdk-nrf-workspace/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "Memfault Project Key not configured. Please visit https://goto.memfault.com/create-key/nrf91 "
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                    ^~~~~~~~~~~~~~
/Users/gminnehan/projects/memfault-sdk-nrf-workspace/nrf/modules/memfault-firmware-sdk/memfault_integration.c:40:1: note: in expansion of macro 'BUILD_ASSERT'
   40 | BUILD_ASSERT(sizeof(CONFIG_MEMFAULT_NCS_PROJECT_KEY) > 1,
      | ^~~~~~~~~~~~
  ```
Copy link
Member Author

gminn commented Apr 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gminn gminn marked this pull request as ready for review April 3, 2025 21:48
@gminn gminn requested a review from a team April 3, 2025 21:48
@gminn gminn changed the title feat: allow Memfault project key optionalempty feat: allow empty Memfault project key Apr 3, 2025
Copy link

@noahp noahp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! i think this is the simplest approach- we do have a built-in structure now, but to avoid messing up existing configurations, i think it's easiest to make the change you made here 👍

https://github.com/memfault/memfault-firmware-sdk/blob/f1a88a848b4f0a634375ab488d2d1f2a52085bfa/ports/zephyr/common/memfault_platform_http.c#L80-L90

@gminn gminn closed this Apr 14, 2025
Copy link
Member Author

gminn commented Apr 14, 2025

Merged upstream at nrfconnect#21559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants