Skip to content

Commit 4a5c939

Browse files
tomchynordicjm
authored andcommitted
suit: Clean API to run Cortex cores
Improve internal API that allows to start Cortex cores. Ref: NCSDK-29997 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 47bdc77 commit 4a5c939

File tree

3 files changed

+52
-40
lines changed

3 files changed

+52
-40
lines changed

subsys/suit/platform/sdfw/include/suit_cpu_run.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@
77
#ifndef SUIT_PLAT_RUN_CPU_H__
88
#define SUIT_PLAT_RUN_CPU_H__
99

10-
#include <suit_platform.h>
10+
#include <suit_plat_err.h>
1111

1212
#ifdef __cplusplus
1313
extern "C" {
1414
#endif
1515

1616
/**
1717
* @brief Run specified CPU.
18+
*
1819
* @note Implementation depends on SoC on which it's built.
1920
*
20-
* @param cpu_id ID of CPU to be started
21-
* @param run_address Start address for given CPU
22-
* @return int 0 in case of success, otherwise error code
21+
* @param[in] cpu_id ID of CPU to be started
22+
* @param[in] run_address Start address for given CPU
23+
*
24+
* @retval SUIT_PLAT_SUCCESS in case of successful start
25+
* @retval SUIT_PLAT_ERR_CRASH if CPU start failed
26+
* @retval SUIT_PLAT_ERR_UNSUPPORTED if handling CPU start is not supported
27+
* @retval SUIT_PLAT_ERR_INVAL if CPU ID is unknown
28+
* @retval SUIT_PLAT_ERR_INCORRECT_STATE if CPU is already started
2329
*/
24-
int suit_plat_cpu_run(uint8_t cpu_id, intptr_t run_address);
30+
suit_plat_err_t suit_plat_cpu_run(uint8_t cpu_id, uintptr_t run_address);
2531

2632
#ifdef __cplusplus
2733
}

subsys/suit/platform/sdfw/src/runners/suit_run_nrf54h20.c

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,58 @@
66

77
#include <suit_cpu_run.h>
88
#include <zephyr/logging/log.h>
9-
#include <suit_platform_internal.h>
109
#include <drivers/nrfx_common.h>
10+
11+
#ifdef CONFIG_SDFW_VPRS
1112
#include <sdfw/vprs.h>
13+
#endif /* CONFIG_SDFW_VPRS */
1214

1315
#ifdef CONFIG_SDFW_RESET_HANDLING_ENABLED
1416
#include <sdfw/reset_mgr.h>
1517
#endif /* CONFIG_SDFW_RESET_HANDLING_ENABLED */
1618

1719
LOG_MODULE_REGISTER(suit_plat_run, CONFIG_SUIT_LOG_LEVEL);
1820

19-
int suit_plat_cpu_run(uint8_t cpu_id, intptr_t run_address)
21+
suit_plat_err_t suit_plat_cpu_run(uint8_t cpu_id, uintptr_t run_address)
2022
{
23+
int ret = 0;
24+
2125
switch (cpu_id) {
2226
case NRF_PROCESSOR_APPLICATION: /* AppCore */
23-
case NRF_PROCESSOR_RADIOCORE: { /* RadioCore */
27+
case NRF_PROCESSOR_RADIOCORE: /* RadioCore */
2428
#ifdef CONFIG_SDFW_RESET_HANDLING_ENABLED
29+
LOG_INF("Starting Cortex core %d from address 0x%lx", cpu_id, run_address);
2530
/* Single run address implies no NSVTOR, so keep at reset value of 0x0. */
26-
return reset_mgr_init_and_boot_processor(cpu_id, run_address, 0);
27-
#else
28-
return SUIT_SUCCESS;
31+
ret = reset_mgr_init_and_boot_processor(cpu_id, run_address, 0);
32+
#else /* CONFIG_SDFW_RESET_HANDLING_ENABLED */
33+
LOG_WRN("Cortex core handling not supported - skip CPU %d start", cpu_id);
2934
#endif /* CONFIG_SDFW_RESET_HANDLING_ENABLED */
30-
} break;
31-
32-
case NRF_PROCESSOR_BBPR: { /* BBPR - Baseband Processor */
33-
LOG_ERR("No implementation for BBPR invoke");
34-
return SUIT_ERR_UNSUPPORTED_PARAMETER;
35-
} break;
35+
break;
3636

37-
case NRF_PROCESSOR_SYSCTRL: { /* SysCtrl */
37+
case NRF_PROCESSOR_SYSCTRL: /* SysCtrl */
38+
#ifdef CONFIG_SDFW_VPRS
3839
LOG_INF("Starting SysCtrl from address 0x%lx", run_address);
39-
return vprs_sysctrl_start((uintptr_t)run_address);
40-
} break;
41-
42-
case NRF_PROCESSOR_PPR: /* PPR(VPR) */
43-
case NRF_PROCESSOR_FLPR: { /* FLPR(VPR) */
44-
LOG_ERR("No implementation for VPR invoke");
45-
return SUIT_ERR_UNSUPPORTED_PARAMETER;
46-
} break;
47-
48-
default: {
49-
LOG_ERR("Unsupported CPU ID");
50-
return SUIT_ERR_UNSUPPORTED_PARAMETER;
40+
ret = vprs_sysctrl_start((uintptr_t)run_address);
41+
#else /* CONFIG_SDFW_VPRS */
42+
LOG_WRN("SysCtrl core handling not supported - skip VPR start");
43+
#endif /* CONFIG_SDFW_VPRS */
44+
break;
45+
46+
case NRF_PROCESSOR_PPR: /* PPR(VPR) */
47+
case NRF_PROCESSOR_FLPR: /* FLPR(VPR) */
48+
LOG_ERR("Application VPR %d start is not supported in SUIT", cpu_id);
49+
return SUIT_PLAT_ERR_UNSUPPORTED;
50+
51+
default:
52+
LOG_ERR("Unsupported CPU ID: %d", cpu_id);
53+
return SUIT_PLAT_ERR_INVAL;
5154
}
55+
56+
if (ret != 0) {
57+
LOG_ERR("Failed to start CPU %d from address 0x%lx (err: %d)", cpu_id, run_address,
58+
ret);
59+
return SUIT_PLAT_ERR_CRASH;
5260
}
61+
62+
return SUIT_PLAT_SUCCESS;
5363
}

subsys/suit/platform/sdfw/src/runners/suit_run_posix.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
#include <suit_cpu_run.h>
88
#include <zephyr/logging/log.h>
9-
#include <suit_platform_internal.h>
10-
#include <suit_platform.h>
119

1210
/*
13-
* Meant to be used in integration tests on posix.
11+
* Meant to be used in integration tests on posix.
1412
* May require changes to accommodate other cpu_ids
1513
*/
1614

@@ -19,18 +17,16 @@
1917

2018
LOG_MODULE_REGISTER(suit_plat_run, CONFIG_SUIT_LOG_LEVEL);
2119

22-
int suit_plat_cpu_run(uint8_t cpu_id, intptr_t run_address)
20+
suit_plat_err_t suit_plat_cpu_run(uint8_t cpu_id, uintptr_t run_address)
2321
{
2422
switch (cpu_id) {
2523
case NRF_PROCESSORPOSIX_1:
26-
case NRF_PROCESSORPOSIX_2: {
24+
case NRF_PROCESSORPOSIX_2:
2725
LOG_INF("Mock AppCore/RadioCore run");
28-
return SUIT_SUCCESS;
29-
} break;
26+
return SUIT_PLAT_SUCCESS;
3027

31-
default: {
28+
default:
3229
LOG_ERR("Unsupported CPU ID (%d)", cpu_id);
33-
return SUIT_ERR_UNSUPPORTED_PARAMETER;
34-
}
30+
return SUIT_PLAT_ERR_INVAL;
3531
}
3632
}

0 commit comments

Comments
 (0)