Skip to content

Commit

Permalink
derive esp_wifi from esp32 component
Browse files Browse the repository at this point in the history
  • Loading branch information
suda-morris committed Apr 1, 2019
1 parent 5b2247d commit 79bb5de
Show file tree
Hide file tree
Showing 48 changed files with 162 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ build_template_app:
- sed -i.bak -e's/CONFIG_OPTIMIZATION_LEVEL_DEBUG\=y/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/' sdkconfig
- make all V=1
# Check if there are any stray printf/ets_printf references in WiFi libs
- cd ../components/esp32/lib
- cd ../components/esp_wifi/lib_esp32
- test $(xtensa-esp32-elf-nm *.a | grep -w printf | wc -l) -eq 0
- test $(xtensa-esp32-elf-nm *.a | grep -w ets_printf | wc -l) -eq 0

Expand Down
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "components/esp32/lib"]
path = components/esp32/lib
url = https://github.com/espressif/esp32-wifi-lib.git

[submodule "components/esptool_py/esptool"]
path = components/esptool_py/esptool
url = https://github.com/espressif/esptool.git
Expand Down Expand Up @@ -69,3 +65,7 @@
[submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"]
path = examples/build_system/cmake/import_lib/main/lib/tinyxml2
url = https://github.com/leethomason/tinyxml2

[submodule "components/esp_wifi/lib_esp32"]
path = components/esp_wifi/lib_esp32
url = https://github.com/espressif/esp32-wifi-lib.git
2 changes: 1 addition & 1 deletion components/bootloader/subproject/main/Makefile.projbuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Submodules normally added in component.mk, but fully qualified
# paths can be added at this level (we need binary librtc to be
# available to link bootloader).
COMPONENT_SUBMODULES += $(IDF_PATH)/components/esp32/lib
COMPONENT_SUBMODULES += $(IDF_PATH)/components/esp_wifi/lib_esp32
35 changes: 2 additions & 33 deletions components/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,41 @@ else()
"cache_err_int.c"
"cache_sram_mmu.c"
"clk.c"
"coexist.c"
"cpu_start.c"
"crosscore_int.c"
"dport_access.c"
"dport_panic_highint_hdl.S"
"esp_adapter.c"
"esp_timer_esp32.c"
"esp_himem.c"
"fast_crypto_ops.c"
"freertos_hooks.c"
"gdbstub.c"
"hw_random.c"
"int_wdt.c"
"intr_alloc.c"
"ipc.c"
"lib_printf.c"
"panic.c"
"phy_init.c"
"pm_esp32.c"
"pm_trace.c"
"reset_reason.c"
"restore.c"
"sleep_modes.c"
"spiram.c"
"spiram_psram.c"
"system_api.c"
"task_wdt.c"
"wifi_init.c")
"task_wdt.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")

set(COMPONENT_REQUIRES driver esp_event efuse)
# driver is a public requirement because esp_sleep.h uses gpio_num_t & touch_pad_t
# app_update is added here because cpu_start.c uses esp_ota_get_app_description() function.
set(COMPONENT_PRIV_REQUIRES
app_trace app_update bootloader_support log mbedtls nvs_flash
pthread smartconfig_ack spi_flash vfs wpa_supplicant espcoredump esp_common)
pthread smartconfig_ack spi_flash vfs wpa_supplicant espcoredump esp_common esp_wifi)

set(COMPONENT_ADD_LDFRAGMENTS linker.lf ld/esp32_fragments.lf)

register_component()

target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
if(NOT CONFIG_NO_BLOBS)
target_link_libraries(${COMPONENT_TARGET} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
endif()
target_linker_script(${COMPONENT_TARGET} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")

if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
Expand Down Expand Up @@ -101,27 +91,6 @@ else()
add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
add_dependencies(${COMPONENT_TARGET} esp32_linker_script)

if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION AND IDF_BUILD_ARTIFACTS)
partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
set(phy_init_data_bin "${IDF_BUILD_ARTIFACTS_DIR}/phy_init_data.bin")

# To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
# the object file to a raw binary
add_custom_command(
OUTPUT ${phy_init_data_bin}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
COMMAND ${CMAKE_C_COMPILER} -x c -c
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${IDF_BUILD_ARTIFACTS_DIR}
-o phy_init_data.obj
${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin}
)
add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})
add_dependencies(flash phy_init_data)

esptool_py_flash_project_args(phy ${phy_partition_offset} ${phy_init_data_bin} FLASH_IN_PROJECT)
endif()

# Enable dynamic esp_timer overflow value if building unit tests
if(esp32_test IN_LIST BUILD_TEST_COMPONENTS)
add_definitions(-DESP_TIMER_DYNAMIC_OVERFLOW_VAL)
Expand Down
13 changes: 1 addition & 12 deletions components/esp32/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
#

COMPONENT_SRCDIRS := .
LIBS ?=
ifndef CONFIG_NO_BLOBS
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy mesh
endif

ifdef CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
# This linker script must come before esp32.project.ld
Expand All @@ -22,23 +18,16 @@ LINKER_SCRIPTS += $(COMPONENT_BUILD_DIR)/esp32.project.ld esp32.peripherals.ld
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
#symbols in it.
COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/libhal.a \
-L$(COMPONENT_PATH)/lib \
$(addprefix -l,$(LIBS)) \
-L $(COMPONENT_PATH)/ld \
-T esp32_out.ld \
-u ld_include_panic_highint_hdl \
$(addprefix -T ,$(LINKER_SCRIPTS)) \

COMPONENT_ADD_LDFRAGMENTS += ld/esp32_fragments.lf linker.lf

ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))

COMPONENT_SUBMODULES += lib

# final linking of project ELF depends on all binary libraries, and
# all linker scripts (except esp32_out.ld, as this is code generated here.)
COMPONENT_ADD_LINKER_DEPS := $(ALL_LIB_FILES) \
$(addprefix ld/, $(filter-out $(COMPONENT_BUILD_DIR)/esp32.project.ld, $(LINKER_SCRIPTS))) \
COMPONENT_ADD_LINKER_DEPS := $(addprefix ld/, $(filter-out $(COMPONENT_BUILD_DIR)/esp32.project.ld, $(LINKER_SCRIPTS))) \
$(COMPONENT_BUILD_DIR)/esp32.project.ld

# Preprocess esp32.ld linker script into esp32_out.ld
Expand Down
4 changes: 2 additions & 2 deletions components/esp32/esp_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include "esp_attr.h"
#include "esp_log.h"
#include "esp_heap_caps.h"
#include "esp_wifi_os_adapter.h"
#include "esp_wifi_internal.h"
#include "esp_private/wifi_os_adapter.h"
#include "esp_private/wifi.h"
#include "esp_phy_init.h"
#include "crypto/md5.h"
#include "crypto/sha1.h"
Expand Down
31 changes: 4 additions & 27 deletions components/esp32/linker.lf
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
[mapping]
archive: libesp32.a
entries:
entries:
panic (noflash)

[mapping]
archive: libphy.a
entries:
* (noflash_data)

[mapping]
archive: libhal.a
entries:
* (noflash_text)

[mapping]
archive: librtc.a
entries:
entries:
* (noflash_text)

[mapping]
archive: libgcc.a
entries:
entries:
lib2funcs (noflash_text)

[mapping]
archive: libgcov.a
entries:
entries:
* (noflash)

[mapping]
archive: libpp.a
entries:
: ESP32_WIFI_IRAM_OPT = y
* (wifi_iram)

[mapping]
archive: libnet80211.a
entries:
: ESP32_WIFI_IRAM_OPT = y
* (wifi_iram)

2 changes: 1 addition & 1 deletion components/esp32/system_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "esp_system.h"
#include "esp_attr.h"
#include "esp_wifi.h"
#include "esp_wifi_internal.h"
#include "esp_private/wifi.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include "esp32/rom/efuse.h"
Expand Down
22 changes: 0 additions & 22 deletions components/esp32/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,6 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
WORKING_DIRECTORY ${COMPONENT_PATH}
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")

# Calculate MD5 value of header file esp_wifi_os_adapter.h
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_os_adapter.h
COMMAND cut -c 1-7
OUTPUT_VARIABLE WIFI_OS_ADAPTER_MD5
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Calculate MD5 value of header file esp_wifi_crypto_types.h
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_crypto_types.h
COMMAND cut -c 1-7
OUTPUT_VARIABLE WIFI_CRYPTO_MD5
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Calculate MD5 value of header file esp_coexist_adapter.h
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_coexist_adapter.h
COMMAND cut -c 1-7
OUTPUT_VARIABLE COEX_ADAPTER_MD5
OUTPUT_STRIP_TRAILING_WHITESPACE)

add_definitions(-DWIFI_OS_ADAPTER_MD5=\"${WIFI_OS_ADAPTER_MD5}\")
add_definitions(-DWIFI_CRYPTO_MD5=\"${WIFI_CRYPTO_MD5}\")
add_definitions(-DCOEX_ADAPTER_MD5=\"${COEX_ADAPTER_MD5}\")

add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")

add_dependencies(${COMPONENT_TARGET} esp32_test_logo)
12 changes: 0 additions & 12 deletions components/esp32/test/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-a

COMPONENT_SRCDIRS := .

# Calculate MD5 value of header file esp_wifi_os_adapter.h
WIFI_OS_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_os_adapter.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_OS_ADAPTER_MD5=$(WIFI_OS_ADAPTER_MD5_VAL)

# Calculate MD5 value of header file esp_wifi_crypto_types.h
WIFI_CRYPTO_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_crypto_types.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_CRYPTO_MD5=$(WIFI_CRYPTO_MD5_VAL)

# Calculate MD5 value of header file esp_coexist_adapter.h
COEX_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_coexist_adapter.h | cut -c 1-7)\"
CFLAGS+=-DCOEX_ADAPTER_MD5=$(COEX_ADAPTER_MD5_VAL)

test_tjpgd.o: test_tjpgd_logo.h

test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg
Expand Down
2 changes: 1 addition & 1 deletion components/esp_event/event_default_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "esp_err.h"
#include "esp_wifi.h"
#include "esp_wifi_internal.h"
#include "esp_private/wifi.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "esp_task.h"
Expand Down
41 changes: 41 additions & 0 deletions components/esp_wifi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
set(COMPONENT_SRCS
"src/coexist.c"
"src/fast_crypto_ops.c"
"src/lib_printf.c"
"src/phy_init.c"
"src/restore.c"
"src/wifi_init.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_PRIV_INCLUDEDIRS)
set(COMPONENT_REQUIRES)
set(COMPONENT_PRIV_REQUIRES "wpa_supplicant" "nvs_flash")
set(COMPONENT_ADD_LDFRAGMENTS "linker.lf")

register_component()

target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")

if(NOT CONFIG_NO_BLOBS)
target_link_libraries(${COMPONENT_TARGET} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
endif()

if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION AND IDF_BUILD_ARTIFACTS)
partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
set(phy_init_data_bin "${IDF_BUILD_ARTIFACTS_DIR}/phy_init_data.bin")
# To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
# the object file to a raw binary
add_custom_command(
OUTPUT ${phy_init_data_bin}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/include/phy_init_data.h
COMMAND ${CMAKE_C_COMPILER} -x c -c
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${IDF_BUILD_ARTIFACTS_DIR}
-o phy_init_data.obj
${CMAKE_CURRENT_LIST_DIR}/include/phy_init_data.h
COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin}
)
add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})
add_dependencies(flash phy_init_data)

esptool_py_flash_project_args(phy ${phy_partition_offset} ${phy_init_data_bin} FLASH_IN_PROJECT)

endif()
21 changes: 21 additions & 0 deletions components/esp_wifi/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Component Makefile
#

COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_SRCDIRS := src

LIBS ?=
ifndef CONFIG_NO_BLOBS
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy mesh
endif

COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/lib_esp32 \
$(addprefix -l,$(LIBS)) \

COMPONENT_ADD_LDFRAGMENTS += linker.lf

COMPONENT_SUBMODULES += lib_esp32

ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib_esp32/lib%.a,$(LIBS))
COMPONENT_ADD_LINKER_DEPS += $(ALL_LIB_FILES)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "esp_err.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "esp_wifi_internal.h"
#include "esp_private/wifi.h"
#include "esp_wifi_crypto_types.h"

#ifdef __cplusplus
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#include "esp_wifi_types.h"
#include "esp_wifi_crypto_types.h"
#include "esp_event.h"
#include "esp_wifi_os_adapter.h"
#include "esp_private/wifi_os_adapter.h"

#ifdef __cplusplus
extern "C" {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions components/esp_wifi/linker.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[mapping]
archive: libphy.a
entries:
* (noflash_data)

[mapping]
archive: librtc.a
entries:
* (noflash_text)

[mapping]
archive: libpp.a
entries:
: ESP32_WIFI_IRAM_OPT = y
* (wifi_iram)

[mapping]
archive: libnet80211.a
entries:
: ESP32_WIFI_IRAM_OPT = y
* (wifi_iram)

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "phy_init_data.h"
#include "esp_coexist_internal.h"
#include "driver/periph_ctrl.h"
#include "esp_wifi_internal.h"
#include "esp_private/wifi.h"

extern wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <esp_event.h>
#include <esp_wifi.h>
#include "esp_log.h"
#include "esp_wifi_internal.h"
#include "esp_private/wifi.h"
#include "esp_pm.h"
#include "soc/rtc.h"
#include "esp_mesh.h"
Expand Down
Loading

0 comments on commit 79bb5de

Please sign in to comment.