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

[Gen 4] change coexistence behavior in wifi connecting or wifi connected states with background BLE low prio activity #2764

Merged
merged 30 commits into from
Jun 13, 2024

Conversation

avtolstoy
Copy link
Member

TODO

volatile bool s_wifiConnectionState = false;
volatile bool s_tdmaSkip = false;

uint32_t s_coexTable[3] = {0x55555555, 0xaaaa5555, 0xf0ffffff};
Copy link
Member Author

Choose a reason for hiding this comment

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

0x55555555 == BT > WLAN, 0xaaaa5555 == WLAN high-Priority > BT > WLAN low-Priority

@scott-brust scott-brust modified the milestones: 5.8.1, 5.8.2 May 6, 2024
@avtolstoy avtolstoy force-pushed the fix/rtl872x-wifi-ble-coex branch 2 times, most recently from 62f327c to dc777df Compare May 22, 2024 13:54
@avtolstoy avtolstoy force-pushed the fix/rtl872x-wifi-ble-coex branch 2 times, most recently from 00120e1 to a4015f8 Compare June 7, 2024 20:42
Copy link
Member

@scott-brust scott-brust left a comment

Choose a reason for hiding this comment

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

Some general questions. Still need to try to understand the actual coexistence changes and their implications

hal/inc/ble_hal.h Show resolved Hide resolved
#define OS_THREAD_PRIORITY_NETWORK (7)
#define OS_THREAD_PRIORITY_NETWORK_HIGH (8)
#define OS_THREAD_PRIORITY_NETWORK (6)
#define OS_THREAD_PRIORITY_NETWORK_HIGH (7)
Copy link
Member

Choose a reason for hiding this comment

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

Do these changes have any effect? Do we know what priority the SDK threads run at? Do we need to take into account their priorities perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just fixing the general problem: MAC network threads should be below LwIP TCP/IP thread.

info.end = (uint32_t)&link_prebootloader_wifi_fw_ram_end;
DCache_CleanInvalidate((uint32_t)&info, sizeof(info));
rtl_wifi_fw_resp resp = {};
int r = km0_km4_ipc_send_request(KM0_KM4_IPC_CHANNEL_GENERIC, KM0_KM4_IPC_MSG_WIFI_FW_INIT, &info, sizeof(info), [](km0_km4_ipc_msg_t* msg, void* context) -> void {
Copy link
Member

Choose a reason for hiding this comment

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

What does the "wifi firmware" actually do? Why does it need to run on KM0?

Copy link
Member Author

Choose a reason for hiding this comment

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

It manages low power wifi modes and mainly for our use-case prioritization between wifi and bt slots. Pretty much the main thing it does in simple terms is set up an interrupt at TBTT interval (100ms generally, depends on AP settings) and depending on the coexistence configuration may switch the RF frontend between WiFi and BLE peripheral. Of course it's a bit more complex than simply that.

Copy link
Member

Choose a reason for hiding this comment

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

ok thanks for the general overview. I'm guessing wifi fw is running on KM0 for performance and hardware reasons? wifi fw is loaded into KM0 ROM?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷 That's how it's implemented by Realtek. Wifi fw is in ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/lib/application/lib_wifi_fw.a, it does use some of the ROM functions, but in general it just runs on KM0 through a set of threads / interrupt handlers. It can run XIP, but XIP is seriously broken as usual, so we run it out of KM4 SRAM (as we are out of KM0 SRAM).

@scott-brust scott-brust merged commit fdc25ca into develop Jun 13, 2024
1 check passed
@scott-brust scott-brust deleted the fix/rtl872x-wifi-ble-coex branch June 13, 2024 17:10
@scott-brust scott-brust mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants