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

STM32 H7: fix USB in sleep mode #13780

Merged
merged 1 commit into from Nov 26, 2020
Merged

Conversation

JojoS62
Copy link
Contributor

@JojoS62 JojoS62 commented Oct 16, 2020

Problem as descriibed in #13641

USBDevice was not working with STM32H7 targets.

in sleep mode, USB interrupts were disabled
and USB Device was not working. Sleep mode is default in Mbed-os
e.g. in a call to sleep_for()

Summary of changes

Disabling ULPI clock in sleep mode is required for H7 targets. Added conditional disabling when macro exists.

Fix is necessary to make USBDevice working on STM32H7 targets.

Impact of changes

Tests were performed on STM32H743VI and Nucleo STM32H7A3ZIT6Q.
Targets without ULPI should not be affected. STM32F401 ompiled and tested positiv.

Migration actions required

Targets with H7 MCU can be checked and USBDevice can be enabled

Documentation

not affected


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


in sleep mode, USB interrupts were disabled
and USB Device was not working. Sleep mode is default in Mbed-os
e.g. in a call to sleep_for()
@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Oct 16, 2020
@ciarmcom ciarmcom requested a review from a team October 16, 2020 23:30
@ciarmcom
Copy link
Member

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

@0xc0170 0xc0170 changed the title fix USB in sleep mode STM32 H7: fix USB in sleep mode Oct 17, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 17, 2020

@ARMmbed/mbed-os-maintainers reviewers bot is not working as reported the last week? Please review

@jeromecoutant
Copy link
Collaborator

Got issues with USB tests and NUCLEO_H743ZI2...
Seems there is in USB_CoreReset...???

@JojoS62
Copy link
Contributor Author

JojoS62 commented Oct 21, 2020

That maybe an issue with the clock setting. There is an errata that the clock recovery system is not working with HSI48, so I used PLL3Q for my custom board.

could you please use this init in SetSystemClock:
https://github.com/JojoS62/custom_targets/blob/bfd51a0af6535af534cd7af54393975d84187780/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_DEVEBOX_H743VI/system_clock.c#L287-L304

The multiplier and dividers need to be adjusted for a 8 MHz xtal.

    PeriphClkInitStruct.PLL3.PLL3M = 2;                              // 8 MHz / 2 = 4MHz
    PeriphClkInitStruct.PLL3.PLL3N = 48;                             // * 48 = 192 MHz
    PeriphClkInitStruct.PLL3.PLL3P = 2;                               // 192 /  2 = 96 MHz (unused)
    PeriphClkInitStruct.PLL3.PLL3Q = 4;                               // 192 / 4 = 48 MHz (USB)

This setting maybe also necessary for the H743ZI2:

        "config": {
            "usb_speed": {
                "help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
                "value": "USE_USB_OTG_FS"
            },

@0xc0170 0xc0170 requested a review from a team October 26, 2020 12:01
Copy link
Collaborator

@jeromecoutant jeromecoutant left a comment

Choose a reason for hiding this comment

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

Let's merge this update.
I will enable USB for NUCLEO-H743 after more tests

@jeromecoutant
Copy link
Collaborator

@0xc0170 Let's start CI ?
Thx

@mbed-ci
Copy link

mbed-ci commented Nov 25, 2020

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️
jenkins-ci/mbed-os-ci_cmake-example-test ✔️
jenkins-ci/mbed-os-ci_dynamic-memory-usage ✔️
jenkins-ci/mbed-os-ci_cloud-client-pytest ✔️

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.

None yet

6 participants