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

FreeRTOS Runtime Counter support. (IDFGH-12057) #13120

Closed
3 tasks done
ammaree opened this issue Feb 6, 2024 · 4 comments
Closed
3 tasks done

FreeRTOS Runtime Counter support. (IDFGH-12057) #13120

ammaree opened this issue Feb 6, 2024 · 4 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@ammaree
Copy link

ammaree commented Feb 6, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.3-dev-1922-g5454d37d49

Espressif SoC revision.

All ESP32 I believe

Operating System used.

macOS

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

N/A

Power Supply used.

USB

What is the expected behavior?

Valid useable runtime information being returned.

What is the actual behavior?

Runtime counter support is inconsistent and largely invalid.

Steps to reproduce.

https://vscode.dev/github/espressif/esp-idf/blob/master/components/freertos/esp_additions/freertos_tasks_c_additions.h#L488
Should be using 'configRUN_TIME_COUNTER_TYPE' to support both u32_t and u64_t

https://vscode.dev/github/espressif/esp-idf/blob/master/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h#L521-L522
We are using a 32 bit data source (with 12.5nSec resolution here) so the value will wrap every minute?

https://vscode.dev/github/espressif/esp-idf/blob/master/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h#L523
We are using an int64_t data source (already not ideal, u64_t preferred) and then casting it to a uint32_t?

It is quite possible that there are more locations where configRUN_TIME_COUNTER_TYPE is not used, or where the source data is not valid.

Debug Logs.

No response

More Information.

No response

@ammaree ammaree added the Type: Bug bugs in IDF label Feb 6, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 6, 2024
@github-actions github-actions bot changed the title FreeRTOS Runtime Counter support. FreeRTOS Runtime Counter support. (IDFGH-12057) Feb 6, 2024
@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels Feb 7, 2024
@o-marshmallow
Copy link
Collaborator

Hello @ammaree ,

Thank you for noticing this, we are going to look into this and fix it

@ammaree
Copy link
Author

ammaree commented Feb 14, 2024

@o-marshmallow
The solution is very simple.

In components/freertos/esp_additions/freertos_tasks_c_additions.h:

488: - uint32_t ulRunTimeCounter;
488: + configRUN_TIME_COUNTER_TYPE ulRunTimeCounter;

in components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:

523: - #define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0)
523: + #define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (configRUN_TIME_COUNTER_TYPE)esp_timer_get_time();} while(0)

Have tested this fix over last week on many different hardware platforms, works 100%

Maybe possible to get the fix through ASAP...

@ammaree
Copy link
Author

ammaree commented Apr 5, 2024

@o-marshmallow

+99 for fixing this, only requires the 2 lines above to restore proper functioning.

Please

@KonstantinKondrashov
Copy link
Collaborator

Hi @ammaree!
Thanks for the help with it. I created an MR with these changes.

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed and removed Status: Selected for Development Issue is selected for development Status: In Progress Work is in progress labels Apr 9, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Reviewing Issue is being reviewed labels Apr 18, 2024
espressif-bot pushed a commit that referenced this issue Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

5 participants