Skip to content

cpu/atmega_common: Use updated time.h#8857

Merged
kYc0o merged 5 commits into
RIOT-OS:masterfrom
ZetaR60:RIOT_atmega_time_dot_h
Jun 28, 2018
Merged

cpu/atmega_common: Use updated time.h#8857
kYc0o merged 5 commits into
RIOT-OS:masterfrom
ZetaR60:RIOT_atmega_time_dot_h

Conversation

@ZetaR60

@ZetaR60 ZetaR60 commented Mar 30, 2018

Copy link
Copy Markdown
Contributor

On the ATmega, functions like mktime and gmtime output garbage. There is a mismatch between some of the definitions in cpu/atmega_common/avr-libc-extra/time.h and avr-libc. I have removed this file so that the system header file can be used. There is a minor struct, not provided by time.h, that I moved. And the time_t typedef now conforms to avr-libc. See also: https://www.nongnu.org/avr-libc/user-manual/group__avr__time.html

Required by: #8842

@jnohlgard

Copy link
Copy Markdown
Member

I think the time.h header was added when avr-libc was missing support for it, I don't remember what version or how long ago that was, but it is a good idea to check that we are not breaking the build for users with a somewhat older avr-libc.

@ZetaR60

ZetaR60 commented Mar 31, 2018

Copy link
Copy Markdown
Contributor Author

I can confirm that many Linux distros do not have a new enough version of avr-libc to include time.h. I could simply update the file so that it matches the current avr-libc provided time.h.

@jnohlgard

Copy link
Copy Markdown
Member

I think that might be a better solution, until the distros catch up.

@ZetaR60

ZetaR60 commented Mar 31, 2018

Copy link
Copy Markdown
Contributor Author

Added time.h from avr-libc-2.0.0. I checked trunk for avr-libc as well, and its only differences from the 2.0.0 release are some comments.

@ZetaR60 ZetaR60 changed the title cpu/atmega_common: Use time.h from system's avr-libc cpu/atmega_common: Use updated time.h Mar 31, 2018
@ZetaR60

ZetaR60 commented Apr 1, 2018

Copy link
Copy Markdown
Contributor Author

Seems to be working well with the #8842 RTC code. The only other uses of time.h I have seen are relatively minor things in cpu/atmega_common/include/sys/stat.h and cpu/atmega_common/include/sys/time.h. Should be ready for CI build testing.

@ZetaR60 ZetaR60 force-pushed the RIOT_atmega_time_dot_h branch 2 times, most recently from 7bb336a to a2c12f7 Compare April 9, 2018 14:26
@ZetaR60

ZetaR60 commented Apr 9, 2018

Copy link
Copy Markdown
Contributor Author

Squashed. Please let me know if there is anything else that needs to be done on this PR.

@ZetaR60

ZetaR60 commented Apr 29, 2018

Copy link
Copy Markdown
Contributor Author

Tested and working with move from cpu/atmega_common/avr-libc-extras to cpu/atmega_common/include/vendor. This prevents CI from doing format checking of the header files (which are copies of avr-libc headers).

@ZetaR60 ZetaR60 mentioned this pull request May 16, 2018
24 tasks
@ZetaR60

ZetaR60 commented May 19, 2018

Copy link
Copy Markdown
Contributor Author

@gebart Is there anything else that is needed for this PR?

@jnohlgard jnohlgard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you move struct timespec to sys/time.h? The posix specification states that it should be defined in time.h

@ZetaR60

ZetaR60 commented May 19, 2018

Copy link
Copy Markdown
Contributor Author

vendor/time.h is an exact copy of the avr-libc-2.0.0 time.h, which didn't include timespec for whatever reason. Should I put it in the avr-libc time.h? It wouldn't be an exact copy anymore.

@jnohlgard

Copy link
Copy Markdown
Member

In RIOT we try to conform to standards as far as reasonable. Let's do it like this: create one commit where you import the avr-libc header with no changes, then create a separate commit where you add the struct definition. This way we can easily reapply the change if we update the header in the future.

@ZetaR60

ZetaR60 commented May 19, 2018

Copy link
Copy Markdown
Contributor Author

Done. Should be clear for future updaters now.

@jnohlgard jnohlgard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. I don't have any atmega boards available for testing. Which test application did you use when you discovered the issue you described in the original post about mktime etc?

@jnohlgard jnohlgard added Area: POSIX Area: POSIX API wrapper Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 19, 2018
@jnohlgard jnohlgard added this to the Release 2018.07 milestone May 19, 2018
@jnohlgard

Copy link
Copy Markdown
Member

tests/pkg_minmea is failing for avr now:

minmea.c: In function 'minmea_gettime':
minmea.c:630:19: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if (timestamp != -1) {
                   ^

@ZetaR60

ZetaR60 commented May 19, 2018

Copy link
Copy Markdown
Contributor Author

I caught this problem when testing tests/periph_rtc for #8842. It outputted garbage because time.h's tm struct defines did not match the assumptions of the code in avr-libc.

Unfortunately there are some compatibility issues with pkg_minmea and sys/timex due to avr-libc implementing non-standard types for time.h. I don't think this is fixable without rewriting those parts of avr-libc. I have blacklisted pkg_minmea and I am working on triage for sys/timex.

@ZetaR60 ZetaR60 force-pushed the RIOT_atmega_time_dot_h branch from da94924 to 73a656f Compare May 19, 2018 16:03
@ZetaR60

ZetaR60 commented May 19, 2018

Copy link
Copy Markdown
Contributor Author

Rebased on trunk to resolve merge conflicts.

@ZetaR60

ZetaR60 commented May 19, 2018

Copy link
Copy Markdown
Contributor Author

I think I have put out all the fires (there were only small ones). Let me know when to squash.

@ZetaR60

ZetaR60 commented May 24, 2018

Copy link
Copy Markdown
Contributor Author

@gebart Squash?

@smlng

smlng commented May 28, 2018

Copy link
Copy Markdown
Member

yes, please squash

@ZetaR60 ZetaR60 force-pushed the RIOT_atmega_time_dot_h branch from 73a656f to bd15ed2 Compare May 28, 2018 17:10
@ZetaR60

ZetaR60 commented May 28, 2018

Copy link
Copy Markdown
Contributor Author

Squashed and double checked with tests/periph_rtc using #8842. Everything is working fine and ready to go.

@kYc0o

kYc0o commented Jun 28, 2018

Copy link
Copy Markdown
Contributor

Looks OK and it's already ACKed, so let's merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: POSIX Area: POSIX API wrapper CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants