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

Add LOWPOWERTIMER for NUCLEO_F401RE and DISCO_F429ZI #3319

Closed
wants to merge 2 commits into from

Conversation

jeromecoutant
Copy link
Collaborator

Description

Add LOWPOWERTIMER for NUCLEO_F401RE and DISCO_F429ZI

Status

READY

Tests

Tests done on top of #3316

Thx

@adbridge
Copy link
Contributor

LGTM 👍

@adbridge
Copy link
Contributor

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@adbridge
Copy link
Contributor

/morph test

@bridadan
Copy link
Contributor

@adbridge Perhaps we should wait on this PR until #3316 is merged?

@0xc0170 0xc0170 removed the needs: CI label Nov 28, 2016
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2016

/morph test

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2016

@adbridge Perhaps we should wait on this PR until #3316 is merged?

That's refactoring. It should be fine to merge this one in as adding new extension, and refactor will come later. (if these PR are not connect, assuming there are not)

@jeromecoutant happy with this one coming in first, then refactor?

@jeromecoutant
Copy link
Collaborator Author

Yes, you can merge. Thx

@mbed-bot
Copy link

Result: SUCCESS

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

/morph test

Output

mbed Build Number: 1175

All builds and test passed!

@bridadan
Copy link
Contributor

The normal tests won't run the low power timer tests. I'll kick off a nightly.

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

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

/morph test-nightly

Output

mbed Build Number: 1176

Test failed!

@bridadan
Copy link
Contributor

@jeromecoutant The test tests-mbed_drivers-lp_timeout failed for the NUCLEO_F401RE for the GCC_ARM toolchain. Can you reproduce this failure?

@jeromecoutant
Copy link
Collaborator Author

Rebase done.

I agree that tests-mbed_drivers-lp_timeout test is now failed...

We found issue is due to #3213 merge
New patch is available in #3345

Thx

@bridadan
Copy link
Contributor

bridadan commented Dec 1, 2016

Thanks for the update @jeromecoutant, let's get #3345 merged in before we rerun the bots on this.

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 2, 2016

#3345 merged, lets rerun CI

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 2, 2016

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Dec 2, 2016

Result: FAILURE

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

/morph test-nightly

Output

mbed Build Number: 1193

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 5, 2016

@jeromecoutant Still lp ticker 500us fails , for nucleo 411re ?

Same as reported above:

`@jeromecoutant The test tests-mbed_drivers-lp_timeout failed for the NUCLEO_F401RE for the GCC_ARM toolchain. Can you reproduce this failure?

@jeromecoutant
Copy link
Collaborator Author

@0xc0170
In my current branch, test is OK with nucleo 411re... I am going to rebase to the master to check again.
But anyway, you could merge this PR as there is no related to this nucleo 411RE... ?
Thx

@adbridge
Copy link
Contributor

@jeromecoutant Could you please retry with GCC version 4.9.3 as we don't currently support v5.x.

@bridadan
Copy link
Contributor

If you can reproduce the failure on your machine with that version of the compiler (available here) then I'm curious what about the STM32F4 code is causing this issue (since it works on other targets just fine).

@jeromecoutant
Copy link
Collaborator Author

Hi

...
[DEBUG] Compile: C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin\arm-none-eabi-g++ ...
...

| NUCLEO_F401RE-GCC_ARM | NUCLEO_F401RE | tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout | 1 | 0 | OK | 0.05 |
| NUCLEO_F401RE-GCC_ARM | NUCLEO_F401RE | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout | 1 | 0 | OK | 1.06 |
| NUCLEO_F401RE-GCC_ARM | NUCLEO_F401RE | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 1 | 0 | OK | 1.07 |
| NUCLEO_F401RE-GCC_ARM | NUCLEO_F401RE | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep | 1 | 0 | OK | 1.07 |
| NUCLEO_F401RE-GCC_ARM | NUCLEO_F401RE | tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout | 1 | 0 | OK | 0.05 |
| NUCLEO_F401RE-GCC_ARM | NUCLEO_F401RE | tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout | 1 | 0 | OK | 5.07 |

@jeromecoutant
Copy link
Collaborator Author

Does Ci use the same compilation options....?

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 15, 2016

Does Ci use the same compilation options....?

Yes, it does. It uses the default profile. We will try to reproduce this locally , will report back

@bridadan
Copy link
Contributor

Ok @jeromecoutant I think I know how you can reproduce this.

  1. Download and use the release of GCC from here: https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update
  2. Checkout to mbed-os master branch (I tested with commit 899c542)
  3. Merge your branch
  4. Run the following
    mbed test -m NUCLEO_F401RE -t GCC_ARM -n tests-mbed_drivers-lp_timeout -DMBED_HEAP_STATS_ENABLED=1 --clean --compile
    mbed test -m NUCLEO_F401RE -t GCC_ARM -n tests-mbed_drivers-lp_timeout --run -v
    

This SHOULD cause the failure we're seeing. The missing bit was the heap stat tracking that we enable in CI (we also enable stack stat tracking with -DMBED_STACK_STATS_ENABLED=1, but I was able to reproduce the problem with just that macro).

If you remove the heap stack tracking, it'll start passing again, which is what you're currently seeing.

FYI @c1728p9

@bridadan
Copy link
Contributor

Have you had any luck reproducing this @jeromecoutant? Thanks for your patience.

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 21, 2016

@jeromecoutant Have you been able to reproduce it?

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 30, 2016

@jeromecoutant bump

@jeromecoutant
Copy link
Collaborator Author

Rebase and fix applied

Note about the fix:
Issue seems to be in mktime function which is calling at the first time __wrap__free_r

Only when MBED_HEAP_STATS_ENABLED is enabled, __wrap__free_r needs to initialize Singleton. This can be done only when IT are enabled...
rtc_read is called at each ticker setup which call core_util_critical_section_enter, which disables IT...

So to be sure that mktime is called at the first time while IT are enabled, rtc_read is called once once during init.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 9, 2017

Only when MBED_HEAP_STATS_ENABLED is enabled, __wrap__free_r needs to initialize Singleton. This can be done only when IT are enabled...
rtc_read is called at each ticker setup which call core_util_critical_section_enter, which disables IT...

So to be sure that mktime is called at the first time while IT are enabled, rtc_read is called once once during init.

Can you provide this info to the commit message. To me it's not clear this workaround, why it fails only when heap stats is enabled. Can't this be reproduced during a regular use ?

@bridadan
Copy link
Contributor

bridadan commented Jan 9, 2017

@jeromecoutant Does this need to be wrapped in #ifdef or can rtc_read just always be called without any adverse effects during the init? It'd be nice to try and reduce the amount of conditional behavior if we can I think.

@jeromecoutant
Copy link
Collaborator Author

Goal is to keep the code size unchanged for user, as this patch is only needed for CI test.

@bridadan
Copy link
Contributor

bridadan commented Jan 9, 2017

@jeromecoutant Ah good point! Can you fix the merge conflict please?

/* __wrap__free_r needs to initialize Singleton not in ISR */
/* rtc_read is called at each ticker setup which call core_util_critical_section_enter */
/* so rtc_read is called once once before other calls */
rtc_read();
Copy link
Contributor

Choose a reason for hiding this comment

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

If malloc or free get called on first call to rtc_read then this is a problem regardless of whether MBED_HEAP_STATS_ENABLED is set, and could lead to a crash. To make this implementation of lp ticker truly interrupt safe then the call to mktime needs to be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But malloc is not called if MBED_HEAP_STATS_ENABLED is not set...

Copy link
Contributor

Choose a reason for hiding this comment

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

I am with @c1728p9 . That function call should not be removed if stats are enabled as it has nothing in common with lp ticker or rtc read function. rtc_read is the one that causing the problems, that one should be changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jeromecoutant MBED_HEAP_STATS_ENABLED does not effect the number of calls to free or malloc, it just hooks those functions to record the number of calls.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 12, 2017

@jeromecoutant Can you remove/replace mktime invocation in the rtc api ?

@jeromecoutant
Copy link
Collaborator Author

Rebase done

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 13, 2017

To replace mktime ?

@jeromecoutant
Copy link
Collaborator Author

Hi
How can we replace mktime and still get a UNIX timestamp?
I can see several mktime call in rtc_read function from several platform vendors...

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 2, 2017

Back to this one. Having the code conditionally compiled based on stats flag is not acceptable. The root cause should be found. I do not fully understand why rtc_read() is causing problems and why is it placed in the lp_ticker init. There are platforms that use RTC peripheral for RTC and lp ticker and did not hit this problem.

We shall pull this code and run it locally to see the failure.

@sg- sg- removed the needs: CI label Feb 9, 2017
@jeromecoutant jeromecoutant deleted the PR_LPT_F4 branch March 6, 2017 10:25
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.

7 participants