STMicroelectronics / stm32g4xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32G4 series.
BSD 3-Clause "New" or "Revised" License
14 stars 9 forks source link

I2C Hal driver in DMA mode is broken #8

Closed olliw42 closed 7 months ago

olliw42 commented 8 months ago

Describe the set-up

Describe the bug When using the I2C hal driver with DMA the communication to an OLED display doesn't work. When using the I2C driver in IT mode the display works fine. The project firmware is found here https://github.com/olliw42/mLRS and the board schematics here https://github.com/olliw42/mLRS-hardware/tree/master/olliw-stm32-based/tx-module-02, if this should be of any help.

Tests have confirmed that the issue is specifically related to the I2C hal driver, that is, is located in the file stm32g4xx_hal_i2c.c

The board including OLED was working fine since ca 1.5 years, up to using commit @75ce54b. The issue appeared recently with upgrading to commit @74ce67c, and remains also after upgrading to the latest commit @7c2e15e. Downgrading back to @75ce54b resolves the issue.

RJMSTM commented 7 months ago

Hello @olliw42 ,

Why you said the problem appeared from the commit @74ce67c and this is a commit for RCC IP?? image

Thanks, Rania

olliw42 commented 7 months ago

thx for looking at it

Why you said the problem appeared from the commit @74ce67c and this is a commit for RCC IP??

The missunderstanding here is that I didn't said what you say I said. I did not say that it appeared from commit @74ce67c. The info I have given implies that the issue occured anywhere from @75ce54b to @74ce67c.

RJMSTM commented 7 months ago

Hello @olliw42 ,

I have test an example I2C_TwoBoards_ComDMA with commit @75ce54b to @74ce67c and example works fine, image

image

HAL_I2C_Master_Transmit_DMAand HAL_I2C_Slave_Transmit_DMAAPI return ok.

Please can you give me details in which API your check the problem.

Many Thanks, Rania

olliw42 commented 7 months ago

I'm afraid I cannot give you the desired details, as I haven't investigated the problem in that deep detail, and I frankly also don't have sufficient deep knowledge on the inner working of the HAL library to make a comment on this (I mean, that's the reason why one uses them, to get ready to go canned code).

All I can refer to is the project in which it is used, and link you to the code used there

The symptom is that OLED display just shows snow, it appears as if the first i2c transfer is just never properly copmpleted.

I suspect the issue comes from changes in the ISR handling brought in by the latest commits, but that's really just a speculation.

As said, when not using DMA mode it all works fine, so the issue is related to using DMA.

I'm sorry I can't be more helpfull than that, As said, I do lack the intimate knowledge on the inner working of the HAL driver.

RJMSTM commented 7 months ago

Hello @olliw42,

We were unable to reproduce your issue, I2c driver work fine in DMA mode. However, the point you reported is not directly related to the firmware published in this repository and we don't treat aspect related to user application in our GitHub repositories. They are rather treated at ST Community level.

Now, as this issue is not directly related to some software component published within this repository (CMSIS, HAL, BSP, etc.) but rather to a user application, please allow me to close it.

Thank you for your comprehension, sorry we will not be able to help you more, we are looking forward to reading from you again.

With regards, Rania

olliw42 commented 7 months ago

@RJMSTM many thx for having taken your time and having looked at it. I understand your reasoning, but am also a bit confused as regards the conclusion it's an issue in the user code, given that the user code works perfectly fine with the earlier driver but not with the latest. It would mean that the user code has a bug which exactly compensates for a bug in the earlier driver, and this so only fopr the g4 but not e.g. f1,f3l0, which while not impossible looks unlikely. Anyway, as said, I understand your reasoning, and like to thank you again for your efforts.