Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USBPD Analyzer often lags with I2C timeout #53

Open
tom-van opened this issue Jan 26, 2025 · 3 comments
Open

USBPD Analyzer often lags with I2C timeout #53

tom-van opened this issue Jan 26, 2025 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers internal bug tracker Issue confirmed and logged into the internal bug tracking system projects Projects-related (demos, applications, examples) issue or pull-request. usb-pd USB Power-Delivery-related issue or pull-request

Comments

@tom-van
Copy link

tom-van commented Jan 26, 2025

Two FreeRTOS threads call at least BSP_PWRMON_GetVoltage() without locking I2C by a mutex.
When another I2C operation is re-entered while the first one is not finished, I2C fails and waits till 3 sec timeout.
Mainly happens at

BSP_PWRMON_GetVoltage(ALERT_VBUS, &_vbusVoltage);

Mutex guarded version BSP_USBPD_PWR_VBUSGetVoltage() should be used instead of BSP_PWRMON_GetVoltage(ALERT_VBUS, ...).
Similarly BSP_USBPD_PWR_VBUSGetCurrent() should replace BSP_PWRMON_GetCurrent(ALERT_VBUS, ...).
Also other I2C should be guarded similarly, e.g. BSP_PWRMON_GetVoltage(ALERT_CC1 / ALERT_CC2 ...) but there is no direct replacement in BSP_USBPD_PWR_ module.

@ALABSTM ALABSTM self-assigned this Jan 27, 2025
@ALABSTM ALABSTM added enhancement New feature or request usb-pd USB Power-Delivery-related issue or pull-request projects Projects-related (demos, applications, examples) issue or pull-request. labels Jan 27, 2025
@ALABSTM
Copy link
Contributor

ALABSTM commented Jan 30, 2025

Hi @tom-van,

Your point looks relevant. Let's ask the development teams and see their feedback.

With regards,

@ALABSTM ALABSTM moved this from To do to Analyzed in stm32cube-mcu-fw-dashboard Jan 30, 2025
@ALABSTM ALABSTM added bug Something isn't working good first issue Good for newcomers and removed enhancement New feature or request labels Jan 30, 2025
@ALABSTM
Copy link
Contributor

ALABSTM commented Jan 30, 2025

ST Internal Reference: 201898

@ALABSTM ALABSTM added the internal bug tracker Issue confirmed and logged into the internal bug tracking system label Jan 30, 2025
@tom-van
Copy link
Author

tom-van commented Jan 30, 2025

After writing this issue I found that in spy mode the mutex is probably not initialized and therefore BSP_USBPD_PWR_VBUSGetVoltage() doesn't work. I fixed the problem using condition similar to

if (hmode != MODE_SPY)
BSP_USBPD_PWR_VBUSGetVoltage(0, &_vbusVoltage);
else
BSP_PWRMON_GetVoltage(ALERT_VBUS, &_vbusVoltage);

however I didn't go to the depth code to find if mutex locking is or isn't necessary in spy mode. Perhaps collisions are not so frequent in spy mode. I would recommend use a mutex always.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers internal bug tracker Issue confirmed and logged into the internal bug tracking system projects Projects-related (demos, applications, examples) issue or pull-request. usb-pd USB Power-Delivery-related issue or pull-request
Projects
Development

No branches or pull requests

2 participants