Skip to content

Sleep: Disallow sleep for targets turning off the systick clock at sleep entry #5086

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 3 commits into from
Oct 13, 2017

Conversation

pan-
Copy link
Member

@pan- pan- commented Sep 13, 2017

Description

When the RTOS is present and the tickless mode is not implemented, it is
expected that the next tick issued by the Systick timer will wake up the MCU.
However nothing prevents an implementation of the ARM architecture to gate the
systick clock signal upon sleep entry.

Therefore on those targets sleep shall be prohibited if the RTOS is present and the
tickless mode is not implemented.

To ease life of porters , a new option has been added in the device add list:
STCLK_OF_DURING_SLEEP. This option expose that the target turn of the systick
clock during sleep.

Targets which exhibit such behavior shall add this define in their device_has list.

Status

READY

Migrations

Silicon vendor has to be informed of this change and add STCLK_OF_DURING_SLEEP to the device_has list of their targets which turn of (or alter) the Systick clock at sleep entry.

YES

Related issues

#4927 and #4893

…ep entry.

When the RTOS is present and the tickless mode is not implemented, it is
expected that the next tick issued by the Systick timer will wake up the MCU.
However nothing prevents an implementation of the ARM architecture to gate the
systick clock signal upon sleep entry.

Therefore on those targets sleep shall be prohibited if the RTOS is present and the
tickless mode is not implemented.

To ease life of porters , a new option has been added in the device add list:
STCLK_OF_DURING_SLEEP. This option expose that the target turn of the systick
clock during sleep.

Targets which exhibit such behavior shall add this define in their device_has list.
@pan- pan- requested review from c1728p9 and 0xc0170 September 13, 2017 09:35
@0xc0170 0xc0170 changed the title Sleep: Disallow sleep for targets turning of the systick clock at sleep entry. Sleep: Disallow sleep for targets turning off the systick clock at sleep entry Sep 19, 2017
"release_versions": ["2", "5"],
"device_name": "nRF52832_xxAA"
},
"DELTA_DFBM_NQ620": {
"supported_form_factors": ["ARDUINO"],
"inherits": ["MCU_NRF52"],
"macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"],
"device_has": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
"device_has_had": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: add ?

Copy link
Contributor

Choose a reason for hiding this comment

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

These targets in this change-set , they extend the parent right? If we do this, add, should we clean? I assume most of them are already defined as device_has in the parent ?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you look at the diff the parent was not defining any device_has. Now it has one which define STCLK_OFF_DURING_SLEEP hence the use of device_has_add in children,

Copy link
Contributor

Choose a reason for hiding this comment

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

I missed that one, then just typo :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix that type on 3065 line? or device_has_had is correct?

@@ -123,7 +127,9 @@ __INLINE static void sleep(void)
{
#if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED))
#if DEVICE_SLEEP
#if (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS)
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Should this be more descriptive DEVICE_SYSTICKCLK..... or DEVICE_SYSTCLK.... ? If I did not read the above comment, I would be guessing what ST clk stands for.

Copy link
Member Author

Choose a reason for hiding this comment

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

STCLK is used in the ARM architecture manuals. I choose to stick with it in the sake of consistency but I can change it.

Copy link
Contributor

@c1728p9 c1728p9 left a comment

Choose a reason for hiding this comment

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

Are the target.json changes needed for the nrf52 since tickless is now turned on for this target with #4991?

@theotherjimmy
Copy link
Contributor

@pan- could you comment?

Replace `device_has_had` by `device_has_add`
@pan-
Copy link
Member Author

pan- commented Sep 25, 2017

Are the target.json changes needed for the nrf52 since tickless is now turned on for this target with #4991?

I believe changes in target.json are still required even if the tickless mode is turned on on NRF52 targets because those targets stop the Systick clock during sleep and this information might be valuable latter.
Tickless presence/absence is taken into account in the sleep function.

@theotherjimmy I've addressed Martin remarks on the typo in targets.json.

@nvlsianpu
Copy link
Contributor

@pan- I want to confirm that nRF52840 behaves similar to nRF52832 so It turn off clock for SysTick while is sleeping as well.

@pan-
Copy link
Member Author

pan- commented Sep 28, 2017

@nvlsianpu I've updated the PR so NRF52840 behavior during sleep is taken into account. Do you think the tickless mode as defined for the NRF52832 would work on NRF52840 ?

@nvlsianpu
Copy link
Contributor

@pan- I think yes - it Should work out of the box. nRF52840 in many areas is just a nRF52832 on steroids :D

@@ -82,7 +82,7 @@ def check_inherits(dict):
"LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT",
"PWMOUT", "RTC", "TRNG","SERIAL", "SERIAL_ASYNCH",
"SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE",
"STORAGE"]
"STORAGE", "STCLK_OFF_DURING_SLEEP"]
Copy link
Contributor

Choose a reason for hiding this comment

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

looking at this again, is this a proper placement for this? Is it device_ ? Wouldnt this be rather a targets config? MBED_CONF_TARGET_STCLK..... - better place/definition for this?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's a device characteristic not a config.

@screamerbg
Copy link
Contributor

@0xc0170 What is gating this PR?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 6, 2017

@bulislaw @c1728p9 happy with this patch?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 9, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Oct 9, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1552

All builds and test passed!

@mbed-ci
Copy link

mbed-ci commented Oct 9, 2017

Build : SUCCESS

Build number : 26
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5086/

Triggering tests

/test mbed-os

@pan-
Copy link
Member Author

pan- commented Oct 10, 2017

Will this be part of 5.6.3 ?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 10, 2017

Will this be part of 5.6.3 ?

Yes, it should be

@mbed-ci
Copy link

mbed-ci commented Oct 10, 2017

Build : ABORTED

Build number : 61
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5086/

@studavekar
Copy link
Contributor

This actually had passed nightly test, So build was aborted and marked the status as passed.

@mbed-ci
Copy link

mbed-ci commented Oct 11, 2017

Build : FAILURE

Build number : 130
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5086/

@theotherjimmy theotherjimmy merged commit a67737f into ARMmbed:master Oct 13, 2017
@pan- pan- deleted the systick_sleep_fix branch July 3, 2018 11:04
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.

10 participants