Skip to content

Commit

Permalink
Upgrade to Zephyr v3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjaeger committed Dec 12, 2023
1 parent 9d89036 commit 631ffe5
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 66 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ jobs:
- name: Run sample build tests
working-directory: thingset-zephyr-sdk
run: |
west build -p -b olimex_lora_stm32wl_devkit samples/counter -- -DOVERLAY_CONFIG=lorawan.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b esp32c3_devkitm samples/counter -- -DOVERLAY_CONFIG=ble.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b esp32c3_devkitm samples/counter -- -DOVERLAY_CONFIG=wifi_websocket.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b olimex_lora_stm32wl_devkit samples/counter -- -DEXTRA_CONF_FILE=lorawan.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b esp32c3_devkitm samples/counter -- -DEXTRA_CONF_FILE=ble.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b esp32c3_devkitm samples/counter -- -DEXTRA_CONF_FILE=wifi_websocket.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b nucleo_l073rz samples/counter -- -DOVERLAY_CONFIG=serial.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b nucleo_l073rz samples/counter -- -DOVERLAY_CONFIG=storage_eeprom.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DOVERLAY_CONFIG=auth.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DOVERLAY_CONFIG=can.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DOVERLAY_CONFIG=log_backend.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DOVERLAY_CONFIG=native_websocket.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b nucleo_l073rz samples/counter -- -DEXTRA_CONF_FILE=serial.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b nucleo_l073rz samples/counter -- -DEXTRA_CONF_FILE=storage_eeprom.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DEXTRA_CONF_FILE=auth.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DEXTRA_CONF_FILE=can.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DEXTRA_CONF_FILE=log_backend.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b native_posix samples/counter -- -DEXTRA_CONF_FILE=native_websocket.conf -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
west build -p -b xiao_esp32c3 samples/serial_ble_gateway -- -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
- name: Run unit tests
Expand Down
1 change: 1 addition & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ endmenu # General Publication Settings
config THINGSET_GENERATE_NODE_ID
bool "Automatically generate node ID"
select HWINFO
select CRC
default y

config THINGSET_NODE_NAME
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ west build -b native_posix samples/counter -t run
## Testing with LoRaWAN

```
west build -b olimex_lora_stm32wl_devkit samples/counter -- -DOVERLAY_CONFIG=lorawan.conf
west build -b olimex_lora_stm32wl_devkit samples/counter -- -DEXTRA_CONF_FILE=lorawan.conf
```

## Testing with CAN bus

```
west build -b native_posix samples/counter -t run -- -DOVERLAY_CONFIG=can.conf
west build -b native_posix samples/counter -t run -- -DEXTRA_CONF_FILE=can.conf
```

## Testing WebSocket with native_posix
Expand All @@ -41,7 +41,7 @@ sudo iptables -A FORWARD -i zeth -o wifi0 -j ACCEPT
Afterwards run the nativ_posix board with websocket support from another shell:

```
west build -b native_posix samples/counter -- -DOVERLAY_CONFIG="native_websocket.conf storage_flash.conf"
west build -b native_posix samples/counter -- -DEXTRA_CONF_FILE="native_websocket.conf storage_flash.conf"
./build/zephyr/zephyr.exe -flash=samples/counter/virtual-flash.bin
```

Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
breathe
sphinx~=5.3
sphinx~=6.2
sphinx_rtd_theme~=1.2
sphinx-notfound-page
sphinx-rtd-theme
sphinx-tabs
4 changes: 0 additions & 4 deletions samples/counter/wifi_websocket.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ CONFIG_NET_L2_ETHERNET=y

CONFIG_ESP32_WIFI_STA_AUTO_DHCPV4=y

# WiFi driver does not seem to work with picolibc and newlib-nano
CONFIG_PICOLIBC=n
CONFIG_NEWLIB_LIBC=y

CONFIG_THINGSET_WIFI=y

# HTTP & Websocket
Expand Down
2 changes: 0 additions & 2 deletions samples/serial_ble_gateway/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y

CONFIG_LOG=y

CONFIG_PICOLIBC=y

# ThingSet library
CONFIG_THINGSET=y

Expand Down
12 changes: 4 additions & 8 deletions src/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/net/buf.h>
#include <zephyr/random/rand32.h>
#include <zephyr/random/random.h>

#include <thingset.h>
#include <thingset/can.h>
Expand Down Expand Up @@ -671,13 +671,9 @@ int thingset_can_init_inst(struct thingset_can *ts_can, const struct device *can
#endif

#ifndef CONFIG_ISOTP_FAST
ts_can->rx_addr.ide = 1;
ts_can->rx_addr.use_ext_addr = 0; /* Normal ISO-TP addressing (using only CAN ID) */
ts_can->rx_addr.use_fixed_addr = 1; /* enable SAE J1939 compatible addressing */

ts_can->tx_addr.ide = 1;
ts_can->tx_addr.use_ext_addr = 0;
ts_can->tx_addr.use_fixed_addr = 1;
/* ISO-TP fixed addressing with SAE J1939 compatible ID */
ts_can->rx_addr.flags = ISOTP_MSG_IDE | ISOTP_MSG_FIXED_ADDR;
ts_can->tx_addr.flags = ISOTP_MSG_IDE | ISOTP_MSG_FIXED_ADDR;
#endif

struct can_filter addr_discovery_filter = {
Expand Down
64 changes: 32 additions & 32 deletions src/isotp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,31 @@ static int get_send_ctx(struct isotp_fast_ctx *ctx, isotp_fast_can_id tx_can_id,
return 0;
}

static inline void free_send_ctx(struct isotp_fast_send_ctx **sctx)
static inline void free_send_ctx(struct isotp_fast_send_ctx *sctx)
{
LOG_DBG("Freeing send context for recipient %x", (*sctx)->tx_can_id);
k_timer_stop(&(*sctx)->timer);
sys_slist_find_and_remove(&(*sctx)->ctx->isotp_send_ctx_list, &(*sctx)->node);
k_mem_slab_free(&isotp_send_ctx_slab, (void **)sctx);
LOG_DBG("Freeing send context for recipient %x", sctx->tx_can_id);
k_timer_stop(&sctx->timer);
sys_slist_find_and_remove(&sctx->ctx->isotp_send_ctx_list, &sctx->node);
k_mem_slab_free(&isotp_send_ctx_slab, sctx);
}

static inline void free_recv_ctx(struct isotp_fast_recv_ctx **rctx)
static inline void free_recv_ctx(struct isotp_fast_recv_ctx *rctx)
{
LOG_DBG("Freeing receive context %x", (*rctx)->rx_can_id);
k_timer_stop(&(*rctx)->timer);
sys_slist_find_and_remove(&(*rctx)->ctx->isotp_recv_ctx_list, &(*rctx)->node);
net_buf_unref((*rctx)->buffer);
LOG_DBG("Freeing receive context %x", rctx->rx_can_id);
k_timer_stop(&rctx->timer);
sys_slist_find_and_remove(&rctx->ctx->isotp_recv_ctx_list, &rctx->node);
net_buf_unref(rctx->buffer);
#ifdef ISOTP_FAST_RECEIVE_QUEUE
k_msgq_purge(&(*rctx)->recv_queue);
k_msgq_cleanup(&(*rctx)->recv_queue);
k_msgq_purge(&rctx->recv_queue);
k_msgq_cleanup(&rctx->recv_queue);
#endif
k_mem_slab_free(&isotp_recv_ctx_slab, (void **)rctx);
k_mem_slab_free(&isotp_recv_ctx_slab, rctx);
}

static void free_recv_ctx_if_unowned(struct isotp_fast_recv_ctx **rctx)
static void free_recv_ctx_if_unowned(struct isotp_fast_recv_ctx *rctx)
{
#ifdef ISOTP_FAST_RECEIVE_QUEUE
if ((*rctx)->pending) {
if (rctx->pending) {
return;
}
#endif
Expand All @@ -119,7 +119,7 @@ static int get_recv_ctx(struct isotp_fast_ctx *ctx, isotp_fast_can_id rx_can_id,
context->frag = net_buf_alloc(&isotp_rx_pool, K_NO_WAIT);
if (context->frag == NULL) {
LOG_ERR("No free buffers");
free_recv_ctx(rctx);
free_recv_ctx(*rctx);
return ISOTP_NO_NET_BUF_LEFT;
}
#ifndef ISOTP_FAST_RECEIVE_QUEUE
Expand All @@ -136,7 +136,7 @@ static int get_recv_ctx(struct isotp_fast_ctx *ctx, isotp_fast_can_id rx_can_id,
}
context->buffer = net_buf_alloc(&isotp_rx_pool, K_NO_WAIT);
if (!context->buffer) {
k_mem_slab_free(&isotp_recv_ctx_slab, (void **)&context);
k_mem_slab_free(&isotp_recv_ctx_slab, context);
LOG_ERR("No net bufs.");
return ISOTP_NO_NET_BUF_LEFT;
}
Expand Down Expand Up @@ -363,7 +363,7 @@ static void receive_state_machine(struct isotp_fast_recv_ctx *rctx)
// net_buf_unref(ctx->buffer);
// ctx->buffer = NULL;
// ctx->state = ISOTP_RX_STATE_RECYCLE;
free_recv_ctx_if_unowned(&rctx);
free_recv_ctx_if_unowned(rctx);
__fallthrough;
case ISOTP_RX_STATE_RECYCLE:
#ifndef ISOTP_FAST_RECEIVE_QUEUE
Expand All @@ -374,7 +374,7 @@ static void receive_state_machine(struct isotp_fast_recv_ctx *rctx)
notify_waiting_receiver(rctx);
#endif
rctx->state = ISOTP_RX_STATE_UNBOUND;
free_recv_ctx_if_unowned(&rctx);
free_recv_ctx_if_unowned(rctx);
break;
case ISOTP_RX_STATE_UNBOUND:
break;
Expand Down Expand Up @@ -775,7 +775,7 @@ static void send_state_machine(struct isotp_fast_send_ctx *sctx)
LOG_DBG("SM error");
sctx->ctx->sent_callback(sctx->error, sctx->cb_arg);
sctx->state = ISOTP_TX_STATE_RESET;
free_send_ctx(&sctx);
free_send_ctx(sctx);
break;

/*
Expand All @@ -790,7 +790,7 @@ static void send_state_machine(struct isotp_fast_send_ctx *sctx)

sctx->ctx->sent_callback(ISOTP_N_OK, sctx->cb_arg);
sctx->state = ISOTP_TX_STATE_RESET;
free_send_ctx(&sctx);
free_send_ctx(sctx);
break;

default:
Expand Down Expand Up @@ -856,13 +856,13 @@ int isotp_fast_bind(struct isotp_fast_ctx *ctx, const struct device *can_dev,
}

#ifdef CONFIG_ISOTP_FAST_BLOCKING_RECEIVE
static void free_recv_await_ctx(struct isotp_fast_ctx *ctx, struct isotp_fast_recv_await_ctx **actx)
static void free_recv_await_ctx(struct isotp_fast_ctx *ctx, struct isotp_fast_recv_await_ctx *actx)
{
sys_slist_find_and_remove(&ctx->wait_recv_list, &(*actx)->node);
if ((*actx)->rctx) {
free_recv_ctx(&(*actx)->rctx);
sys_slist_find_and_remove(&ctx->wait_recv_list, &actx->node);
if (actx->rctx) {
free_recv_ctx(actx->rctx);
}
k_mem_slab_free(&isotp_recv_await_ctx_slab, (void **)actx);
k_mem_slab_free(&isotp_recv_await_ctx_slab, actx);
}
#endif

Expand All @@ -877,7 +877,7 @@ int isotp_fast_unbind(struct isotp_fast_ctx *ctx)
struct isotp_fast_recv_await_ctx *next;
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&ctx->wait_recv_list, actx, next, node)
{
free_recv_await_ctx(ctx, &actx);
free_recv_await_ctx(ctx, actx);
}
#endif
return ISOTP_N_OK;
Expand Down Expand Up @@ -931,7 +931,7 @@ int isotp_fast_recv(struct isotp_fast_ctx *ctx, struct can_filter sender, uint8_
LOG_DBG("Waiting for message matching %x:%x", sender.id, sender.mask);
ret = k_sem_take(&actx->sem, timeout);
if (ret == -EAGAIN) {
free_recv_await_ctx(ctx, &actx);
free_recv_await_ctx(ctx, actx);
LOG_DBG("Timed out waiting for first message");
return ISOTP_RECV_TIMEOUT;
}
Expand All @@ -942,7 +942,7 @@ int isotp_fast_recv(struct isotp_fast_ctx *ctx, struct can_filter sender, uint8_
if (actx->rctx->error != 0) {
LOG_DBG("Error %d occurred", actx->rctx->error);
ret = actx->rctx->error;
free_recv_await_ctx(ctx, &actx);
free_recv_await_ctx(ctx, actx);
return ret;
}

Expand All @@ -953,7 +953,7 @@ int isotp_fast_recv(struct isotp_fast_ctx *ctx, struct can_filter sender, uint8_
if (actx->rctx->error != 0) {
LOG_DBG("Error %d occurred", actx->rctx->error);
ret = actx->rctx->error;
free_recv_await_ctx(ctx, &actx);
free_recv_await_ctx(ctx, actx);
return ret;
}
if (pos == 0) {
Expand All @@ -978,10 +978,10 @@ int isotp_fast_recv(struct isotp_fast_ctx *ctx, struct can_filter sender, uint8_
}
actx->rctx->pending = false;
if (rem_len == 0) {
free_recv_await_ctx(ctx, &actx);
free_recv_await_ctx(ctx, actx);
}
if (ret == -EAGAIN) {
free_recv_await_ctx(ctx, &actx);
free_recv_await_ctx(ctx, actx);
LOG_DBG("Timed out waiting on more packets");
return ISOTP_RECV_TIMEOUT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/log_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void process(const struct log_backend *const backend, union log_msg_gener
snprintf(log_module, sizeof(log_module), "%s", sname);

/* HEXDUMPs are ignored and the log messages should be extracted w/o line ending */
log_output_process(&log_output_thingset, 0, NULL, NULL, log_level, package, NULL, 0,
log_output_process(&log_output_thingset, 0, NULL, NULL, NULL, log_level, package, NULL, 0,
LOG_OUTPUT_FLAG_CRLF_NONE);

/* ToDo: Implement rate limit to avoid congestion */
Expand Down
2 changes: 1 addition & 1 deletion src/lorawan.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/lorawan/lorawan.h>
#include <zephyr/random/rand32.h>
#include <zephyr/random/random.h>
#include <zephyr/sys/util.h>

#include <thingset.h>
Expand Down
2 changes: 1 addition & 1 deletion src/sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <zephyr/drivers/hwinfo.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/random/rand32.h>
#include <zephyr/random/random.h>
#include <zephyr/sys/crc.h>

#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion src/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <zephyr/net/socket.h>
#include <zephyr/net/tls_credentials.h>
#include <zephyr/net/websocket.h>
#include <zephyr/random/rand32.h>
#include <zephyr/random/random.h>
#include <zephyr/shell/shell.h>

#include <thingset.h>
Expand Down
4 changes: 2 additions & 2 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ manifest:
url-base: https://github.com/LibreSolar
projects:
- name: zephyr
remote: libresolar
revision: v3.4-branch
remote: zephyrproject
revision: v3.5-branch
import:
name-allowlist:
- cmsis
Expand Down

0 comments on commit 631ffe5

Please sign in to comment.