Mbed-os: RTC tests should start from year 2000+

Created on 10 May 2018  路  7Comments  路  Source: ARMmbed/mbed-os

Description

While running RTC tests on a new platform that is coming, we realized that certain RTC tests are causing problems because are expecting the MCU to handle old years correctly, for example, 1970.

See:
https://github.com/ARMmbed/mbed-os/blob/master/TESTS/mbed_hal/rtc_time_conv/main.cpp
https://github.com/ARMmbed/mbed-os/blob/master/TESTS/mbed_hal/rtc_time/main.cpp#L58

These dates are not supported in all MCUs. They are not applicable anymore given we are in 2018.

This enhancement/bug fix request is to relax RTC tests to start from the year 2000 onwards.

[ ] Question
[X] Enhancement
[X] Bug

@bulislaw @Przemek

closed_in_jira drivers mirrored bug

All 7 comments

Internal reference: IOTMORF-2349

Which boards can't handle UNIX timestamps? I actually don't get how it works or doesn't work... if you write 0 they treat it as year 2000? That sounds like it can cause problems... I mean they should just increment whatever is in the register and it's up to the system to do the conversion.

Details in internal ticket.

@mprse Please review

As per internal conversation with @bulislaw

The HW is handling years in BCD.

Our RTC spec is working in seconds from epoch and that's what they will get anyway. So in their implementation, they will need to handle the conversion from sec to their date in BCD, they can handle base manipulation internally. Very quick pseudocode with workaround.

// rtc_write(0); /* setting time to 1970-01-01 00:00:00 */
--
time_t base;
聽
void rtc_write(time_t t)
{
base = first_addressable_date - t;
bcd_t bcd_data = seconds_to_bcd(t - base)
write_to_hw(bcd_data);
}
聽
time_t rtc_read(void)
{
bcd_t bcd_data = read_from_hw();
time_t t = bcd_to_seconds(bcd_data);
聽
return t + base;
}

@0xc0170 I'd suggest we set the appropriate labels and close this ticket. Thanks!

Thanks for the update. I'll close this ticket as resolved, given the snippet above should help to fix the problem.

ARM Internal Ref: MBOTRIAGE-42

Was this page helpful?
0 / 5 - 0 ratings