Skip to content

STM32L4 TRNG clock configuration #11679

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

Merged
merged 1 commit into from
Oct 21, 2019
Merged

Conversation

jeromecoutant
Copy link
Collaborator

Description

Fixes #11674

In some cases, mainly STM32L4, STM targets that have TRNG will use RCC_RNGCLKSOURCE_PLL even if the CLOCK_SOURCE is defined to be USE_PLL_MSI and TRNG should use RCC_RNGCLKSOURCE_MSI instead.
USE_PLL_MSI was defined in the system_clock.c and isn't seen in the trng_api.c thus evaluating to 0 when preprocessing

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@jarlamsa

Release Notes

@ciarmcom ciarmcom requested review from jarlamsa and a team October 14, 2019 09:00
@ciarmcom
Copy link
Member

@jeromecoutant, thank you for your changes.
@jarlamsa @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@jarlamsa jarlamsa left a comment

Choose a reason for hiding this comment

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

This addition fixes the seen issues. Will the USE_PLL_MSI be 0x1 with all the future boards as well? If there are going to be changes to the TRNG-initialisation (adding more different possibilities for RNG clock selections), there might be a need to make modifications here, and could be good to document.

@jeromecoutant
Copy link
Collaborator Author

@jarlamsa I have updated my patch.
We think it is easier to understand and to maintain.

@LMESTM

Copy link
Contributor

@LMESTM LMESTM left a comment

Choose a reason for hiding this comment

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

While cleaning up I'd like to have comment updated

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
error("RNG clock configuration error\n");
}

#elif defined(TARGET_STM32L4)
/* RNG clock configuration could be already done by USB */
Copy link
Contributor

Choose a reason for hiding this comment

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

to be very precise it's not RNG clock configuration but RNG clock source selection
and comment should add that RNG and USB clocks have the same source, so the common source selection could be already done by USB

}
}
else {
/* MSI clock is not enabled, RNG clock is configured on PLL */
Copy link
Contributor

Choose a reason for hiding this comment

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

/* MSI clock is not enabled, so PLL selected as RNG clock source */

@jarlamsa
Copy link
Contributor

Thank you for the quick response and fix.
Verified with DISCO_L475VG_IOT01A to be working.

@jarlamsa
Copy link
Contributor

@0xc0170 could you please review and start CI for this?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 15, 2019

marked for CI, we are finilizing 5.14.1 RC, this PR will go into once it is completed.

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 17, 2019

@jeromecoutant Ready for ci but rebase needed, please do and will start CI

@jeromecoutant
Copy link
Collaborator Author

Rebase done, please start CI
Thx

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 17, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Oct 17, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-IAR

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 18, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Oct 18, 2019

Test run: FAILED

Summary: 3 of 4 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-GCC_ARM
  • jenkins-ci/mbed-os-ci_build-ARM
  • jenkins-ci/mbed-os-ci_build-IAR

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 18, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Oct 18, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 merged commit 42cb19b into ARMmbed:master Oct 21, 2019
@jeromecoutant jeromecoutant deleted the PR_L4_TRNG branch October 21, 2019 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM trng_api uses always RCC_RNGCLKSOURCE_PLL
6 participants