Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cca13e0

Browse files
donghengdongheng
authored andcommitted
feat(make): Sync code from esp-idf and modify for ESP8266
Commit ID: f6bfe13e
1 parent 09d8546 commit cca13e0

File tree

86 files changed

+2168
-775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2168
-775
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(COMPONENT_SRCDIRS ".")
2+
set(COMPONENT_ADD_INCLUDEDIRS "include")
3+
4+
set(COMPONENT_REQUIRES "spi_flash")
5+
set(COMPONENT_PRIV_REQUIRES "bootloader_support" "util")
6+
7+
register_component()
8+
9+
if(CONFIG_APP_UPDATE_CHECK_APP_SUM)
10+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SUM=1)
11+
endif()
12+
13+
if(CONFIG_APP_UPDATE_CHECK_APP_HASH)
14+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SHA256=1)
15+
endif()

components/aws_iot/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if(CONFIG_AWS_IOT_SDK)
2+
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
3+
set(COMPONENT_SRCDIRS "aws-iot-device-sdk-embedded-C/src port")
4+
else()
5+
message(STATUS "Building empty aws_iot component due to configuration")
6+
endif()
7+
8+
set(COMPONENT_REQUIRES ssl)
9+
set(COMPONENT_PRIV_REQUIRES jsmn esp-tls)
10+
11+
register_component()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# bootloader component logic is all in project_include.cmake,
2+
# and subproject/CMakeLists.txt.
3+
#
4+
# This file is only included so the build system finds the
5+
# component
6+
7+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
if(BOOTLOADER_BUILD)
2+
return() # don't keep recursing!
3+
endif()
4+
5+
# Glue to build the bootloader subproject binary as an external
6+
# cmake project under this one
7+
#
8+
#
9+
set(bootloader_build_dir "${CMAKE_BINARY_DIR}/bootloader")
10+
set(bootloader_binary_files
11+
"${bootloader_build_dir}/bootloader.elf"
12+
"${bootloader_build_dir}/bootloader.bin"
13+
"${bootloader_build_dir}/bootloader.map"
14+
)
15+
16+
externalproject_add(bootloader
17+
# TODO: support overriding the bootloader in COMPONENT_PATHS
18+
SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject"
19+
BINARY_DIR "${bootloader_build_dir}"
20+
CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH}
21+
INSTALL_COMMAND ""
22+
BUILD_ALWAYS 1 # no easy way around this...
23+
BUILD_BYPRODUCTS ${bootloader_binary_files}
24+
)
25+
26+
# this is a hack due to an (annoying) shortcoming in cmake, it can't
27+
# extend the 'clean' target to the external project
28+
# see thread: https://cmake.org/pipermail/cmake/2016-December/064660.html
29+
#
30+
# So for now we just have the top-level build remove the final build products...
31+
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
32+
ADDITIONAL_MAKE_CLEAN_FILES
33+
${bootloader_binary_files})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
if(NOT SDKCONFIG)
4+
message(FATAL_ERROR "Bootloader subproject expects the SDKCONFIG variable to be passed "
5+
"in by the parent build process.")
6+
endif()
7+
8+
if(NOT IDF_PATH)
9+
message(FATAL_ERROR "Bootloader subproject expects the IDF_PATH variable to be passed "
10+
"in by the parent build process.")
11+
endif()
12+
13+
set(COMPONENTS esptool_py bootloader bootloader_support spi_flash log esp8266 util partition_table)
14+
set(BOOTLOADER_BUILD 1)
15+
add_definitions(-DBOOTLOADER_BUILD=1)
16+
17+
set(COMPONENT_REQUIRES_COMMON log esp8266 spi_flash)
18+
19+
set(MAIN_SRCS main/bootloader_start.c)
20+
21+
include("${IDF_PATH}/tools/cmake/project.cmake")
22+
project(bootloader)
23+
24+
target_linker_script(bootloader.elf
25+
"main/esp8266.bootloader.ld"
26+
"main/esp8266.bootloader.rom.ld")
27+
# Imported from esp8266 component
28+
target_linker_script(bootloader.elf ${ESP8266_BOOTLOADER_LINKER_SCRIPTS})
29+
target_link_libraries(bootloader.elf ${ESP8266_BOOTLOADER_LIBS})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set(COMPONENT_SRCDIRS "src")
2+
3+
if(${BOOTLOADER_BUILD})
4+
set(COMPONENT_ADD_INCLUDEDIRS "include include_priv")
5+
set(COMPONENT_REQUIRES)
6+
set(COMPONENT_PRIV_REQUIRES spi_flash util)
7+
else()
8+
set(COMPONENT_ADD_INCLUDEDIRS "include")
9+
set(COMPONENT_PRIV_INCLUDEDIRS "include_priv")
10+
set(COMPONENT_REQUIRES)
11+
set(COMPONENT_PRIV_REQUIRES spi_flash util ssl)
12+
endif()
13+
14+
register_component()
15+
16+
if(CONFIG_APP_UPDATE_CHECK_APP_SUM)
17+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SUM=1)
18+
endif()
19+
20+
if(CONFIG_APP_UPDATE_CHECK_APP_HASH)
21+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D CONFIG_ENABLE_BOOT_CHECK_SHA256=1)
22+
endif()

components/cjson/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
set(COMPONENT_SRCDIRS cJSON)
22
set(COMPONENT_ADD_INCLUDEDIRS cJSON)
33

4-
set(COMPONENT_REQUIRES "")
4+
set(COMPONENT_REQUIRES newlib)
55

66
register_component()
7+
8+
if(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL)
9+
target_compile_definitions(${COMPONENT_NAME} PRIVATE -D CJSON_SPRINTF_FLOAT=1)
10+
endif()

components/coap/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ set_source_files_properties(
4040
PROPERTIES COMPILE_FLAGS
4141
-Wno-implicit-fallthrough)
4242

43+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D WITH_POSIX)

components/esp-tls/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(COMPONENT_SRCS "esp_tls.c")
22
set(COMPONENT_ADD_INCLUDEDIRS ".")
33

4-
set(COMPONENT_REQUIRES mbedtls)
5-
set(COMPONENT_PRIV_REQUIRES lwip nghttp)
4+
set(COMPONENT_REQUIRES ssl)
5+
set(COMPONENT_PRIV_REQUIRES lwip)
66

77
register_component()

components/esp8266/CMakeLists.txt

Lines changed: 85 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,96 @@
1-
set(COMPONENT_SRCDIRS source driver)
1+
if(BOOTLOADER_BUILD)
2+
# For bootloader, all we need from esp8266 is headers
3+
set(COMPONENT_ADD_INCLUDEDIRS include)
4+
# set(COMPONENT_REQUIRES ${COMPONENTS})
5+
set(COMPONENT_SRCS source/ets_printf.c)
6+
register_component(esp8266)
27

3-
set(COMPONENT_ADD_INCLUDEDIRS include)
8+
# as cmake won't attach linker args to a header-only library, attach
9+
# linker args directly to the bootloader.elf
10+
set(ESP8266_BOOTLOADER_LINKER_SCRIPTS
11+
"${CMAKE_CURRENT_SOURCE_DIR}/ld/esp8266.rom.ld"
12+
PARENT_SCOPE
13+
)
414

5-
set(COMPONENT_PRIV_INCLUDEDIRS include/driver)
15+
set(ESP8266_BOOTLOADER_LIBS
16+
"-L ${CMAKE_CURRENT_SOURCE_DIR}/lib"
17+
"core"
18+
PARENT_SCOPE
19+
)
620

7-
set(COMPONENT_REQUIRES lwip)
8-
set(COMPONENT_PRIV_REQUIRES freertos)
21+
else()
22+
# Regular app build
923

10-
register_component()
24+
set(COMPONENT_SRCDIRS "driver source")
25+
set(COMPONENT_ADD_INCLUDEDIRS "include")
26+
set(COMPONENT_PRIV_INCLUDEDIRS "include/driver")
1127

12-
target_link_libraries(${COMPONENT_NAME} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
13-
if(NOT CONFIG_NO_BLOBS)
14-
target_link_libraries(${COMPONENT_NAME} gcc hal core
15-
net80211 phy pp smartconfig ssc wpa espnow wps)
16-
endif()
28+
set(COMPONENT_REQUIRES newlib)
29+
# driver is a public requirement because esp_sleep.h uses gpio_num_t & touch_pad_t
30+
# tcpip_adapter is a public requirement because esp_event.h uses tcpip_adapter types
31+
set(COMPONENT_PRIV_REQUIRES "log" "nvs_flash" "spi_flash" "tcpip_adapter" "bootloader_support" "util" "esp_ringbuf")
1732

18-
target_link_libraries(${COMPONENT_NAME} "-u call_user_start")
33+
register_component()
1934

20-
set(ESPTOOLPY_FLASHSIZE ${CONFIG_ESPTOOLPY_FLASHSIZE})
35+
target_link_libraries(esp8266 "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
36+
if(NOT CONFIG_NO_BLOBS)
37+
target_link_libraries(esp8266 gcc hal core net80211 phy pp smartconfig ssc wpa espnow wps)
38+
endif()
39+
target_linker_script(esp8266 "${CMAKE_CURRENT_BINARY_DIR}/esp8266_out.ld" "${CMAKE_CURRENT_BINARY_DIR}/esp8266_common_out.ld")
2140

22-
if(ESPTOOLPY_FLASHSIZE STREQUAL "512KB")
23-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.512.${CONFIG_ESPTOOLPY_APP_NUM}.ld)
24-
endif()
25-
if(ESPTOOLPY_FLASHSIZE STREQUAL "1MB")
26-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.1024.${CONFIG_ESPTOOLPY_APP_NUM}.ld)
27-
endif()
28-
if(ESPTOOLPY_FLASHSIZE STREQUAL "2MB")
29-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.1024.${CONFIG_ESPTOOLPY_APP_NUM}.ld)
30-
endif()
31-
if(ESPTOOLPY_FLASHSIZE STREQUAL "2MB-c1")
32-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.2048.ld)
33-
endif()
34-
if(ESPTOOLPY_FLASHSIZE STREQUAL "4MB")
35-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.1024.${CONFIG_ESPTOOLPY_APP_NUM}.ld)
36-
endif()
37-
if(ESPTOOLPY_FLASHSIZE STREQUAL "4MB-c1")
38-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.2048.ld)
39-
endif()
40-
if(ESPTOOLPY_FLASHSIZE STREQUAL "8MB")
41-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.2048.ld)
42-
endif()
43-
if(ESPTOOLPY_FLASHSIZE STREQUAL "16MB")
44-
set(ESP8266_LINKER_SCRIPTS eagle.app.v6.new.2048.ld)
45-
endif()
41+
target_linker_script(esp8266
42+
"ld/esp8266.rom.ld"
43+
"ld/esp8266.peripherals.ld"
44+
)
45+
46+
target_link_libraries(esp8266 "-u call_user_start")
47+
48+
# Preprocess esp8266.ld linker script to include configuration, becomes esp8266_out.ld
49+
set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld)
50+
add_custom_command(
51+
OUTPUT esp8266_out.ld
52+
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp8266_out.ld ${CFLAGS} -I ${CONFIG_DIR} ${LD_DIR}/esp8266.ld
53+
MAIN_DEPENDENCY ${LD_DIR}/esp8266.ld ${SDKCONFIG_H}
54+
COMMENT "Generating memory map linker script..."
55+
VERBATIM)
56+
add_custom_command(
57+
OUTPUT esp8266_common_out.ld
58+
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp8266_common_out.ld -I ${CONFIG_DIR} ${LD_DIR}/esp8266.common.ld
59+
MAIN_DEPENDENCY ${LD_DIR}/esp8266.common.ld ${SDKCONFIG_H}
60+
COMMENT "Generating section linker script..."
61+
VERBATIM)
62+
add_custom_target(esp8266_linker_script DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/esp8266_out.ld" "${CMAKE_CURRENT_BINARY_DIR}/esp8266_common_out.ld")
63+
add_dependencies(esp8266 esp8266_linker_script)
64+
65+
if(CONFIG_ESP8266_PHY_INIT_DATA_IN_PARTITION)
66+
set(PHY_INIT_DATA_BIN phy_init_data.bin)
4667

47-
target_linker_script(${COMPONENT_NAME}
48-
ld/${ESP8266_LINKER_SCRIPTS}
49-
ld/eagle.app.v6.common.ld
50-
ld/eagle.rom.addr.v6.ld)
68+
# To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
69+
# the object file to a raw binary
70+
add_custom_command(
71+
OUTPUT ${PHY_INIT_DATA_BIN}
72+
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
73+
COMMAND ${CMAKE_C_COMPILER} -x c -c
74+
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${CMAKE_BINARY_DIR}
75+
-o phy_init_data.obj
76+
${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
77+
COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${PHY_INIT_DATA_BIN}
78+
)
79+
add_custom_target(phy_init_data ALL DEPENDS ${PHY_INIT_DATA_BIN})
80+
add_dependencies(flash phy_init_data)
5181

52-
target_compile_options(${COMPONENT_NAME} PUBLIC -Wno-error=char-subscripts -Wno-error=unknown-pragmas -Wno-error=implicit-function-declaration
53-
-Wno-error=pointer-sign -Wno-error=switch -Wno-error=maybe-uninitialized -Wno-error=format=
54-
-Wno-error=unused-value -Wno-error=address -Wno-error=return-type -Wno-error=format-extra-args
55-
-Wno-error=format-zero-length -Wno-error=unused-label -Wno-error=sizeof-pointer-memaccess)
82+
endif()
5683

57-
target_compile_options(${COMPONENT_NAME} PUBLIC -DICACHE_FLASH)
84+
if(CONFIG_ESP_FILENAME_MACRO_NO_PATH)
85+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D __ESP_FILE__=__FILE__)
86+
endif()
87+
88+
if(CONFIG_ESP_FILENAME_MACRO_RAW)
89+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D __ESP_FILE__=__FILE__)
90+
endif()
91+
92+
if(CONFIG_ESP_FILENAME_MACRO_NULL)
93+
target_compile_definitions(${COMPONENT_NAME} PUBLIC -D __ESP_FILE__="null")
94+
endif()
95+
96+
endif()

0 commit comments

Comments
 (0)