Skip to content

Conversation

@watsk
Copy link
Contributor

@watsk watsk commented Mar 22, 2024

[WIN32-MingW Demo] TickType_t width is defined based on compiler type.(32bit/64bit)

Description

32bit TickType_t is used if compiler is MinGW32. 64bit TickType_t is used if compiler is MinGW64.

[Reason of change]
Before this change, 32bit TickType_t was always used in MinGW demo. It was inefficient for 64bit compiler. In addition, MinGW64 reported warnings for the cast operation between TickType_t and void * pointer because of different width. 64bit TickType_t should be used instead of 32bit if compiler is 64bit.

[Additional change]
Even if 64bit TickType_t is used, MinGW64 still reported warnings for the cast operation between 32bit variable and pointer type. To solve that, uint32_t has been replaced by UBaseType_t in some functions and %u has been replaced by %llu in printf().

[Related forum topic]
This PR is derived by the following topic in the forum.
64bit application on FreeRTOS windows port

[Limitation]
There are still same warnings in TraceRecorder module because 32bit variables are used as address there. They cannot be modified because TraceRecorder is out of FreeRTOS.

Test Steps

  1. Build WIN32-MingW Demo by MinGW64 on Debug configuration and on Debug_CodeCoverage configuration.

  2. Confirm there is no warning for the cast operation. (Except for TraceRecorder)

  3. Run executable on both configurations.

  4. Confirm they are running successfully.

  5. Confirm code coverage is kept after change.

  6. Those tests are performed by also MinGW32 as regression tests.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

If this PR is accepted, I will send another PR for similar changes for MSVC-Demo.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

watsk added 5 commits March 22, 2024 21:29
…ype.(32bit/64bit)

32bit TickType_t is used if compiler is MinGW32. 64bit TickType_t is used if compiler is MinGW64.

Reason of change: Before this change, 32bit TickType_t is always used in MinGW demo. It is inefficient  for 64bit compiler. In addition, MinGW64 reported warnings for the cast operation between TickType_t and (void *) pointer because of different width. 64bit TickType_t should be used instead of 32bit if compiler is 64bit.
Reason of change: %u specifier corrupts 64bit tick count because it supports only 32bit value. %llu can be used for both of 64bit value and 32bit value.(After casting to 64bit)
…seType_t.

Reason of change: These variables are cast to/from pointer type in existing codes. 64bit compiler(MinGW64) reports warnings for the cast operations between uint32_t and pointer type. UBaseType_t solves those warnings because it has same width as pointer type on both of MinGW32 and MinGW64.
…seType_t.

Same change as previous commit is applied to source codes which are built only on Debug configuration.
…havior is not changed. Reason of change is to follow coding style guide of FreeRTOS.
@watsk watsk requested a review from a team as a code owner March 22, 2024 14:24
@ActoryOu
Copy link
Member

Hi @watsk,
Thanks for your contribution!
There is a CI failing in 32bit MingW. Could you please check if that matches your expectation?

Thank you.

@watsk
Copy link
Contributor Author

watsk commented Mar 23, 2024

@ActoryOu
Thank you for telling me about about build failure.
I found that FreeRTOS/Source submodule(FreeRTOS-kernel) is too old and it makes build failure.
This PR depends on the recent FreeRTOS-kernel update. (FreeRTOS-kernel #1011)
I was testing this PR on the latest FreeRTOS-kernel.

Can I update submodule in this PR? Or should submodule be updated on another PR separately?

@ActoryOu
Copy link
Member

@ActoryOu Thank you for telling me about about build failure. I found that FreeRTOS/Source submodule(FreeRTOS-kernel) is too old and it makes build failure. This PR depends on the recent FreeRTOS-kernel update. (FreeRTOS-kernel #1011) I was testing this PR on the latest FreeRTOS-kernel.

Can I update submodule in this PR? Or should submodule be updated on another PR separately?

Hi @watsk,
Yes, if updating submodule is couple with your change, they should be put together in same PR. Feel free to update this PR with the change.

Thanks for your contribution!

…UBaseType_t.

Additional modification for solving compiler warnings for the cast operation on MinGW64.
@watsk
Copy link
Contributor Author

watsk commented Mar 25, 2024

@ActoryOu
Thank you for your kind explanation.
I updated FreeRTOS-kernel submodule to the latest revision. It is newer than the revision which I actually need but I thought the latest one is better.
I also sent one more change because I found that type modification should be applied to one more variable.
I'm sorry for that I have uploaded insufficient changes at first.

@watsk
Copy link
Contributor Author

watsk commented Mar 26, 2024

@ActoryOu
Thank you for merging main into this branch and running CI check.
CI check failed on "verify-manifest" step. Then, I modified manifest.yml.
I didn't know manifest.yml should be updated when submodule is updated.
Could you run CI check again?

@watsk
Copy link
Contributor Author

watsk commented Mar 26, 2024

@ActoryOu
I modified prefix of variables because I found my modification does not follow coding style guide.
I confirmed demo application is built and run successfully as "full demo Debug" and "blinky demo Debug" and "Debug_CodeCoverage" on both of MinGW32 and MinGW64.

aggarg and others added 2 commits March 27, 2024 12:13
@ActoryOu
Copy link
Member

@watsk,
Sorry for late response. I was occurpied by other tasks for a few days.
Thanks for your contribution. It now looks good to me.

@ActoryOu ActoryOu merged commit 076430b into FreeRTOS:main Mar 27, 2024
@watsk
Copy link
Contributor Author

watsk commented Mar 27, 2024

@aggarg, @ActoryOu
Thank you for reviewing and correcting code to follow style guide.
I'm happy to know this PR has been accepted.

@aggarg
Copy link
Member

aggarg commented Mar 28, 2024

@watsk Thank you for your contribution!

Zangetsu112 pushed a commit to Zangetsu112/FreeRTOS-evpp that referenced this pull request Aug 18, 2025
….(32bit/64bit) (FreeRTOS#1199)

* [WIN32-MingW Demo] Add tick type width definition based on compiler type.(32bit/64bit)
32bit TickType_t is used if compiler is MinGW32. 64bit TickType_t is used if compiler is MinGW64.

Reason of change: Before this change, 32bit TickType_t is always used in MinGW demo. It is inefficient  for 64bit compiler. In addition, MinGW64 reported warnings for the cast operation between TickType_t and (void *) pointer because of different width. 64bit TickType_t should be used instead of 32bit if compiler is 64bit.

* [WIN32-MingW Demo] Change printf() format specifiers from %u to %llu.

Reason of change: %u specifier corrupts 64bit tick count because it supports only 32bit value. %llu can be used for both of 64bit value and 32bit value.(After casting to 64bit)

* [WIN32-MingW Demo] Change type of some variables from uint32_t to UBaseType_t.

Reason of change: These variables are cast to/from pointer type in existing codes. 64bit compiler(MinGW64) reports warnings for the cast operations between uint32_t and pointer type. UBaseType_t solves those warnings because it has same width as pointer type on both of MinGW32 and MinGW64.

* [WIN32-MingW Demo] Change type of some variables from uint32_t to UBaseType_t.

Same change as previous commit is applied to source codes which are built only on Debug configuration.

* [WIN32-MingW Demo] Add brackets to the condition in #if statement. Behavior is not changed. Reason of change is to follow coding style guide of FreeRTOS.

* Update "FreeRTOS/Source" submodule(FreeRTOS-kernel) to FreeRTOS#1008.

* [WIN32-MingW Demo] Change type of one more variable from uint32_t to UBaseType_t.

Additional modification for solving compiler warnings for the cast operation on MinGW64.

* Update FreeRTOS-kernel submodule version in manifest.yml.

* Modify prefix of variables to follow coding style guide.

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: ActoryOu <ousc@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants