Skip to content

Commit

Permalink
tests: benchmarks: multicore: idle_ppr: Synchronize cores
Browse files Browse the repository at this point in the history
Synchronize startup of APP, Radio and PPR cores.

Signed-off-by: Sebastian Głąb <[email protected]>
  • Loading branch information
nordic-segl committed Feb 25, 2025
1 parent 58ff006 commit e24a977
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/kernel.h>
#include <zephyr/cache.h>
#include <zephyr/drivers/gpio.h>

#include <zephyr/logging/log.h>
Expand All @@ -15,6 +16,11 @@ static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
static struct k_timer my_timer;
static bool timer_expired;

#define SHM_START_ADDR (DT_REG_ADDR(DT_NODELABEL(cpuapp_cpurad_ipc_shm)))
volatile static uint32_t *shared_var = (volatile uint32_t *) SHM_START_ADDR;
#define APP_IS_READY (1)
#define RADIO_IS_READY (2)

void my_timer_handler(struct k_timer *dummy)
{
timer_expired = true;
Expand Down Expand Up @@ -42,6 +48,40 @@ int main(void)

k_timer_init(&my_timer, my_timer_handler, NULL);

/* Synchronize all three cores.
* APP indicates it's ready.
* Radio waits for APP then indicates it's ready.
* APP and PPR wait for RADIO.
*/
#if defined(CONFIG_SOC_NRF54H20_CPUAPP)
LOG_DBG("APP starts");
/* Inform that APP is ready */
*shared_var = APP_IS_READY;
sys_cache_data_flush_range((void *) shared_var, sizeof(*shared_var));
LOG_DBG("APP wrote APP_IS_READY: %u", *shared_var);
#elif defined(CONFIG_SOC_NRF54H20_CPURAD)
LOG_DBG("RADIO starts");
/* Wait until APP is ready */
while (*shared_var != APP_IS_READY) {
k_usleep(500);
sys_cache_data_invd_range((void *) shared_var, sizeof(*shared_var));
LOG_DBG("shared_var is: %u", *shared_var);
}
LOG_DBG("RADIO found that APP_IS_READY");
/* Inform that RADIO is ready */
*shared_var = RADIO_IS_READY;
sys_cache_data_flush_range((void *) shared_var, sizeof(*shared_var));
LOG_DBG("RADIO wrote RADIO_IS_READY: %u", *shared_var);
sys_cache_data_invd_range((void *) shared_var, sizeof(*shared_var));
#endif
/* APP and PPR wait for RADIO */
while (*shared_var != RADIO_IS_READY) {
k_usleep(500);
sys_cache_data_invd_range((void *) shared_var, sizeof(*shared_var));
LOG_DBG("shared_var is: %u", *shared_var);
}
LOG_DBG("RADIO_IS_READY");

/* Run test forever */
while (1) {
timer_expired = false;
Expand Down

0 comments on commit e24a977

Please sign in to comment.