Skip to content

Merge feature-hal-spec-sleep to master #6994

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

Closed
wants to merge 18 commits into from
Closed

Conversation

bulislaw
Copy link
Member

Description

New HAL Sleep API.

Pull request type

[ ] Fix
[ ] Refactor
[ ] New target
[x] Feature
[ ] Breaking change

0xc0170 and others added 18 commits May 15, 2018 13:40
Sleep - within 10us
Deepsleep - within 10ms

Note about mbed boards with interface, moved to lpc176x, as they are target related,
should be documented in the target documentation.

The tests will come as separate PR, to conform to this updates to sleep API.
These boards will be re-enabled when sleep driver for them is ready.

Note:
This operation is done by removing "SLEEP" feature from target's "device_has" list (in targets.json config file).
For NRF52_DK removing of "SLEEP" feature causes some timing issues which have influence on tests. In order to successfully disable this board we need to disable also related features like "USTICKER", "LOWPOERTIMER" and slightly modify ticker tests, so they will not be executed if usticker support is not available (by default all targets support us ticker).
…abled in deep-sleep mode.

This is done because of possible limitations of lowpower ticker freq/width.
Compile this file only when DEVICE_LOWPOWERTIMER is defined.
These platforms are not consistent with the new sleep standards.
I implemented the SLEEP feature for Rnesas mbed boards.
The mainly changing is here.
- hal_sleep()
  To satisfy the mbed specificationm, I implemented this function newly by using "sleep" that is one of low power mode that is incorporated in our hardware(RZ_A1).
  In the "sleep", peripheral and memory state are maintained, and the peripherals continue to work and can generate interrupts.

- hal_deepsleep()
  To satisfy the mbed specificationm, I implemented this function newly by combined using "sleep" and "module standby" that is the low power mode that is incorporated in our hardware(RZ_A1).
  The "module standby" is peripheral module's powerdown.
  Also in case of our "module standby", it need to read register as dummy when access to each register.
Signed-off-by: Mahesh Mahadevan <[email protected]>
@bulislaw
Copy link
Member Author

@cmonr First one is ready for testing.

@cmonr
Copy link
Contributor

cmonr commented May 23, 2018

@bulislaw Cool. Will take a quick look at it whilst Travis CI does it thing.

@cmonr
Copy link
Contributor

cmonr commented May 23, 2018

@bulislaw Is this PR just the feature branch coming into master, or are there other PRs in her as well?

@bulislaw
Copy link
Member Author

It's feature branch, but it has some of the partners code that wasn't validated by the CI.

@cmonr
Copy link
Contributor

cmonr commented May 23, 2018

Alrgiht. I saw the auto-merges close those PRs. Was hoping that this method wouldn't do that, but oh well.

From the PoV of master, the effect is the same. The changes are still gated by CI.

FYI @ARMmbed/mbed-os-maintainers

@cmonr cmonr requested review from 0xc0170, c1728p9, a user and ithinuel and removed request for a user May 24, 2018 02:17
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Looks good - particularly glad to see specification of "deep sleep".

I would like to draw to your attention one significant issue with the current deep sleep specification - the console. If using a "proper" buffered console - like UARTSerial, deep sleep is rendered non-functional, as we must lock deep sleep to get serial IRQs. This is quite unfortunate as we're encouraging and setting apps to use buffered serial (it's an absolute requirement for some), thus reducing the number of apps that can deep sleep.

The deep sleep + console combo only "works" because the legacy serial console requires you to spin to transfer data, and if you're not spinning on RX you drop input. So that terrible behaviour isn't affected by sleep at all.

I think we may need some sort of mechanism to flag "extra devices that work in deep sleep on this platform".

Issue suggesting that here: #5943

We may also want a mechanism to request "output only" on UARTSerial, so we don't claim the RX interrupt.

We are currently in something of a knot with GreenTea - we're wanting to make it use buffered serial to solve various comms problems, but just setting that on locks out deep sleep tests...

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.

It seems that there are some dependency with #6995
I think it should be reasonable to merge first this one, and then the ticker branch (and not in parallel)

@0xc0170
Copy link
Contributor

0xc0170 commented May 24, 2018

I would like to draw to your attention one significant issue with the current deep sleep specification - the console. If using a "proper" buffered console - like UARTSerial, deep sleep is rendered non-functional, as we must lock deep sleep to get serial IRQs. This is quite unfortunate as we're encouraging and setting apps to use buffered serial (it's an absolute requirement for some), thus reducing the number of apps that can deep sleep.

I think we may need some sort of mechanism to flag "extra devices that work in deep sleep on this platform".

Shall this be captured in Serial specs work to capture it there ?

The flag - this comes from time to time, targets hooks to overwrite the default locking or similar approach to have this "sort of mechanism to flag"

@kjbracey
Copy link
Contributor

Shall this be captured in Serial specs work to capture it there ?

I think we do need to tackle it from two ends, basically independently

  • a general HAL mechanism for letting targets declare that extra devices beyond the minimum do work in deep sleep.

  • something in UARTSerial+retargetting to allow write-only opening to avoid locking deep sleep for unwanted RX on platforms without the above extension.

So I think that goes to "general HAL" and "serial/stream C++/retarget layers", not necessarily anything for the "serial HAL" specifically. But perhaps a general mechanism could be done as part of the serial HAL package.

Still a bit stuck with greentea, but the latter mechanism could maybe be runtime switchable - we effectively close serial input while doing the deep sleep tests, then reopen.

@0xc0170
Copy link
Contributor

0xc0170 commented May 24, 2018

/morph build

@0xc0170
Copy link
Contributor

0xc0170 commented May 24, 2018

Will retrigger the build once emac lands (might cause some conflicts), the current build aborted. This shoud happen shortly 🤞

@mbed-ci
Copy link

mbed-ci commented May 24, 2018

Build : FAILURE

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

@cmonr
Copy link
Contributor

cmonr commented May 24, 2018

Marking as DNM since this will be coming in a larger PR.

@cmonr
Copy link
Contributor

cmonr commented May 24, 2018

Removed labeling to make 5.9 tags easier to sort through. Will be brought in with #7009.

@0xc0170 0xc0170 closed this May 28, 2018
@0xc0170 0xc0170 deleted the feature-hal-spec-sleep branch June 21, 2018 13:39
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.