@@ -6,12 +6,6 @@ if(DEFINED ENV{MEMFAULT_ZEPHYR_EXTRA_MODULE_INCLUDE})
6
6
list (APPEND ZEPHYR_EXTRA_MODULES $ENV{ZEPHYR_BASE} /../modules/memfault-firmware-sdk/ports)
7
7
endif ()
8
8
9
- # Required for app to compile against nRF Connect SDK <= v1.2
10
- if (DEFINED ENV{MEMFAULT_INCLUDE_ZEPHYR_BOILERPLATE})
11
- include ($ENV{ZEPHYR_BASE} /cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
12
- include ($ENV{ZEPHYR_BASE} /../nrf/cmake/boilerplate.cmake)
13
- endif ()
14
-
15
9
# Starting in nRF Connect SDK >= 1.3, versions are exposed in
16
10
# a CMake package:
17
11
# https://github.com/nrfconnect/sdk-nrf/blob/master/share/ncs-package/cmake/NcsConfig.cmake
@@ -20,65 +14,93 @@ endif()
20
14
# which is not something that can be achieved with Zephyr today
21
15
find_package (Ncs HINTS $ENV{ZEPHYR_BASE} /../nrf)
22
16
23
- # Conditionally set Kconfig variables based on nRF Connect SDK version
17
+ if (NOT NCS_VERSION_MAJOR)
18
+ # Note: If we cannot resolve the NCS version, assume we are using 1.2.x which is the oldest
19
+ # version Memfault has been tested against
20
+ set (NCS_VERSION_MAJOR 1)
21
+ set (NCS_VERSION_MINOR 2)
22
+ set (NCS_VERSION_PATCH 0)
23
+ endif ()
24
+
25
+ # Below we conditionally set Kconfig variables based on nRF Connect SDK version
24
26
# (since setting non-existent variables result in a build time error which
25
27
# would break compiling older builds)
26
28
#
27
29
# Zephyrs Kconfig extension pulls variables via the "CMake variable cache"
28
30
# so we set the ones we need here using that:
29
- # https://docs.zephyrproject.org/latest/guides/build/kconfig/setting.html#the-initial-configuration
30
- if (NCS_VERSION_MAJOR)
31
- if (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} LESS 5 )
32
- # Legacy name for CONFIG_DEBUG_THREAD_INFO needed for nRF Connect version <= 1.5
33
- # due to the version of Zephyr included (pre v2.5)
34
- set (CONFIG_OPENOCD_SUPPORT n CACHE INTERNAL "" )
35
- elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} LESS 6 )
36
- # Required for logging to work from crash, deprecated in Zephyr included in NCS 1.6
37
- set (CONFIG_LOG_IMMEDIATE y CACHE INTERNAL "" )
38
- elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} GREATER_EQUAL 6 )
39
- set (CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES n CACHE INTERNAL "" )
40
- set (CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "" )
41
-
42
- set (CONFIG_NEWLIB_LIBC y CACHE INTERNAL "" )
43
- endif ()
31
+ # https://docs.zephyrproject.org/latest/build/kconfig/setting.html#the-initial-configuration
32
+
33
+ if (${NCS_VERSION_MAJOR} .${NCS_VERSION_MINOR} .${NCS_VERSION_PATCH} VERSION_LESS 1.3)
34
+ else () # nRF Connect SDK Version >= 1.3.0
35
+ # We cannot set for NCS <= 1.2 because on older versions of zephyr the argument was not
36
+ # directly user-configurable (no prompt in Kconfig)
37
+ set (CONFIG_SHELL_LOG_BACKEND n CACHE INTERNAL "" )
38
+ endif ()
44
39
40
+ if (${NCS_VERSION_MAJOR} .${NCS_VERSION_MINOR} .${NCS_VERSION_PATCH} VERSION_LESS 1.5)
41
+ # Legacy name for CONFIG_DEBUG_THREAD_INFO needed for nRF Connect version <= 1.5
42
+ # due to the version of Zephyr included (pre v2.5)
43
+ set (CONFIG_OPENOCD_SUPPORT y CACHE INTERNAL "" )
44
+ else () # nRF Connect SDK Version >= 1.5.0
45
45
# Enable Memfault FOTA Support
46
46
#
47
- # We enable conditionally because prior to NCS < 1.4 a small patch (https://mflt.io/nrf-fota) was
47
+ # We enable conditionally because prior to NCS < 1.5 a small patch (https://mflt.io/nrf-fota) was
48
48
# needed in order for things to work
49
- if (${NCS_VERSION_MAJOR} .${NCS_VERSION_MINOR} .${NCS_VERSION_PATCH} GREATER_EQUAL 1.5.0)
50
- set (CONFIG_MEMFAULT_FOTA y CACHE INTERNAL "" )
51
- set (CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE 400 CACHE INTERNAL "" )
52
- set (CONFIG_DOWNLOAD_CLIENT_STACK_SIZE 1600 CACHE INTERNAL "" )
53
-
54
- # Note: Can optionally be changed to =y to implement
55
- # a custom event handler for FOTA events
56
- # CONFIG_MEMFAULT_FOTA_DOWNLOAD_CALLBACK_CUSTOM=n
49
+ set (CONFIG_MEMFAULT_FOTA y CACHE INTERNAL "" )
50
+ set (CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE 400 CACHE INTERNAL "" )
51
+ set (CONFIG_DOWNLOAD_CLIENT_STACK_SIZE 1600 CACHE INTERNAL "" )
52
+
53
+ # Note: Can optionally be changed to =y to implement
54
+ # a custom event handler for FOTA events
55
+ # CONFIG_MEMFAULT_FOTA_DOWNLOAD_CALLBACK_CUSTOM=n
56
+ endif ()
57
+
58
+
59
+ if (${NCS_VERSION_MAJOR} .${NCS_VERSION_MINOR} .${NCS_VERSION_PATCH} VERSION_LESS 1.6.0)
60
+ # Required for logging to work from crash but deprecated in Zephyr included in NCS 1.6
61
+ set (CONFIG_LOG_IMMEDIATE y CACHE INTERNAL "" )
62
+
63
+ # NCS 1.6 was the first one which introduced setting the project key via
64
+ # Kconfig. Look for this argument and remap to a regular compiler definition
65
+ # that gets picked up in memfault_demo_app/src/main.c
66
+ if (CONFIG_MEMFAULT_NCS_PROJECT_KEY)
67
+ add_compile_definitions (MEMFAULT_NCS_PROJECT_KEY=${CONFIG_MEMFAULT_NCS_PROJECT_KEY} )
68
+ unset (CONFIG_MEMFAULT_NCS_PROJECT_KEY CACHE )
57
69
endif ()
70
+ else () # nRF Connect SDK Version >= 1.6.0
71
+ set (CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES n CACHE INTERNAL "" )
72
+ set (CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "" )
73
+ set (CONFIG_NEWLIB_LIBC y CACHE INTERNAL "" )
74
+ endif ()
58
75
76
+ if (${NCS_VERSION_MAJOR} .${NCS_VERSION_MINOR} .${NCS_VERSION_PATCH} VERSION_LESS 1.7.99)
59
77
# These were removed in NCS 1.8.0, but are needed prior to that. Enable them
60
78
# if NCS version <1.7.99 (.99 patch version is used for the next revision's
61
79
# development series)
62
- if (${NCS_VERSION_MAJOR} .${NCS_VERSION_MINOR} .${NCS_VERSION_PATCH} VERSION_LESS 1.7.99)
63
- set (CONFIG_BSD_LIBRARY y CACHE INTERNAL "" )
64
- set (CONFIG_BSD_LIBRARY_SYS_INIT n CACHE INTERNAL "" )
65
- # ^ Note: CONFIG_BSD_ were renamed to _NRF_MODEM_ in
66
- # nRF Connect SDK v1.5. We use the legacy names for now
67
- # so this app can continue to compile on older targets
68
- #
69
- # CONFIG_NRF_MODEM_LIB
70
- # CONFIG_NRF_MODEM_LIB_SYS_INIT
71
-
72
- # For nRF Connect SDK v1.5 default value changed here
73
- set (CONFIG_AT_CMD_SYS_INIT n CACHE INTERNAL "" )
74
- else () # nRF Connect SDK Version >= 1.8.0
75
- # in v1.8+, use the modem_info library to get the IMEI for device_serial
76
- set (CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "" )
77
- set (CONFIG_MODEM_INFO y CACHE INTERNAL "" )
78
-
79
- # Use SPM instead of TFM for Secure Firmware as TFM does not (yet) support forwarding of fault handlers
80
- set (CONFIG_BUILD_WITH_TFM n CACHE INTERNAL "" )
81
- endif ()
80
+ set (CONFIG_BSD_LIBRARY y CACHE INTERNAL "" )
81
+ set (CONFIG_BSD_LIBRARY_SYS_INIT n CACHE INTERNAL "" )
82
+ # ^ Note: CONFIG_BSD_ were renamed to _NRF_MODEM_ in
83
+ # nRF Connect SDK v1.5. We use the legacy names here
84
+ # so the app can continue to compile on older targets
85
+ #
86
+ # CONFIG_NRF_MODEM_LIB
87
+ # CONFIG_NRF_MODEM_LIB_SYS_INIT
88
+
89
+ # For nRF Connect SDK v1.5 default value changed here
90
+ set (CONFIG_AT_CMD_SYS_INIT n CACHE INTERNAL "" )
91
+ else () # nRF Connect SDK Version >= 1.8.0
92
+ # in v1.8+, use the modem_info library to get the IMEI for device_serial
93
+ set (CONFIG_MODEM_INFO y CACHE INTERNAL "" )
94
+
95
+ # Use SPM instead of TFM for Secure Firmware as TFM does not (yet) support forwarding of fault handlers
96
+ set (CONFIG_BUILD_WITH_TFM n CACHE INTERNAL "" )
97
+ endif ()
98
+
99
+ # Required for app to compile against nRF Connect SDK <= v1.2
100
+ # Must be included after updating Kconfig settings in CMake Cache above
101
+ if (DEFINED ENV{MEMFAULT_INCLUDE_ZEPHYR_BOILERPLATE})
102
+ include ($ENV{ZEPHYR_BASE} /cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
103
+ include ($ENV{ZEPHYR_BASE} /../nrf/cmake/boilerplate.cmake)
82
104
endif ()
83
105
84
106
find_package (Zephyr HINTS $ENV{ZEPHYR_BASE} )
0 commit comments