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

drivers: crc: Add hardware-based CRC driver #74977

Closed
wants to merge 4 commits into from

Conversation

zkat2
Copy link
Collaborator

@zkat2 zkat2 commented Jun 25, 2024

Adds hardware support for CRC-8-CCITT and CRC-32-IEEE calculations and introduces a devicetree binding for STM32 CRC.

@zephyrbot zephyrbot added platform: STM32 ST Micro STM32 area: Devicetree Binding PR modifies or adds a Device Tree binding labels Jun 25, 2024
Copy link

Hello @zkat2, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@erwango
Copy link
Member

erwango commented Jun 25, 2024

@mathieuchopstm Would you mind having a look ?

@zkat2 zkat2 marked this pull request as draft June 25, 2024 17:05
@zkat2 zkat2 marked this pull request as draft June 25, 2024 17:05
@pdgendt pdgendt requested a review from ceolin June 26, 2024 06:35
mathieuchopstm

This comment was marked as outdated.

@zkat2 zkat2 marked this pull request as ready for review July 3, 2024 17:11
Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

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

This is going in the right direction IMO, there are some compliance issues that need attention.

Comment on lines 7 to 16
#include <zephyr/logging/log.h>
#include <errno.h>
#include <soc.h>
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include <zephyr/init.h>
#include <zephyr/drivers/crc.h>
#include "stm32_ll_crc.h"

LOG_MODULE_REGISTER(crc_stm32);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to pass the logging level from Kconfig.

Try to group includes and have some order like system > zephyr > SoC

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(crc_stm32, CONFIG_CRC_HW_LOG_LEVEL);

#include <errno.h>

#include <zephyr/device.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include <zephyr/drivers/crc.h>

#include <soc.h>
#include <stm32_ll_crc.h>

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Looks promising, thanks.

Some additional requests as you're introducing a brand new API:

  • API doc, see doc/hardware/peripherals/dac.rst as a minimum doc page
  • Add yourself as maintainer in MAINTAINERS.yaml
  • Last (maybe the most important): please provide a sample or a test (both would be ideal ;)) in order:
    • to demonstrate how to use the API and how to configure a device
    • ensure the API and related drivers are compiled systematically in CI

@zkat2 zkat2 marked this pull request as draft July 8, 2024 17:24
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Few more comments but we're getting there, thanks for the work so far.

Also, as you're introducing a new API, I've added flag "Architecture review", so it could be introduced to Architecture working group on next session (Tuesday 5PM CET, see https://github.com/zephyrproject-rtos/zephyr/wiki/Architecture-Working-Group). It would be nice that you're able to join, but it is not blocking if you can't .

@zkat2 zkat2 marked this pull request as draft August 5, 2024 12:47
@zkat2 zkat2 force-pushed the zkat2_branch branch 6 times, most recently from 3423893 to 53243de Compare August 5, 2024 16:07
@henrikbrixandersen
Copy link
Member

Any plans to make this driver subsystem provide backends for https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/crc.h ?

@zkat2 zkat2 force-pushed the zkat2_branch branch 4 times, most recently from f16c5fb to 8864920 Compare August 6, 2024 10:00
Zoe Kaute added 4 commits August 6, 2024 11:32
Adds support for hardware-based  CRC-8-CCITT and CRC-32-IEEE calculations.

Signed-off-by: Zoe Kaute <zoe.kaute@brillpower.com>
Introduces a new sample that demonstrates how to use the
hardware-based CRC API.

Signed-off-by: Zoe Kaute <zoe.kaute@brillpower.com>
Add a test suite to validate the hardware-based CRC API.

Signed-off-by: Zoe Kaute <zoe.kaute@brillpower.com>
Add the CRC node to stm32g4 device tree source file.

Signed-off-by: Zoe Kaute <zoe.kaute@brillpower.com>
@zkat2 zkat2 marked this pull request as ready for review August 6, 2024 10:45
@carlescufi
Copy link
Member

carlescufi commented Aug 6, 2024

Architecture WG:

  • @gmarull and @carlescufi object with the fact that we are now left with 2 completely separate CRC APIs: the one in this PR and the existing software-based one in sys/crc.h
  • One option would be to introduce something akin to the random subsystem, where there is a single API and then multiple backends, one of which uses the entropy driver API
  • The other option would be to keep the API in this PR but add a software implementation, but then instancing may be an issue
  • Check if mbedTLS has support for CRC APIs? @ceolin
  • @zkat2 feel free to join the Architecture WG to discuss this again

@zkat2
Copy link
Collaborator Author

zkat2 commented Aug 6, 2024

@carlescufi Are you able to elaborate what these two options would entail? Are you suggesting an API rework or grouping the hardware and software implementations in a subsystem? Any additional details or examples would be appreciated.

@ceolin
Copy link
Member

ceolin commented Aug 7, 2024

Architecture WG:

  • @gmarull and @carlescufi object with the fact that we are now left with 2 completely separate CRC APIs: the one in this PR and the existing software-based one in sys/crc.h
  • One option would be to introduce something akin to the random subsystem, where there is a single API and then multiple backends, one of which uses the entropy driver API
  • The other option would be to keep the API in this PR but add a software implementation, but then instancing may be an issue
  • Check if mbedTLS has support for CRC APIs? @ceolin

As far as I can tell you there is no CRC.

  • @zkat2 feel free to join the Architecture WG to discuss this again

Copy link

github-actions bot commented Oct 7, 2024

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Oct 7, 2024
@github-actions github-actions bot closed this Oct 21, 2024
@henrikbrixandersen
Copy link
Member

@zkat2 Hey! Sorry to see this work abandoned. Do you have any plans - and bandwidth - for resuming work on this? I'd love to collaborate on it, if needed.

@thenguyenyf
Copy link
Contributor

@zkat2 Hey! Sorry to see this work abandoned. Do you have any plans - and bandwidth - for resuming work on this? I'd love to collaborate on it, if needed.

Hello @henrikbrixandersen . We are preparing for a CRC hardware-based device driver (which similar to implementation in this PR) and we also introduce a CRC subsystem (implementation is quite similar to random system) includes a software backend (using sys/crc.h) and a CRC hardware backend (using CRC device driver). It will be sent out at the end of this week.

@thenguyenyf
Copy link
Contributor

Hello. I have sent out a PR to add a CRC device driver implementation for Renesas RA device that referred to this PR here #87557. I'm also implement a new CRC subsystem using software/hardware backend implementation.
@henrikbrixandersen , @zkat2 , could you please visit and leave it some comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture Review Discussion in the Architecture WG required area: Devicetree Binding PR modifies or adds a Device Tree binding area: Process area: Samples Samples platform: STM32 ST Micro STM32 Stale
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

10 participants