Skip to content

Commit 3a990d8

Browse files
committed
update to Golioth v0.7.1
Update to most recent Golioth Zephyr SDK release v0.7.1 which uses: * nRF Connect SDK v2.4.1 (NCS) * Zephyr v3.3.99-ncs1-1 Changes in this commit: * Updates for Golioth Zephy SDK: * update to use zcbor instead of qcbor * update RPC functions to use zcbor * update network-info repo revision to use new version that is zcbor compatible * update flash.c/flash.h files to match what is present in the DFU sample * boards/nrf9160dk_nrf9160_ns: update configuration * boards/aludel_mini_v1_sparkfun9160_ns: update configuration * Updates for new NCS/Zephyr version: * update LTE link control: Disable samples/common link control and use in-app link control to start connection asynchronously * main.c: return int from main() * battery_monitor: use void as initialization param * Misc updates: * golioth-boards: include as a module * remove module.yml: no longer needed for golioth-boards * network-info: include as a module * main: use LOG instead of printk for button errors Signed-off-by: Mike Szczys <[email protected]>
1 parent e5cdc7d commit 3a990d8

File tree

12 files changed

+165
-170
lines changed

12 files changed

+165
-170
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ build*/
66
.cache
77
credentials.conf
88
__pycache__/
9-
golioth-boards
109
libostentus
11-
network_info/

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ target_sources(app PRIVATE src/libostentus/libostentus.c)
1717
target_sources_ifdef(CONFIG_BOOTLOADER_MCUBOOT app PRIVATE src/dfu/flash.c)
1818

1919
add_subdirectory_ifdef(CONFIG_ALUDEL_BATTERY_MONITOR src/battery_monitor)
20-
add_subdirectory(src/network_info)

boards/aludel_mini_v1_sparkfun9160_ns.conf

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,37 @@ CONFIG_HEAP_MEM_POOL_SIZE=4096
66
CONFIG_NEWLIB_LIBC=y
77

88
# Networking
9-
CONFIG_NET_NATIVE=n
109
CONFIG_NET_SOCKETS_OFFLOAD=y
10+
CONFIG_NET_IPV6=y
11+
CONFIG_NET_IPV6_NBR_CACHE=n
12+
CONFIG_NET_IPV6_MLD=n
1113

1214
# Increase native TLS socket implementation, so that it is chosen instead of
1315
# offloaded nRF91 sockets
1416
CONFIG_NET_SOCKETS_TLS_PRIORITY=35
1517

16-
# LTE link control
17-
CONFIG_LTE_LINK_CONTROL=y
18-
CONFIG_LTE_AUTO_INIT_AND_CONNECT=y
19-
2018
# Modem library
2119
CONFIG_NRF_MODEM_LIB=y
20+
CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y
21+
22+
# LTE connectivity with network connection manager
23+
CONFIG_LTE_CONNECTIVITY=y
24+
CONFIG_NET_CONNECTION_MANAGER=y
25+
CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=1024
2226

23-
# Use NCS fork of mbedTLS, as Zephyr built-in mbedTLS integration (CONFIG_MBEDTLS_BUILTIN) is in
24-
# conflict with CONFIG_NRF_SECURITY
25-
CONFIG_MBEDTLS_TLS_LIBRARY=y
26-
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
27-
CONFIG_MBEDTLS_GCM_C=y
28-
# ... and disable options y-selected by NCS for no good reason
27+
# Increased sysworkq size, due to LTE connectivity
28+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
29+
30+
# Disable options y-selected by NCS for no good reason
2931
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=n
3032
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED=n
31-
# ... also increase heap size to "high enough to make it work"
32-
CONFIG_MBEDTLS_HEAP_SIZE=49152
3333

3434
# Battery Support
3535
CONFIG_ALUDEL_BATTERY_MONITOR=y
3636

3737
# Add Network Info Support
3838
CONFIG_MODEM_INFO=y
3939
CONFIG_GOLIOTH_RPC_MAX_RESPONSE_LEN=512
40+
41+
# Generate MCUboot compatible images
42+
CONFIG_BOOTLOADER_MCUBOOT=y

boards/nrf9160dk_nrf9160_ns.conf

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,37 @@ CONFIG_HEAP_MEM_POOL_SIZE=4096
66
CONFIG_NEWLIB_LIBC=y
77

88
# Networking
9-
CONFIG_NET_NATIVE=n
109
CONFIG_NET_SOCKETS_OFFLOAD=y
10+
CONFIG_NET_IPV6=y
11+
CONFIG_NET_IPV6_NBR_CACHE=n
12+
CONFIG_NET_IPV6_MLD=n
1113

1214
# Increase native TLS socket implementation, so that it is chosen instead of
1315
# offloaded nRF91 sockets
1416
CONFIG_NET_SOCKETS_TLS_PRIORITY=35
1517

16-
# LTE link control
17-
CONFIG_LTE_LINK_CONTROL=y
18-
CONFIG_LTE_AUTO_INIT_AND_CONNECT=y
19-
2018
# Modem library
2119
CONFIG_NRF_MODEM_LIB=y
20+
CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y
21+
22+
# LTE connectivity with network connection manager
23+
CONFIG_LTE_CONNECTIVITY=y
24+
CONFIG_NET_CONNECTION_MANAGER=y
25+
CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=1024
26+
27+
# Increased sysworkq size, due to LTE connectivity
28+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
2229

23-
# Use NCS fork of mbedTLS, as Zephyr built-in mbedTLS integration (CONFIG_MBEDTLS_BUILTIN) is in
24-
# conflict with CONFIG_NRF_SECURITY
25-
CONFIG_MBEDTLS_TLS_LIBRARY=y
26-
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
27-
CONFIG_MBEDTLS_GCM_C=y
28-
# ... and disable options y-selected by NCS for no good reason
30+
# Disable options y-selected by NCS for no good reason
2931
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=n
3032
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED=n
31-
# ... also increase heap size to "high enough to make it work"
32-
CONFIG_MBEDTLS_HEAP_SIZE=49152
33+
34+
# Battery Support
35+
CONFIG_ALUDEL_BATTERY_MONITOR=n
3336

3437
# Add Network Info Support
3538
CONFIG_MODEM_INFO=y
3639
CONFIG_GOLIOTH_RPC_MAX_RESPONSE_LEN=512
40+
41+
# Generate MCUboot compatible images
42+
CONFIG_BOOTLOADER_MCUBOOT=y

prj.conf

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,33 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
CONFIG_GOLIOTH_SAMPLES_COMMON=y
5-
6-
# Generic networking options
7-
CONFIG_NETWORKING=y
8-
CONFIG_NET_IPV4=y
9-
CONFIG_NET_IPV6=n
10-
11-
# Logging
12-
CONFIG_NET_LOG=y
13-
14-
# Network Shell
15-
CONFIG_NET_SHELL=y
16-
17-
# TLS configuration
18-
CONFIG_MBEDTLS_ENABLE_HEAP=y
19-
CONFIG_MBEDTLS_HEAP_SIZE=10240
5+
CONFIG_GOLIOTH_SAMPLE_NRF91_LTE_MONITOR=n #App implements its own LTE Monitor
206

217
# Application
8+
CONFIG_LOG_BACKEND_GOLIOTH=y
229
CONFIG_MAIN_STACK_SIZE=4096
2310

24-
CONFIG_GOLIOTH=y
2511
CONFIG_GOLIOTH_FW=y
26-
CONFIG_GOLIOTH_SYSTEM_CLIENT=y
27-
28-
CONFIG_LOG_BACKEND_GOLIOTH=y
29-
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
3012

31-
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
32-
33-
CONFIG_BOOTLOADER_MCUBOOT=y
3413
CONFIG_FLASH=y
3514
CONFIG_FLASH_MAP=y
3615
CONFIG_NVS=y
16+
CONFIG_STREAM_FLASH=y
3717
CONFIG_IMG_MANAGER=y
3818
CONFIG_IMG_ERASE_PROGRESSIVELY=y
3919
CONFIG_REBOOT=y
4020

21+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
22+
4123
CONFIG_JSON_LIBRARY=y
4224

4325
CONFIG_SETTINGS=y
26+
CONFIG_GOLIOTH_SETTINGS=y
4427
CONFIG_SETTINGS_RUNTIME=y
28+
CONFIG_GOLIOTH_SAMPLE_PSK_SETTINGS=y
4529
CONFIG_GOLIOTH_SAMPLE_SETTINGS_AUTOLOAD=y
4630
CONFIG_GOLIOTH_SAMPLE_SETTINGS_SHELL=y
47-
CONFIG_GOLIOTH_SETTINGS=y
4831

4932
CONFIG_GOLIOTH_RPC=y
33+
CONFIG_NETWORK_INFO=y
5034
CONFIG_I2C=y

src/app_rpc.c

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ LOG_MODULE_REGISTER(app_rpc, LOG_LEVEL_DBG);
1010

1111
#include <net/golioth/system_client.h>
1212
#include <net/golioth/rpc.h>
13-
#include <qcbor/qcbor.h>
14-
#include <qcbor/qcbor_spiffy_decode.h>
1513
#include <zephyr/logging/log_ctrl.h>
1614
#include <zephyr/sys/reboot.h>
1715

18-
#include "network_info.h"
16+
#include <network_info.h>
1917
#include "app_rpc.h"
2018

2119
static struct golioth_client *client;
@@ -36,39 +34,32 @@ static void reboot_work_handler(struct k_work *work)
3634
}
3735
K_WORK_DEFINE(reboot_work, reboot_work_handler);
3836

39-
static enum golioth_rpc_status on_get_network_info(QCBORDecodeContext *request_params_array,
40-
QCBOREncodeContext *response_detail_map,
37+
static enum golioth_rpc_status on_get_network_info(zcbor_state_t *request_params_array,
38+
zcbor_state_t *response_detail_map,
4139
void *callback_arg)
4240
{
43-
QCBORError qerr;
44-
45-
qerr = QCBORDecode_GetError(request_params_array);
46-
if (qerr != QCBOR_SUCCESS) {
47-
LOG_ERR("Failed to decode array items: %d (%s)", qerr, qcbor_err_to_str(qerr));
48-
return GOLIOTH_RPC_INVALID_ARGUMENT;
49-
}
50-
5141
network_info_add_to_map(response_detail_map);
5242

5343
return GOLIOTH_RPC_OK;
5444
}
5545

56-
static enum golioth_rpc_status on_set_log_level(QCBORDecodeContext *request_params_array,
57-
QCBOREncodeContext *response_detail_map,
46+
static enum golioth_rpc_status on_set_log_level(zcbor_state_t *request_params_array,
47+
zcbor_state_t *response_detail_map,
5848
void *callback_arg)
5949
{
60-
double a;
61-
uint32_t log_level;
62-
QCBORError qerr;
63-
64-
QCBORDecode_GetDouble(request_params_array, &a);
65-
qerr = QCBORDecode_GetError(request_params_array);
66-
if (qerr != QCBOR_SUCCESS) {
67-
LOG_ERR("Failed to decode array item: %d (%s)", qerr, qcbor_err_to_str(qerr));
50+
double param_0;
51+
uint8_t log_level;
52+
bool ok;
53+
54+
LOG_WRN("on_set_log_level");
55+
56+
ok = zcbor_float_decode(request_params_array, &param_0);
57+
if (!ok) {
58+
LOG_ERR("Failed to decode array item");
6859
return GOLIOTH_RPC_INVALID_ARGUMENT;
6960
}
7061

71-
log_level = (uint32_t)a;
62+
log_level = (uint8_t)param_0;
7263

7364
if ((log_level < 0) || (log_level > LOG_LEVEL_DBG)) {
7465

@@ -90,11 +81,15 @@ static enum golioth_rpc_status on_set_log_level(QCBORDecodeContext *request_para
9081
}
9182

9283
LOG_WRN("Log levels for %d modules set to: %d", source_id, log_level);
84+
85+
ok = zcbor_tstr_put_lit(response_detail_map, "log_modules") &&
86+
zcbor_float64_put(response_detail_map, (double)source_id);
87+
9388
return GOLIOTH_RPC_OK;
9489
}
9590

96-
static enum golioth_rpc_status on_reboot(QCBORDecodeContext *request_params_array,
97-
QCBOREncodeContext *response_detail_map,
91+
static enum golioth_rpc_status on_reboot(zcbor_state_t *request_params_array,
92+
zcbor_state_t *response_detail_map,
9893
void *callback_arg)
9994
{
10095
/* Use work queue so this RPC can return confirmation to Golioth */
@@ -113,7 +108,6 @@ static void rpc_log_if_register_failure(int err)
113108
int app_rpc_init(struct golioth_client *state_client)
114109
{
115110
client = state_client;
116-
network_info_init();
117111
int err = app_rpc_register(client);
118112
return err;
119113
}

src/battery_monitor/battery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int divider_setup(void)
178178

179179
static bool battery_ok;
180180

181-
static int battery_setup(const struct device *arg)
181+
static int battery_setup(void)
182182
{
183183
LOG_INF("Initializing battery measurement");
184184

src/dfu/flash.c

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,35 @@ LOG_MODULE_REGISTER(golioth_dfu, LOG_LEVEL_DBG);
1212

1313
#include "flash.h"
1414

15-
/* NCS' fork of Zephyr does not implement DT_FIXED_PARTITION_EXISTS macro yet */
16-
#ifndef DT_FIXED_PARTITION_EXISTS
17-
#define DT_FIXED_PARTITION_EXISTS(node_id) DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_partitions)
18-
#endif
19-
20-
/* NCS' fork of Zephyr does not implement FIXED_PARTITION_ macros yet */
21-
#ifndef FIXED_PARTITION_EXISTS
22-
#define FIXED_PARTITION_EXISTS(label) DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(label))
23-
#endif
24-
25-
/* NCS' fork of Zephyr does not implement FIXED_PARTITION_ macros yet */
26-
#ifndef FIXED_PARTITION_ID
27-
#define FIXED_PARTITION_ID(label) DT_FIXED_PARTITION_ID(DT_NODELABEL(label))
28-
#endif
29-
3015
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
31-
#define SLOT0_LABEL slot0_ns_partition
32-
#define SLOT1_LABEL slot1_ns_partition
16+
#define SLOT0_LABEL slot0_ns_partition
3317
#else
34-
#define SLOT0_LABEL slot0_partition
35-
#define SLOT1_LABEL slot1_partition
18+
#define SLOT0_LABEL slot0_partition
3619
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
3720

3821
/* FIXED_PARTITION_ID() values used below are auto-generated by DT */
3922
#define FLASH_AREA_IMAGE_PRIMARY FIXED_PARTITION_ID(SLOT0_LABEL)
40-
#if FIXED_PARTITION_EXISTS(SLOT1_LABEL)
41-
#define FLASH_AREA_IMAGE_SECONDARY FIXED_PARTITION_ID(SLOT1_LABEL)
42-
#endif
4323

4424
char current_version_str[sizeof("255.255.65535")];
4525

46-
static int current_version_init(const struct device *dev)
26+
static int current_version_init(void)
4727
{
4828
struct mcuboot_img_header hdr;
4929
int written;
5030
int err;
5131

5232
err = boot_read_bank_header(FLASH_AREA_IMAGE_PRIMARY, &hdr, sizeof(hdr));
5333
if (err) {
54-
LOG_ERR("Failed to read primary area (%u) header: %d", FLASH_AREA_IMAGE_PRIMARY,
55-
err);
34+
LOG_ERR("Failed to read primary area (%u) header: %d",
35+
FLASH_AREA_IMAGE_PRIMARY, err);
5636
return err;
5737
}
5838

59-
written =
60-
snprintf(current_version_str, sizeof(current_version_str), "%u.%u.%u",
61-
(unsigned int)hdr.h.v1.sem_ver.major, (unsigned int)hdr.h.v1.sem_ver.minor,
62-
(unsigned int)hdr.h.v1.sem_ver.revision);
39+
written = snprintf(current_version_str, sizeof(current_version_str),
40+
"%u.%u.%u",
41+
(unsigned int) hdr.h.v1.sem_ver.major,
42+
(unsigned int) hdr.h.v1.sem_ver.minor,
43+
(unsigned int) hdr.h.v1.sem_ver.revision);
6344
if (written >= sizeof(current_version_str)) {
6445
LOG_ERR("Version string is too long!");
6546
current_version_str[0] = '\0';
@@ -81,7 +62,8 @@ SYS_INIT(current_version_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
8162
*
8263
* @note This is a copy of zephyr_img_mgmt_flash_check_empty() from mcumgr.
8364
*/
84-
static int flash_area_check_empty(const struct flash_area *fa, bool *out_empty)
65+
static int flash_area_check_empty(const struct flash_area *fa,
66+
bool *out_empty)
8567
{
8668
uint32_t data[16];
8769
off_t addr;

src/dfu/flash.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ static inline int flash_img_prepare(struct flash_img_context *flash)
3232
return 0;
3333
}
3434

35-
static inline int flash_img_buffered_write(struct flash_img_context *ctx, const uint8_t *data,
36-
size_t len, bool flush)
35+
static inline
36+
int flash_img_buffered_write(struct flash_img_context *ctx, const uint8_t *data,
37+
size_t len, bool flush)
3738
{
3839
return 0;
3940
}
4041

4142
/** Boot upgrade request modes */
42-
#define BOOT_UPGRADE_TEST 0
43-
#define BOOT_UPGRADE_PERMANENT 1
43+
#define BOOT_UPGRADE_TEST 0
44+
#define BOOT_UPGRADE_PERMANENT 1
4445

4546
static inline int boot_request_upgrade(int permanent)
4647
{

0 commit comments

Comments
 (0)