diff --git a/samples/subsys/ipc/ipc_service/icmsg/remote/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay b/samples/subsys/ipc/ipc_service/icmsg/remote/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay index 2219b7b78fa..b0e1f0d5034 100644 --- a/samples/subsys/ipc/ipc_service/icmsg/remote/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay +++ b/samples/subsys/ipc/ipc_service/icmsg/remote/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay @@ -39,3 +39,7 @@ &cpuflpr_vevif_tx { status = "okay"; }; + +&uart30 { + /delete-property/ hw-flow-control; +}; diff --git a/samples/subsys/ipc/ipc_service/icmsg/remote/src/main.c b/samples/subsys/ipc/ipc_service/icmsg/remote/src/main.c index 5cabd03ac77..e4b51369cdc 100644 --- a/samples/subsys/ipc/ipc_service/icmsg/remote/src/main.c +++ b/samples/subsys/ipc/ipc_service/icmsg/remote/src/main.c @@ -14,26 +14,44 @@ #include LOG_MODULE_REGISTER(remote, LOG_LEVEL_INF); - +#if defined(CONFIG_MULTITHREADING) K_SEM_DEFINE(bound_sem, 0, 1); +#else +volatile uint32_t bound_sem = 1; +volatile uint32_t recv_sem = 1; +#endif + +static unsigned char expected_message = 'a'; +static size_t expected_len = PACKET_SIZE_START; +static size_t received; static void ep_bound(void *priv) { + received = 0; +#if defined(CONFIG_MULTITHREADING) k_sem_give(&bound_sem); +#else + bound_sem = 0; +#endif LOG_INF("Ep bounded"); } static void ep_recv(const void *data, size_t len, void *priv) { +#if defined(CONFIG_ASSERT) struct data_packet *packet = (struct data_packet *)data; - static unsigned char expected_message = 'a'; - static size_t expected_len = PACKET_SIZE_START; __ASSERT(packet->data[0] == expected_message, "Unexpected message. Expected %c, got %c", expected_message, packet->data[0]); __ASSERT(len == expected_len, "Unexpected length. Expected %zu, got %zu", expected_len, len); +#endif + +#ifndef CONFIG_MULTITHREADING + recv_sem = 0; +#endif + received += len; expected_message++; expected_len++; @@ -61,11 +79,17 @@ static int send_for_time(struct ipc_ept *ep, const int64_t sending_time_ms) ret = ipc_service_send(ep, &msg, mlen); if (ret == -ENOMEM) { /* No space in the buffer. Retry. */ + ret = 0; continue; } else if (ret < 0) { LOG_ERR("Failed to send (%c) failed with ret %d", msg.data[0], ret); break; } +#if !defined(CONFIG_MULTITHREADING) + else { + recv_sem = 1; + } +#endif msg.data[0]++; if (msg.data[0] > 'Z') { @@ -79,7 +103,12 @@ static int send_for_time(struct ipc_ept *ep, const int64_t sending_time_ms) mlen = PACKET_SIZE_START; } +#if defined(CONFIG_MULTITHREADING) k_usleep(1); +#else + while ((recv_sem != 0) && ((k_uptime_get() - start) < sending_time_ms)) { + }; +#endif } LOG_INF("Sent %zu [Bytes] over %lld [ms]", bytes_sent, sending_time_ms); @@ -111,12 +140,17 @@ int main(void) } ret = ipc_service_register_endpoint(ipc0_instance, &ep, &ep_cfg); - if (ret != 0) { + if (ret < 0) { LOG_ERR("ipc_service_register_endpoint() failure"); return ret; } +#if defined(CONFIG_MULTITHREADING) k_sem_take(&bound_sem, K_FOREVER); +#else + while (bound_sem != 0) { + }; +#endif ret = send_for_time(&ep, SENDING_TIME_MS); if (ret < 0) { @@ -124,6 +158,7 @@ int main(void) return ret; } + LOG_INF("Received %zu [Bytes] in total", received); LOG_INF("IPC-service REMOTE demo ended"); return 0; diff --git a/samples/subsys/ipc/ipc_service/icmsg/sample.yaml b/samples/subsys/ipc/ipc_service/icmsg/sample.yaml index 298c41f56db..3df06a80a42 100644 --- a/samples/subsys/ipc/ipc_service/icmsg/sample.yaml +++ b/samples/subsys/ipc/ipc_service/icmsg/sample.yaml @@ -18,6 +18,7 @@ tests: - "host: Sent" - "host: Received" - "host: IPC-service HOST demo ended" + sample.ipc.icmsg.nrf54l15: platform_allow: nrf54l15pdk/nrf54l15/cpuapp integration_platforms: @@ -26,4 +27,60 @@ tests: extra_args: icmsg_SNIPPET=nordic-flpr sysbuild: true - harness: remote + harness: console + harness_config: + type: multi_line + ordered: false + regex: + - "host: IPC-service HOST demo started" + - "host: Ep bounded" + - "host: Perform sends for" + - "host: Sent" + - "host: Received" + - "host: IPC-service HOST demo ended" + + sample.ipc.icmsg.nrf54l15_no_multithreading: + platform_allow: nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf54l15pdk/nrf54l15/cpuapp + tags: ipc + extra_args: + icmsg_SNIPPET=nordic-flpr + icmsg_CONFIG_MULTITHREADING=n + icmsg_CONFIG_LOG_MODE_MINIMAL=y + remote_CONFIG_MULTITHREADING=n + remote_CONFIG_LOG_MODE_MINIMAL=y + sysbuild: true + harness: console + harness_config: + type: multi_line + ordered: false + regex: + - "I: IPC-service HOST demo started" + - "I: Ep bounded" + - "I: Perform sends for" + - "I: Sent" + - "I: Received" + - "I: IPC-service HOST demo ended" + + sample.ipc.icmsg.nrf54l15_remote_no_multithreading: + platform_allow: nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf54l15pdk/nrf54l15/cpuapp + tags: ipc + extra_args: + icmsg_SNIPPET=nordic-flpr + remote_CONFIG_MULTITHREADING=n + remote_CONFIG_LOG_MODE_MINIMAL=y + sysbuild: true + harness: console + harness_config: + type: multi_line + ordered: false + regex: + - "host: IPC-service HOST demo started" + - "host: Ep bounded" + - "host: Perform sends for" + - "host: Sent" + - "host: Received" + - "host: IPC-service HOST demo ended" diff --git a/samples/subsys/ipc/ipc_service/icmsg/src/main.c b/samples/subsys/ipc/ipc_service/icmsg/src/main.c index a13477aa368..bbc8f103641 100644 --- a/samples/subsys/ipc/ipc_service/icmsg/src/main.c +++ b/samples/subsys/ipc/ipc_service/icmsg/src/main.c @@ -18,29 +18,42 @@ #include LOG_MODULE_REGISTER(host, LOG_LEVEL_INF); - +#if defined(CONFIG_MULTITHREADING) K_SEM_DEFINE(bound_sem, 0, 1); +#else +volatile uint32_t bound_sem = 1; +volatile uint32_t recv_sem = 1; +#endif + static unsigned char expected_message = 'A'; static size_t expected_len = PACKET_SIZE_START; - static size_t received; static void ep_bound(void *priv) { received = 0; - +#if defined(CONFIG_MULTITHREADING) k_sem_give(&bound_sem); +#else + bound_sem = 0; +#endif LOG_INF("Ep bounded"); } static void ep_recv(const void *data, size_t len, void *priv) { +#if defined(CONFIG_ASSERT) struct data_packet *packet = (struct data_packet *)data; __ASSERT(packet->data[0] == expected_message, "Unexpected message. Expected %c, got %c", expected_message, packet->data[0]); __ASSERT(len == expected_len, "Unexpected length. Expected %zu, got %zu", expected_len, len); +#endif + +#ifndef CONFIG_MULTITHREADING + recv_sem = 0; +#endif received += len; expected_message++; @@ -75,6 +88,11 @@ static int send_for_time(struct ipc_ept *ep, const int64_t sending_time_ms) LOG_ERR("Failed to send (%c) failed with ret %d", msg.data[0], ret); break; } +#if !defined(CONFIG_MULTITHREADING) + else { + recv_sem = 1; + } +#endif msg.data[0]++; if (msg.data[0] > 'z') { @@ -88,7 +106,12 @@ static int send_for_time(struct ipc_ept *ep, const int64_t sending_time_ms) mlen = PACKET_SIZE_START; } +#if defined(CONFIG_MULTITHREADING) k_usleep(1); +#else + while ((recv_sem != 0) && ((k_uptime_get() - start) < sending_time_ms)) { + }; +#endif } LOG_INF("Sent %zu [Bytes] over %lld [ms]", bytes_sent, sending_time_ms); @@ -125,7 +148,12 @@ int main(void) return ret; } +#if defined(CONFIG_MULTITHREADING) k_sem_take(&bound_sem, K_FOREVER); +#else + while (bound_sem != 0) { + }; +#endif ret = send_for_time(&ep, SENDING_TIME_MS); if (ret < 0) { @@ -134,7 +162,11 @@ int main(void) } LOG_INF("Wait 500ms. Let remote core finish its sends"); +#if defined(CONFIG_MULTITHREADING) k_msleep(500); +#else + k_busy_wait(500000); +#endif LOG_INF("Received %zu [Bytes] in total", received);