Hi @yoji sato san, we confirmed that this was a bug in the code that requires a fix. We have planned to fix that in our next release. Many thanks for reporting that. Also please let us know if this problem impacts on your project so that we can provide some patch code for you as an interim solution.
Does time management in the Azure RTOS IoT HUB sample cause a Year 2038 problem?
Currently, we are evaluating the communication with IoT HUB of Azure with AzureRTOS
by referring to the following sample project.
Azure_RTOS_6.1_Renesas_RX65N_RSK_2MB_e2studio_CCRX_Sample_2021_11_19.zip
sample_azure_iot_embedded_sdk
In the above implementation, the system time is synchronized by SNTP, and it seems that
it operates based on the time in seconds acquired there, but the time information seems
to be 32 bits.
Won't this cause the Year 2038 problem?
1 additional answer
Sort by: Most helpful
-
Bo Chen 596 Reputation points Microsoft Employee
2022-04-21T09:28:31.35+00:00 Hi @yoji sato As NTPv3 timestamps are represented as a 64-bit unsigned number in seconds relative to 00:00:00 UTC on 1 January 1900. The integer part is in the first 32bits (136 years), so the time for NTP will overflow in 2036 (1900 + 136). The time in middleware will overflow in 2106 (1970 + 136) since it uses Unix time.
Two options for product.
- If you have another way to get/sync the time, you may use it instead of SNTP in sample.
- If your device has OTA feature, you are able to use SNTPv3 to sync the time for now, once we have the NTPv4 (I believe we will add NTPv4 in future), you may update the firmware to use NTPv4 to sync.
Some information for reference as below:
Unix time: it is the number of seconds that have elapsed since the Unix epoch, excluding leap seconds, the Unix epoch is 00:00:00 UTC on 1 January 1970.
NTP time: it is the number of seconds elapsed since the Unix epoch (00:00:00 UTC on 1 January 1900).
NTPv3 Timestamp Format : 32-bit for seconds, 32-bit for fraction,
NTPv4 Data Types: There is a 128-bit date format, the 128-bit date format includes a 64-bit signed seconds field spanning 584 billion years and a 64-bit fraction field.