Skip to content

Commit

Permalink
feat(wifi_remote): Add slave selection and peview targets
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cermak committed Sep 26, 2024
1 parent 2e53b81 commit 345c457
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 45 deletions.
1 change: 1 addition & 0 deletions components/esp_wifi_remote/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ menu "Wi-Fi Remote"
bool
default y

orsource "./Kconfig.slave_select.in"
orsource "./Kconfig.soc_wifi_caps.in"
orsource "./Kconfig.rpc.in"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This file is auto-generated
menu "ESP Hosted Mock"
choice SLAVE_IDF_TARGET
prompt "choose slave target"
default SLAVE_IDF_TARGET_ESP32
Expand All @@ -15,9 +14,6 @@ menu "ESP Hosted Mock"
bool "esp32c2"
config SLAVE_IDF_TARGET_ESP32C6
bool "esp32c6"
config SLAVE_IDF_TARGET_ESP32H2
bool "esp32h2"
config SLAVE_IDF_TARGET_ESP32P4
bool "esp32p4"
config SLAVE_IDF_TARGET_ESP32C5
bool "esp32c5"
endchoice
endmenu
42 changes: 37 additions & 5 deletions components/esp_wifi_remote/Kconfig.soc_wifi_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,46 @@ if SLAVE_IDF_TARGET_ESP32C6

endif # ESP32C6

if SLAVE_IDF_TARGET_ESP32H2
if SLAVE_IDF_TARGET_ESP32C5

endif # ESP32H2

if SLAVE_IDF_TARGET_ESP32P4
config SLAVE_SOC_WIFI_SUPPORTED
bool
default y

config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
int
default 12

endif # ESP32P4
config SLAVE_SOC_WIFI_HW_TSF
bool
default y

config SLAVE_SOC_WIFI_FTM_SUPPORT
bool
default n

config SLAVE_SOC_WIFI_GCMP_SUPPORT
bool
default y

config SLAVE_SOC_WIFI_WAPI_SUPPORT
bool
default y

config SLAVE_SOC_WIFI_CSI_SUPPORT
bool
default y

config SLAVE_SOC_WIFI_MESH_SUPPORT
bool
default y

config SLAVE_SOC_WIFI_HE_SUPPORT
bool
default y

config SLAVE_SOC_WIFI_HE_SUPPORT_5G
bool
default y

endif # ESP32C5
62 changes: 29 additions & 33 deletions components/esp_wifi_remote/scripts/generate_and_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import subprocess
from collections import namedtuple

from idf_build_apps.constants import SUPPORTED_TARGETS
from idf_build_apps.constants import PREVIEW_TARGETS, SUPPORTED_TARGETS
from pycparser import c_ast, c_parser, preprocess_file

Param = namedtuple('Param', ['ptr', 'array', 'qual', 'type', 'name'])
Expand Down Expand Up @@ -161,45 +161,42 @@ def get_vars(parameters):

def generate_kconfig_wifi_caps(idf_path, component_path):
kconfig = os.path.join(component_path, 'Kconfig.soc_wifi_caps.in')
slave_select = os.path.join(component_path, 'Kconfig.slave_select.in')
sdkconfig_files = []
with open(kconfig, 'w') as out:
out.write(f'# {AUTO_GENERATED}\n')
for slave_target in SUPPORTED_TARGETS:
out.write(f'\nif SLAVE_IDF_TARGET_{slave_target.upper()}\n\n')
with open(kconfig, 'w') as slave_caps, open(slave_select, 'w') as slave:
slave_caps.write(f'# {AUTO_GENERATED}\n')
slave.write(f'# {AUTO_GENERATED}\n')
slave.write(' choice SLAVE_IDF_TARGET\n')
slave.write(' prompt "choose slave target"\n')
slave.write(' default SLAVE_IDF_TARGET_ESP32\n')
for slave_target in SUPPORTED_TARGETS + PREVIEW_TARGETS:
add_slave = False
kconfig_content = []
soc_caps = os.path.join(idf_path, 'components', 'soc', slave_target, 'include', 'soc', 'Kconfig.soc_caps.in')
with open(soc_caps, 'r') as f:
for line in f:
if line.strip().startswith('config SOC_WIFI_'):
if 'config SOC_WIFI_SUPPORTED' in line:
# if WiFi supported for this target, test it as a slave
# if WiFi supported for this target, add it to Kconfig slave options and test this slave
add_slave = True
sdkconfig = os.path.join(component_path, 'test', 'smoke_test', f'sdkconfig.ci.slave_{slave_target}')
open(sdkconfig, 'w').write(f'CONFIG_SLAVE_IDF_TARGET_{slave_target.upper()}=y\n')
sdkconfig_files.append(sdkconfig)
replaced = re.compile(r'SOC_WIFI_').sub('SLAVE_SOC_WIFI_', line)
out.write(f' {replaced}')
line = f.readline() # type
out.write(f' {line}')
line = f.readline() # default
out.write(f' {line}\n')
out.write(f'endif # {slave_target.upper()}\n')
return [kconfig] + sdkconfig_files


def generate_test_kconfig(component_path):
path = os.path.join(component_path, 'test','smoke_test','components','esp_hosted','Kconfig')
with open(path, 'w') as f:
f.write(f'# {AUTO_GENERATED}\n')
f.write('menu "ESP Hosted Mock"\n')
f.write(' choice SLAVE_IDF_TARGET\n')
f.write(' prompt "choose slave target"\n')
f.write(' default SLAVE_IDF_TARGET_ESP32\n')
for slave_target in SUPPORTED_TARGETS:
config = 'SLAVE_IDF_TARGET_' + slave_target.upper()
f.write(f' config {config}\n')
f.write(f' bool "{slave_target}"\n')
f.write(' endchoice\n')
f.write('endmenu\n')
return [path]
replaced = re.sub(r'SOC_WIFI_', 'SLAVE_SOC_WIFI_', line)
kconfig_content.append(f' {replaced}')
kconfig_content.append(f' {f.readline()}') # type
kconfig_content.append(f' {f.readline()}\n') # default
if add_slave:
slave_caps.write(f'\nif SLAVE_IDF_TARGET_{slave_target.upper()}\n\n')
slave_caps.writelines(kconfig_content)
slave_caps.write(f'endif # {slave_target.upper()}\n')

slave_config_name = 'SLAVE_IDF_TARGET_' + slave_target.upper()
slave.write(f' config {slave_config_name}\n')
slave.write(f' bool "{slave_target}"\n')

slave.write(' endchoice\n')
return [kconfig, slave_select] + sdkconfig_files


def generate_remote_wifi_api(function_prototypes, component_path):
Expand Down Expand Up @@ -311,6 +308,7 @@ def generate_kconfig(idf_path, component_path):
f.write(' config ESP_WIFI_REMOTE_ENABLED\n')
f.write(' bool\n')
f.write(' default y\n\n')
f.write(' orsource "./Kconfig.slave_select.in"\n')
f.write(' orsource "./Kconfig.soc_wifi_caps.in"\n')
f.write(' orsource "./Kconfig.rpc.in"\n')
for line1 in lines:
Expand Down Expand Up @@ -377,8 +375,6 @@ def compare_files(base_dir, component_path, files_to_check):

files_to_check = []

files_to_check += generate_test_kconfig(component_path)

files_to_check += generate_kconfig_wifi_caps(idf_path, component_path)

files_to_check += generate_remote_wifi_api(function_prototypes, component_path)
Expand Down
5 changes: 4 additions & 1 deletion components/esp_wifi_remote/test/smoke_test/main/smoke_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ void app_main(void)
esp_wifi_init(&cfg);
esp_wifi_deinit();

run_all_wifi_apis();
#if CONFIG_SOC_WIFI_SUPPORTED
run_all_wifi_remote_apis();
#else
run_all_wifi_apis();
#endif
}

0 comments on commit 345c457

Please sign in to comment.