Skip to content

cpu/samd21: i2c timing with compiler optimization #5460

@PeterKietzmann

Description

@PeterKietzmann

The i2c driver for samd21 CPUs has timing problems with the standard compiler optimization -Os. The optimization level for this CPU was enabled in #2848. It seems that e.g. this code line is not executed which may lead to collisions on the bus. In my case I got stuck using tests/drivers_tmp006 with an Atmel samr21-xpro and an external tmp006 sensor. As a bugfix I see two alternatives (for now):

  1. Disable size optimisation for samd21 again by reverting cpu/samd21: set optimization level to -Os #2848
  • PRO: Who knows where else it introduced failures?
  • CON: Huge code sizes
   text    data     bss     dec     hex filename
  15516     128    2792   18436    4804 ...samr21-xpro/driver_tmp006.elf
  1. Stay with -Os and use puts() instead of DEBUG() at critical parts (as shown above)
  • PRO: Smaller code sizes; Does not hurt in this case; Improves current situation
  • CON: Seems a bit like a random solution; Probably compiler dependant?; Similar bugs in other drivers possible
   text    data     bss     dec     hex filename
  10236     128    2792   13156    3364 ...samr21-xpro/driver_tmp006.elf

BTW: I used gcc version 5.2.1 20151202 (release) [ARM/embedded-5-branch revision 231848]

What's your opinion?

Metadata

Metadata

Assignees

Labels

Area: driversArea: Device driversDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRState: archivedState: The PR has been archived for possible future re-adaptationType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions