Skip to content

Conversation

@vaussard
Copy link
Contributor

On STM32L4, a NACK on the I2C bus triggers an I2C event interrupt (see
for example Figure 420 in the STM32L4x6 TRM). But the current logic
expects an I2C error interrupt. As a result, the NACK interrupt is
not acknowledged and leads to an IRQ storm which freezes the system.

Factorize the NACK handling code to share it between event and error
ISRs, then call it from the event ISR if we compile for STM32L4.

@vaussard vaussard requested a review from ydamigos as a code owner May 17, 2018 13:36
@codecov-io
Copy link

codecov-io commented May 17, 2018

Codecov Report

Merging #7626 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7626      +/-   ##
==========================================
+ Coverage   55.31%   55.32%   +<.01%     
==========================================
  Files         470      470              
  Lines       51913    51913              
  Branches     9923     9923              
==========================================
+ Hits        28718    28719       +1     
+ Misses      19270    19269       -1     
  Partials     3925     3925
Impacted Files Coverage Δ
lib/posix/pthread.c 69.84% <0%> (+0.5%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad6b890...2252e36. Read the comment docs.

@erwango erwango added the platform: STM32 ST Micro STM32 label May 17, 2018
Copy link
Contributor

@ydamigos ydamigos left a comment

Choose a reason for hiding this comment

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

Actually, NACK is an I2C event interrupt for all series supported by i2c_ll_stm32_v2. We just need to move NACK handling code to event ISR.

On STM32F0/F3/L0/L4, a NACK on the I2C bus triggers an I2C event
interrupt. But the current logic expects an I2C error interrupt.
As a result, the NACK interrupt is not acknowledged and leads to
an IRQ storm which freezes the system.

Move the NACK handling code to the event ISR.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
@vaussard vaussard force-pushed the i2c_stm32_nack_on_l4 branch from be1c05a to 2252e36 Compare May 18, 2018 06:13
@vaussard
Copy link
Contributor Author

Actually, NACK is an I2C event interrupt for all series supported by i2c_ll_stm32_v2. We just need to move NACK handling code to event ISR.

Indeed, this is the case on STM32F0/F3/L0/L4. I moved the NACK handling to the event ISR and updated the commit message accordingly.

@ydamigos
Copy link
Contributor

Now that we handle NACK in event ISR the if (LL_I2C_IsActiveFlag_NACK(i2c)) block in stm32_i2c_combined_isr could be removed. What do you think?

data->current.is_nack = 1;
} else {
data->current.is_err = 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not seem to be in the right place in the event handler, it should be handled before looking at the message it self.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vaussard Here is the Linux implementation of the same IP (STM32F7 uses the same i2c IP) https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-stm32f7.c#L670

@aurel32
Copy link
Contributor

aurel32 commented Jul 4, 2018

@vaussard , this bug has been fixed as part of PR #5224, more precisely in commit 81cfdec. I confirm it works fine with an STM32F7 SoC. If you can confirm the issue is also fixed in your case, I guess this PR can just be closed.

@vaussard
Copy link
Contributor Author

vaussard commented Jul 5, 2018

Indeed, commit 81cfdec should also fixe the issue. Closing this PR, I did not had a lot of time to work on it anyway.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants