-
Notifications
You must be signed in to change notification settings - Fork 7.3k
drivers: crypto: Add initial support for rpi_pico sha256 accelerator #85036
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
base: main
Are you sure you want to change the base?
Conversation
0d6e6b8
to
a2b3bb7
Compare
a2b3bb7
to
19c04b7
Compare
@ceolin @valeriosetti @ThreeEights Could you take a look if you have a bit of a while? |
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.
The PR looks OK to me. I cannot test it locally because I don't have a board at hand, but at least the test that was extended builds correctly. I only left one minor non-blocking question/comment.
zephyr_library_sources_ifdef(CONFIG_CRYPTO_SMARTBOND crypto_smartbond.c) | ||
zephyr_library_sources_ifdef(CONFIG_CRYPTO_STM32 crypto_stm32.c) | ||
zephyr_library_sources_ifdef(CONFIG_CRYPTO_TINYCRYPT_SHIM crypto_tc_shim.c) | ||
# zephyr-keep-sorted-stop |
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.
Sorting - good idea!
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.
nit: I'd prefer it if the sorting is one commit, and the addition is a separate commit. The end result is the same, but it's easier to to see the two orthogonal things going on.
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.
Thanks for addressing previous comment. However reviewing the PR again I found a couple of new ones that I missed before. Sorry
a6aeaeb
to
f2ca146
Compare
Could you take a look at it? |
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.
The change looks functionally good, but I am concerned about the outright copy and paste of BSD code, then relabeling it as Apache 2.
I feel like someone else needs to comment on this.
zephyr_library_sources_ifdef(CONFIG_CRYPTO_SMARTBOND crypto_smartbond.c) | ||
zephyr_library_sources_ifdef(CONFIG_CRYPTO_STM32 crypto_stm32.c) | ||
zephyr_library_sources_ifdef(CONFIG_CRYPTO_TINYCRYPT_SHIM crypto_tc_shim.c) | ||
# zephyr-keep-sorted-stop |
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.
nit: I'd prefer it if the sorting is one commit, and the addition is a separate commit. The end result is the same, but it's easier to to see the two orthogonal things going on.
LOG_MODULE_REGISTER(sha_rpi_pico_sha256, CONFIG_CRYPTO_LOG_LEVEL); | ||
|
||
/* | ||
* This is based on the pico_sha256 implementation in the Pico-SDK. |
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.
Original code is a https://github.com/raspberrypi/pico-sdk/blob/2.1.0/src/rp2_common/pico_sha256/sha256.c , it's 3-Clause BSD (BSD-3-Clause
).
I feel like this file has lifted-and-shifted too much for someone to ignore (many lines of code are the same, just formatted to meet the Zephyr Project's coding style).
I'd be happy if this file had a BSD-3-Clause on it. Zephyr must be compatible with this, we link against BSD-3-Clause all over the place. It's not easy t osee examples of that, however.
Alternatively, we could modify the version of the source code in the hal_rpi_pico
. This is something I prefer to avoid, but that feels better at ensuring the software licence is upheld.
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.
The codes derived from pico-sdk were separated into crypto_rpi_pico_sha256.h
, and the license changed to BSD-3.
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.
nit: I'd prefer it if the sorting is one commit, and the addition is a separate commit. The end result is the same, but it's easier to to see the two orthogonal things going on.
Addressed.
Add `zephyr-keep-sorted` and reorder file entries alphabetically. Signed-off-by: TOKITA Hiroshi <[email protected]>
Add `hardware_sha256/include` to `zephyr_include_directories`. Use the header only. Signed-off-by: TOKITA Hiroshi <[email protected]>
Add basic support for RaspberryPi Pico's SHA256 hardware accelerator. Signed-off-by: TOKITA Hiroshi <[email protected]>
Added sha256 accelerator to rpi_pico. Signed-off-by: TOKITA Hiroshi <[email protected]>
Add rpi_pico2 to the crypto_hash test target. Signed-off-by: TOKITA Hiroshi <[email protected]>
This PR contains BSD-3 derived code. (drivers/crypto/crypto_rpi_pico_sha256.h) |
I think, based on the conversation at #81183 (comment) that this won't be a viable solution. My suggestion is
I know that this may feel contradictory to an earlier stance I have of "don't change the Pico SDK unless you have to." I feel like this is one of those times. That said, I also hope we can do this in a way that makes wiring up the DMA engine to the SHA256 accelerator easy: it's a prime example of where one wants to offload this whilst the CPUs do something more useful. |
DMA processing must be based on Zephyr's API, and I have determined that this part cannot be used. This is the main reason why I forked this file. |
Yes, I understand what problem you found. The approach you took was to breach the terms of the licence, which is not cool. "fork"ing a file is not a thing. My suggestion is written out above as 3 steps. If you don't understand the steps as written, please ask specific clarifying questions. |
I've never heard of the BSD 3 clause license code can't forking. |
Your original approach was to:
This, to me, is a concerning behaviour. It should not require other people to check/monitor/flag that you are breaching other licence terms, you should do this yourself. After I flagged this you have subsequently corrected this by putting back the original copyright notice, and license. From a technical perspective I don't like how this has been achieved, but that is not the concern I am raising here. |
This is exactly as you pointed out. |
Add basic support for RaspberryPi Pico's SHA256 hardware accelerator.