├── .gitignore ├── .gitlab-ci.yml ├── .gitlab └── ci │ ├── build_firmware.sh │ └── check_hosted_ng_version.sh ├── .gitmodules ├── LICENSES ├── Apache-2.0 ├── GPL-2.0 └── README.md ├── README.md ├── basic_block_diagram.jpg ├── esp_hosted_fg ├── README.md ├── common │ ├── LICENSES │ │ ├── Apache-2.0 │ │ └── GPL-2.0 │ ├── component.mk │ ├── esp_hosted_config.pb-c.c │ ├── include │ │ ├── adapter.h │ │ ├── esp_fw_version.h │ │ ├── esp_hosted_config.pb-c.h │ │ ├── esp_hosted_custom_rpc.h │ │ └── esp_hosted_log.h │ ├── proto │ │ ├── README.md │ │ ├── build_proto.sh │ │ └── esp_hosted_config.proto │ └── utils │ │ ├── esp_hosted_cli.c │ │ └── esp_hosted_cli.h ├── docs │ ├── ESP-Hosted-FG.jpg │ ├── Linux_based_host │ │ ├── Auto_Network_Setup.md │ │ ├── Getting_started.md │ │ ├── Linux_based_architecture.md │ │ ├── Linux_based_readme.md │ │ ├── Network_Split.md │ │ ├── Raw_TP_Testing.md │ │ ├── SDIO_setup.md │ │ ├── SPI_setup.md │ │ ├── Troubleshoot.md │ │ ├── UART_setup.md │ │ ├── directory_structure.md │ │ ├── linux_hosted_design.svg │ │ ├── ota_update.md │ │ ├── porting_guide.md │ │ ├── rpi_esp32_c6_setup.jpg │ │ ├── rpi_esp32c6_sdio_setup.png │ │ └── rpi_esp32s3_spi_uart_setup.jpg │ ├── MCU_based_host │ │ ├── Getting_started.md │ │ ├── MCU_based_architecture.md │ │ ├── MCU_based_design.png │ │ ├── MCU_based_readme.md │ │ ├── Raw_TP_Testing.md │ │ ├── SDIO_setup.md │ │ ├── SPI_setup.md │ │ ├── directory_structure.md │ │ ├── mcu_api.md │ │ ├── stm32_esp32_sdio_setup.jpg │ │ └── stm_esp32_c6_setup.jpg │ ├── common │ │ ├── c_demo.md │ │ ├── contrl_path.md │ │ ├── contrl_path.png │ │ ├── ctrl_apis.md │ │ ├── ctrl_path_python.gif │ │ ├── python_demo.md │ │ └── serial_apis.md │ ├── esp_hosted_performance.png │ ├── icons │ │ ├── BLE4.2.svg │ │ ├── BLE5.0.svg │ │ ├── BLE5.3.svg │ │ ├── ClassicBT.svg │ │ ├── esp32.svg │ │ ├── esp32c2.svg │ │ ├── esp32c3.svg │ │ ├── esp32c5.svg │ │ ├── esp32c6.svg │ │ ├── esp32s2.svg │ │ ├── esp32s3.svg │ │ ├── sdio_only.svg │ │ ├── sdio_uart.svg │ │ ├── spi_only.svg │ │ ├── spi_uart.svg │ │ ├── wifi.svg │ │ ├── wifi_6.svg │ │ └── wifi_dual_band.svg │ ├── sdio_protocol.md │ └── spi_protocol.md ├── esp │ └── esp_driver │ │ ├── network_adapter │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── main │ │ │ ├── CMakeLists.txt │ │ │ ├── Kconfig.projbuild │ │ │ ├── esp_hosted_coprocessor.c │ │ │ ├── esp_hosted_coprocessor.h │ │ │ ├── esp_hosted_lwip_src_port_hook.h │ │ │ ├── host_power_save.c │ │ │ ├── host_power_save.h │ │ │ ├── http_req.c │ │ │ ├── idf_component.yml │ │ │ ├── interface.h │ │ │ ├── lwip_filter.c │ │ │ ├── lwip_filter.h │ │ │ ├── mempool.c │ │ │ ├── mempool.h │ │ │ ├── mempool_ll.c │ │ │ ├── mempool_ll.h │ │ │ ├── mqtt_example.c │ │ │ ├── mqtt_example.h │ │ │ ├── protocomm_pserial.c │ │ │ ├── protocomm_pserial.h │ │ │ ├── sdio_slave_api.c │ │ │ ├── sdio_slave_api.h │ │ │ ├── slave_bt.c │ │ │ ├── slave_bt.h │ │ │ ├── slave_control.c │ │ │ ├── slave_control.h │ │ │ ├── spi_slave_api.c │ │ │ ├── stats.c │ │ │ └── stats.h │ │ ├── partitions.esp32.csv │ │ ├── partitions.esp32c2.csv │ │ ├── partitions.esp32c3.csv │ │ ├── partitions.esp32c5.csv │ │ ├── partitions.esp32c6.csv │ │ ├── partitions.esp32s2.csv │ │ ├── partitions.esp32s3.csv │ │ ├── sdkconfig.defaults │ │ ├── sdkconfig.defaults.esp32 │ │ ├── sdkconfig.defaults.esp32c2 │ │ ├── sdkconfig.defaults.esp32c3 │ │ ├── sdkconfig.defaults.esp32c5 │ │ ├── sdkconfig.defaults.esp32c6 │ │ ├── sdkconfig.defaults.esp32s2 │ │ └── sdkconfig.defaults.esp32s3 │ │ ├── remove-idf.ps1 │ │ ├── remove-idf.sh │ │ ├── setup-idf.ps1 │ │ ├── setup-idf.sh │ │ └── setup_windows11.md └── host │ ├── LICENSES │ ├── Apache-2.0 │ └── GPL-2.0 │ ├── components │ ├── include │ │ └── esp_queue.h │ └── src │ │ └── esp_queue.c │ ├── control_lib │ ├── Makefile │ ├── include │ │ └── ctrl_api.h │ └── src │ │ ├── ctrl_api.c │ │ ├── ctrl_core.c │ │ └── include │ │ └── ctrl_core.h │ ├── linux │ ├── LICENSE │ ├── host_control │ │ ├── LICENSE │ │ ├── c_support │ │ │ ├── Makefile │ │ │ ├── app_custom_rpc.c │ │ │ ├── app_custom_rpc.h │ │ │ ├── ctrl_config.h │ │ │ ├── hosted_daemon.c │ │ │ ├── hosted_shell.c │ │ │ ├── hosted_shell.h │ │ │ ├── nw_helper_func.c │ │ │ ├── nw_helper_func.h │ │ │ ├── stress.c │ │ │ ├── test.c │ │ │ ├── test.h │ │ │ └── test_utils.c │ │ ├── python_support │ │ │ ├── Makefile │ │ │ ├── commands_lib.py │ │ │ ├── commands_map_py_to_c.py │ │ │ ├── hosted_py_header.py │ │ │ ├── py_parse │ │ │ │ ├── cmds.py │ │ │ │ ├── nw_helper_func.py │ │ │ │ └── process.py │ │ │ ├── run_dhcp_server.sh │ │ │ ├── setup_python.sh │ │ │ ├── stop_dhcp_server.sh │ │ │ ├── stress.py │ │ │ └── test.py │ │ ├── rpi_init.sh │ │ └── spidev_disabler.dts │ ├── host_driver │ │ └── esp32 │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── esp.h │ │ │ ├── esp_api.h │ │ │ ├── esp_bt.c │ │ │ ├── esp_bt_api.h │ │ │ ├── esp_fw_verify.c │ │ │ ├── esp_fw_verify.h │ │ │ ├── esp_if.h │ │ │ ├── esp_kernel_port.h │ │ │ ├── esp_rb.c │ │ │ ├── esp_rb.h │ │ │ ├── esp_serial.c │ │ │ ├── esp_serial.h │ │ │ ├── esp_stats.c │ │ │ ├── esp_stats.h │ │ │ ├── esp_utils.h │ │ │ ├── main.c │ │ │ ├── sdio │ │ │ ├── esp_sdio.c │ │ │ ├── esp_sdio_api.c │ │ │ ├── esp_sdio_api.h │ │ │ └── esp_sdio_decl.h │ │ │ └── spi │ │ │ ├── esp_spi.c │ │ │ └── esp_spi.h │ └── port │ │ ├── include │ │ └── platform_wrapper.h │ │ └── src │ │ └── platform_wrapper.c │ ├── stm32 │ ├── LICENSE │ ├── app │ │ ├── app_main.c │ │ ├── app_main.h │ │ ├── app_main_api.c │ │ ├── app_main_api.h │ │ ├── control │ │ │ ├── control.c │ │ │ ├── control.h │ │ │ └── control_utils.c │ │ └── data │ │ │ ├── arp_server_stub.c │ │ │ └── arp_server_stub.h │ ├── common │ │ ├── common.c │ │ ├── common.h │ │ ├── stats.c │ │ ├── stats.h │ │ ├── trace.h │ │ ├── util.c │ │ └── util.h │ ├── driver │ │ ├── netif │ │ │ └── netdev_if.h │ │ ├── network │ │ │ ├── netdev_api.c │ │ │ ├── netdev_api.h │ │ │ ├── netdev_stub.c │ │ │ └── netdev_stub.h │ │ ├── serial │ │ │ ├── serial_drv.h │ │ │ ├── serial_ll_if.c │ │ │ └── serial_ll_if.h │ │ └── transport │ │ │ ├── sdio │ │ │ ├── sdio_api.c │ │ │ ├── sdio_api.h │ │ │ ├── sdio_drv.c │ │ │ ├── sdio_drv.h │ │ │ ├── sdio_host.c │ │ │ ├── sdio_host.h │ │ │ ├── sdio_ll.c │ │ │ ├── sdio_ll.h │ │ │ └── sdio_reg.h │ │ │ ├── spi │ │ │ ├── spi_drv.c │ │ │ └── spi_drv.h │ │ │ ├── transport_drv.c │ │ │ └── transport_drv.h │ ├── port │ │ ├── include │ │ │ └── platform_wrapper.h │ │ └── src │ │ │ └── platform_wrapper.c │ └── proj │ │ ├── prepare_project.bat │ │ ├── prepare_project.sh │ │ ├── sdio │ │ ├── .cproject │ │ ├── .project │ │ └── stm_sdio_host.ioc │ │ └── spi │ │ ├── .cproject │ │ ├── .project │ │ ├── stm_spi_host_v1.ioc │ │ └── stm_spi_host_v2.ioc │ └── virtual_serial_if │ ├── include │ └── serial_if.h │ └── src │ └── serial_if.c └── esp_hosted_ng ├── README.md ├── VERSION ├── docs ├── ESP-Hosted-NG.jpg ├── Raw_TP_Testing.md ├── Troubleshoot.md ├── bluetooth.md ├── directory_structure.md ├── host_sleep.md ├── porting_guide.md ├── rpi_esp32_c3_setup.jpg ├── rpi_esp32_sdio_setup.jpeg ├── rpi_esp32_spi_setup.jpg ├── rpi_esp32_uart_setup.jpeg ├── rpi_esp32c3_uart_setup.jpg ├── sdio_protocol.md ├── setup.md └── spi_protocol.md ├── esp └── esp_driver │ ├── .env │ ├── LICENSE │ ├── README.md │ ├── lib │ ├── esp32 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libmesh.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ ├── libsmartconfig.a │ │ └── libwapi.a │ ├── esp32c2 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ └── libsmartconfig.a │ ├── esp32c3 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libmesh.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ ├── libsmartconfig.a │ │ └── libwapi.a │ ├── esp32c5 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libmesh.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ ├── libsmartconfig.a │ │ └── libwapi.a │ ├── esp32c6 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libmesh.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ ├── libsmartconfig.a │ │ └── libwapi.a │ ├── esp32s2 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libmesh.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ ├── libsmartconfig.a │ │ └── libwapi.a │ ├── esp32s3 │ │ ├── libcore.a │ │ ├── libespnow.a │ │ ├── libmesh.a │ │ ├── libnet80211.a │ │ ├── libpp.a │ │ ├── libsmartconfig.a │ │ └── libwapi.a │ └── esp_wifi_driver.h │ ├── network_adapter │ ├── CMakeLists.txt │ ├── LICENSE │ ├── main │ │ ├── CMakeLists.txt │ │ ├── Kconfig.projbuild │ │ ├── app_main.c │ │ ├── cmd.c │ │ ├── esp_wifi_driver.h │ │ ├── include │ │ │ ├── adapter.h │ │ │ ├── app_main.h │ │ │ ├── cmd.h │ │ │ ├── esp.h │ │ │ ├── esp_fw_version.h │ │ │ ├── interface.h │ │ │ ├── sdio_slave_api.h │ │ │ ├── slave_bt.h │ │ │ ├── stats.h │ │ │ └── wifi_defs.h │ │ ├── sdio_slave_api.c │ │ ├── slave_bt.c │ │ ├── spi_slave_api.c │ │ └── stats.c │ ├── partitions.esp32c2.csv │ ├── sdkconfig.ci │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32 │ ├── sdkconfig.defaults.esp32c2 │ ├── sdkconfig.defaults.esp32c3 │ ├── sdkconfig.defaults.esp32c5 │ ├── sdkconfig.defaults.esp32c6 │ ├── sdkconfig.defaults.esp32s2 │ └── sdkconfig.defaults.esp32s3 │ ├── setup.ps1 │ └── setup.sh └── host ├── LICENSE ├── Makefile ├── esp_bt.c ├── esp_cfg80211.c ├── esp_cmd.c ├── esp_debugfs.c ├── esp_log.c ├── esp_stats.c ├── esp_utils.c ├── include ├── adapter.h ├── esp.h ├── esp_api.h ├── esp_bt_api.h ├── esp_cfg80211.h ├── esp_cmd.h ├── esp_fw_version.h ├── esp_if.h ├── esp_kernel_port.h ├── esp_stats.h ├── esp_utils.h └── utils.h ├── main.c ├── rpi_init.sh ├── sdio ├── esp_sdio.c ├── esp_sdio_api.c ├── esp_sdio_api.h └── esp_sdio_decl.h ├── spi ├── esp_spi.c └── esp_spi.h └── spidev_disabler.dts /.gitignore: -------------------------------------------------------------------------------- 1 | esp_hosted_fg/esp/esp_driver/CMakeCache.txt 2 | esp_hosted_fg/esp/esp_driver/CMakeFiles 3 | esp_hosted_fg/esp/esp_driver/Makefile 4 | esp_hosted_fg/esp/esp_driver/build 5 | esp_hosted_fg/esp/esp_driver/cmake_install.cmake 6 | esp_hosted_fg/esp/esp_driver/network_adapter/build 7 | esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig 8 | esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.old 9 | esp_hosted_ng/esp/esp_driver/CMakeCache.txt 10 | esp_hosted_ng/esp/esp_driver/CMakeFiles 11 | esp_hosted_ng/esp/esp_driver/Makefile 12 | esp_hosted_ng/esp/esp_driver/build 13 | esp_hosted_ng/esp/esp_driver/cmake_install.cmake 14 | esp_hosted_ng/esp/esp_driver/network_adapter/build 15 | esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig 16 | esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.old 17 | -------------------------------------------------------------------------------- /.gitlab/ci/build_firmware.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ensure script stops on errors 4 | set -e 5 | 6 | TGT_NAME=$1 7 | 8 | # Navigate to the target directory 9 | cd esp_hosted_ng/esp/esp_driver/ 10 | 11 | # Setup IDF and required libraries 12 | yes | ./setup.sh -f 13 | 14 | cd esp-idf 15 | echo "Exporting variables" 16 | . ./export.sh 17 | 18 | cd ../network_adapter 19 | 20 | # Check if the second argument (assumed to be a string) matches "spi" 21 | if [ "$2" = "spi" ]; then 22 | # Check if sdkconfig.ci exists 23 | if [ -f "sdkconfig.ci" ]; then 24 | # Append the content of sdkconfig.ci to sdkconfig.defaults 25 | echo "appending ci config to default" 26 | cat sdkconfig.ci >> sdkconfig.defaults 27 | else 28 | echo "Error: sdkconfig.ci does not exist." 29 | exit 1 30 | fi 31 | fi 32 | 33 | echo "Setting target as $TGT_NAME" 34 | idf.py set-target $TGT_NAME 35 | idf.py build 36 | 37 | # Check if the build was successful 38 | if [ ! -f "build/network_adapter.bin" ]; then 39 | echo "Compilation failed; exit 1" 40 | exit 1 41 | fi 42 | 43 | echo "Build successful" 44 | -------------------------------------------------------------------------------- /.gitlab/ci/check_hosted_ng_version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | if [ -z "${HOSTED_NG_PATH:-}" ]; then 6 | echo "HOSTED_NG_PATH must be set before running this script" 7 | exit 1 8 | fi 9 | 10 | FAILURES=0 11 | 12 | function check_md5() { 13 | local host_filename="$1" 14 | local fw_filename="$2" 15 | 16 | local md5_from_host 17 | local md5_from_fw 18 | 19 | md5_from_host=$(md5sum "$host_filename" | cut -c 1-7) 20 | md5_from_fw=$(md5sum "$fw_filename" | cut -c 1-7) 21 | 22 | echo "Comparing MD5 checksums for:" 23 | echo " $host_filename (host) -> $md5_from_host" 24 | echo " $fw_filename (firmware) -> $md5_from_fw" 25 | 26 | if [ "$md5_from_host" != "$md5_from_fw" ]; then 27 | echo " error: MD5 mismatch!" 28 | FAILURES=$((FAILURES + 1)) 29 | fi 30 | } 31 | 32 | function check_version_update() { 33 | local network_adapter_dir="${HOSTED_NG_PATH}/esp/esp_driver/network_adapter" 34 | local version_file="${HOSTED_NG_PATH}/esp/esp_driver/network_adapter/main/include/esp_fw_version.h" 35 | 36 | # Determine the base commit for the MR 37 | local target_branch="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-master}" 38 | local base_commit 39 | git fetch origin master --depth=1 40 | base_commit=$(git merge-base HEAD "origin/$target_branch") 41 | 42 | # Check if there are changes in network_adapter_dir in the MR range 43 | if git diff --quiet "$base_commit" HEAD -- "$network_adapter_dir"; then 44 | echo "No changes in ${network_adapter_dir}, skipping version check." 45 | else 46 | # Check if version_file was also updated 47 | if ! git diff --quiet "$base_commit" HEAD -- "$version_file"; then 48 | echo "Change detected in firmware, and version has been updated." 49 | else 50 | echo "error: version must be updated when changes are made in firmware" 51 | FAILURES=$((FAILURES + 1)) 52 | fi 53 | fi 54 | } 55 | 56 | echo "Checking if version in host matches version in firmware" 57 | check_md5 "${HOSTED_NG_PATH}/esp/esp_driver/network_adapter/main/include/esp_fw_version.h" \ 58 | "${HOSTED_NG_PATH}/host/include/esp_fw_version.h" 59 | 60 | echo "Checking if interface in host matches interface in firmware" 61 | check_md5 "${HOSTED_NG_PATH}/esp/esp_driver/network_adapter/main/include/adapter.h" \ 62 | "${HOSTED_NG_PATH}/host/include/adapter.h" 63 | 64 | echo "Checking if version file was updated with network adapter changes" 65 | check_version_update 66 | 67 | if [ $FAILURES -gt 0 ]; then 68 | echo "$FAILURES check(s) failed." 69 | exit 1 70 | else 71 | echo "All checks passed." 72 | fi 73 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "esp_hosted_fg/common/protobuf-c"] 2 | path = esp_hosted_fg/common/protobuf-c 3 | url = https://github.com/protobuf-c/protobuf-c.git 4 | -------------------------------------------------------------------------------- /LICENSES/README.md: -------------------------------------------------------------------------------- 1 | ## Applicable LICENSE Information: 2 | 3 | ``` 4 | ├── esp_hosted_fg (Dual-licensed under Apache-2.0 or GPL-2.0-only, at your option) 5 | │   ├── common (Dual-licensed under Apache-2.0 or GPL-2.0-only, at your option) 6 | │   ├── esp (Apache-2.0) 7 | │   ├── host 8 | │   ├── components (Dual-licensed under Apache-2.0 or GPL-2.0-only, at your option) 9 | │   ├── control_lib (Dual-licensed under Apache-2.0 or GPL-2.0-only, at your option) 10 | │      ├── linux (GPL-2.0-only) 11 | │      ├── stm32 (Apache-2.0) 12 | │      └── virtual_serial_if (Dual-licensed under Apache-2.0 or GPL-2.0-only, at your option) 13 | ├── esp_hosted_ng (GPL-2.0-only) 14 | │   └── host (GPL-2.0-only) 15 | ``` 16 | -------------------------------------------------------------------------------- /basic_block_diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/basic_block_diagram.jpg -------------------------------------------------------------------------------- /esp_hosted_fg/common/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Component Makefile 3 | # 4 | 5 | COMPONENT_ADD_INCLUDEDIRS := include 6 | -------------------------------------------------------------------------------- /esp_hosted_fg/common/include/esp_fw_version.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | /* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ 3 | 4 | #ifndef __ESP_FW_VERSION__H 5 | #define __ESP_FW_VERSION__H 6 | 7 | #define PROJECT_NAME "FG" 8 | #define PROJECT_VERSION_MAJOR_1 1 9 | #define PROJECT_VERSION_MAJOR_2 0 10 | #define PROJECT_VERSION_MINOR 0 11 | #define PROJECT_REVISION_PATCH_1 0 12 | #define PROJECT_REVISION_PATCH_2 0 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /esp_hosted_fg/common/include/esp_hosted_custom_rpc.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESP_HOSTED_RPC_H__ 2 | #define __ESP_HOSTED_RPC_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* This file contains the custom RPC message IDs shared between the ESP Firmware and the Host side Protobuf Application. 9 | 10 | * These IDs are just demonstration purpose. You can customize them as per your application requirements. 11 | */ 12 | 13 | 14 | enum custom_rpc_req_id { 15 | CUSTOM_RPC_REQ_ID__ONLY_ACK = 1, 16 | CUSTOM_RPC_REQ_ID__ECHO_BACK_RESPONSE = 2, 17 | CUSTOM_RPC_REQ_ID__ECHO_BACK_AS_EVENT = 3, 18 | /* Add more request IDs as needed */ 19 | }; 20 | 21 | enum custom_rpc_event_id { 22 | /* Slave use this event to send back data received in CUSTOM_RPC_REQ_ID__ECHO_BACK_AS_EVENT */ 23 | CUSTOM_RPC_EVENT_ID__DEMO_ECHO_BACK_REQUEST = 100, 24 | CUSTOM_RPC_EVENT_ID__DEMO_SIMPLE_EVENT = 101, 25 | /* Add more event IDs as needed */ 26 | }; 27 | 28 | #endif /* __ESP_HOSTED_RPC_H__ */ 29 | -------------------------------------------------------------------------------- /esp_hosted_fg/common/include/esp_hosted_log.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __ESP_HOSTED_LOG_H 18 | #define __ESP_HOSTED_LOG_H 19 | #include "esp_log.h" 20 | 21 | #define ESP_PRIV_HEXDUMP(tag1, tag2, buff, buf_len, display_len, curr_level) \ 22 | if ( LOG_LOCAL_LEVEL >= curr_level) { \ 23 | int len_to_print = 0; \ 24 | len_to_print = display_len/common/proto 10 | 11 | protoc-c esp_hosted_config.proto --c_out=. 12 | 13 | mv esp_hosted_config.pb-c.c ../ 14 | 15 | mv esp_hosted_config.pb-c.h ../include/ 16 | ``` 17 | 18 | Existing control commands are available for use. 19 | 20 | To send an new command 21 | 1. Add C function in `host/host_common/commands.c` 22 | 2. Create python binding in `host/linux/host_control/python_support/commands_map_py_to_c.py` and its python function in `host/linux/host_control/python_support/commands_lib.py`. 23 | 3. Add ESP side C function in `esp/esp_driver/network_adapter/main/slave_commands.c`, respective to python function, to handle added message field. 24 | 25 | User can test added functionality using `host/linux/host_control/python_support/test.py`. 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/common/proto/build_proto.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | which protoc-c > /dev/null 4 | if [ $? -ne 0 ]; then 5 | echo "Please install protoc-c" 6 | exit 1 7 | fi 8 | 9 | protoc-c ./esp_hosted_config.proto --c_out=. 10 | if [ $? -ne 0 ]; then 11 | echo "Build failed, Please review esp_hosted_config.proto" 12 | exit 1 13 | fi 14 | 15 | mv esp_hosted_config.pb-c.h ../include/esp_hosted_config.pb-c.h 16 | mv esp_hosted_config.pb-c.c ../esp_hosted_config.pb-c.c 17 | 18 | echo "Generated protobuf definitions successfully" 19 | -------------------------------------------------------------------------------- /esp_hosted_fg/common/utils/esp_hosted_cli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _ESP_HOSTED_CLI_H_ 8 | #define _ESP_HOSTED_CLI_H_ 9 | 10 | #include "sdkconfig.h" 11 | 12 | /* host */ 13 | #ifdef CONFIG_ESP_HOSTED_HOST 14 | #include "esp_hosted_config.h" 15 | #include "power_save_drv.h" 16 | #endif 17 | 18 | /* coprocessor */ 19 | #ifdef CONFIG_ESP_HOSTED_COPROCESSOR 20 | #ifdef CONFIG_ESP_HOSTED_CLI_ENABLED 21 | #include "host_power_save.h" 22 | #define H_ESP_HOSTED_CLI_ENABLED 1 23 | #endif /*CONFIG_ESP_HOSTED_CLI_ENABLED*/ 24 | 25 | #ifdef CONFIG_SLAVE_MANAGES_WIFI 26 | #define H_SLAVE_MANAGES_WIFI 1 27 | #endif 28 | #endif /*CONFIG_ESP_HOSTED_COPROCESSOR*/ 29 | 30 | 31 | #ifdef H_ESP_HOSTED_CLI_ENABLED 32 | int esp_hosted_cli_start(); 33 | #endif 34 | 35 | #endif /* _ESP_HOSTED_CLI_H_ */ 36 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/ESP-Hosted-FG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/ESP-Hosted-FG.jpg -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/Linux_based_architecture.md: -------------------------------------------------------------------------------- 1 | # System Architecture: Linux Based Host 2 | Below diagram depicts building blocks of Linux based ESP-Hosted solution. 3 | 4 | ![ESP-Hosted linux based design](./linux_hosted_design.png) 5 | 6 | 7 | ## 1. ESP Host Software 8 | 9 | This implements ESP-Hosted solution part that runs on Linux host. It mainly consists of following. 10 | * ESP Host Driver 11 | * Control/command interface 12 | * Python convenience scripts 13 | 14 | --- 15 | 16 | ### 1.1 ESP Host Driver 17 | 18 | ESP Host driver implements following. 19 | 20 | * **SDIO Host driver** 21 | This implements data path over SDIO interface. Communication protocol is explained in further section. 22 | 23 | * **SPI Host driver** 24 | This implements data path over SPI interface. Communication protocol is explained in further section. 25 | 26 | * **Virtual Serial interface driver** 27 | This implements virtual serial interface over SDIO/SPI interface. This virtual serial interface is used as a control interface to configure Wi-Fi of ESP peripheral 28 | 29 | * **802.3 network interface** 30 | This registers two network interfaces with Linux kernel: ethsta0 and ethap0. This allows exchange of 802.3 frames between Linux kernel and ESP firmware. 31 | 32 | * **HCI interface** 33 | This registers HCI interface with Linux kernel. This interface is implemented over SDIO/SPI. 34 | 35 | 36 | --- 37 | 38 | ### 1.2 Control/Command Interface 39 | 40 | * This implements custom control commands that are based on protobuf. 41 | * These commands are used to control and configure Wi-Fi on ESP peripheral. 42 | * Control interface makes use of virtual serial interface provided by ESP Host driver. 43 | * There are 2 flavors of control interface implementation: 44 | * C based implementation 45 | * Python based implementation - It uses C based implementation using `ctypes` package. 46 | * API's are described in subsequent section 47 | * Control path design and implemetation details explained in [Control Path](../common/contrl_path.md) documentation 48 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/Raw_TP_Testing.md: -------------------------------------------------------------------------------- 1 | # Raw Throughput testing 2 | 3 | - This is the optional feature to test throughput over required transport layer (SPI or SDIO). 4 | - When ENABLED, this will bypass Wi-Fi traffic and push the dummy data traffic on transport layer directly to check maximum throughput on the current transport. 5 | - This feature will also help you to check if transport layer is properly configured or not. 6 | - This requires ESP firmware to be manually flashed with below steps. 7 | 8 | ## Steps to test Raw TP 9 | 10 | - On Host side: 11 | 1. While setting up the host, pass `rawtp` argument to `rpi_init.sh`. 12 | - e.g if you are setting Wi-Fi over SDIO and you want to test raw TP over SDIO interface, then compile and load host driver as below: 13 | ```sh 14 | $ cd esp_hosted_fg/host/linux/host_control/ 15 | $ ./rpi_init.sh sdio rawtp 16 | ``` 17 | 18 | - On ESP side: 19 | 1. Go to `esp_hosted_fg/esp/esp_driver/network_adapter/main/stats.h` 20 | 2. Enable raw throughput tetsing feature by making `TEST_RAW_TP` value to `1`. 21 | 3. There are two directions to test raw throughput and at a time, throughput can be tested only in one direction (simplex). 22 | - ESP to Host : For this, make `TEST_RAW_TP__ESP_TO_HOST` value to 1 23 | - Host to ESP : For this, make `TEST_RAW_TP__ESP_TO_HOST` value to 0 24 | 4. Build and flash ESP firmware again. 25 | 26 | **Note** 27 | Please revert these configurations once raw throughput testing is done 28 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/directory_structure.md: -------------------------------------------------------------------------------- 1 | ### Directory structure for Linux based host 2 | 3 | ``` 4 | ├── esp_hosted_fg 5 | │ │ 6 | │ ├── host (host directory is common for MCU and MPU) 7 | │ │   ├── LICENSES 8 | │ │   │   ├── Apache-2.0 9 | │ │   │   └── GPL-2.0 10 | │ │   ├── components (common utilities like queue etc) 11 | │ │   ├── control_lib (Hosted control path library) 12 | │ │ ├── linux 13 | │ │ │   ├── host_control (Contain necessary files for installation of control path) 14 | │ │ │   │   ├── c_support (Contain files to test basic control path commands and stress.c for stress testing) 15 | │ │ │   │   ├── python_support (Contain python scripts for Wi-Fi functionality, 16 | │ │ │   │   │ `test.py` to test basic control path commands, stress.py for stress testing, also 17 | │ │ │   │   │ `commands_lib.py` control path commands implementation using 18 | │ │ │   │   │ `ctypes` module converts command requests from python to c and maps command responses from c to python) 19 | │ │ │   │   ├── rpi_init.sh (Installation sequence for ESP-Hosted-FG driver) 20 | │ │ │   │   └── spidev_disabler.dts (dts file for SPI transport) 21 | │ │ │   ├── host_driver (Contain ESP-Hosted-FG kernel module files) 22 | │ │ │   │ └── esp32 (ESP-Hosted kernel module files) 23 | │ │ │   │ ├── sdio (Contain SDIO transport files used by kernel module to communicate 24 | │ │ │   │ │ with ESP peripheral) 25 | │ │ │   │ └── spi (Contain SPI transport files used by kernel module to communicate 26 | │ │ │ │ with ESP peripheral) 27 | │ │   │   └── port (Porting files for OS abstraction, contains wrappers for thread creation, semaphore operations, memory functions, 28 | │ │ │ serial driver operations etc) 29 | │ │   └── virtual_serial_if (Virtual serial interface, platform agnostic layer which provides abstraction to setup control path 30 | │ │ over serial driver) 31 | ``` 32 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/ota_update.md: -------------------------------------------------------------------------------- 1 | ## **ESP-Hosted OTA update ESP image** 2 | 3 | Please note, Maximum size of New OTA image binary depends upon - 4 | 1. Total flash size available 5 | 2. OTA partition size in partition table 6 | As per current limits, upto 1MB binary size is supported which is configurable using custom partition table CSV. Please refer [partition tables](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html) for more info. 7 | 8 | - There are basic three [control path APIs](../common/ctrl_apis.md#1-control-path-apis) for OTA are provided 9 | - C and python demo apps make use of them to do OTA update 10 | - [ota_begin()](../common/ctrl_apis.md#123-ctrl_cmd_t-ota_beginctrl_cmd_t-req) 11 | - Sets available OTA partition in flash for OTA write operation and erase it 12 | - [ota_write()](../common/ctrl_apis.md#124-ctrl_cmd_t-ota_writectrl_cmd_t-req) 13 | - Write chunk of OTA image data on OTA partition in flash 14 | - [ota_end()](../common/ctrl_apis.md#125-ctrl_cmd_t-ota_endctrl_cmd_t-req) 15 | - Validate written OTA image, set OTA partition for next boot and reboot ESP after 5 sec 16 | 17 | ## **How to use** 18 | 19 | ### On ESP side 20 | Build and flash ESP-Hosted application using `idf.py build flash monitor`. 21 | 22 | ### On Host side 23 | 24 | #### Note 25 | 1. Please stop ongoing BT/BLE operations before starting OTA process. 26 | 2. OTA operation should not get interrupted by any other control path command. 27 | 3. OTA update using HTTP URL is only supported in python. In case HTTP based OTA update is desired, user can do the same using third party HTTP client library. 28 | 4. The OTA update using C currently assumes the complete binary is downloaded locally. 29 | 30 | ### Python Implementation 31 | User can skip step 1, if station is connected to AP and IP is assigned to `ethsta0` interface. 32 | 33 | 1. Perform station connect using [wifi station mode operations](Getting_started.md#111-wi-fi-station-mode-operations) 34 | -> Connect to external access point. 35 | 36 | 2. For further details follow this [Link](../common/python_demo.md#ota-update). 37 | 38 | ### C Implementation 39 | 40 | For Further details follow this [Link](../common/c_demo.md#some-points-to-note) -> `OTA`. 41 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/rpi_esp32_c6_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/Linux_based_host/rpi_esp32_c6_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/rpi_esp32c6_sdio_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/Linux_based_host/rpi_esp32c6_sdio_setup.png -------------------------------------------------------------------------------- /esp_hosted_fg/docs/Linux_based_host/rpi_esp32s3_spi_uart_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/Linux_based_host/rpi_esp32s3_spi_uart_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_fg/docs/MCU_based_host/MCU_based_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/MCU_based_host/MCU_based_design.png -------------------------------------------------------------------------------- /esp_hosted_fg/docs/MCU_based_host/Raw_TP_Testing.md: -------------------------------------------------------------------------------- 1 | # Raw Throughput testing 2 | 3 | - This is the optional feature to test throughput over required transport layer (SPI or SDIO). 4 | - When ENABLED, this will bypass Wi-Fi traffic and push the dummy data traffic on transport layer directly to check maximum throughput on the current transport. 5 | - This feature will also help you to check if transport layer is properly configured or not. 6 | - This requires ESP firmware to be manually flashed with below steps. 7 | 8 | ## Steps to test Raw TP 9 | 10 | - On Host side: 11 | 1. Go to `esp_hosted_fg/host/stm32/common/stats.h` 12 | 2. Enable raw throughput tetsing feature by making `TEST_RAW_TP` value to `1`. 13 | 3. There are two directions to test raw throughput and at a time, throughput can be tested only in one direction (simplex). 14 | - ESP to Host : For this, make `TEST_RAW_TP__ESP_TO_HOST` value to 1 15 | - Host to ESP : For this, make `TEST_RAW_TP__ESP_TO_HOST` value to 0 16 | 4. Build and flash ESP firmware again. 17 | 18 | - On ESP side: 19 | 1. Go to `esp_hosted_fg/esp/esp_driver/network_adapter/main/stats.h` 20 | 2. Enable raw throughput tetsing feature by making `TEST_RAW_TP` value to `1`. 21 | 3. There are two directions to test raw throughput and at a time, throughput can be tested only in one direction (simplex). 22 | - ESP to Host : For this, make `TEST_RAW_TP__ESP_TO_HOST` value to 1 23 | - Host to ESP : For this, make `TEST_RAW_TP__ESP_TO_HOST` value to 0 24 | 4. Build and flash ESP firmware again. 25 | 26 | **Note** 27 | Please revert these configurations once raw throughput testing is done 28 | 29 | ## Raw Throughput Numbers 30 | 31 | | ESP32 Board | STM32 Board | Transport | TX case | RX case | 32 | |:---------:|:------:|:----------:|:---:|:--:| 33 | | ESP32 | STM32F412ZGT6-Nucleo 144 | SDIO | 5.22 Mbps | 5.32 Mbps | 34 | | ESP32/ESP32S2/ESP32S3/ESP32C2/ESP32C3 | STM32F469I-Discovery | SPI | 2.88 Mbps | 2.28 Mbps | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/MCU_based_host/directory_structure.md: -------------------------------------------------------------------------------- 1 | ### Directory structure for MCU based host 2 | 3 | ``` 4 | ├── esp_hosted_fg 5 | │ │  6 | │ ├── host (host directory is common for MCU and MPU) 7 | │   │ ├── LICENSES 8 | │   │ │   ├── Apache-2.0 9 | │   │ │   └── GPL-2.0 10 | │   │ ├── components (common utilities like queue etc) 11 | │   │ ├── control_lib (Hosted control path library) 12 | │ │ ├── stm32 13 | │   │ │   ├── app (Contain Initialization sequence of STM32 firmware, control 14 | │   │ │   │ │ and data path modules) 15 | │   │ │   │   ├── control (Contain files for control path, used for Wi-Fi connectivity) 16 | │   │ │   │   └── data (Contain files for demo APP, ARP server. The application 17 | │   │ │   │ would need to be hooked here.) 18 | │ │ │   ├── common (Contain common constructs used across app, driver) 19 | │ │ │   ├── driver (Contain modules of networking, serial interface and SPI transport) 20 | │ │ │   │   ├── netif (API for network device operation (netdev)) 21 | │ │ │   │   ├── network (Contain netdev API implementation and network stub. Network stub 22 | │ │ │   │ │ should be replace by actual network stub like lwip by user) 23 | │ │ │   │   ├── serial (Contain Virtual Serial Interface implemented over SPI transport) 24 | │ │ │   │   └── transport 25 | │ │ │   │   ├── SDIO (Contain driver for SDIO transport) 26 | │ │ │   │   └── SPI (Contain driver for SPI transport) 27 | │ │ │   ├── proj (Contain windows 'batch'(.bat) file and sh scripts for project setup. Also contain 28 | │ │ │ │ `.ioc` file which is HAL layer for STM32, used in project installation in STM32CubeIDE) 29 | │   │ │   └── port (Porting files for OS abstraction, contains wrappers 30 | │ │ │ for thread creation, semaphore operations, memory functions, 31 | │ │ │ serial driver operations etc) 32 | │   │ └── virtual_serial_if (Virtual serial interface, platform agnostic layer, 33 | │ │ which provides abstraction to setup control path 34 | │ │ over serial driver) 35 | ``` 36 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/MCU_based_host/stm32_esp32_sdio_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/MCU_based_host/stm32_esp32_sdio_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_fg/docs/MCU_based_host/stm_esp32_c6_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/MCU_based_host/stm_esp32_c6_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_fg/docs/common/contrl_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/common/contrl_path.png -------------------------------------------------------------------------------- /esp_hosted_fg/docs/common/ctrl_path_python.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/common/ctrl_path_python.gif -------------------------------------------------------------------------------- /esp_hosted_fg/docs/esp_hosted_performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_fg/docs/esp_hosted_performance.png -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/BLE4.2.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | BLE-4.2 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/BLE5.0.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | BLE-5.0 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/BLE5.3.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | BLE-5.3 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/ClassicBT.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Classic-BT 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32c2.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32-C2 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32c3.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32-C3 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32c5.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32-C5 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32c6.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32-C6 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32s2.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32-S2 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/esp32s3.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ESP32-S3 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/sdio_only.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | SDIO Only 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/sdio_uart.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | SDIO 18 | 19 | 20 | 21 | 22 | 23 | UART 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/spi_only.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | SPI Only 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/spi_uart.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | SPI 18 | 19 | 20 | 21 | 22 | 23 | UART 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/wifi.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Wi-Fi 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/wifi_6.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Wi-Fi 6 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/docs/icons/wifi_dual_band.svg: -------------------------------------------------------------------------------- 1 | 2 | ESP-Hosted transport 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Wi-Fi Dual-Band 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | file(READ "../../../common/include/esp_fw_version.h" HEADER_CONTENTS) 6 | set(PROJECT_VERSION_REGEX "#define[ \t]+PROJECT_NAME[ \t]+\"([A-Z]+)\"[ \t\n]+#define[ \t]+PROJECT_VERSION_MAJOR_1[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_VERSION_MAJOR_2[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_VERSION_MINOR[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_REVISION_PATCH_1[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_REVISION_PATCH_2[ \t]+([0-9]+)") 7 | string(REGEX MATCH "${PROJECT_VERSION_REGEX}" PROJECT_VERSION_MATCH "${HEADER_CONTENTS}") 8 | 9 | if(PROJECT_VERSION_MATCH) 10 | set(PROJECT_NAME "${CMAKE_MATCH_1}") 11 | set(PROJECT_VERSION_MAJOR_1 "${CMAKE_MATCH_2}") 12 | set(PROJECT_VERSION_MAJOR_2 "${CMAKE_MATCH_3}") 13 | set(PROJECT_VERSION_MINOR "${CMAKE_MATCH_4}") 14 | set(PROJECT_REVISION_PATCH_1 "${CMAKE_MATCH_5}") 15 | set(PROJECT_REVISION_PATCH_2 "${CMAKE_MATCH_6}") 16 | 17 | # Construct project version 18 | set(PROJECT_VER "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR_1}.${PROJECT_VERSION_MAJOR_2}.${PROJECT_VERSION_MINOR}.${PROJECT_REVISION_PATCH_1}.${PROJECT_REVISION_PATCH_2}") 19 | 20 | message(*************************************************************************************) 21 | message(" Building ESP-Hosted Firmware version :: ${PROJECT_VER} ") 22 | message(*************************************************************************************) 23 | endif() 24 | 25 | set(PROJECT_VER "${PROJECT_VER}") 26 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 27 | project(network_adapter) 28 | idf_build_set_property(COMPILE_OPTIONS "-fdiagnostics-color=always" APPEND) 29 | 30 | if(NOT CONFIG_IDF_TARGET_ESP32C2 AND NOT CONFIG_IDF_TARGET_ESP32C3) 31 | idf_component_get_property(lwip lwip COMPONENT_LIB) 32 | if(TARGET ${lwip}) 33 | # Use generator expressions to only apply to non-INTERFACE targets 34 | get_target_property(lwip_type ${lwip} TYPE) 35 | if(NOT lwip_type STREQUAL "INTERFACE_LIBRARY") 36 | message(STATUS "********** Configuring LWIP for network split mode with custom hook **********") 37 | target_include_directories(${lwip} PRIVATE "${PROJECT_DIR}/main") 38 | target_compile_definitions(${lwip} PRIVATE "-DESP_IDF_LWIP_HOOK_FILENAME=\"esp_hosted_lwip_src_port_hook.h\"") 39 | endif() 40 | endif() 41 | else() 42 | message(STATUS "********** Skipping LWIP for network split mode with custom hook **********") 43 | # Do not reference esp_http_client for esp32c2 and esp32c3 44 | endif() -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(common_dir "../../../../common") 2 | 3 | set(COMPONENT_SRCS 4 | "slave_control.c" 5 | "${common_dir}/esp_hosted_config.pb-c.c" 6 | "${common_dir}/utils/esp_hosted_cli.c" 7 | "protocomm_pserial.c" 8 | "esp_hosted_coprocessor.c" 9 | "slave_bt.c" 10 | "mempool.c" 11 | "stats.c" 12 | "mempool_ll.c" 13 | "host_power_save.c" 14 | "lwip_filter.c" 15 | ) 16 | 17 | if(CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_MQTT) 18 | list(APPEND COMPONENT_SRCS mqtt_example.c) 19 | endif() 20 | 21 | if(CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_HTTP_CLIENT) 22 | list(APPEND COMPONENT_SRCS http_req.c) 23 | endif() 24 | 25 | set(COMPONENT_ADD_INCLUDEDIRS 26 | "." 27 | "${common_dir}/include" 28 | "${common_dir}/utils" 29 | ) 30 | 31 | if(CONFIG_ESP_SDIO_HOST_INTERFACE) 32 | list(APPEND COMPONENT_SRCS sdio_slave_api.c) 33 | else(CONFIG_ESP_SPI_HOST_INTERFACE) 34 | list(APPEND COMPONENT_SRCS spi_slave_api.c) 35 | endif() 36 | 37 | register_component() 38 | target_compile_definitions(${COMPONENT_LIB} PRIVATE) 39 | 40 | # Add directory of protocomm_priv.h to include paths 41 | idf_component_get_property(protocomm_dir protocomm COMPONENT_DIR) 42 | target_include_directories(${COMPONENT_LIB} PRIVATE "${protocomm_dir}/src/common") 43 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/esp_hosted_coprocessor.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __NETWORK_ADAPTER_PRIV__H 18 | #define __NETWORK_ADAPTER_PRIV__H 19 | 20 | #include "adapter.h" 21 | 22 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) 23 | #include "esp_mac.h" 24 | #define ESP_TCPIP_INIT() esp_netif_init(); 25 | #else 26 | #define ESP_TCPIP_INIT() tcpip_adapter_init() 27 | #endif 28 | 29 | typedef struct { 30 | interface_context_t *context; 31 | } adapter; 32 | 33 | esp_err_t esp_hosted_coprocessor_init(void); 34 | #endif 35 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/host_power_save.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __HOST_POWER_SAVE_H__ 8 | #define __HOST_POWER_SAVE_H__ 9 | 10 | #include "sdkconfig.h" 11 | #include "interface.h" 12 | 13 | #if defined(CONFIG_HOST_DEEP_SLEEP_ALLOWED) 14 | #error "Host power save is not supported, yet. will be supported in future releases" 15 | #if CONFIG_HOST_WAKEUP_GPIO == -1 16 | #error "CONFIG_HOST_WAKEUP_GPIO is not configured. Either disable host power save or configure the host wakeup GPIO pin using 'idf.py menuconfig'" 17 | #endif 18 | #define H_HOST_PS_ALLOWED 1 19 | extern uint8_t power_save_on; 20 | extern int64_t host_wakeup_time; 21 | #endif 22 | 23 | 24 | void host_power_save_init(void (*host_wakeup_callback)(void)); 25 | void host_power_save_deinit(void); 26 | int is_host_wakeup_needed(interface_buffer_handle_t *buf_handle); 27 | int wakeup_host(uint32_t timeout_ms); 28 | void host_power_save_alert(uint32_t ps_evt); 29 | 30 | /* Add new API to get last wakeup time */ 31 | static inline int64_t get_last_wakeup_time(void) 32 | { 33 | #if H_HOST_PS_ALLOWED 34 | return host_wakeup_time; 35 | #else 36 | return 0; 37 | #endif 38 | } 39 | 40 | static inline int is_host_power_saving(void) 41 | { 42 | #if H_HOST_PS_ALLOWED 43 | return power_save_on; 44 | #else 45 | return 0; 46 | #endif 47 | } 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | cmd_system: 3 | path: ${IDF_PATH}/examples/system/console/advanced/components/cmd_system 4 | rules: 5 | - if: target not in ["esp32c2", "esp32c3"] 6 | espressif/iperf: 7 | version: "*" 8 | rules: 9 | - if: target not in ["esp32c2", "esp32c3"] 10 | espressif/iperf-cmd: 11 | version: "~0.1.1" 12 | rules: 13 | - if: target not in ["esp32c2", "esp32c3"] 14 | esp-qa/wifi-cmd: 15 | version: "~0.1.0" 16 | rules: 17 | - if: target not in ["esp32c2", "esp32c3"] 18 | esp-qa/ping-cmd: 19 | version: "~0.0.1" 20 | rules: 21 | - if: target not in ["esp32c2", "esp32c3"] 22 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/lwip_filter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | typedef enum { 8 | SLAVE_LWIP_BRIDGE, 9 | HOST_LWIP_BRIDGE, 10 | BOTH_LWIP_BRIDGE, 11 | INVALID_BRIDGE, 12 | } hosted_l2_bridge; 13 | 14 | #if defined(CONFIG_NETWORK_SPLIT_ENABLED) && defined(CONFIG_LWIP_ENABLE) 15 | #include "esp_hosted_lwip_src_port_hook.h" 16 | 17 | hosted_l2_bridge filter_and_route_packet(void *frame_data, uint16_t frame_length); 18 | 19 | int configure_host_static_port_forwarding_rules(const char *ports_str_tcp_src, const char *ports_str_tcp_dst, 20 | const char *ports_str_udp_src, const char *ports_str_udp_dst); 21 | #endif 22 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/mqtt_example.h: -------------------------------------------------------------------------------- 1 | /* MQTT (over TCP) Example 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | #ifndef __MQTT_EXAMPLE_H__ 10 | #define __MQTT_EXAMPLE_H__ 11 | 12 | #ifdef CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_MQTT 13 | esp_err_t example_mqtt_init(void); 14 | esp_err_t example_mqtt_resume(void); 15 | esp_err_t example_mqtt_pause(void); 16 | #endif 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/protocomm_pserial.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #pragma once 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include "esp_hosted_config.pb-c.h" 23 | typedef esp_err_t (*pserial_xmit)(uint8_t *buf, ssize_t len); 24 | typedef ssize_t (*pserial_recv)(uint8_t *buf, ssize_t len); 25 | 26 | esp_err_t protocomm_pserial_start(protocomm_t *pc, pserial_xmit xmit, pserial_recv recv); 27 | esp_err_t protocomm_pserial_data_ready(protocomm_t *pc, uint8_t * in, int len, int msg_id); 28 | 29 | 30 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) 31 | #define QUEUE_HANDLE QueueHandle_t 32 | #else 33 | #define QUEUE_HANDLE xQueueHandle 34 | #endif 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/main/sdio_slave_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __SDIO_SLAVE_API_H 18 | #define __SDIO_SLAVE_API_H 19 | 20 | #if CONFIG_SOC_SDIO_SLAVE_SUPPORTED 21 | #else 22 | #error "SDIO is not supported for this target. Please use SPI" 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,1792K, 7 | ota_1,app,ota_1,0x1D0000,1792K, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32c2.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,0xf0000, 7 | ota_1,app,ota_1,0x100000,0xf0000, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32c3.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,1536K, 7 | ota_1,app,ota_1,0x190000,1536K, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32c5.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,1536K, 7 | ota_1,app,ota_1,0x190000,1536K, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32c6.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,1536K, 7 | ota_1,app,ota_1,0x190000,1536K, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32s2.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,1536K, 7 | ota_1,app,ota_1,0x190000,1536K, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/partitions.esp32s3.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,1536K, 7 | ota_1,app,ota_1,0x190000,1536K, 8 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # BT Configuration 2 | CONFIG_BT_ENABLED=y 3 | CONFIG_BT_CONTROLLER_ONLY=y 4 | 5 | # OTA 6 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 7 | CONFIG_PARTITION_TABLE_TWO_OTA=y 8 | 9 | # OS 10 | CONFIG_FREERTOS_HZ=1000 11 | CONFIG_ESP_WIFI_NVS_ENABLED=y 12 | 13 | # Linux Host Deep Sleep allowed? 14 | #------------------------------- 15 | # Linux host power save is not yet supported on FG 16 | CONFIG_HOST_DEEP_SLEEP_ALLOWED=n 17 | CONFIG_HOST_WAKEUP_GPIO=-1 18 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 2 | CONFIG_SDIO_DAT2_DISABLED= 3 | 4 | # BT Configuration 5 | CONFIG_BT_ENABLED=y 6 | CONFIG_BT_CONTROLLER_ONLY=y 7 | CONFIG_BT_BLUEDROID_ENABLED= 8 | CONFIG_BTDM_CONTROLLER_MODE_BTDM=y 9 | CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y 10 | CONFIG_BTDM_CTRL_AUTO_LATENCY=y 11 | CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=y 12 | CONFIG_BTDM_CTRL_MODEM_SLEEP=y 13 | 14 | # BT over UART 15 | #CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4=y 16 | #CONFIG_BTDM_CTRL_HCI_MODE_UART_H4=y 17 | #CONFIG_BT_HCI_UART_NO=1 18 | #CONFIG_BT_HCI_UART_BAUDRATE=921600 19 | 20 | #CO-EX config 21 | CONFIG_FREERTOS_UNICORE=n 22 | CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y 23 | CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 24 | CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 25 | CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y 26 | 27 | CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16 28 | CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 29 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y 30 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=64 31 | 32 | # OTA 33 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 34 | 35 | # partitions 36 | CONFIG_PARTITION_TABLE_CUSTOM=y 37 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.esp32.csv" 38 | 39 | # iram optimization 40 | CONFIG_ESP_WIFI_RX_IRAM_OPT=y 41 | CONFIG_ESP_WIFI_IRAM_OPT=y 42 | CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y 43 | CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y 44 | CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y 45 | 46 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 47 | #CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 48 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c2: -------------------------------------------------------------------------------- 1 | # 1. CPU 2 | #-------- 3 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_120=y 4 | 5 | # 2. BT Configuration 6 | #--------------------- 7 | CONFIG_BT_ENABLED=n 8 | CONFIG_BT_CONTROLLER_ONLY=y 9 | CONFIG_BT_LE_SLEEP_ENABLE=y 10 | 11 | # 2.1 BLE over SPI/SDIO 12 | #----------------------- 13 | CONFIG_BT_LE_HCI_INTERFACE_USE_RAM=y 14 | 15 | # 2.2 BLE over UART 16 | #------------------- 17 | #UART pins, Enable below config, delete sdkconfig and rebuild 18 | #CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y 19 | #CONFIG_BT_LE_HCI_UART_FLOWCTRL=n 20 | #CONFIG_BT_LE_HCI_UART_TX_PIN=5 21 | #CONFIG_BT_LE_HCI_UART_RX_PIN=18 22 | 23 | 24 | # 3. Partition Table 25 | #-------------------- 26 | CONFIG_PARTITION_TABLE_CUSTOM=y 27 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.esp32c2.csv" 28 | 29 | # 4. Mempool 30 | #------------ 31 | CONFIG_ESP_CACHE_MALLOC=y 32 | 33 | 34 | # 5 LWIP split 35 | #--------------- 36 | 37 | CONFIG_NETWORK_SPLIT_ENABLED=n 38 | 39 | 40 | # 6. Wifi config 41 | #---------------- 42 | #CONFIG_WIFI_CMD_BASIC_ONLY=y 43 | 44 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8 45 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=16 46 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=16 47 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 48 | CONFIG_ESP_WIFI_TX_BA_WIN=8 49 | #CONFIG_ESP_WIFI_TX_BA_WIN=16 50 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 51 | CONFIG_ESP_WIFI_RX_BA_WIN=8 52 | #CONFIG_ESP_WIFI_RX_BA_WIN=14 53 | 54 | CONFIG_ESP_WIFI_RX_IRAM_OPT=y 55 | CONFIG_ESP_WIFI_IRAM_OPT=y 56 | 57 | 58 | # 7. Optimizations 59 | #------------------- 60 | CONFIG_COMPILER_OPTIMIZATION_SIZE=y 61 | #CONFIG_COMPILER_OPTIMIZATION_PERF=y 62 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 63 | 64 | 65 | # 8. Stats 66 | #----------- 67 | CONFIG_ESP_PKT_STATS=y 68 | 69 | 70 | # 9. Mem optimizations 71 | #--------------------- 72 | CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y 73 | CONFIG_ESP32_DEFAULT_CPU_FREQ_120=y 74 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=120 75 | CONFIG_FREERTOS_UNICORE=y 76 | 77 | #10. C2 specific opts 78 | #--------------------- 79 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n 80 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y 81 | 82 | CONFIG_ESP_DEFAULT_TASK_STACK_SIZE=2048 83 | 84 | #11. C2 26 MHz XTAL chips 85 | # C2 generally in MP has 26MHz. 86 | # If your C2 has 40MHz, just comment below lines 87 | #--------------------------------- 88 | CONFIG_SOC_XTAL_SUPPORT_26M=y 89 | CONFIG_XTAL_FREQ_26=y 90 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32s2: -------------------------------------------------------------------------------- 1 | # 1. CPU 2 | #-------- 3 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=240 4 | 5 | # 2. Partition Table 6 | #-------------------- 7 | CONFIG_PARTITION_TABLE_CUSTOM=y 8 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.esp32s2.csv" 9 | 10 | # 3. Mempool 11 | #------------ 12 | CONFIG_ESP_CACHE_MALLOC=y 13 | 14 | 15 | # 4.1 LWIP split 16 | #--------------- 17 | 18 | CONFIG_NETWORK_SPLIT_ENABLED=y 19 | CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_START=61440 20 | CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_END=65535 21 | CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_START=61440 22 | CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_END=65535 23 | 24 | CONFIG_ESP_DEFAULT_LWIP_SLAVE=y 25 | 26 | # 4.2 LWIP split examples 27 | #------------------------- 28 | CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_MQTT=n 29 | 30 | 31 | # 5. Transport config 32 | #--------------------- 33 | # CONFIG_ESP_SDIO_NSEND_PSAMPLE=y 34 | # CONFIG_ESP_SDIO_DEFAULT_SPEED=y 35 | # CONFIG_ESP_SDIO_STREAMING_MODE=n 36 | 37 | # For SPI Full duplex C6 on ESP32-P4-Function-EV-Board, please uncomment below 38 | #CONFIG_C6_SPI_WITH_P4=y 39 | 40 | 41 | # 6. Wifi config 42 | #---------------- 43 | CONFIG_WIFI_CMD_BASIC_ONLY=y 44 | 45 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 46 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 47 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 48 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 49 | CONFIG_ESP_WIFI_TX_BA_WIN=16 50 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 51 | CONFIG_ESP_WIFI_RX_BA_WIN=16 52 | 53 | CONFIG_ESP_WIFI_RX_IRAM_OPT=y 54 | CONFIG_ESP_WIFI_IRAM_OPT=y 55 | 56 | # 7. LWIP config 57 | #---------------- 58 | CONFIG_LWIP_TCP_SND_BUF_DEFAULT=11520 59 | CONFIG_LWIP_TCP_WND_DEFAULT=11520 60 | CONFIG_LWIP_TCP_RECVMBOX_SIZE=16 61 | CONFIG_LWIP_UDP_RECVMBOX_SIZE=16 62 | CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 63 | CONFIG_LWIP_TCP_SACK_OUT=y 64 | CONFIG_LWIP_TCPIP_CORE_LOCKING=y 65 | CONFIG_LWIP_TCPIP_CORE_LOCKING_INPUT=y 66 | 67 | 68 | # 8. Optimizations 69 | #------------------- 70 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 71 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 72 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 73 | CONFIG_SPI_MASTER_ISR_IN_IRAM=n 74 | 75 | 76 | # 9. Stats 77 | #----------- 78 | #CONFIG_ESP_HOSTED_FUNCTION_PROFILING=y 79 | CONFIG_ESP_PKT_STATS=y 80 | 81 | # 10. Priorities 82 | ---------------- 83 | CONFIG_IPERF_TRAFFIC_TASK_PRIORITY=18 84 | CONFIG_IPERF_REPORT_TASK_PRIORITY=18 85 | CONFIG_ESP_DEFAULT_TASK_PRIO=18 86 | 87 | 88 | # 11. Mem optimizations 89 | #--------------------- 90 | CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y 91 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/remove-idf.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Alias("h")] 3 | [switch]$help 4 | ) 5 | 6 | ### Script to remove ESP-IDF 7 | # 8 | # Delete the ESP-IDF directory, if it exists 9 | # 10 | ### 11 | 12 | 13 | $ESP_IDF_DIR="esp-idf" 14 | 15 | function Show-Help { 16 | Write-Host "Usage: .\remove-idf.ps1 [-help/-h]" 17 | Write-Host "Remove $ESP_IDF_DIR directory." 18 | Write-Host "" 19 | Write-Host "Options:" 20 | Write-Host " -help/-h Show this help message" 21 | exit 0 22 | } 23 | 24 | if ($help) { Show-Help } 25 | 26 | if (Test-Path -Path $ESP_IDF_DIR) { 27 | Write-Host "WARNING: This will delete $ESP_IDF_DIR directory." 28 | $response = Read-Host "Continue? [y/N]" 29 | if ($response -ne 'y') { Write-Host "Aborted."; exit 1 } 30 | Write-Host "Deleting $ESP_IDF_DIR." 31 | Remove-Item -Path $ESP_IDF_DIR -Recurse -Force 32 | } else { 33 | Write-Error "$ESP_IDF_DIR directory does not exists: cannot delete" 34 | exit 1 35 | } 36 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/remove-idf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### Script to remove ESP-IDF 4 | # 5 | # Delete the ESP-IDF directory, if it exists 6 | # 7 | ### 8 | 9 | ESP_IDF_DIR="esp-idf" 10 | 11 | show_help() { 12 | echo "Usage: .\remove-idf.ps1 [-help/-h]" 13 | echo "Remove $ESP_IDF_DIR directory." 14 | echo "" 15 | echo "Options:" 16 | echo " -h, --help Show this help message" 17 | exit 0 18 | } 19 | 20 | # Parse CLI arguments 21 | for arg in "$@"; do 22 | case "$arg" in 23 | -h|--help) 24 | show_help 25 | break; 26 | ;; 27 | *) 28 | echo "Unknown option: $arg" 29 | show_help 30 | break; 31 | ;; 32 | esac 33 | done 34 | 35 | # Check if esp-idf is present 36 | is_esp_idf_dir_present() { 37 | if [ -d "${ESP_IDF_DIR}" ] 38 | then 39 | echo 1 40 | else 41 | echo 0 42 | fi 43 | } 44 | 45 | # check for presence of ESP-IDF directory 46 | ESP_IDF_PRESENT=$(is_esp_idf_dir_present) 47 | 48 | if [ "${ESP_IDF_PRESENT}" -eq "1" ] 49 | then 50 | echo "WARNING: This will delete ${ESP_IDF_DIR} directory." 51 | read -p "Continue? [y/N]: " confirm 52 | if [[ "$confirm" != "y" && "$confirm" != "Y" ]] 53 | then 54 | echo "Aborted." 55 | exit 1 56 | fi 57 | 58 | rm -fr ${ESP_IDF_DIR} 59 | result=$? 60 | if [ "${result}" -ne "0" ] 61 | then 62 | echo "FAILED to delete ${ESP_IDF_DIR} directory. Aborting." 63 | exit 1 64 | fi 65 | else 66 | echo "${ESP_IDF_DIR} directory does not exists: cannot delete" 67 | echo "Aborted." 68 | exit 1 69 | fi 70 | -------------------------------------------------------------------------------- /esp_hosted_fg/esp/esp_driver/setup_windows11.md: -------------------------------------------------------------------------------- 1 | # Setup for building ESP-Hosted-FG on Windows 11 2 | 3 | Follow these steps to setup ESP-IDF and to compile ESP-Hosted-FG using the 4 | ESP-IDF configured Windows Powershell Command Line tool. 5 | 6 | 1. Install and setup ESP-IDF on Windows as documented in the [Standard Setup of Toolchain for 7 | Windows](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html). 8 | 9 | 2. Use the ESP-IDF [Powershell Command 10 | Prompt](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html#using-the-command-prompt) to execute `setup-idf.ps1` in the `esp_hosted_fg/esp/esp_driver` 11 | directory. It will setup ESP-IDF in the `esp-idf` directory to be used by 12 | `network_adapter`. Run `setup-idf.ps1 -h` for supported options. To 13 | remove the ESP-IDF installed by `setup-idf.ps1`, you can run the 14 | `remove-idf.ps1` script. 15 | 16 | 3. Setup ESP-IDF environment by running `export.ps1` in `esp-idf` 17 | directory 18 | 19 | 4. In the `network_adapter` directory of this project, input command 20 | `idf.py set-target ` to set target. 21 | 22 | 5. Use `idf.py build` to recompile `network_adapter` and generate new 23 | firmware. 24 | 25 | 6. Use `idf.py flash` to flash the firmware. 26 | 27 | 7. Use `idf.py monitor` to monitor the serial out. You can combine 28 | these two steps (flash and monitor) by running `idf.py flash monitor`. 29 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/components/include/esp_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Espressif Systems Wireless LAN device driver 3 | * 4 | * Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD 5 | * SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 6 | */ 7 | 8 | #ifndef __ESP_QUEUE_H__ 9 | #define __ESP_QUEUE_H__ 10 | 11 | #define ESP_QUEUE_SUCCESS 0 12 | #define ESP_QUEUE_ERR_UNINITALISED -1 13 | #define ESP_QUEUE_ERR_MEMORY -2 14 | 15 | typedef struct q_element { 16 | void *buf; 17 | int buf_len; 18 | } esp_queue_elem_t; 19 | 20 | /* Queue based on Linked List */ 21 | typedef struct esp_queue_node { 22 | void *data; 23 | struct esp_queue_node* next; 24 | } q_node_t; 25 | 26 | typedef struct esp_queue { 27 | q_node_t *front, *rear; 28 | } esp_queue_t; 29 | 30 | esp_queue_t* create_esp_queue(void); 31 | void *esp_queue_get(esp_queue_t* q); 32 | int esp_queue_put(esp_queue_t* q, void *data); 33 | void esp_queue_destroy(esp_queue_t** q); 34 | 35 | #endif /*__ESP_QUEUE_H__*/ 36 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/components/src/esp_queue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Espressif Systems Wireless LAN device driver 3 | * 4 | * Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD 5 | * SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 6 | */ 7 | 8 | #include 9 | #include 10 | #include "esp_queue.h" 11 | 12 | /* create new node */ 13 | static q_node_t * new_q_node(void *data) 14 | { 15 | q_node_t* new_node = (q_node_t*)malloc(sizeof(q_node_t)); 16 | if (!new_node) 17 | return NULL; 18 | new_node->data = data; 19 | new_node->next = NULL; 20 | return new_node; 21 | } 22 | 23 | /* Create app queue */ 24 | esp_queue_t* create_esp_queue(void) 25 | { 26 | esp_queue_t* q = (esp_queue_t*)malloc(sizeof(esp_queue_t)); 27 | if (!q) 28 | return NULL; 29 | 30 | q->front = q->rear = NULL; 31 | return q; 32 | } 33 | 34 | /* Put element in app queue */ 35 | int esp_queue_put(esp_queue_t* q, void *data) 36 | { 37 | q_node_t* new_node = NULL; 38 | 39 | if (!q) { 40 | printf("q undefined\n"); 41 | return ESP_QUEUE_ERR_UNINITALISED; 42 | } 43 | 44 | new_node = new_q_node(data); 45 | if (!new_node) { 46 | printf("malloc failed in qpp_q_put\n"); 47 | return ESP_QUEUE_ERR_MEMORY; 48 | } 49 | 50 | /* queue empty condition */ 51 | if (q->rear == NULL) { 52 | q->front = q->rear = new_node; 53 | return ESP_QUEUE_SUCCESS; 54 | } 55 | 56 | q->rear->next = new_node; 57 | q->rear = new_node; 58 | return ESP_QUEUE_SUCCESS; 59 | } 60 | 61 | /* Get element in app queue */ 62 | void *esp_queue_get(esp_queue_t* q) 63 | { 64 | void * data = NULL; 65 | q_node_t* temp = NULL; 66 | 67 | if (!q || q->front == NULL) 68 | return NULL; 69 | 70 | /* move front one node ahead */ 71 | temp = q->front; 72 | 73 | if (!temp) 74 | return NULL; 75 | 76 | q->front = q->front->next; 77 | 78 | data = temp->data; 79 | 80 | free(temp); 81 | temp = NULL; 82 | 83 | /* If front is NULL, change rear also as NULL */ 84 | if (q->front == NULL) 85 | q->rear = NULL; 86 | 87 | return data; 88 | } 89 | 90 | void esp_queue_destroy(esp_queue_t** q) 91 | { 92 | q_node_t* temp = NULL; 93 | 94 | if (!q || !*q) 95 | return; 96 | 97 | while ((*q)->front) { 98 | 99 | temp = (*q)->front; 100 | (*q)->front = (*q)->front->next; 101 | 102 | if (temp->data) { 103 | free(temp->data); 104 | temp->data = NULL; 105 | } 106 | 107 | free(temp); 108 | temp = NULL; 109 | } 110 | 111 | free(*q); 112 | *q = NULL; 113 | } 114 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/control_lib/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | # Compiler and linker flags 4 | CROSS_COMPILE := 5 | CFLAGS = -Wall -g -fPIC 6 | LDFLAGS = -lpthread -lrt 7 | 8 | # Directory paths 9 | DIR_ROOT = $(CURDIR)/../.. 10 | DIR_COMMON = $(DIR_ROOT)/common 11 | DIR_COMPONENTS = $(DIR_ROOT)/host/components 12 | DIR_SERIAL = $(DIR_ROOT)/host/virtual_serial_if 13 | DIR_LINUX_PORT = $(DIR_ROOT)/host/linux/port 14 | DIR_CONTROL_LIB = $(DIR_ROOT)/host/control_lib 15 | 16 | # Include paths 17 | INCLUDE += -I$(DIR_COMMON)/protobuf-c 18 | INCLUDE += -I$(DIR_COMMON)/include 19 | INCLUDE += -I$(DIR_CONTROL_LIB)/include 20 | INCLUDE += -I$(DIR_CONTROL_LIB)/src/include 21 | INCLUDE += -I$(DIR_SERIAL)/include 22 | INCLUDE += -I$(DIR_COMPONENTS)/include 23 | INCLUDE += -I$(DIR_LINUX_PORT)/include 24 | 25 | # Source files for the core library 26 | CORE_SRC = $(DIR_COMMON)/protobuf-c/protobuf-c/protobuf-c.c 27 | CORE_SRC += $(DIR_COMMON)/esp_hosted_config.pb-c.c 28 | CORE_SRC += $(DIR_CONTROL_LIB)/src/ctrl_core.c 29 | CORE_SRC += $(DIR_CONTROL_LIB)/src/ctrl_api.c 30 | CORE_SRC += $(DIR_SERIAL)/src/serial_if.c 31 | CORE_SRC += $(DIR_COMPONENTS)/src/esp_queue.c 32 | CORE_SRC += $(DIR_LINUX_PORT)/src/platform_wrapper.c 33 | 34 | # Target library 35 | LIBCONTROL = libesp_hosted_rpc.so 36 | LIBCONTROL_STATIC = libesp_hosted_rpc.a 37 | 38 | .PHONY: all clean shared static 39 | 40 | all: shared static 41 | 42 | shared: $(LIBCONTROL) 43 | 44 | static: $(LIBCONTROL_STATIC) 45 | 46 | # Build the shared library 47 | $(LIBCONTROL): $(CORE_SRC) 48 | $(CROSS_COMPILE)$(CC) $(CFLAGS) $(INCLUDE) -shared -o $@ $^ $(LDFLAGS) 49 | 50 | # Build the static library 51 | $(LIBCONTROL_STATIC): $(CORE_SRC:.c=.o) 52 | ar rcs $@ $^ 53 | 54 | %.o: %.c 55 | $(CROSS_COMPILE)$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ 56 | 57 | install: all 58 | @mkdir -p $(DIR_ROOT)/lib 59 | @cp -f $(LIBCONTROL) $(LIBCONTROL_STATIC) $(DIR_ROOT)/lib/ 60 | 61 | clean: 62 | rm -f $(LIBCONTROL) $(LIBCONTROL_STATIC) $(CORE_SRC:.c=.o) 63 | 64 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/control_lib/src/include/ctrl_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Espressif Systems Wireless LAN device driver 3 | * 4 | * Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD 5 | * SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 6 | */ 7 | 8 | #ifndef __CTRL_CORE_H 9 | #define __CTRL_CORE_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include "ctrl_api.h" 15 | 16 | #define BIT(n) (1UL << (n)) 17 | 18 | #define MAX_SSID_LENGTH 32 19 | #define MIN_PWD_LENGTH 8 20 | #define MAX_PWD_LENGTH 64 21 | #define MIN_CHNL_NO 1 22 | #define MAX_CHNL_NO 11 23 | #define MIN_CONN_NO 1 24 | #define MAX_CONN_NO 10 25 | 26 | /* 27 | * Allows user app to create low level protobuf request 28 | * returns SUCCESS(0) or FAILURE(-1) 29 | */ 30 | int ctrl_app_send_req(ctrl_cmd_t *app_req); 31 | 32 | /* When request is sent without an async callback, this function will be called 33 | * It will wait for control response or timeout for control response 34 | * This is only used in synchrounous control path 35 | * 36 | * Input: 37 | * > req - control request from user 38 | * 39 | * Returns: control response or NULL in case of timeout 40 | * 41 | **/ 42 | ctrl_cmd_t * ctrl_wait_and_parse_sync_resp(ctrl_cmd_t *req); 43 | 44 | 45 | /* Checks if async control response callback is available 46 | * in argument passed of type control request 47 | * 48 | * Input: 49 | * > req - control request from user 50 | * 51 | * Returns: 52 | * > CALLBACK_AVAILABLE - if a non NULL asynchrounous control response 53 | * callback is available 54 | * In case of failures - 55 | * > MSG_ID_OUT_OF_ORDER - if request msg id is unsupported 56 | * > CALLBACK_NOT_REGISTERED - if aync callback is not available 57 | **/ 58 | int is_async_resp_callback_registered(ctrl_cmd_t *req); 59 | #endif /* __CTRL_CORE_H */ 60 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/c_support/app_custom_rpc.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2025 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef __APP_CUSTOM_RPC_H__ 22 | #define __APP_CUSTOM_RPC_H__ 23 | 24 | #include 25 | #include "ctrl_api.h" 26 | #include "esp_hosted_custom_rpc.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | * @brief Custom RPC Demo 1: Send a request with only acknowledgement 34 | * 35 | * This demo shows how to send a custom RPC request with packed data 36 | * and receive only an acknowledgement. No specific data is expected in response. 37 | * 38 | * @return SUCCESS if the operation was successful, FAILURE otherwise 39 | */ 40 | int custom_rpc_demo1_request_only_ack(void); 41 | 42 | /** 43 | * @brief Custom RPC Demo 2: Send a request and get echo back as response 44 | * 45 | * This demo shows how to send a custom RPC request with packed data 46 | * and receive an echo back response. The response is verified to be 47 | * the same as the sent data. 48 | * 49 | * @return SUCCESS if the operation was successful, FAILURE otherwise 50 | */ 51 | int custom_rpc_demo2_request_echo_back_as_response(void); 52 | 53 | /** 54 | * @brief Custom RPC Demo 3: Send a request and get echo back as event 55 | * 56 | * This demo shows how to send a custom RPC request with packed data 57 | * and receive an echo back as an event. The event data is verified 58 | * in the event handler. 59 | * 60 | * @return SUCCESS if the operation was successful, FAILURE otherwise 61 | */ 62 | int custom_rpc_demo3_request_echo_back_as_event(void); 63 | 64 | /** 65 | * @brief Custom RPC Event Handler 66 | * 67 | * This function is called when a custom RPC event is received. 68 | * 69 | * @param app_event The custom RPC event 70 | */ 71 | int custom_rpc_event_handler(ctrl_cmd_t *app_event); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* __APP_CUSTOM_RPC_H__ */ 78 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/c_support/hosted_shell.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | */ 7 | 8 | #ifndef HOSTED_SHELL_H 9 | #define HOSTED_SHELL_H 10 | 11 | #include "ctrl_api.h" 12 | #include 13 | 14 | #define USE_REPLXX 1 15 | 16 | /* Shell interface wrapper macros */ 17 | #ifdef USE_REPLXX 18 | #include 19 | #define SHELL_INIT() replxx_init() 20 | #define SHELL_CLEANUP(replxx) replxx_end(replxx) 21 | #define SHELL_READ_LINE(replxx) replxx_input(replxx, "esp-hosted> ") 22 | #define SHELL_ADD_HISTORY(replxx, line) replxx_history_add(replxx, line) 23 | #define SHELL_SAVE_HISTORY(replxx, file) replxx_history_save(replxx, file) 24 | #define SHELL_LOAD_HISTORY(replxx, file) replxx_history_load(replxx, file) 25 | #define SHELL_SET_COMPLETION_CALLBACK(replxx, callback, user_data) replxx_set_completion_callback(replxx, callback, user_data) 26 | #define SHELL_SET_HINT_CALLBACK(replxx, callback, user_data) replxx_set_hint_callback(replxx, callback, user_data) 27 | #define SHELL_PRINT(replxx, fmt, ...) replxx_print(replxx, fmt, ##__VA_ARGS__) 28 | //#define SHELL_FREE(ptr) replxx_free(ptr); 29 | #else 30 | /* Add other shell library wrappers here */ 31 | #endif 32 | 33 | /* Define command argument types */ 34 | typedef enum { 35 | ARG_TYPE_STRING, 36 | ARG_TYPE_INT, 37 | ARG_TYPE_BOOL, 38 | ARG_TYPE_CHOICE 39 | } arg_type_t; 40 | 41 | /* Define command argument structure */ 42 | typedef struct { 43 | const char *name; /* Argument name with -- prefix */ 44 | const char *help; /* Help text */ 45 | arg_type_t type; /* Argument type */ 46 | bool required; /* Whether argument is required */ 47 | const char **choices; /* Valid choices for ARG_TYPE_CHOICE */ 48 | } cmd_arg_t; 49 | 50 | /* Command structure */ 51 | typedef struct { 52 | const char *name; 53 | const char *help; 54 | int (*handler)(int argc, char **argv); 55 | const cmd_arg_t *args; 56 | int arg_count; 57 | } shell_command_t; 58 | 59 | /* Shell context */ 60 | typedef struct { 61 | Replxx *shell_handle; 62 | int running; 63 | pthread_t ip_restore_thread; 64 | } shell_context_t; 65 | 66 | /* Command completion callback */ 67 | void shell_completion_callback(const char *text, replxx_completions *completions, int *context_len, void *user_data); 68 | 69 | /* Command hint callback */ 70 | void shell_hint_callback(const char *text, replxx_hints *hints, int *context_len, ReplxxColor *color, void *user_data); 71 | 72 | /* Get shell context */ 73 | shell_context_t *get_shell_context(void); 74 | 75 | #endif /* HOSTED_SHELL_H */ 76 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/c_support/nw_helper_func.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifndef NW_HELPER_FUNC_H 4 | #define NW_HELPER_FUNC_H 5 | 6 | #define STA_INTERFACE "ethsta0" 7 | #define AP_INTERFACE "ethap0" 8 | #define MAC_ADDR_LENGTH 18 9 | 10 | #define SUCCESS 0 11 | #define FAILURE -1 12 | 13 | /* Network state structure */ 14 | typedef struct { 15 | char mac_addr[MAC_ADDR_LENGTH]; 16 | char ip_addr[MAC_ADDR_LENGTH]; 17 | char netmask[MAC_ADDR_LENGTH]; 18 | char gateway[MAC_ADDR_LENGTH]; 19 | char dns_addr[MAC_ADDR_LENGTH]; 20 | char default_route[MAC_ADDR_LENGTH]; 21 | uint8_t ip_valid; 22 | uint8_t dns_valid; 23 | uint8_t network_up; 24 | } network_info_t; 25 | 26 | int down_sta_netdev(const network_info_t *info); 27 | int up_sta_netdev(const network_info_t *info); 28 | int up_sta_netdev__with_static_ip_dns_route(const network_info_t *info); 29 | 30 | int down_softap_netdev(const network_info_t *info); 31 | int up_softap_netdev(const network_info_t *info); 32 | 33 | int remove_default_gateway(const char *gateway); 34 | int add_default_gateway(const char *gateway); 35 | int remove_dns(const char *dns); 36 | int add_dns(const char *dns); 37 | int set_network_static_ip(int sockfd, const char* iface, const char* ip, const char* netmask, const char* gateway); 38 | 39 | int create_socket(int domain, int type, int protocol, int *sock); 40 | int close_socket(int sock); 41 | 42 | int interface_up(int sockfd, const char* iface); 43 | int interface_down(int sockfd, const char* iface); 44 | 45 | int set_hw_addr(int sockfd, const char* iface, const char* mac); 46 | int convert_mac_to_bytes(uint8_t *out, size_t out_size, const char *s); 47 | 48 | int update_host_network_port_range(uint16_t port_start, uint16_t port_end); 49 | int clear_host_network_port_range(void); 50 | #endif 51 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/python_support/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | CFLAGS = -Wall -fPIC 4 | CROSS_COMPILE := 5 | 6 | SRCS = $(wildcard *.c) 7 | OBJS = $(SRCS:.c=.o) 8 | 9 | DIR_ROOT = $(CURDIR)/../../../../ 10 | LIB_DIR = $(DIR_ROOT)/host/control_lib 11 | CONTROL_LIB = $(LIB_DIR)/libesp_hosted_rpc.a 12 | 13 | DIR_COMMON = $(DIR_ROOT)/common 14 | DIR_CTRL_LIB = $(DIR_ROOT)/host/control_lib 15 | DIR_SERIAL = $(DIR_ROOT)/host/virtual_serial_if 16 | DIR_COMPONENTS = $(DIR_ROOT)/host/components 17 | DIR_LINUX_PORT = $(DIR_ROOT)/host/linux/port 18 | 19 | INCLUDE += -I$(DIR_COMMON)/protobuf-c 20 | INCLUDE += -I$(DIR_COMMON)/include 21 | INCLUDE += -I$(DIR_CTRL_LIB)/include 22 | INCLUDE += -I$(DIR_CTRL_LIB)/src/include 23 | INCLUDE += -I$(DIR_SERIAL)/include 24 | INCLUDE += -I$(DIR_COMPONENTS)/include 25 | INCLUDE += -I$(DIR_LINUX_PORT)/include 26 | INCLUDE += -I. 27 | 28 | LIBPATH = -L$(LIB_DIR) 29 | LIBS = -Wl,--whole-archive $(CONTROL_LIB) -Wl,--no-whole-archive 30 | LINKER = -lrt -lpthread 31 | 32 | TARGET = commands.so 33 | 34 | .PHONY: all clean ensure_libs 35 | 36 | all: ensure_libs $(TARGET) 37 | 38 | ensure_libs: 39 | @if [ ! -f $(CONTROL_LIB) ]; then \ 40 | echo "Building control library first..."; \ 41 | $(MAKE) -C $(DIR_CTRL_LIB) install; \ 42 | fi 43 | 44 | %.o: %.c 45 | $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ 46 | 47 | $(TARGET): $(OBJS) 48 | $(CC) $(CFLAGS) -shared -o $@ $^ $(LIBPATH) $(LIBS) $(LINKER) 49 | 50 | clean: 51 | rm -f $(TARGET) *.o 52 | $(MAKE) -C $(DIR_CTRL_LIB) clean 53 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/python_support/setup_python.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | # Install python3 5 | sudo apt install python3 6 | 7 | # Python virtual environment steps are explained in documentation at 8 | # https://github.com/espressif/esp-hosted/blob/master/esp_hosted_fg/docs/common/python_demo.md#demo-app-in-python 9 | # Current setup assumes python venv is not needed. 10 | sudo python3 -m pip install prompt_toolkit fire argparse docstring_parser requests 11 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/python_support/stop_dhcp_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script stops the custom dnsmasq instance started by run_dhcp_server.sh 4 | 5 | echo "[stop_dhcp_server.sh] Stopping DHCP server..." 6 | 7 | # Check if the script is run as root 8 | if [ "$EUID" -ne 0 ]; then 9 | echo "[stop_dhcp_server.sh] This script must be run as root. Exiting." 10 | exit 1 11 | fi 12 | 13 | echo "[stop_dhcp_server.sh] Looking for custom dnsmasq instance(s) running on port 40000..." 14 | PIDS=$(ps -eaf | grep -i "dnsmasq" | grep -- "--port=40000" | grep -v grep | awk '{print $2}') 15 | if [ -n "$PIDS" ]; then 16 | echo "[stop_dhcp_server.sh] > Stopping custom dnsmasq instance(s) with PID(s): $PIDS" 17 | sudo kill $PIDS 18 | echo "[stop_dhcp_server.sh] Custom dnsmasq instance(s) stopped." 19 | else 20 | echo "[stop_dhcp_server.sh] No custom dnsmasq instance running" 21 | fi 22 | 23 | echo "[stop_dhcp_server.sh] DHCP server stop complete." 24 | exit 0 25 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_control/spidev_disabler.dts: -------------------------------------------------------------------------------- 1 | /dts-v1/; 2 | /plugin/; 3 | 4 | / { 5 | compatible = "brcm,bcm2708"; 6 | 7 | fragment@0 { 8 | target = <&spidev0>; 9 | 10 | __overlay__ { 11 | status = "disabled"; 12 | }; 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/Makefile: -------------------------------------------------------------------------------- 1 | CONFIG_BT_ENABLED := y 2 | CONFIG_TEST_RAW_TP := n 3 | CONFIG_INFO_LOGS=y 4 | CONFIG_DEBUG_LOGS=n 5 | CONFIG_VERBOSE_LOGS=n 6 | #CONFIG_ESP_HOSTED_USE_WORKQUEUE=y # If set 'n', would semaphore based solution 7 | 8 | # In case of SDIO as transport, one of slave chipset used, 9 | # CONFIG_TARGET_ESP32 OR 10 | # CONFIG_TARGET_ESP32C6 11 | # need to be added depending upon slave in use 12 | # rpi_init.sh will add that flag using ESP_SLAVE 13 | ESP_SLAVE := "" 14 | 15 | # Imx8mm 16 | # CROSS_COMPILE := "/opt/fsl-imx-wayland/5.15-kirkstone/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-" 17 | # KERNEL := "/home/u64/imx8_dev_board/imx-yocto-bsp/build/tmp/work/imx8mm_lpddr4_evk-poky-linux/linux-imx/5.15.52+gitAUTOINC+36363d8623-r0/build" 18 | 19 | CROSS_COMPILE := 20 | KERNEL := /lib/modules/$(shell uname -r)/build 21 | ARCH := arm64 22 | 23 | #Default interface is sdio 24 | MODULE_NAME=esp32_sdio 25 | 26 | #Targets passed overrrides default value 27 | ifeq ($(target), sdio) 28 | MODULE_NAME=esp32_sdio 29 | endif 30 | 31 | ifeq ($(target), spi) 32 | MODULE_NAME=esp32_spi 33 | endif 34 | 35 | ifeq ($(CONFIG_TEST_RAW_TP), y) 36 | EXTRA_CFLAGS += -DCONFIG_TEST_RAW_TP 37 | endif 38 | 39 | ifeq ($(CONFIG_BT_ENABLED), y) 40 | EXTRA_CFLAGS += -DCONFIG_BT_ENABLED 41 | module_objects += esp_bt.o 42 | endif 43 | 44 | EXTRA_CFLAGS += -I$(PWD)/../../../../common/include -I$(PWD) 45 | 46 | ifeq ($(MODULE_NAME), esp32_sdio) 47 | EXTRA_CFLAGS += -I$(PWD)/sdio 48 | module_objects += sdio/esp_sdio.o sdio/esp_sdio_api.o 49 | endif 50 | 51 | ifeq ($(MODULE_NAME), esp32_spi) 52 | EXTRA_CFLAGS += -I$(PWD)/spi 53 | module_objects += spi/esp_spi.o 54 | endif 55 | 56 | ifneq ($(ESP_SLAVE), "") 57 | EXTRA_CFLAGS += -D$(ESP_SLAVE) 58 | endif 59 | 60 | ifeq ($(CONFIG_INFO_LOGS), y) 61 | EXTRA_CFLAGS += -DCONFIG_INFO_LOGS 62 | endif 63 | 64 | ifeq ($(CONFIG_DEBUG_LOGS), y) 65 | EXTRA_CFLAGS += -DCONFIG_INFO_LOGS 66 | EXTRA_CFLAGS += -DCONFIG_DEBUG_LOGS 67 | endif 68 | 69 | ifeq ($(CONFIG_VERBOSE_LOGS), y) 70 | EXTRA_CFLAGS += -DCONFIG_INFO_LOGS 71 | EXTRA_CFLAGS += -DCONFIG_DEBUG_LOGS 72 | EXTRA_CFLAGS += -DCONFIG_VERBOSE_LOGS 73 | endif 74 | 75 | PWD := $(shell pwd) 76 | 77 | obj-m := $(MODULE_NAME).o 78 | $(MODULE_NAME)-y := main.o esp_stats.o $(module_objects) 79 | $(MODULE_NAME)-y += esp_serial.o esp_rb.o esp_fw_verify.o 80 | 81 | all: 82 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) modules 83 | 84 | clean: 85 | rm -rf *.o sdio/*.o spi/*.o *.ko 86 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) clean 87 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef _esp_api__h_ 22 | #define _esp_api__h_ 23 | 24 | #include "esp.h" 25 | 26 | int esp_add_card(struct esp_adapter *adapter); 27 | int esp_remove_card(struct esp_adapter *adapter); 28 | void esp_process_new_packet_intr(struct esp_adapter *adapter); 29 | struct esp_adapter * esp_get_adapter(void); 30 | struct sk_buff * esp_alloc_skb(u32 len); 31 | int esp_send_packet(struct esp_adapter *adapter, struct sk_buff *skb); 32 | u8 esp_is_bt_supported_over_sdio(u32 cap); 33 | int esp_is_tx_queue_paused(void); 34 | void esp_tx_pause(void); 35 | void esp_tx_resume(void); 36 | int process_init_event(u8 *evt_buf, u8 len); 37 | void process_capabilities(u8 cap); 38 | void process_test_capabilities(u8 cap); 39 | int is_host_sleeping(void); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_bt_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef __esp_bt_api_h_ 22 | #define __esp_bt_api_h_ 23 | 24 | #include "esp.h" 25 | 26 | int esp_init_bt(struct esp_adapter *adapter); 27 | int esp_deinit_bt(struct esp_adapter *adapter); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_fw_verify.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 4 | * 5 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 6 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 7 | * (the "License"). You may use, redistribute and/or modify this File in 8 | * accordance with the terms and conditions of the License, a copy of which 9 | * is available by writing to the Free Software Foundation, Inc., 10 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 11 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 12 | * 13 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 14 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 15 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 16 | * this warranty disclaimer. 17 | */ 18 | #include "esp_utils.h" 19 | 20 | #include "esp.h" 21 | #include "esp_fw_verify.h" 22 | 23 | #define VERSION_BUFFER_SIZE 50 24 | 25 | // default: we do strict check 26 | static fw_check_t fw_check_type = FW_CHECK_STRICT; 27 | 28 | int set_fw_check_type(fw_check_t check) 29 | { 30 | fw_check_type = check; 31 | 32 | return 0; 33 | } 34 | 35 | fw_check_t get_fw_check_type(void) 36 | { 37 | return fw_check_type; 38 | } 39 | 40 | int check_esp_version(struct fw_version *ver) 41 | { 42 | char version_str[VERSION_BUFFER_SIZE] = { 0 }; 43 | 44 | snprintf(version_str, VERSION_BUFFER_SIZE, "%s-%u.%u.%u.%u.%u", 45 | ver->project_name, ver->major1, ver->major2, ver->minor, ver->revision_patch_1, ver->revision_patch_2); 46 | 47 | esp_info("Driver supports Firmware version: %s\n", RELEASE_VERSION); 48 | esp_info("ESP Firmware version: %s\n", version_str); 49 | if (fw_check_type == FW_CHECK_STRICT) { 50 | if (strncmp(RELEASE_VERSION, version_str, strlen(version_str)) != 0) { 51 | esp_err("Incompatible ESP firmware release detected. Please use correct ESP-Hosted branch/compatible release\n"); 52 | return -1; 53 | } 54 | } 55 | return 0; 56 | } 57 | 58 | int process_fw_data(struct fw_version *fw_p, int tag_len) 59 | { 60 | if (tag_len != sizeof(struct fw_version)) { 61 | esp_err("Length not matching to firmware data size\n"); 62 | return -1; 63 | } 64 | 65 | return check_esp_version(fw_p); 66 | } 67 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_fw_verify.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2024 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef _ESP_FW_VERIFY_H_ 22 | #define _ESP_FW_VERIFY_H_ 23 | 24 | #include "adapter.h" 25 | 26 | #include "esp_fw_version.h" 27 | 28 | #define STRINGIFY_HELPER(x) #x 29 | #define STRINGIFY(x) STRINGIFY_HELPER(x) 30 | 31 | #define RELEASE_VERSION PROJECT_NAME "-" STRINGIFY(PROJECT_VERSION_MAJOR_1) "." STRINGIFY(PROJECT_VERSION_MAJOR_2) "." STRINGIFY(PROJECT_VERSION_MINOR) "." STRINGIFY(PROJECT_REVISION_PATCH_1) "." STRINGIFY(PROJECT_REVISION_PATCH_2) 32 | 33 | // enums to control checking of firmware version received from slave against driver version 34 | typedef enum { 35 | FW_CHECK_OFF = 0, // don't verify received fw version 36 | FW_CHECK_STRICT = 1, // strict: exact match with version in fw_version.h 37 | // add other types here 38 | } fw_check_t; 39 | 40 | int set_fw_check_type(fw_check_t check); 41 | fw_check_t get_fw_check_type(void); 42 | int check_esp_version(struct fw_version *ver); 43 | int process_fw_data(struct fw_version *fw_p, int tag_len); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_if.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef __ESP_IF__H_ 22 | #define __ESP_IF__H_ 23 | 24 | #include "esp.h" 25 | 26 | struct esp_if_ops { 27 | int (*init)(struct esp_adapter *adapter); 28 | struct sk_buff* (*read)(struct esp_adapter *adapter); 29 | int (*write)(struct esp_adapter *adapter, struct sk_buff *skb); 30 | int (*deinit)(struct esp_adapter *adapter); 31 | }; 32 | 33 | int esp_init_interface_layer(struct esp_adapter *adapter); 34 | void esp_deinit_interface_layer(void); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_rb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The citation should list that the code comes from the book "Linux Device 3 | * Drivers" by Alessandro Rubini and Jonathan Corbet, published 4 | * by O'Reilly & Associates.No warranty is attached; 5 | * 6 | * */ 7 | 8 | #ifndef _ESP_RB_H_ 9 | #define _ESP_RB_H_ 10 | 11 | typedef struct esp_rb { 12 | wait_queue_head_t wq; /* waitqueue to wait for data */ 13 | unsigned char *buf, *end; /* actual queue start and end */ 14 | size_t size; 15 | unsigned char *rp, *wp; /* current read/write pointers */ 16 | struct semaphore sem; /* Mutex to protect rb */ 17 | } esp_rb_t; 18 | 19 | int esp_rb_init(esp_rb_t *rb, size_t sz); 20 | void esp_rb_cleanup(esp_rb_t *rb); 21 | int esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block); 22 | int esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz); 23 | int get_free_space(esp_rb_t *rb); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_serial.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef _ESP_SERIAL_H_ 22 | #define _ESP_SERIAL_H_ 23 | 24 | int esp_serial_init(void * priv); 25 | void esp_serial_cleanup(void); 26 | int esp_serial_reinit(void *priv); 27 | 28 | int esp_serial_data_received(int dev_index, const char *data, size_t len); 29 | #endif 30 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_stats.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef __ESP_STAT__H__ 22 | #define __ESP_STAT__H__ 23 | 24 | #include "esp.h" 25 | 26 | #ifdef CONFIG_TEST_RAW_TP 27 | #define TEST_RAW_TP 1 28 | #else 29 | #define TEST_RAW_TP 0 30 | #endif 31 | 32 | #if TEST_RAW_TP 33 | 34 | #define TEST_RAW_TP__BUF_SIZE 1460 35 | 36 | #define ESP_TEST_RAW_TP__RX 0 37 | #define ESP_TEST_RAW_TP__TX 1 38 | 39 | void esp_raw_tp_queue_resume(void); 40 | #endif 41 | 42 | void test_raw_tp_cleanup(void); 43 | void update_test_raw_tp_rx_stats(u16 len); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/esp_utils.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2024 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef _ESP_UTILS_H_ 22 | #define _ESP_UTILS_H_ 23 | 24 | #define pr_fmt(fmt) "%s: %s: " fmt, KBUILD_MODNAME, __func__ 25 | 26 | #define esp_err pr_err 27 | #define esp_warn pr_warn 28 | 29 | #ifdef CONFIG_INFO_LOGS 30 | #define esp_info pr_info 31 | #else 32 | #define esp_info(...) do {} while(0) 33 | #endif 34 | 35 | #ifdef CONFIG_DEBUG_LOGS 36 | #define esp_dbg pr_debug 37 | #else 38 | #define esp_dbg(...) do {} while(0) 39 | #endif 40 | 41 | #ifdef CONFIG_VERBOSE_LOGS 42 | #define esp_verbose pr_debug 43 | #else 44 | #define esp_verbose(...) do {} while(0) 45 | #endif 46 | 47 | #include 48 | #include 49 | 50 | #ifdef CONFIG_DEBUG_LOGS 51 | static inline void esp_hex_dump_dbg(const char *prefix_str, const void *buf, size_t len) 52 | { 53 | esp_dbg("%s new hex dump\n", prefix_str); 54 | print_hex_dump(KERN_DEBUG, prefix_str, DUMP_PREFIX_ADDRESS, 16, 1, buf, len, 1); 55 | } 56 | #else 57 | #define esp_hex_dump_dbg(...) do {} while (0) 58 | #endif 59 | 60 | #ifdef CONFIG_VERBOSE_LOGS 61 | static inline void esp_hex_dump_verbose(const char *prefix_str, const void *buf, size_t len) 62 | { 63 | esp_dbg("%s new hex dump\n", prefix_str); 64 | print_hex_dump(KERN_DEBUG, prefix_str, DUMP_PREFIX_ADDRESS, 16, 1, buf, len, 1); 65 | } 66 | #else 67 | #define esp_hex_dump_verbose(...) do {} while (0) 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/sdio/esp_sdio_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 6 | * 7 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 8 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 9 | * (the "License"). You may use, redistribute and/or modify this File in 10 | * accordance with the terms and conditions of the License, a copy of which 11 | * is available by writing to the Free Software Foundation, Inc., 12 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 | * 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 | * this warranty disclaimer. 19 | */ 20 | 21 | #ifndef _ESP_SDIO_API_H_ 22 | #define _ESP_SDIO_API_H_ 23 | #include "esp_sdio_decl.h" 24 | 25 | int esp_read_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 26 | int esp_read_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 27 | int esp_write_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 28 | int esp_write_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/linux/host_driver/esp32/spi/esp_spi.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD 4 | * 5 | * This software file (the "File") is distributed by Espressif Systems (Shanghai) 6 | * PTE LTD under the terms of the GNU General Public License Version 2, June 1991 7 | * (the "License"). You may use, redistribute and/or modify this File in 8 | * accordance with the terms and conditions of the License, a copy of which 9 | * is available by writing to the Free Software Foundation, Inc., 10 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 11 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 12 | * 13 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 14 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 15 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 16 | * this warranty disclaimer. 17 | */ 18 | #ifndef _ESP_SPI_H_ 19 | #define _ESP_SPI_H_ 20 | 21 | #include "esp.h" 22 | 23 | #define SPI_BUF_SIZE 1600 24 | 25 | /* SPI device states */ 26 | enum spi_device_state { 27 | SPI_DEVICE_RUNNING, 28 | SPI_DEVICE_RESETTING 29 | }; 30 | 31 | enum spi_flags_e { 32 | ESP_SPI_BUS_CLAIMED, 33 | ESP_SPI_BUS_SET, 34 | ESP_SPI_GPIO_HS_REQUESTED, 35 | ESP_SPI_GPIO_HS_IRQ_DONE, 36 | ESP_SPI_GPIO_DR_REQUESTED, 37 | ESP_SPI_GPIO_DR_IRQ_DONE, 38 | ESP_SPI_DATAPATH_OPEN, 39 | }; 40 | 41 | struct esp_spi_context { 42 | struct esp_adapter *adapter; 43 | struct spi_device *esp_spi_dev; 44 | struct sk_buff_head tx_q[MAX_PRIORITY_QUEUES]; 45 | struct sk_buff_head rx_q[MAX_PRIORITY_QUEUES]; 46 | struct workqueue_struct *spi_workqueue; 47 | struct work_struct spi_work; 48 | struct delayed_work spi_delayed_work; 49 | struct work_struct reinit_work; 50 | atomic_t device_state; 51 | enum context_state state; 52 | uint8_t spi_clk_mhz; 53 | unsigned long spi_flags; 54 | int handshake_gpio; 55 | int dataready_gpio; 56 | }; 57 | 58 | enum { 59 | CLOSE_DATAPATH, 60 | OPEN_DATAPATH, 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/stm32/app/app_main.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | /** prevent recursive inclusion **/ 17 | #ifndef __APP_MAIN_H 18 | #define __APP_MAIN_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** Includes **/ 25 | #include "netdev_api.h" 26 | 27 | /** Exported macros **/ 28 | 29 | /** Exported variables **/ 30 | 31 | /** Inline functions **/ 32 | 33 | /** Exported Functions **/ 34 | extern stm_ret_t send_arp_req(struct network_handle *net_handle, uint8_t *src_mac, 35 | uint32_t *src_ip, uint8_t *dst_mac, uint32_t *dst_ip); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/stm32/app/app_main_api.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | /** Include **/ 17 | #include "trace.h" 18 | #include "app_main_api.h" 19 | 20 | /** Exported Constants/Macros **/ 21 | 22 | /** Exported variables **/ 23 | 24 | /** Function declarations **/ 25 | 26 | /** Function definitions **/ 27 | 28 | /** Exported Functions **/ 29 | 30 | /** 31 | * @brief Print details of arp received 32 | * @param stream - input stream 33 | * len - len of buffer 34 | * custom_str - prepend string with, could be NULL 35 | * @retval None 36 | */ 37 | void print_stream(uint8_t *stream, int len, char *custom_str) 38 | { 39 | #if DEBUG_STREAM_ENABLED 40 | uint16_t idx; 41 | if(custom_str) 42 | printf("%s -> ",custom_str); 43 | else 44 | printf("stream -> "); 45 | 46 | for (idx=0;idx<200;idx++) { 47 | if (idx%16==0) 48 | printf("\n%04x: ",idx); 49 | if (idx%8==0) 50 | printf(" "); 51 | printf("%02x",stream[idx]); 52 | } 53 | printf("\n"); 54 | #endif 55 | } 56 | 57 | /** 58 | * @brief set val from stream at offset of len 59 | * @param stream - input stream 60 | * val - buffer to be set 61 | * offset - offset from stream 62 | * len - len of buffer 63 | * @retval None 64 | */ 65 | void stream_set(uint8_t * stream, const void *val, uint8_t offset, uint16_t len) 66 | { 67 | uint8_t * src = (uint8_t *)val; 68 | uint16_t idx; 69 | 70 | for (idx=0;idx transport and ESP one from use spi/stm_spi_host_v2.ioc, if not already done 37 | echo For transport and use spi/stm_spi_host_v1.ioc, if not already done 38 | echo For transport and use sdio/stm_sdio_host.ioc, if not already done 39 | 40 | goto error 41 | ) 42 | 43 | rem ### check project directory exist ### 44 | IF not exist %WORKSPACE%\%PROJ_NAME% ( 45 | echo %WORKSPACE%\%PROJ_NAME% does not exist 46 | echo Either incorrect workspace directory or ioc project not imported 47 | echo For transport and ESP one from use spi/stm_spi_host_v2.ioc, if not already done 48 | echo For transport and use spi/stm_spi_host_v1.ioc, if not already done 49 | echo For transport and use sdio/stm_sdio_host.ioc, if not already done 50 | goto error 51 | ) 52 | 53 | rem ### search and replace project files ### 54 | DEL %WORKSPACE%\%PROJ_NAME%\.project 2>NUL 55 | DEL %WORKSPACE%\%PROJ_NAME%\.cproject 2>NUL 56 | 57 | rem ### .project file requires '/' instead of '\' as filepath separator 58 | rem ### and leading '/' before the filepath to work properly 59 | rem ### in STM32CubeIDE on Windows 11 60 | rem ### example: c:\esp\esp_hosted\esp_hosted_fg is converted to: 61 | rem ### /c:/esp/esp_hosted/esp_hosted_fg 62 | set "CODE_BASE_2=/%CODE_BASE:\=/%" 63 | 64 | setLocal EnableDelayedExpansion 65 | For /f "tokens=* delims= " %%a in (%TRANSPORT%\.project) do ( 66 | Set str=%%a 67 | set str=!str:CODE_BASE_PLACE_HOLDER=%CODE_BASE_2%! 68 | echo !str!>> %WORKSPACE%\%PROJ_NAME%\.project 69 | ) 70 | ENDLOCAL 71 | 72 | 73 | setLocal EnableDelayedExpansion 74 | For /f "tokens=* delims= " %%a in (%TRANSPORT%\.cproject) do ( 75 | Set str=%%a 76 | set str=!str:CODE_BASE_PLACE_HOLDER=%CODE_BASE%! 77 | echo !str!>> %WORKSPACE%\%PROJ_NAME%\.cproject 78 | ) 79 | ENDLOCAL 80 | 81 | rem ### touch .mxproject file ### 82 | copy /b %WORKSPACE%\%PROJ_NAME%\.mxproject +,, >NUL 83 | 84 | echo success. Now open STM32CubeIDE with %WORKSPACE% 85 | :error 86 | EXIT /B 1 87 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/stm32/proj/prepare_project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script copies and touches the .project, .cproject and .mxproject files 4 | # This is required to make STM32CubeIDE recognize the new project import 5 | 6 | PROJ_NAME= 7 | CODE_BASE= 8 | 9 | function usage() { 10 | echo "$0 " 11 | echo "Transport - either spi or sdio" 12 | echo "Workspace_directory - Workspace directory created for STM32CubeIDE" 13 | } 14 | 15 | function copy_and_touch_files() { 16 | CWD=`pwd` 17 | cd ../../../ 18 | CODE_BASE=`pwd` 19 | cd $CWD 20 | cp ./${TRANSPORT}/.project $WORKSPACE/$PROJ_NAME/ 21 | cp ./${TRANSPORT}/.cproject $WORKSPACE/$PROJ_NAME/ 22 | sed -i.bak "s#CODE_BASE_PLACE_HOLDER#$CODE_BASE#" $WORKSPACE/$PROJ_NAME/.project 23 | sed -i.bak "s#CODE_BASE_PLACE_HOLDER#$CODE_BASE#" $WORKSPACE/$PROJ_NAME/.cproject 24 | touch $WORKSPACE/$PROJ_NAME/.mxproject 25 | echo "success. Now, please open STM32CubeIDE with $WORKSPACE" 26 | } 27 | 28 | if [ "$1" == '-h' ] || [ "$1" == '--help' ] ; then 29 | usage 30 | exit 0 31 | fi 32 | 33 | if [ "$#" != "2" ] ; then 34 | echo "Err: Incorrect number of arguments passed" 35 | usage 36 | exit 1 37 | else 38 | if [ "$1" != "spi" -a "$1" != "sdio" ] ; then 39 | echo "ERR: Invalid transport value" 40 | usage 41 | exit 1 42 | fi 43 | TRANSPORT=$1 44 | WORKSPACE=$2 45 | PROJ_NAME=stm_${TRANSPORT}_host 46 | fi 47 | 48 | 49 | 50 | if [ ! -d $WORKSPACE ]; then 51 | echo "Err: $WORKSPACE directory not found. Please follow documentation to import STM project from stm__host_.ioc first" 52 | echo " is applicable only for SPI transport" 53 | echo "SPI : for ESP32 wroom/wrover use stm_spi_host_v1.ioc " 54 | echo " : for other ESP modules use stm_spi_host_v2.ioc" 55 | echo "SDIO: for ESP32 use stm_sdio_host.ioc" 56 | usage 57 | exit 1; 58 | fi 59 | 60 | if [ ! -d $WORKSPACE/$PROJ_NAME ]; then 61 | echo "Err: Either incorrect Workspace directory or ioc project not imported." 62 | echo "Please follow documentation to import STM project from stm__host_.ioc if not already done" 63 | echo "SPI : for ESP32 wroom/wrover use stm_spi_host_v1.ioc " 64 | echo " : for other ESP modules use stm_spi_host_v2.ioc" 65 | echo "SDIO: for ESP32 use stm_sdio_host.ioc" 66 | usage 67 | exit 1; 68 | fi 69 | 70 | copy_and_touch_files 71 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/stm32/proj/sdio/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | stm_sdio_host 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature 28 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 29 | com.st.stm32cube.ide.mcu.MCURootProjectNature 30 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 31 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 32 | 33 | 34 | 35 | common 36 | 2 37 | CODE_BASE/common 38 | 39 | 40 | host 41 | 2 42 | CODE_BASE/host 43 | 44 | 45 | 46 | 47 | CODE_BASE 48 | file:CODE_BASE_PLACE_HOLDER 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/stm32/proj/spi/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | stm_spi_host 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature 28 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 29 | com.st.stm32cube.ide.mcu.MCURootProjectNature 30 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 31 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 32 | 33 | 34 | 35 | common 36 | 2 37 | CODE_BASE/common 38 | 39 | 40 | host 41 | 2 42 | CODE_BASE/host 43 | 44 | 45 | 46 | 47 | CODE_BASE 48 | file:CODE_BASE_PLACE_HOLDER 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /esp_hosted_fg/host/virtual_serial_if/include/serial_if.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD 2 | /* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ 3 | 4 | /** prevent recursive inclusion **/ 5 | #ifndef __SERIAL_IF_H 6 | #define __SERIAL_IF_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include "adapter.h" 12 | #include "platform_wrapper.h" 13 | 14 | #define SIZE_OF_TYPE 1 15 | #define SIZE_OF_LENGTH 2 16 | 17 | /* 18 | * The data written on serial driver file, `SERIAL_IF_FILE` from adapter.h 19 | * In TLV i.e. Type Length Value format, to transfer data between host and ESP32 20 | * | type | length | value | 21 | * Types are 0x01 : for endpoint name 22 | * 0x02 : for data 23 | * length is respective value field's data length in 16 bits 24 | * value is actual data to be transferred 25 | */ 26 | uint16_t compose_tlv(uint8_t* buf, uint8_t* data, uint16_t data_length); 27 | 28 | /* Parse the protobuf encoded data in format of tag, length and value 29 | * Thi will help application to decode protobuf payload and payload length 30 | **/ 31 | uint8_t parse_tlv(uint8_t* data, uint32_t* pro_len); 32 | 33 | /* Open the serial driver for serial operations 34 | **/ 35 | int transport_pserial_open(void); 36 | 37 | /* Close the serial driver for serial operations 38 | **/ 39 | int transport_pserial_close(void); 40 | 41 | /* Send buffer with length as argument on transport as serial interface type 42 | **/ 43 | int transport_pserial_send(uint8_t* data, uint16_t data_length); 44 | 45 | /* Read and return number of bytes and buffer from serial interface 46 | **/ 47 | uint8_t * transport_pserial_read(uint32_t *out_nbyte); 48 | #endif 49 | -------------------------------------------------------------------------------- /esp_hosted_ng/VERSION: -------------------------------------------------------------------------------- 1 | Version 2 | - Project: NG 3 | - Current Version: 1.0.4.0.0 4 | 5 | Format 6 | - .... 7 | 8 | Description 9 | - MAJOR_1: Primary major version – significant changes 10 | - MAJOR_2: Secondary major version – product branch or protocol variant 11 | - MINOR: Minor version: feature updates 12 | - PATCH_1: Small revisions 13 | - PATCH_2: Bug fixes 14 | -------------------------------------------------------------------------------- /esp_hosted_ng/docs/ESP-Hosted-NG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/docs/ESP-Hosted-NG.jpg -------------------------------------------------------------------------------- /esp_hosted_ng/docs/Raw_TP_Testing.md: -------------------------------------------------------------------------------- 1 | # Raw Throughput testing 2 | 3 | - This feature provides functionality to test throughput over required transport layer (SPI or SDIO). 4 | - When triggered by host, this will bypass Wi-Fi traffic and push the dummy data traffic on transport layer directly to check maximum throughput on the current transport. 5 | - This feature will also help you to check if transport layer is properly configured or not. 6 | 7 | ## Steps to test Raw TP 8 | 9 | - Raw throughput feature is enabled by default for ESP firmware 10 | - On Host side: 11 | 1. While setting up the host, pass `rawtp_host_to_esp` or `rawtp_esp_to_host` as a argument to `rpi_init.sh`. 12 | - e.g if you are setting Wi-Fi over SDIO and you want to test raw TP from ESP to host over SDIO interface, then compile and load host driver as below: 13 | ```sh 14 | $ cd esp_hosted_ng/host/ 15 | $ ./rpi_init.sh sdio rawtp_esp_to_host 16 | ``` 17 | 2. RAW throught is enabled by default for host, to disable it set the value of `TEST_RAW_TP` to 0 in `esp_hosted/esp_hosted_ng/host/include/stats.h` 18 | 19 | 20 | -------------------------------------------------------------------------------- /esp_hosted_ng/docs/directory_structure.md: -------------------------------------------------------------------------------- 1 | ### Directory structure for Linux based host 2 | 3 | ``` 4 | ├── esp_hosted_ng 5 | │ │ 6 | │ ├── host (host directory for Linux based host) 7 | │ │ ├── rpi_init.sh (Installation sequence for ESP-Hosted-NG driver) 8 | │ │ │   └── spidev_disabler.dts (dts file for SPI transport) 9 | │ │ ├── sdio (Contain SDIO transport files used by kernel module to communicate 10 | │ │ │ with ESP peripheral) 11 | │ │ └── spi (Contain SPI transport files used by kernel module to communicate 12 | │ │ with ESP peripheral) 13 | ``` 14 | -------------------------------------------------------------------------------- /esp_hosted_ng/docs/rpi_esp32_c3_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/docs/rpi_esp32_c3_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_ng/docs/rpi_esp32_sdio_setup.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/docs/rpi_esp32_sdio_setup.jpeg -------------------------------------------------------------------------------- /esp_hosted_ng/docs/rpi_esp32_spi_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/docs/rpi_esp32_spi_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_ng/docs/rpi_esp32_uart_setup.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/docs/rpi_esp32_uart_setup.jpeg -------------------------------------------------------------------------------- /esp_hosted_ng/docs/rpi_esp32c3_uart_setup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/docs/rpi_esp32c3_uart_setup.jpg -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/.env: -------------------------------------------------------------------------------- 1 | IDF_TAG=v5.4 2 | IDF_COMMIT="67c1de1eebe095d554d281952fde63c16ee2dca0" 3 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/README.md: -------------------------------------------------------------------------------- 1 | # Espressif Wireless Framework 2 | 3 | ## Introduction 4 | 5 | This project is used to build firmware for esp-hosted-ng solution 6 | 7 | ## Building on Linux using Command Prompt 8 | 9 | 1. run `./setup.sh` to setup environment, it will setup esp-idf which is to be used by `network_adapter` 10 | 11 | 2. setup compiling environment by `. ./export.sh` in esp-idf directory 12 | 13 | 3. In the `network_adapter` directory of this project, input command `idf.py set-target ` to set target. 14 | 15 | 4. Use `idf.py build` to recompile `network_adapter` and generate new firmware. 16 | 17 | ## Building on Windows 11 using Command Prompt 18 | 19 | 1. Install and setup ESP-IDF on Windows as documented in the [Standard Setup of Toolchain for 20 | Windows](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html). 21 | 22 | 2. Use the ESP-IDF [Powershell Command 23 | Prompt](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html#using-the-command-prompt) to execute `setup.ps1`. It will setup `esp-idf` as a submodule to be used by `network_adapter`. 24 | :warning: **This command is dangerous. It will revert all your local changes. Stash if need to keep them**. 25 | 26 | 3. Setup compiling environment by running `export.ps1` in `esp-idf` 27 | directory 28 | 29 | 4. In the `network_adapter` directory of this project, input command 30 | `idf.py set-target ` to set target. 31 | 32 | 5. Use `idf.py build` to recompile `network_adapter` and generate new 33 | firmware. 34 | 35 | 6. Use `idf.py flash` to flash the firmware. 36 | 37 | 7. Use `idf.py monitor` to monitor the serial out. You can combine 38 | these two steps (flash and monitor) by running `idf.py flash monitor`. 39 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libmesh.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32/libwapi.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c2/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c2/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c2/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c2/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c2/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libmesh.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c3/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libwapi.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libmesh.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c5/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c5/libwapi.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libmesh.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32c6/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libwapi.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libmesh.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s2/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libwapi.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libcore.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libespnow.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libmesh.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libnet80211.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libpp.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libsmartconfig.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/lib/esp32s3/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-hosted/0699edf7e4f48028f6d4bd6032418ef7c7395c11/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libwapi.a -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | file(READ "main/include/esp_fw_version.h" HEADER_CONTENTS) 6 | set(PROJECT_VERSION_REGEX "#define[ \t]+PROJECT_NAME[ \t]+\"([A-Z]+)\"[ \t\n]+#define[ \t]+PROJECT_VERSION_MAJOR_1[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_VERSION_MAJOR_2[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_VERSION_MINOR[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_REVISION_PATCH_1[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_REVISION_PATCH_2[ \t]+([0-9]+)") 7 | string(REGEX MATCH "${PROJECT_VERSION_REGEX}" PROJECT_VERSION_MATCH "${HEADER_CONTENTS}") 8 | 9 | if(PROJECT_VERSION_MATCH) 10 | set(PROJECT_NAME "${CMAKE_MATCH_1}") 11 | set(PROJECT_VERSION_MAJOR_1 "${CMAKE_MATCH_2}") 12 | set(PROJECT_VERSION_MAJOR_2 "${CMAKE_MATCH_3}") 13 | set(PROJECT_VERSION_MINOR "${CMAKE_MATCH_4}") 14 | set(PROJECT_REVISION_PATCH_1 "${CMAKE_MATCH_5}") 15 | set(PROJECT_REVISION_PATCH_2 "${CMAKE_MATCH_6}") 16 | 17 | # Construct project version 18 | set(PROJECT_VER "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR_1}.${PROJECT_VERSION_MAJOR_2}.${PROJECT_VERSION_MINOR}.${PROJECT_REVISION_PATCH_1}.${PROJECT_REVISION_PATCH_2}") 19 | 20 | message(*************************************************************************************) 21 | message(" Building ESP-Hosted Firmware version :: ${PROJECT_VER} ") 22 | message(*************************************************************************************) 23 | else() 24 | message(FATAL_ERROR "Failed to read project version from main/include/esp_fw_version.h") 25 | endif() 26 | 27 | set(PROJECT_VER "${PROJECT_VER}") 28 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 29 | set(EXCLUDE_COMPONENTS wpa_supplicant) 30 | project(network_adapter) 31 | idf_build_set_property(COMPILE_OPTIONS "-fdiagnostics-color=always" APPEND) 32 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "app_main.c" "slave_bt.c" "cmd.c" "stats.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS "./include") 3 | 4 | if(CONFIG_ESP_SDIO_HOST_INTERFACE) 5 | list(APPEND COMPONENT_SRCS sdio_slave_api.c) 6 | else(CONFIG_ESP_SPI_HOST_INTERFACE) 7 | list(APPEND COMPONENT_SRCS spi_slave_api.c) 8 | endif() 9 | 10 | 11 | register_component() 12 | 13 | target_compile_definitions(${COMPONENT_LIB} PRIVATE) 14 | 15 | # Add directory of protocomm_priv.h to include paths 16 | idf_component_get_property(protocomm_dir protocomm COMPONENT_DIR) 17 | target_include_directories(${COMPONENT_LIB} PRIVATE "${protocomm_dir}/src/common") 18 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/app_main.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __NETWORK_ADAPTER_PRIV__H 18 | #define __NETWORK_ADAPTER_PRIV__H 19 | 20 | #include "adapter.h" 21 | 22 | typedef struct { 23 | interface_context_t *context; 24 | } adapter; 25 | 26 | struct wow_config { 27 | uint8_t any; 28 | uint8_t disconnect; 29 | uint8_t magic_pkt; 30 | uint8_t four_way_handshake; 31 | uint8_t eap_identity_req; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/esp.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __ESP__H 18 | #define __ESP__H 19 | 20 | #include "adapter.h" 21 | #define TASK_DEFAULT_STACK_SIZE 4096 22 | #define TASK_DEFAULT_PRIO 22 23 | 24 | #define u8 uint8_t 25 | #define u16 uint16_t 26 | #define u32 uint32_t 27 | #define u64 uint64_t 28 | 29 | #if defined CONFIG_ESP_SDIO_HOST_INTERFACE 30 | #define SDIO_SLAVE_QUEUE_SIZE 20 31 | #define RX_BUF_SIZE 2048 32 | #define RX_BUF_NUM 20 33 | 34 | #elif defined CONFIG_ESP_SPI_HOST_INTERFACE 35 | #define RX_BUF_SIZE 1600 36 | 37 | #else 38 | #error "Undefined transport" 39 | #endif 40 | 41 | #define MAX_ALLOWED_BUF_PAYLOAD_LEN (RX_BUF_SIZE-sizeof(struct esp_payload_header)) 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/esp_fw_version.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | /* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ 3 | 4 | #ifndef __ESP_FW_VERSION__H 5 | #define __ESP_FW_VERSION__H 6 | 7 | #define PROJECT_NAME "NG" 8 | #define PROJECT_VERSION_MAJOR_1 1 9 | #define PROJECT_VERSION_MAJOR_2 0 10 | #define PROJECT_VERSION_MINOR 4 11 | #define PROJECT_REVISION_PATCH_1 0 12 | #define PROJECT_REVISION_PATCH_2 1 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/interface.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __TRANSPORT_LAYER_INTERFACE_H 18 | #define __TRANSPORT_LAYER_INTERFACE_H 19 | #include "esp_err.h" 20 | 21 | #ifdef CONFIG_ESP_SDIO_HOST_INTERFACE 22 | 23 | #if defined(CONFIG_IDF_TARGET_ESP32)||defined(CONFIG_IDF_TARGET_ESP32C6) 24 | #include "driver/sdio_slave.h" 25 | #else 26 | #error "SDIO is not supported" 27 | #endif 28 | 29 | #endif 30 | 31 | typedef enum { 32 | LENGTH_1_BYTE = 1, 33 | LENGTH_2_BYTE = 2, 34 | LENGTH_3_BYTE = 3, 35 | LENGTH_4_BYTE = 4, 36 | } byte_length; 37 | 38 | typedef void *wlan_buf_handle_t; 39 | 40 | typedef enum { 41 | SDIO = 0, 42 | SPI = 1, 43 | } transport_layer; 44 | 45 | typedef enum { 46 | DEINIT, 47 | INIT, 48 | ACTIVE, 49 | DEACTIVE, 50 | } INTERFACE_STATE; 51 | 52 | typedef struct { 53 | union { 54 | #ifdef CONFIG_ESP_SDIO_HOST_INTERFACE 55 | sdio_slave_buf_handle_t sdio_buf_handle; 56 | #endif 57 | wlan_buf_handle_t wlan_buf_handle; 58 | void *priv_buffer_handle; 59 | }; 60 | uint8_t if_type; 61 | uint8_t if_num; 62 | uint8_t *payload; 63 | uint8_t flag; 64 | uint16_t payload_len; 65 | uint16_t seq_num; 66 | uint8_t pkt_type; 67 | 68 | void (*free_buf_handle)(void *buf_handle); 69 | } interface_buffer_handle_t; 70 | 71 | typedef struct { 72 | /* 73 | union { 74 | } phy_context; 75 | */ 76 | INTERFACE_STATE state; 77 | } interface_handle_t; 78 | 79 | typedef struct { 80 | interface_handle_t * (*init)(void); 81 | int32_t (*write)(interface_handle_t *handle, interface_buffer_handle_t *buf_handle); 82 | int (*read)(interface_handle_t *handle, interface_buffer_handle_t *buf_handle); 83 | esp_err_t (*reset)(interface_handle_t *handle); 84 | void (*deinit)(interface_handle_t *handle); 85 | } if_ops_t; 86 | 87 | typedef struct { 88 | transport_layer type; 89 | void *priv; 90 | if_ops_t *if_ops; 91 | int (*event_handler)(uint8_t bitmap); 92 | } interface_context_t; 93 | 94 | interface_context_t * interface_insert_driver(int (*callback)(uint8_t val)); 95 | int interface_remove_driver(); 96 | /*void generate_startup_event(uint8_t cap);*/ 97 | esp_err_t send_to_host(uint8_t prio_q_idx, interface_buffer_handle_t *buf_handle); 98 | esp_err_t send_bootup_event_to_host(uint8_t cap); 99 | #endif 100 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/sdio_slave_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __SDIO_SLAVE_API_H 18 | #define __SDIO_SLAVE_API_H 19 | 20 | #ifdef CONFIG_IDF_TARGET_ESP32 21 | #elif defined CONFIG_IDF_TARGET_ESP32S2 22 | #error "SDIO is not supported for ESP32S2. Please use SPI" 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/stats.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef __STATS__H__ 18 | #define __STATS__H__ 19 | 20 | #include 21 | #include "adapter.h" 22 | #include "endian.h" 23 | #include "freertos/FreeRTOS.h" 24 | #include "freertos/semphr.h" 25 | 26 | #define SEC_TO_MSEC(x) (x*1000) 27 | #define MSEC_TO_USEC(x) (x*1000) 28 | #define SEC_TO_USEC(x) (x*1000*1000) 29 | 30 | /* Stats CONFIG: 31 | * 32 | * 1. CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS 33 | * These are debug stats to show the CPU utilization by all tasks 34 | * This is set through sdkconfig 35 | */ 36 | 37 | #ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS 38 | /* Stats to show task wise CPU utilization */ 39 | #define STATS_TICKS pdMS_TO_TICKS(1000*2) 40 | #define ARRAY_SIZE_OFFSET 5 41 | 42 | void debug_runtime_stats_task(void* pvParameters); 43 | #endif 44 | 45 | /* TEST_RAW_TP is disabled on production. 46 | * This is only to test the throughout over transport 47 | * like SPI or SDIO. In this testing, dummy task will 48 | * push the packets over transport. 49 | * Currently this testing is possible on one direction 50 | * at a time 51 | */ 52 | 53 | #include "esp_timer.h" 54 | #include "interface.h" 55 | 56 | /* Raw throughput is supported only one direction 57 | * at a time 58 | * i.e. ESP to Host OR 59 | * Host to ESP 60 | */ 61 | 62 | #define TEST_RAW_TP__BUF_SIZE 1460 63 | #define TEST_RAW_TP__TIMEOUT SEC_TO_USEC(1) 64 | 65 | typedef struct { 66 | esp_timer_handle_t timer; 67 | size_t cur_interval; 68 | int64_t t_start; 69 | SemaphoreHandle_t done; 70 | } test_args_t; 71 | 72 | void debug_update_raw_tp_rx_count(uint16_t len); 73 | 74 | void debug_log_firmware_version(void); 75 | void create_debugging_tasks(void); 76 | void debug_get_raw_tp_conf(uint32_t raw_tp_type); 77 | void debug_set_wifi_logging(void); 78 | int process_raw_tp(uint8_t if_type, uint8_t *payload, uint16_t payload_len); 79 | int process_set_time(uint8_t if_type, uint8_t *payload, uint16_t payload_len); 80 | #endif /*__STATS__H__*/ 81 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/main/include/wifi_defs.h: -------------------------------------------------------------------------------- 1 | #define WLAN_FC_STYPE_ASSOC_REQ 0 2 | 3 | #define WLAN_FC_STYPE_ASSOC_RESP 1 4 | 5 | #define WLAN_FC_STYPE_REASSOC_REQ 2 6 | 7 | #define WLAN_FC_STYPE_REASSOC_RESP 3 8 | 9 | #define WLAN_FC_STYPE_PROBE_REQ 4 10 | 11 | #define WLAN_FC_STYPE_PROBE_RESP 5 12 | 13 | #define WLAN_FC_STYPE_BEACON 8 14 | 15 | #define WLAN_FC_STYPE_ATIM 9 16 | 17 | #define WLAN_FC_STYPE_DISASSOC 10 18 | 19 | #define WLAN_FC_STYPE_AUTH 11 20 | 21 | #define WLAN_FC_STYPE_DEAUTH 12 22 | 23 | #define WLAN_FC_STYPE_ACTION 13 24 | 25 | #define IEEE_HEADER_SIZE 24 26 | 27 | #define DEFAULT_SCAN_LIST_SIZE 1 28 | 29 | #define IE_POS_ASSOC_RESP_STATUS 2 30 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/partitions.esp32c2.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,16K, 4 | otadata,data,ota,0xd000,8K, 5 | phy_init,data,phy,0xf000,4K, 6 | ota_0,app,ota_0,0x10000,0xf0000, 7 | ota_1,app,ota_1,0x100000,0xf0000, 8 | 9 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.ci: -------------------------------------------------------------------------------- 1 | CONFIG_ESP_SPI_HOST_INTERFACE=y 2 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y 2 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 3 | CONFIG_SDIO_DAT2_DISABLED= 4 | 5 | # BT Configuration 6 | CONFIG_BT_ENABLED=y 7 | CONFIG_BT_CONTROLLER_ONLY=y 8 | CONFIG_BT_BLUEDROID_ENABLED= 9 | CONFIG_BTDM_CTRL_MODE_BTDM=y 10 | CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y 11 | 12 | CONFIG_ESP32_WIFI_NVS_ENABLED= 13 | # OTA 14 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 15 | CONFIG_PARTITION_TABLE_TWO_OTA=y 16 | CONFIG_FREERTOS_HZ=1000 17 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32: -------------------------------------------------------------------------------- 1 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 2 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 3 | CONFIG_SDIO_DAT2_DISABLED= 4 | 5 | # BT Configuration 6 | CONFIG_BT_ENABLED=y 7 | CONFIG_BT_CONTROLLER_ONLY=y 8 | CONFIG_BT_BLUEDROID_ENABLED= 9 | CONFIG_BTDM_CONTROLLER_MODE_BTDM=y 10 | CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y 11 | CONFIG_BTDM_CTRL_AUTO_LATENCY=y 12 | 13 | CONFIG_ESP32_WIFI_NVS_ENABLED= 14 | 15 | # BT over UART 16 | #CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4=y 17 | #CONFIG_BTDM_CTRL_HCI_MODE_UART_H4=y 18 | #CONFIG_BT_HCI_UART_NO=1 19 | #CONFIG_BT_HCI_UART_BAUDRATE=921600 20 | 21 | #CO-EX config 22 | CONFIG_FREERTOS_UNICORE=n 23 | CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y 24 | CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 25 | CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 26 | CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y 27 | 28 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16 29 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=40 30 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64 31 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 32 | CONFIG_ESP_WIFI_TX_BA_WIN=32 33 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 34 | CONFIG_ESP_WIFI_RX_BA_WIN=32 35 | 36 | # OTA 37 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 38 | CONFIG_PARTITION_TABLE_TWO_OTA=y 39 | 40 | # iram text optimization 41 | CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y 42 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c2: -------------------------------------------------------------------------------- 1 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_120=y 2 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=120 3 | CONFIG_FREERTOS_UNICORE=y 4 | 5 | # BT Configuration 6 | CONFIG_BT_ENABLED=y 7 | CONFIG_BT_CONTROLLER_ONLY=y 8 | CONFIG_BT_BLUEDROID_ENABLED= 9 | CONFIG_BT_LE_SLEEP_ENABLE=y 10 | 11 | #UART pins, Enable below config, delete sdkconfig and rebuild 12 | #CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y 13 | CONFIG_BT_LE_HCI_UART_FLOWCTRL=n 14 | CONFIG_BT_LE_HCI_UART_TX_PIN=5 15 | CONFIG_BT_LE_HCI_UART_RX_PIN=18 16 | 17 | CONFIG_ESP_WIFI_NVS_ENABLED= 18 | 19 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n 20 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y 21 | CONFIG_PARTITION_TABLE_TWO_OTA=y 22 | CONFIG_PARTITION_TABLE_CUSTOM=y 23 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.esp32c2.csv" 24 | CONFIG_PARTITION_TABLE_FILENAME="partitions.esp32c2.csv" 25 | 26 | CONFIG_ESP_SPI_RX_Q_SIZE=6 27 | CONFIG_ESP_SPI_TX_Q_SIZE=6 28 | 29 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=14 30 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=6 31 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=6 32 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 33 | CONFIG_ESP_WIFI_TX_BA_WIN=6 34 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 35 | CONFIG_ESP_WIFI_RX_BA_WIN=6 36 | 37 | CONFIG_BT_BTC_TASK_STACK_SIZE=4096 38 | # CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set 39 | CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y 40 | CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN=y 41 | CONFIG_BT_GATTC_CONNECT_RETRY_COUNT=20 42 | 43 | 44 | # less memory usage 45 | CONFIG_BT_ACL_CONNECTIONS=2 46 | CONFIG_BT_LE_MSYS_1_BLOCK_COUNT=6 47 | CONFIG_BT_LE_MSYS_2_BLOCK_COUNT=8 48 | CONFIG_BT_LE_ACL_BUF_COUNT=8 49 | CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT=16 50 | CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT=4 51 | CONFIG_LWIP_MAX_SOCKETS=4 52 | CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=6 53 | CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y 54 | CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y 55 | CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y 56 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c3: -------------------------------------------------------------------------------- 1 | CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y 2 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 3 | CONFIG_FREERTOS_UNICORE=y 4 | CONFIG_SDIO_DAT2_DISABLED= 5 | 6 | # BT Configuration 7 | CONFIG_BT_ENABLED=y 8 | CONFIG_BT_CONTROLLER_ONLY=y 9 | CONFIG_BT_BLUEDROID_ENABLED= 10 | CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y 11 | CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n 12 | CONFIG_BTDM_CTRL_MODE_BTDM=n 13 | CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y 14 | 15 | CONFIG_ESP32_WIFI_NVS_ENABLED= 16 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=20 17 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=40 18 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=40 19 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 20 | CONFIG_ESP_WIFI_TX_BA_WIN=32 21 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 22 | CONFIG_ESP_WIFI_RX_BA_WIN=32 23 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c5: -------------------------------------------------------------------------------- 1 | # BLE over UART: 2 | # Enable below config, delete sdkconfig, build/ and rebuild 3 | # CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y 4 | CONFIG_BT_LE_HCI_UART_TX_PIN=5 5 | CONFIG_BT_LE_HCI_UART_RX_PIN=13 6 | CONFIG_BT_LE_HCI_UART_FLOWCTRL=n 7 | 8 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=40 9 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=60 10 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=40 11 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 12 | CONFIG_ESP_WIFI_TX_BA_WIN=32 13 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 14 | CONFIG_ESP_WIFI_RX_BA_WIN=32 15 | CONFIG_ESP_WIFI_NVS_ENABLED=n 16 | CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS=n 17 | CONFIG_ESP_WIFI_ENABLE_WIFI_TX_STATS=n 18 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c6: -------------------------------------------------------------------------------- 1 | CONFIG_SDIO_DAT2_DISABLED= 2 | 3 | # BT Configuration 4 | CONFIG_BT_ENABLED=y 5 | CONFIG_BT_CONTROLLER_ONLY=y 6 | CONFIG_BT_BLUEDROID_ENABLED= 7 | CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y 8 | CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n 9 | CONFIG_BTDM_CTRL_MODE_BTDM=n 10 | 11 | # SPI/SDIO only 12 | CONFIG_BT_LE_HCI_INTERFACE_USE_RAM=y 13 | 14 | # BLE over UART: 15 | # Enable below config, delete sdkconfig, build/ and rebuild 16 | # CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y 17 | CONFIG_BT_LE_HCI_UART_TX_PIN=5 18 | CONFIG_BT_LE_HCI_UART_RX_PIN=12 19 | CONFIG_BT_LE_HCI_UART_FLOWCTRL=n 20 | # 4 pin solution is not working yet for c6 21 | # #CONFIG_BT_LE_HCI_UART_RTS_PIN=9 22 | # #CONFIG_BT_LE_HCI_UART_CTS_PIN=13 23 | 24 | CONFIG_ESP32_WIFI_NVS_ENABLED= 25 | 26 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=40 27 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=60 28 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=40 29 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 30 | CONFIG_ESP_WIFI_TX_BA_WIN=32 31 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 32 | CONFIG_ESP_WIFI_RX_BA_WIN=32 33 | CONFIG_ESP_WIFI_NVS_ENABLED=n 34 | CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS=n 35 | CONFIG_ESP_WIFI_ENABLE_WIFI_TX_STATS=n 36 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32s2: -------------------------------------------------------------------------------- 1 | # BT Configuration 2 | CONFIG_BT_ENABLED= 3 | CONFIG_BT_CONTROLLER_ONLY= 4 | CONFIG_BT_BLUEDROID_ENABLED= 5 | CONFIG_BT_LE_SLEEP_ENABLE= 6 | -------------------------------------------------------------------------------- /esp_hosted_ng/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | #For battery sensitive usage, can reduce the CPU frequency 2 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y 3 | CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 4 | 5 | # BT Configuration 6 | CONFIG_BT_ENABLED=y 7 | CONFIG_BT_CONTROLLER_ONLY=y 8 | CONFIG_BT_BLUEDROID_ENABLED= 9 | CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y 10 | CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n 11 | CONFIG_BTDM_CTRL_MODE_BTDM=n 12 | CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y 13 | 14 | CONFIG_ESP32_WIFI_NVS_ENABLED= 15 | 16 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16 17 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64 18 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64 19 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 20 | CONFIG_ESP_WIFI_TX_BA_WIN=32 21 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 22 | CONFIG_ESP_WIFI_RX_BA_WIN=32 23 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/Makefile: -------------------------------------------------------------------------------- 1 | # Toolchain Path 2 | CROSS_COMPILE := 3 | # Linux Kernel header 4 | KERNEL := /lib/modules/$(shell uname -r)/build 5 | # Architecture 6 | ARCH := $(shell uname -m) 7 | 8 | # Check and adjust ARCH for specific cases 9 | ifeq ($(ARCH), x86_64) 10 | ARCH := x86 11 | endif 12 | 13 | ifeq ($(ARCH), aarch64) 14 | ARCH := arm64 15 | endif 16 | 17 | #Default interface is sdio 18 | MODULE_NAME=esp32_sdio 19 | 20 | #enable logging by default 21 | CONFIG_DEBUG_LOGS := y 22 | 23 | ifeq ($(CONFIG_AP_SUPPORT), y) 24 | EXTRA_CFLAGS += -DCONFIG_AP_MODE 25 | endif 26 | 27 | #Targets passed overrrides default value 28 | ifeq ($(target), sdio) 29 | MODULE_NAME=esp32_sdio 30 | endif 31 | 32 | ifeq ($(target), spi) 33 | MODULE_NAME=esp32_spi 34 | endif 35 | 36 | #debug_flags := -DDEBUG 37 | 38 | EXTRA_CFLAGS += -I$(PWD)/include -I$(PWD) 39 | 40 | ifeq ($(MODULE_NAME), esp32_sdio) 41 | EXTRA_CFLAGS += -I$(PWD)/sdio 42 | module_objects += sdio/esp_sdio.o sdio/esp_sdio_api.o 43 | endif 44 | 45 | ifeq ($(MODULE_NAME), esp32_spi) 46 | EXTRA_CFLAGS += -I$(PWD)/spi 47 | module_objects += spi/esp_spi.o 48 | endif 49 | 50 | module_objects += esp_bt.o main.o esp_cmd.o esp_utils.o esp_cfg80211.o esp_stats.o esp_debugfs.o esp_log.o 51 | #$(foreach obj,$(module_objects),$(eval CFLAGS_$(obj:.o=).o := $(debug_flags))) 52 | CFLAGS_esp_log.o = -DDEBUG 53 | 54 | PWD := $(shell pwd) 55 | 56 | obj-m := $(MODULE_NAME).o 57 | $(MODULE_NAME)-y := $(module_objects) 58 | 59 | all: clean 60 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) modules 61 | 62 | clean: 63 | rm -rf *.o sdio/*.o spi/*.o *.ko 64 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) clean 65 | 66 | check: 67 | make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL) M=$(PWD) $(module_objects) 68 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/esp_log.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "utils.h" 5 | 6 | #define esp_fmt(fmt) "%s: %s: " fmt, KBUILD_MODNAME, function 7 | extern int log_level; 8 | static char *get_kern_log_level(int level) 9 | { 10 | char *kern_level; 11 | 12 | switch(level) { 13 | case ESP_ERR: 14 | kern_level = KERN_ERR; 15 | break; 16 | case ESP_WARNING: 17 | kern_level = KERN_WARNING; 18 | break; 19 | case ESP_INFO: 20 | kern_level = KERN_INFO; 21 | break; 22 | case ESP_DEBUG: 23 | kern_level = KERN_DEBUG; 24 | break; 25 | case ESP_VERBOSE: 26 | kern_level = KERN_DEBUG; 27 | break; 28 | default: 29 | kern_level = KERN_DEBUG; 30 | break; 31 | } 32 | 33 | return kern_level; 34 | } 35 | 36 | void esp_logger(int level, const char *function, const char* fmt, ...) 37 | { 38 | char *kern_level; 39 | struct va_format vaf; 40 | va_list args; 41 | 42 | if (level > log_level) 43 | return; 44 | 45 | kern_level = get_kern_log_level(level); 46 | 47 | va_start(args, fmt); 48 | 49 | vaf.fmt = fmt; 50 | vaf.va = &args; 51 | 52 | printk("%s%s: %s: %pV", kern_level, KBUILD_MODNAME, function, &vaf); 53 | 54 | va_end(args); 55 | } 56 | 57 | void esp_hex_dump(const char *prefix_str, const void *buf, size_t len) 58 | { 59 | print_hex_dump(KERN_INFO, prefix_str, DUMP_PREFIX_ADDRESS, 16, 1, buf, len, 1); 60 | } 61 | 62 | void esp_hex_dump_verbose(const char *prefix_str, const void *buf, size_t len) 63 | { 64 | if (log_level >= ESP_VERBOSE) 65 | print_hex_dump(KERN_INFO, prefix_str, DUMP_PREFIX_ADDRESS, 16, 1, buf, len, 1); 66 | } 67 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/esp_utils.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #include "utils.h" 9 | #include "esp_utils.h" 10 | 11 | 12 | int wpa_cipher_to_alg(int cipher) 13 | { 14 | switch (cipher) { 15 | case WLAN_CIPHER_SUITE_CCMP: 16 | return WIFI_WPA_ALG_CCMP; 17 | #ifdef CONFIG_GCMP 18 | case WLAN_CIPHER_SUITE_GCMP_256: 19 | case WLAN_CIPHER_SUITE_GCMP: 20 | return WIFI_WPA_ALG_GCMP; 21 | #endif 22 | case WLAN_CIPHER_SUITE_TKIP: 23 | return WIFI_WPA_ALG_TKIP; 24 | case WLAN_CIPHER_SUITE_WEP104: 25 | return WIFI_WPA_ALG_WEP104; 26 | case WLAN_CIPHER_SUITE_WEP40: 27 | return WIFI_WPA_ALG_WEP40; 28 | case WLAN_CIPHER_SUITE_AES_CMAC: 29 | return WIFI_WPA_ALG_IGTK; 30 | } 31 | return WIFI_WPA_ALG_NONE; 32 | } 33 | 34 | char * esp_chipname_from_id(int chipset_id) 35 | { 36 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32) 37 | return "ESP32"; 38 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32S2) 39 | return "ESP32-S2"; 40 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32S3) 41 | return "ESP32-S3"; 42 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32C2) 43 | return "ESP32-C2"; 44 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32C3) 45 | return "ESP32-C3"; 46 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32C6) 47 | return "ESP32-C6"; 48 | if (chipset_id == ESP_FIRMWARE_CHIP_ESP32C5) 49 | return "ESP32-C5"; 50 | 51 | return "Unknown Chip"; 52 | } 53 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef _esp_api__h_ 9 | #define _esp_api__h_ 10 | 11 | #include "esp.h" 12 | 13 | #define RET_ON_FAIL(x) \ 14 | do { \ 15 | int ret = (x); \ 16 | if (!!(ret)) { \ 17 | esp_err("%s failure, ret: %d\n", #x, ret); \ 18 | return ret; \ 19 | } \ 20 | } while (0); \ 21 | 22 | int esp_add_card(struct esp_adapter *adapter); 23 | int esp_remove_card(struct esp_adapter *adapter); 24 | void esp_process_new_packet_intr(struct esp_adapter *adapter); 25 | struct esp_adapter *esp_get_adapter(void); 26 | struct esp_wifi_device *get_priv_from_payload_header(struct esp_payload_header *header); 27 | struct sk_buff *esp_alloc_skb(u32 len); 28 | int esp_send_packet(struct esp_adapter *adapter, struct sk_buff *skb); 29 | u8 esp_is_bt_supported_over_sdio(u32 cap); 30 | void esp_tx_pause(struct esp_wifi_device *priv); 31 | void esp_tx_resume(struct esp_wifi_device *priv); 32 | void esp_init_priv(struct net_device *ndev); 33 | void esp_port_open(struct esp_wifi_device *priv); 34 | void esp_port_close(struct esp_wifi_device *priv); 35 | void esp_remove_network_interfaces(struct esp_adapter *adapter); 36 | void print_capabilities(u32 cap); 37 | void process_capabilities(struct esp_adapter *adapter); 38 | int esp_is_tx_queue_paused(struct esp_wifi_device *priv); 39 | int esp_deinit_module(struct esp_adapter *adapter); 40 | int esp_validate_chipset(struct esp_adapter *adapter, u8 chipset); 41 | int esp_adjust_spi_clock(struct esp_adapter *adapter, u8 spi_clk_mhz); 42 | void process_test_capabilities(u32 raw_tp_mode); 43 | int esp_init_raw_tp(struct esp_adapter *adapter); 44 | bool esp_is_valid_hardware_id(int hardware_id); 45 | char *esp_get_hardware_name(int hardware_id); 46 | int generate_slave_intr(void *context, u8 data); 47 | int esp_start_ota(struct esp_adapter *adapter, char *ota_file); 48 | #endif 49 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_bt_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef __esp_bt_api_h_ 9 | #define __esp_bt_api_h_ 10 | 11 | #include 12 | #include "esp.h" 13 | 14 | 15 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) 16 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)) 17 | #define hci_skb_pkt_type(skb) bt_cb((skb))->pkt_type 18 | #else 19 | #error "ESP-Hosted solution doesn't supported below kernel version < 2.6.34" 20 | #endif 21 | #endif 22 | 23 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) 24 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)) 25 | #define HCI_PRIMARY HCI_BREDR 26 | #else 27 | #error "ESP-Hosted solution doesn't supported below kernel version < 2.6.34" 28 | #endif 29 | #endif 30 | 31 | int esp_init_bt(struct esp_adapter *adapter); 32 | int esp_deinit_bt(struct esp_adapter *adapter); 33 | void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len); 34 | void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_cfg80211.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef __esp_cfg80211_h_ 9 | #define __esp_cfg80211_h_ 10 | 11 | #include 12 | 13 | struct wireless_dev *esp_cfg80211_add_iface(struct wiphy *wiphy, 14 | const char *name, 15 | unsigned char name_assign_type, 16 | enum nl80211_iftype type, 17 | struct vif_params *params); 18 | int esp_add_wiphy(struct esp_adapter *adapter); 19 | int esp_remove_wiphy(struct esp_adapter *adapter); 20 | int esp_mark_disconnect(struct esp_wifi_device *priv, uint16_t reason, 21 | uint8_t locally_disconnect); 22 | int esp_mark_scan_done_and_disconnect(struct esp_wifi_device *priv, 23 | uint8_t locally_disconnect); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_fw_version.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | /* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ 3 | 4 | #ifndef __ESP_FW_VERSION__H 5 | #define __ESP_FW_VERSION__H 6 | 7 | #define PROJECT_NAME "NG" 8 | #define PROJECT_VERSION_MAJOR_1 1 9 | #define PROJECT_VERSION_MAJOR_2 0 10 | #define PROJECT_VERSION_MINOR 4 11 | #define PROJECT_REVISION_PATCH_1 0 12 | #define PROJECT_REVISION_PATCH_2 1 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_if.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef __ESP_IF__H_ 9 | #define __ESP_IF__H_ 10 | 11 | #include "esp.h" 12 | 13 | struct esp_if_ops { 14 | int (*init)(struct esp_adapter *adapter); 15 | struct sk_buff* (*read)(struct esp_adapter *adapter); 16 | int (*write)(struct esp_adapter *adapter, struct sk_buff *skb); 17 | int (*deinit)(struct esp_adapter *adapter); 18 | }; 19 | 20 | int esp_init_interface_layer(struct esp_adapter *adapter, u32 speed); 21 | void esp_deinit_interface_layer(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_stats.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef __ESP_STAT__H__ 9 | #define __ESP_STAT__H__ 10 | 11 | #include "esp.h" 12 | 13 | #define TEST_RAW_TP 1 14 | 15 | #if TEST_RAW_TP 16 | 17 | #define TEST_RAW_TP__BUF_SIZE 1460 18 | 19 | #define ESP_TEST_RAW_TP__RX 0 20 | #define ESP_TEST_RAW_TP__TX 1 21 | 22 | void esp_raw_tp_queue_resume(void); 23 | #endif 24 | 25 | void test_raw_tp_cleanup(void); 26 | void update_test_raw_tp_rx_stats(u16 len); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/esp_utils.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef __esp_utils_h_ 9 | #define __esp_utils_h_ 10 | 11 | #include "esp.h" 12 | 13 | #define WPA_CIPHER_NONE BIT(0) 14 | #define WPA_CIPHER_WEP40 BIT(7) 15 | #define WPA_CIPHER_WEP104 BIT(8) 16 | #define WPA_CIPHER_TKIP BIT(1) 17 | #define WPA_CIPHER_CCMP BIT(3) 18 | #define WPA_CIPHER_AES_128_CMAC BIT(5) 19 | #define WPA_CIPHER_SMS4 BIT(10) 20 | #define WPA_CIPHER_GCMP BIT(11) 21 | #define WPA_CIPHER_GCMP_256 BIT(12) 22 | #define WPA_CIPHER_BIP_GMAC_128 BIT(13) 23 | #define WPA_CIPHER_BIP_GMAC_256 BIT(14) 24 | 25 | enum wpa_alg { 26 | WIFI_WPA_ALG_NONE = 0, 27 | WIFI_WPA_ALG_WEP40 = 1, 28 | WIFI_WPA_ALG_TKIP = 2, 29 | WIFI_WPA_ALG_CCMP = 3, 30 | WIFI_WAPI_ALG_SMS4 = 4, 31 | WIFI_WPA_ALG_WEP104 = 5, 32 | WIFI_WPA_ALG_WEP = 6, 33 | WIFI_WPA_ALG_IGTK = 7, 34 | WIFI_WPA_ALG_PMK = 8, 35 | WIFI_WPA_ALG_GCMP = 9, 36 | }; 37 | 38 | int wpa_cipher_to_alg(int cipher); 39 | 40 | char * esp_chipname_from_id(int chipset_id); 41 | 42 | typedef enum { 43 | WIFI_MODE_NULL = 0, /**< Null mode */ 44 | WIFI_MODE_STA, /**< Wi-Fi station mode */ 45 | WIFI_MODE_AP, /**< Wi-Fi soft-AP mode */ 46 | WIFI_MODE_APSTA, /**< Wi-Fi station + soft-AP mode */ 47 | WIFI_MODE_MAX 48 | } esp_wifi_mode_t; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/include/utils.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 4 | * 5 | */ 6 | #ifndef _UTIL_H_ 7 | #define _UTIL_H_ 8 | 9 | #include 10 | #include 11 | 12 | 13 | #ifndef NUMBER_1M 14 | #define NUMBER_1M 1000000 15 | #endif 16 | 17 | #ifndef MAC2STR 18 | #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] 19 | #endif 20 | #ifndef MACSTR 21 | #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" 22 | #endif 23 | 24 | enum esp_log_level { 25 | ESP_ERR, 26 | ESP_WARNING, 27 | ESP_INFO, 28 | ESP_DEBUG, 29 | ESP_VERBOSE, 30 | }; 31 | 32 | void esp_logger(int level, const char *function, const char* format, ...); 33 | void esp_hex_dump(const char *prefix_str, const void *buf, size_t len); 34 | void esp_hex_dump_verbose(const char *prefix_str, const void *buf, size_t len); 35 | 36 | int debugfs_init(void); 37 | void debugfs_exit(void); 38 | 39 | #define esp_err(format, ...) esp_logger(ESP_ERR, __func__, format, ##__VA_ARGS__) 40 | #define esp_warn(format, ...) esp_logger(ESP_WARNING, __func__, format, ##__VA_ARGS__) 41 | #define esp_info(format, ...) esp_logger(ESP_INFO, __func__, format, ##__VA_ARGS__) 42 | #define esp_dbg(format, ...) esp_logger(ESP_DEBUG, __func__, format, ##__VA_ARGS__) 43 | #define esp_verbose(format, ...) esp_logger(ESP_VERBOSE, __func__, format, ##__VA_ARGS__) 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/sdio/esp_sdio_api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Espressif Systems Wireless LAN device driver 4 | * 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 6 | * 7 | */ 8 | #ifndef _ESP_SDIO_API_H_ 9 | #define _ESP_SDIO_API_H_ 10 | #include "esp_sdio_decl.h" 11 | 12 | int esp_read_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 13 | int esp_read_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 14 | int esp_write_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 15 | int esp_write_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/spi/esp_spi.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 4 | * 5 | */ 6 | 7 | #ifndef _ESP_SPI_H_ 8 | #define _ESP_SPI_H_ 9 | 10 | #include "esp.h" 11 | 12 | #define HANDSHAKE_PIN 22 13 | #define SPI_IRQ gpio_to_irq(HANDSHAKE_PIN) 14 | #define SPI_DATA_READY_PIN 27 15 | #define SPI_DATA_READY_IRQ gpio_to_irq(SPI_DATA_READY_PIN) 16 | #define SPI_BUF_SIZE 1600 17 | 18 | enum spi_flags_e { 19 | ESP_SPI_BUS_CLAIMED, 20 | ESP_SPI_BUS_SET, 21 | ESP_SPI_GPIO_HS_REQUESTED, 22 | ESP_SPI_GPIO_HS_IRQ_DONE, 23 | ESP_SPI_GPIO_DR_REQUESTED, 24 | ESP_SPI_GPIO_DR_IRQ_DONE, 25 | ESP_SPI_DATAPATH_OPEN, 26 | }; 27 | 28 | struct esp_spi_context { 29 | struct esp_adapter *adapter; 30 | struct spi_device *esp_spi_dev; 31 | struct sk_buff_head tx_q[MAX_PRIORITY_QUEUES]; 32 | struct sk_buff_head rx_q[MAX_PRIORITY_QUEUES]; 33 | struct workqueue_struct *spi_workqueue; 34 | struct work_struct spi_work; 35 | struct workqueue_struct *nw_cmd_reinit_workqueue; 36 | struct work_struct nw_cmd_reinit_work; 37 | uint8_t spi_clk_mhz; 38 | uint8_t reserved[2]; 39 | unsigned long spi_flags; 40 | }; 41 | 42 | enum { 43 | CLOSE_DATAPATH, 44 | OPEN_DATAPATH, 45 | }; 46 | 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /esp_hosted_ng/host/spidev_disabler.dts: -------------------------------------------------------------------------------- 1 | /dts-v1/; 2 | /plugin/; 3 | 4 | / { 5 | compatible = "brcm,bcm2708"; 6 | 7 | fragment@0 { 8 | target = <&spidev0>; 9 | 10 | __overlay__ { 11 | status = "disabled"; 12 | }; 13 | }; 14 | }; 15 | --------------------------------------------------------------------------------