Skip to content

Conversation

@julianuziemblo
Copy link
Contributor

@julianuziemblo julianuziemblo commented Oct 15, 2025

clang-format-diff and codespell checked locally to be passing because of the PR's size

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: armv7m7-imxrt117x-evk, armv7a7-imx6ull-dataro

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

@gemini-code-assist
Copy link

Summary of Changes

Hello @julianuziemblo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the hardware support by integrating the CYW4373E USB WiFi modem. It introduces a new USB HAL driver and a message buffer protocol for the Wireless Host Driver, alongside refactoring the existing bus communication architecture. These changes aim to improve modularity, efficiency, and adaptability to different WiFi interfaces and firmware capabilities.

Highlights

  • CYW4373E USB WiFi Modem Support: Introduced comprehensive support for the CYW4373E USB WiFi modem, enabling new hardware capabilities.
  • USB HAL Driver Implementation: Added a new Hardware Abstraction Layer (HAL) driver for USB (cyhal_usb.c, cyhal_usb.h) to manage USB device interactions.
  • Message Buffer Protocol Integration: Integrated a message buffer protocol into the Wireless Host Driver (WHD) bus protocols, enhancing communication efficiency and flexibility. This includes new files like whd_commonring.c, whd_flowring.c, whd_msgbuf_txrx.c, and whd_ring.c.
  • RTOS Queue Functionality: Implemented new queue functionalities within cyabs_rtos.c and cyabs_rtos.h, providing robust inter-thread communication mechanisms.
  • WHD Protocol Abstraction: Refactored existing bus protocols (whd_cdc_bdc.c, whd_cdc_bdc.h) to utilize a new whd_proto structure, introducing a more abstract and extensible protocol layer.
  • Firmware Capability Reading: Added functionality to read firmware capabilities, allowing the host to dynamically adapt to features supported by the WiFi firmware.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link

Summary of Changes

Hello @julianuziemblo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the hardware compatibility of the WiFi stack by integrating support for the CYW4373E USB WiFi modem. It involves a substantial architectural overhaul of the Wireless Host Driver (WHD) to introduce a flexible protocol layer capable of handling various bus types, including the newly added USB. This change ensures that the system can seamlessly communicate with WiFi modules over different interfaces, improving adaptability and future-proofing the driver.

Highlights

  • CYW4373E USB WiFi Modem Support: Introduced comprehensive support for the CYW4373E USB WiFi modem, including a new USB Hardware Abstraction Layer (HAL) driver.
  • WHD Bus Protocol Refactoring: Refactored the Wireless Host Driver (WHD) architecture to support multiple bus protocols (SDIO, SPI, M2M, USB) through a new whd_proto layer, enhancing modularity and extensibility.
  • New WHD Components: Added new WHD files for common ring, flow ring, and message buffer handling (whd_commonring.c, whd_flowring.c, whd_msgbuf_txrx.c, whd_ring.c, whd_trxhdr.h) to facilitate the new protocol layer.
  • Queue Functionality in RTOS HAL: Implemented queue functionalities (cy_rtos_queue_init, cy_rtos_queue_put, cy_rtos_queue_get, etc.) and new error codes (CY_RTOS_QUEUE_FULL, CY_RTOS_QUEUE_EMPTY) within the cyabs_rtos HAL.
  • Conditional Compilation Enhancements: Extensively utilized conditional compilation (#ifndef PROTO_MSGBUF, #ifdef BLHS_SUPPORT, #ifdef CYCFG_ULP_SUPPORT_ENABLED) across various files to manage different bus interface types and features.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the CYW4373E USB WiFi modem, which involves adding a new USB HAL implementation and refactoring the WHD layer for multiple bus protocols. The changes are extensive and well-structured. My review has identified a few critical issues in the new cyhal_usb.c and cyabs_rtos.c files, including a logic error in a queue reset function, incorrect loop conditions, and potential infinite loops in error handling. Addressing these points will improve the robustness and correctness of the new USB WiFi support.

@gemini-code-assist
Copy link

Summary of Changes

Hello @julianuziemblo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the hardware compatibility of the WiFi driver by adding full support for the CYW4373E USB WiFi modem. The changes involve creating a dedicated USB HAL driver, seamlessly integrating it into the existing Wireless Host Driver (WHD) architecture, and introducing a flexible protocol abstraction layer. This refactoring allows for easier adoption of different communication protocols (like message buffers) and enhances the overall robustness and maintainability of the WiFi stack.

Highlights

  • CYW4373E USB WiFi Modem Support: Introduced comprehensive support for the CYW4373E USB WiFi modem, including a new USB Hardware Abstraction Layer (HAL) driver and its integration into the Wireless Host Driver (WHD) framework.
  • Protocol Abstraction Layer: Implemented a generic protocol abstraction layer (whd_proto) to handle both CDC/BDC and message buffer protocols, improving modularity and extensibility of the WiFi driver.
  • RTOS Queue Management: Enhanced the RTOS abstraction layer with new queue functionalities, including initialization, enqueue/dequeue operations, and related error codes, improving inter-thread communication.
  • Build System and Core WHD Updates: Updated the build system (Makefile) and core WHD components to accommodate the new USB interface, conditionally compiling SDIO-specific code and integrating new message buffer protocol files.
  • Chip-Specific Constants and Functionalities: Modified various chip-specific constants and functionalities, including chanspec definitions, NVRAM download addresses, and WPA3 security support in the AP mode.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the CYW4373E USB WiFi modem. The changes are extensive, including a new USB Hardware Abstraction Layer (HAL), a new message buffer protocol, and modifications across the codebase to integrate the new USB interface type. While the overall approach seems sound, I've identified a few critical issues in the new USB HAL implementation that could lead to system lock-ups. There are also some bugs and documentation inconsistencies in the new RTOS queue abstraction that should be addressed. Additionally, I've pointed out the use of a magic number that should be replaced with a named constant for better code clarity and maintainability.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the CYW4373E USB WiFi modem. The changes are extensive, touching many files to introduce the USB interface and adapt the existing code to be bus-agnostic. New HAL files for USB are added, and existing HAL and WHD files are refactored.

I've found a few issues, including a critical bug in the new queue implementation, and several high-severity issues in the new USB HAL implementation related to memory management, potential infinite loops, and uninitialized variables. There are also some medium-severity issues regarding busy-wait loops. Please see my detailed comments.

@github-actions
Copy link

github-actions bot commented Oct 15, 2025

Unit Test Results

9 462 tests  ±0   8 873 ✅ ±0   51m 14s ⏱️ +9s
  561 suites ±0     589 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 9eaa89e. ± Comparison against base commit 7479440.

♻️ This comment has been updated with latest results.

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch from a526315 to a1076ba Compare October 15, 2025 13:50
@julianuziemblo
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the CYW4373E USB WiFi modem. This is a significant feature addition, introducing a new USB interface type alongside the existing SDIO, SPI, and M2M interfaces. The changes include a new USB HAL implementation (cyhal_usb.c), updates to Makefiles, and modifications to existing HAL and BSP files to accommodate the new interface. Additionally, a lock-free SPSC queue implementation has been added to cyabs_rtos.c.

My review focuses on the new code. I've found a few issues in the new queue implementation in cyabs_rtos.c and in the new USB HAL in cyhal_usb.c. Specifically, the queue item counting and space calculation logic is incorrect, and the USB bulk send function does not handle short writes, which could lead to data loss. I've provided suggestions to fix these issues. The rest of the changes for integrating the USB support look good and are well-structured.

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch from a1076ba to 47e0e75 Compare October 15, 2025 15:09
@julianuziemblo
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the CYW4373E USB WiFi modem, which involves significant changes across the HAL, WHD, and LwIP port layers. The changes include adding a new USB HAL implementation, refactoring the bus protocol layer to support USB, and updating various files to accommodate the new hardware and protocol. Overall, the changes are well-structured, but I've identified a few issues related to potential bugs, code correctness, and maintainability that should be addressed.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the CYW4373E USB WiFi modem, which involves substantial changes across the Wi-Fi stack. Key additions include a new USB HAL implementation, and a significant refactoring of the Wi-Fi Host Driver (WHD) to abstract the bus protocol layer, enabling support for SDIO, SPI, and USB interfaces, as well as different data protocols like CDC/BDC and the new MSGBUF. The changes are extensive but generally well-structured, moving towards a more modular design. I have identified a critical bug that could lead to a crash, along with a couple of high-severity issues related to portability and potential performance problems that should be addressed.

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch 3 times, most recently from 8103402 to 2191b19 Compare October 20, 2025 17:33
@nalajcie
Copy link
Member

was the new version of WHD driver tested on DTR platform?

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch 3 times, most recently from 30835af to 30f6d97 Compare October 27, 2025 15:33
@julianuziemblo
Copy link
Contributor Author

julianuziemblo commented Oct 27, 2025

was the new version of WHD driver tested on DTR platform?

Tested, works, even with current firmware, CLM and NVRAM.

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch 5 times, most recently from fc245ba to a0c9292 Compare November 27, 2025 14:14
@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch from a0c9292 to f3bc2e2 Compare December 10, 2025 10:15
@julianuziemblo julianuziemblo mentioned this pull request Dec 10, 2025
14 tasks
Imported from Infineon's AIROC-Wi-Fi-Bluetooth-STM32 repository v1.7.1.5645
New WHD version is 3.3.0.24096

JIRA: RTOS-216
@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch 2 times, most recently from 9d95cb0 to 6c57a6d Compare December 10, 2025 14:48
Bus failure is usually indicative of device disconnect, so we can just
exit when this happens.

JIRA: RTOS-216
Some targets may not support the way periferal access is done in other
targets (at least for now).

JIRA: RTOS-216
@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-216 branch from 6c57a6d to 9eaa89e Compare December 15, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants