-
Notifications
You must be signed in to change notification settings - Fork 7k
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
drivers: firmware: scmi: add optional crc #86347
Open
AndreHeinemans-NXP
wants to merge
1
commit into
zephyrproject-rtos:main
Choose a base branch
from
AndreHeinemans-NXP:add-crc-to-scmi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_library() | ||
|
||
zephyr_library_sources_ifdef(CONFIG_ARM_SCMI_NXP_VENDOR_EXTENSIONS shmem.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2025 NXP | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config ARM_SCMI_NXP_VENDOR_EXTENSIONS | ||
bool "Allow NXP specific SCMI features" | ||
select CRC | ||
help | ||
When enabled, additional SCMI features specific to NXP will be available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2025 NXP | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/drivers/firmware/scmi/shmem.h> | ||
#include <zephyr/sys/crc.h> | ||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(arm_scmi_shmem_nxp); | ||
|
||
#define SMT_CRC_NONE 0U | ||
#define SMT_CRC_XOR 1U /* Unsupported */ | ||
#define SMT_CRC_J1850 2U /* Unsupported */ | ||
#define SMT_CRC_CRC32 3U | ||
|
||
int scmi_shmem_vendor_read_message(const struct scmi_shmem_layout *layout) | ||
{ | ||
uint32_t validation_type = layout->res1[0]; | ||
|
||
if (validation_type == SMT_CRC_CRC32) { | ||
if (layout->res1[1] != crc32_ieee((const uint8_t *)&layout->msg_hdr, layout->len)) { | ||
LOG_ERR("bad message crc"); | ||
return -EBADMSG; | ||
} | ||
} else if (validation_type == SMT_CRC_NONE) { | ||
/* do nothing */ | ||
} else { | ||
LOG_ERR("invalid validation type 0x%x", validation_type); | ||
return -EINVAL; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int scmi_shmem_vendor_write_message(struct scmi_shmem_layout *layout) | ||
{ | ||
uint32_t validation_type = layout->res1[0]; | ||
|
||
if (validation_type == SMT_CRC_CRC32) { | ||
layout->res1[1] = crc32_ieee((const uint8_t *)&layout->msg_hdr, layout->len); | ||
} else if (validation_type == SMT_CRC_NONE) { | ||
/* do nothing */ | ||
} else { | ||
LOG_ERR("invalid validation type 0x%x", validation_type); | ||
return -EINVAL; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will enable mandatory CRC validation for all applications on imx95_m7 using ddr config. So this will break any application which doesn't encode the CRC.
e.g sound open firmware: https://github.com/thesofproject/sof/blob/main/app/boards/imx95_evk_mimx9596_m7_ddr.conf
I don't think we should add this kind of checks in the scmi core itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default the imx-sm does enable CRC, hence this PR to make Zephyr actually work with the "Hello world" example.
See imx-sm source
https://github.com/nxp-imx/imx-sm/blob/a07928b4a69e092667c3c2dc61adc36b5eaaf836/configs/mx95evk.cfg#L335
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not mandatory since you can override this setting in the application. All applications who do not need it only have to add 'CONFIG_ARM_SCMI_SHMEM_USE_CRC=n' to their config.
The reason that I enabled it by default on the imx95_evk is that system-manager (imx-sm) also has it enabled by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unreasonable to ask applications to know about CONFIG_ARM_SCMI_SHMEM_USE_CRC and disable it.
I think your particular application should explicitly enable it.
AFAIK I understand your first end goal is to make default "Hello World" sample to work on M7 with the default imx-sm config.
Looks like we have a conflict here. Allow me some time to better understand the context and then decide on a solution that works for everyone.
PRs are blocked for 4.2 so we do have some time until we can merge this.