arduino / arduino/ArduinoCore-samd
Random hang at SERCOM.cpp:526
- Dominant language
- C
- Stars
- 502
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to set up multi-master I2C communication on board running an ATSAMD21G18 (2 masters and slave so far) with this code: [https://github.com/kb-/Arduino-I2C-2way-anydata/tree/dd5597835c9a8a89ff23cc17605bb6f59faa5699](url)
One of the masters randomly hangs after a large number of transfers (around 70 000 on average), always at line 526 of SERCOM.cpp
The same behavior occurred on 5 different boards I tried, 2 different models.
I'm getting this in the backtrace but can't figure out what's wrong :
> (gdb) bt
#0 0x0000331a in SERCOM::sendDataMasterWIRE (
this=this@entry=0x20000300 , data=)
at /home/oe/.arduino15/packages/misfittech/hardware/samd/1.0.0/cores/arduino/SERCOM.cpp:526
#1 0x0000275a in TwoWire::endTransmission (this=this@entry=0x2000018c ,
stopBit=stopBit@entry=true)
at /home/oe/.arduino15/packages/misfittech/hardware/samd/1.0.0/libraries/Wire/Wire.cpp:134
#2 0x00002784 in TwoWire::endTransmission (this=this@entry=0x2000018c )
at /home/oe/.arduino15/packages/misfittech/hardware/samd/1.0.0/libraries/Wire/Wire.cpp:151
#3 0x0000224c in loop ()
at /home/oe/sketchbook/Master_test_i2c_data2/Master_test_i2c_data2.ino:81
#4 0x00003846 in main ()
at /home/oe/.arduino15/packages/misfittech/hardware/samd/1.0.0/cores/arduino/main.cpp:46
It doesn't occur with one master only (4 000 000 successful transfers).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with SERCOM.cpp:526 and the calls from Wire.cpp:134, using the multi-master example linked in the issue. Reproduce the hang with the Master_test_i2c_data2.ino loop and compare it with the one-master case. Done means identifying the multi-master failure and preventing the transfer from hanging, with the reproduction scenario covered by a test or documented verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100