-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix RISC-V configMTIMECMP_BASE_ADDRESS (64-bit) stored in 32-bit int #1176
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
Fix RISC-V configMTIMECMP_BASE_ADDRESS (64-bit) stored in 32-bit int #1176
Conversation
Related to FreeRTOS#189 Update `configMTIMECMP_BASE_ADDRESS` to be stored in a 64-bit integer. * Change the type of `ullMachineTimerCompareRegisterBase` to `uint64_t` in `portable/GCC/RISC-V/port.c`. * Change the type of `ullMachineTimerCompareRegisterBase` to `uint64_t` in `portable/IAR/RISC-V/port.c`. * Update the initialization of `ullMachineTimerCompareRegisterBase` to use `configMTIMECMP_BASE_ADDRESS` in both files.
Hello @vishwamartur, Thank you! |
@vishwamartur Would you please share how you tested these changes on 32-bit and 64-bit platforms as the same code is used on both the platforms. |
Thank you for the feedback! I haven’t tested these changes yet, as I currently lack access to a compatible platform for both 32-bit and 64-bit verification. If you have any suggestions for alternative testing methods or an emulator that could support this setup, I’d be glad to give it a try. Thanks again! |
|
I tested this change using Qemu and looks good to me. On a side note, I'd suggest to use the PR template as it guides you what all information to provide when creating a PR (which includes testing). |
This produces a compiler warning on 32-bit because it truncates a 64-bit integer into a pointer. FreeRTOS doesn't appear to have a type that can hold an integer with the same width as a pointer. |
Use architecture-dependent UBaseType_t instead of fixed type for ullMachineTimerCompareRegisterBase. This type is defined to uint32_t or uint64_t based on XLEN, resolving warnings on 32-bit platforms. Reported by landretk@ on the PR FreeRTOS#1176. Signed-off-by: Gaurav Aggarwal <[email protected]>
Thank you pointing this out. I agree that we should use UBaseType_t as it is defined correctly based on XLEN. Here is the PR to address this - #1258. Thank you again for bringing this to our attention. |
Use architecture-dependent UBaseType_t instead of fixed type for ullMachineTimerCompareRegisterBase. This type is defined to uint32_t or uint64_t based on XLEN, resolving warnings on 32-bit platforms. Reported by landretk@ on the PR #1176. Signed-off-by: Gaurav Aggarwal <[email protected]>
Related to #189
Update
configMTIMECMP_BASE_ADDRESS
to be stored in a 64-bit integer.ullMachineTimerCompareRegisterBase
touint64_t
inportable/GCC/RISC-V/port.c
.ullMachineTimerCompareRegisterBase
touint64_t
inportable/IAR/RISC-V/port.c
.ullMachineTimerCompareRegisterBase
to useconfigMTIMECMP_BASE_ADDRESS
in both files.