Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf_rpc: Add function for single group initialization #1593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vge0rge
Copy link
Contributor

@Vge0rge Vge0rge commented Nov 27, 2024

Adds the function nrf_rpc_init_group to allow initializing an nrf_rpc group individually. This is useful when groups need to be initialized in different boot stages.

nrf_rpc_init now takes into account that a group could could be initialized using the nrf_rpc_init_group and avoids initializiting again.

@Vge0rge Vge0rge requested a review from doki-nordic as a code owner November 27, 2024 13:48
@Vge0rge Vge0rge changed the title nrf_prc: Add function for single group initialization nrf_rpc: Add function for single group initialization Nov 27, 2024
@Vge0rge Vge0rge force-pushed the 54h20_psa_rng branch 3 times, most recently from 1351882 to 7a4cfd2 Compare December 4, 2024 22:13
@Vge0rge Vge0rge force-pushed the 54h20_psa_rng branch 2 times, most recently from 6d9476d to 326b004 Compare December 9, 2024 08:42
return 0;
}

int nrf_rpc_init(nrf_rpc_err_handler_t err_handler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The err_handler is never assigned to global handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I changed that.

static void default_err_handler(const struct nrf_rpc_err_report *report)
{
NRF_RPC_ERR("nRF RPC error %d ocurred. See nRF RPC logs for more details", report->code);
k_oops();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be OS-independent code. k_oops() is a Zephyr function. Please pass it through OS porting layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this, do you refer to this OS porting layer do you refer to the nrf_rpc one?
So what you are proposing is to add another function here:
https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/nrf_rpc/nrf_rpc_os.c

Which handles the error case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an opinion on this Pawel? I can do what I am describing here if you have the same understanding as me

@pdunaj pdunaj dismissed doki-nordic’s stale review December 11, 2024 16:14

reviewer is away. nitpicks were addressed


NRF_RPC_ASSERT(transport != NULL);
if(group->data->transport_initialized) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space missing
s/if(/if (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for (NRF_RPC_AUTO_ARR_FOR(iter, group, &nrf_rpc_groups_array,
const struct nrf_rpc_group)) {

transport_init_single(receive_cb, group);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error is not checked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional though, because I saw in the previous implementation they didn't return an error when a single initialization failed.
The logic here:

for (NRF_RPC_AUTO_ARR_FOR(iter, group, &nrf_rpc_groups_array,

Should be the same with the logic in the function transport_init_single basically.

The error that I return in this function is the logic which exists here:

if (waiting_group_count > 0) {

@@ -1144,20 +1162,67 @@ int nrf_rpc_init(nrf_rpc_err_handler_t err_handler)
return err;
}

for (i = 0; i < CONFIG_NRF_RPC_CMD_CTX_POOL_SIZE; i++) {
for (int i = 0; i < CONFIG_NRF_RPC_CMD_CTX_POOL_SIZE; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/int/size_t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int nrf_rpc_init_group(const struct nrf_rpc_group *group)
{
int err = nrf_rpc_prepare_init();
if(err < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space if (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

NRF_RPC_DBG("Initializing nRF RPC module");

err = nrf_rpc_prepare_init();
if(err < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@pdunaj
Copy link
Contributor

pdunaj commented Dec 11, 2024

I assume that @doki-nordic have seen no problems with the actual change.
See few style issues to fix but the biggest problem is that error is ignored when transport is initialized.

@pdunaj
Copy link
Contributor

pdunaj commented Dec 12, 2024

Hi @Vge0rge , please just fix the error handling and I will approve and merge.

@Vge0rge Vge0rge force-pushed the 54h20_psa_rng branch 2 times, most recently from fefd809 to d078aad Compare December 19, 2024 16:07
Copy link
Contributor

@frkv frkv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming the k_oops abstraction is handled in follow-up work

Adds the function nrf_rpc_init_group to allow initializing
an nrf_rpc group individually. This is useful when
groups need to be initialized in different boot stages.

nrf_rpc_init now takes into account that a group could
could be initialized using the nrf_rpc_init_group and
avoids initializiting again.

Signed-off-by: Georgios Vasilakis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants