esp_wifi: fix wrong path of phy_init_data

Closes https://github.com/espressif/esp-idf/issues/3482
This commit is contained in:
suda-morris 2019-06-12 11:52:23 +08:00
parent 6b7c5dc37e
commit c5c716e9d7
8 changed files with 72 additions and 45 deletions

View file

@ -1,44 +1,10 @@
ifdef CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
PHY_INIT_DATA_OBJ = $(BUILD_DIR_BASE)/phy_init_data.o
PHY_INIT_DATA_BIN = $(BUILD_DIR_BASE)/phy_init_data.bin
# Command to flash PHY init data partition
PHY_INIT_DATA_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(PHY_DATA_OFFSET) $(PHY_INIT_DATA_BIN)
ESPTOOL_ALL_FLASH_ARGS += $(PHY_DATA_OFFSET) $(PHY_INIT_DATA_BIN)
ESP32_COMPONENT_PATH := $(COMPONENT_PATH)
$(PHY_INIT_DATA_OBJ): $(ESP32_COMPONENT_PATH)/phy_init_data.h $(BUILD_DIR_BASE)/include/sdkconfig.h
$(summary) CC $(notdir $@)
printf "#include \"phy_init_data.h\"\n" | $(CC) -I $(BUILD_DIR_BASE)/include -I $(ESP32_COMPONENT_PATH) -I $(ESP32_COMPONENT_PATH)/include -c -o $@ -xc -
$(PHY_INIT_DATA_BIN): $(PHY_INIT_DATA_OBJ)
$(summary) BIN $(notdir $@)
$(OBJCOPY) -O binary $< $@
phy_init_data: $(PHY_INIT_DATA_BIN)
phy_init_data-flash: $(BUILD_DIR_BASE)/phy_init_data.bin
@echo "Flashing PHY init data..."
$(PHY_INIT_DATA_FLASH_CMD)
phy_init_data-clean:
rm -f $(PHY_INIT_DATA_BIN) $(PHY_INIT_DATA_OBJ)
all: phy_init_data
flash: phy_init_data
endif # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
# Enable psram cache bug workaround in compiler if selected # Enable psram cache bug workaround in compiler if selected
ifdef CONFIG_SPIRAM_CACHE_WORKAROUND ifdef CONFIG_SPIRAM_CACHE_WORKAROUND
CFLAGS+=-mfix-esp32-psram-cache-issue CFLAGS+=-mfix-esp32-psram-cache-issue
CXXFLAGS+=-mfix-esp32-psram-cache-issue CXXFLAGS+=-mfix-esp32-psram-cache-issue
endif endif
# Enable dynamic esp_timer overflow value if building unit tests # Enable dynamic esp_timer overflow value if building unit tests
ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","") ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","")
CPPFLAGS += -DESP_TIMER_DYNAMIC_OVERFLOW_VAL CPPFLAGS += -DESP_TIMER_DYNAMIC_OVERFLOW_VAL
endif endif

View file

@ -1,3 +1,6 @@
idf_build_get_property(idf_target IDF_TARGET)
idf_build_get_property(build_dir BUILD_DIR)
set(COMPONENT_SRCS set(COMPONENT_SRCS
"src/coexist.c" "src/coexist.c"
"src/fast_crypto_ops.c" "src/fast_crypto_ops.c"
@ -6,7 +9,7 @@ set(COMPONENT_SRCS
"src/phy_init.c" "src/phy_init.c"
"src/restore.c" "src/restore.c"
"src/wifi_init.c") "src/wifi_init.c")
set(COMPONENT_ADD_INCLUDEDIRS "include") set(COMPONENT_ADD_INCLUDEDIRS "include" "${idf_target}/include")
set(COMPONENT_PRIV_INCLUDEDIRS) set(COMPONENT_PRIV_INCLUDEDIRS)
set(COMPONENT_PRIV_REQUIRES wpa_supplicant nvs_flash) set(COMPONENT_PRIV_REQUIRES wpa_supplicant nvs_flash)
@ -15,13 +18,13 @@ if(NOT CONFIG_ESP32_NO_BLOBS)
endif() endif()
register_component() register_component()
target_link_libraries(${COMPONENT_LIB} PUBLIC "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}") target_link_libraries(${COMPONENT_LIB} PUBLIC "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${idf_target}")
if(NOT CONFIG_ESP32_NO_BLOBS) if(NOT CONFIG_ESP32_NO_BLOBS)
set(blobs coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps) set(blobs coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
foreach(blob ${blobs}) foreach(blob ${blobs})
add_library(${blob} STATIC IMPORTED) add_library(${blob} STATIC IMPORTED)
set_property(TARGET ${blob} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}/lib${blob}.a) set_property(TARGET ${blob} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib_${idf_target}/lib${blob}.a)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob}) target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
foreach(_blob ${blobs}) foreach(_blob ${blobs})
@ -35,7 +38,7 @@ if(NOT CONFIG_ESP32_NO_BLOBS)
endif() endif()
if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION) if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
idf_build_get_property(build_dir BUILD_DIR) idf_component_get_property(esp_common_dir esp_common COMPONENT_DIR)
partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset") partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
set(phy_init_data_bin "${build_dir}/phy_init_data.bin") set(phy_init_data_bin "${build_dir}/phy_init_data.bin")
@ -43,11 +46,11 @@ if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
# the object file to a raw binary # the object file to a raw binary
add_custom_command( add_custom_command(
OUTPUT ${phy_init_data_bin} OUTPUT ${phy_init_data_bin}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${idf_target}/include/phy_init_data.h
COMMAND ${CMAKE_C_COMPILER} -x c -c COMMAND ${CMAKE_C_COMPILER} -x c -c
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${build_dir} -I ${esp_common_dir}/include -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${build_dir}/config
-o phy_init_data.obj -o phy_init_data.obj
${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h ${CMAKE_CURRENT_LIST_DIR}/${idf_target}/include/phy_init_data.h
COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin} 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_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})

View file

@ -0,0 +1,32 @@
ifdef CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
PHY_INIT_DATA_OBJ = $(BUILD_DIR_BASE)/phy_init_data.o
PHY_INIT_DATA_BIN = $(BUILD_DIR_BASE)/phy_init_data.bin
# Command to flash PHY init data partition
PHY_INIT_DATA_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(PHY_DATA_OFFSET) $(PHY_INIT_DATA_BIN)
ESPTOOL_ALL_FLASH_ARGS += $(PHY_DATA_OFFSET) $(PHY_INIT_DATA_BIN)
ESP_WIFI_COMPONENT_PATH := $(COMPONENT_PATH)
$(PHY_INIT_DATA_OBJ): $(ESP_WIFI_COMPONENT_PATH)/$(IDF_TARGET)/include/phy_init_data.h $(BUILD_DIR_BASE)/include/sdkconfig.h
$(summary) CC $(notdir $@)
printf "#include \"phy_init_data.h\"\n" | $(CC) -I $(BUILD_DIR_BASE)/include -I $(ESP_WIFI_COMPONENT_PATH)/../esp_common/include -I $(ESP_WIFI_COMPONENT_PATH)/include -I $(ESP_WIFI_COMPONENT_PATH)/$(IDF_TARGET)/include -c -o $@ -xc -
$(PHY_INIT_DATA_BIN): $(PHY_INIT_DATA_OBJ)
$(summary) BIN $(notdir $@)
$(OBJCOPY) -O binary $< $@
phy_init_data: $(PHY_INIT_DATA_BIN)
phy_init_data-flash: $(BUILD_DIR_BASE)/phy_init_data.bin
@echo "Flashing PHY init data..."
$(PHY_INIT_DATA_FLASH_CMD)
phy_init_data-clean:
rm -f $(PHY_INIT_DATA_BIN) $(PHY_INIT_DATA_OBJ)
all: phy_init_data
flash: phy_init_data
endif # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION

View file

@ -2,7 +2,7 @@
# Component Makefile # Component Makefile
# #
COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_ADD_INCLUDEDIRS := include $(IDF_TARGET)/include
COMPONENT_SRCDIRS := src COMPONENT_SRCDIRS := src
ifndef CONFIG_ESP32_NO_BLOBS ifndef CONFIG_ESP32_NO_BLOBS

View file

@ -48,7 +48,7 @@ PHY initialization data
The PHY initialization data is used for RF calibration. The PHY initialization data is used for RF calibration.
There are two ways to get the PHY initialization data. There are two ways to get the PHY initialization data.
One is the default initialization data which is located in the header file :idf_file:`components/esp32/phy_init_data.h`. One is the default initialization data which is located in the header file :idf_file:`components/esp_wifi/esp32/include/phy_init_data.h`.
It is embedded into the application binary after compiling and then stored into read-only memory (DROM). It is embedded into the application binary after compiling and then stored into read-only memory (DROM).
To use the default initialization data, please go to ``menuconfig`` and disable :ref:`CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION`. To use the default initialization data, please go to ``menuconfig`` and disable :ref:`CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION`.

View file

@ -57,6 +57,7 @@ function run_tests()
BOOTLOADER_BINS="bootloader/bootloader.elf bootloader/bootloader.bin" BOOTLOADER_BINS="bootloader/bootloader.elf bootloader/bootloader.bin"
APP_BINS="app-template.elf app-template.bin" APP_BINS="app-template.elf app-template.bin"
PHY_INIT_BIN="phy_init_data.bin"
print_status "Initial clean build" print_status "Initial clean build"
# if make fails here, everything fails # if make fails here, everything fails
@ -283,6 +284,18 @@ function run_tests()
rm sdkconfig sdkconfig.defaults rm sdkconfig sdkconfig.defaults
make defconfig make defconfig
print_status "can build with phy_init_data"
make clean > /dev/null
rm -f sdkconfig.defaults
rm -f sdkconfig
echo "CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION=y" >> sdkconfig.defaults
make defconfig > /dev/null
make || failure "Failed to build with PHY_INIT_DATA"
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PHY_INIT_BIN}
rm sdkconfig
rm sdkconfig.defaults
make defconfig
print_status "Empty directory not treated as a component" print_status "Empty directory not treated as a component"
mkdir -p components/esp32 mkdir -p components/esp32
make || failure "Failed to build with empty esp32 directory in components" make || failure "Failed to build with empty esp32 directory in components"

View file

@ -58,6 +58,7 @@ function run_tests()
BOOTLOADER_BINS="bootloader/bootloader.elf bootloader/bootloader.bin" BOOTLOADER_BINS="bootloader/bootloader.elf bootloader/bootloader.bin"
APP_BINS="app-template.elf app-template.bin" APP_BINS="app-template.elf app-template.bin"
PARTITION_BIN="partition_table/partition-table.bin" PARTITION_BIN="partition_table/partition-table.bin"
PHY_INIT_BIN="phy_init_data.bin"
BUILD_ARTIFACTS="project_description.json flasher_args.json config/kconfig_menus.json config/sdkconfig.json" BUILD_ARTIFACTS="project_description.json flasher_args.json config/kconfig_menus.json config/sdkconfig.json"
IDF_COMPONENT_PREFIX="__idf" IDF_COMPONENT_PREFIX="__idf"
@ -342,6 +343,18 @@ function run_tests()
rm sdkconfig; rm sdkconfig;
rm sdkconfig.defaults; rm sdkconfig.defaults;
print_status "can build with phy_init_data"
idf.py clean > /dev/null;
idf.py fullclean > /dev/null;
rm -f sdkconfig.defaults;
rm -f sdkconfig;
echo "CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION=y" >> sdkconfig.defaults;
idf.py reconfigure > /dev/null;
idf.py build || failure "Failed to build with PHY_INIT_DATA"
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} ${PHY_INIT_BIN}
rm sdkconfig;
rm sdkconfig.defaults;
print_status "Building a project with CMake library imported and PSRAM workaround, all files compile with workaround" print_status "Building a project with CMake library imported and PSRAM workaround, all files compile with workaround"
# Test for libraries compiled within ESP-IDF # Test for libraries compiled within ESP-IDF
rm -rf build rm -rf build
@ -440,7 +453,7 @@ endmenu\n" >> ${IDF_PATH}/Kconfig;
print_status "If a component directory is added to COMPONENT_DIRS, its sibling directories are not added" print_status "If a component directory is added to COMPONENT_DIRS, its sibling directories are not added"
clean_build_dir clean_build_dir
mkdir -p mycomponents/mycomponent mkdir -p mycomponents/mycomponent
echo "idf_component_register()" > mycomponents/mycomponent/CMakeLists.txt echo "idf_component_register()" > mycomponents/mycomponent/CMakeLists.txt
# first test by adding single component directory to EXTRA_COMPONENT_DIRS # first test by adding single component directory to EXTRA_COMPONENT_DIRS
mkdir -p mycomponents/esp32 mkdir -p mycomponents/esp32