|
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) |
2 | 7 |
|
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 | + ) |
4 | 14 |
|
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 | + ) |
6 | 20 |
|
7 | | -set(COMPONENT_REQUIRES lwip) |
8 | | -set(COMPONENT_PRIV_REQUIRES freertos) |
| 21 | +else() |
| 22 | + # Regular app build |
9 | 23 |
|
10 | | -register_component() |
| 24 | + set(COMPONENT_SRCDIRS "driver source") |
| 25 | + set(COMPONENT_ADD_INCLUDEDIRS "include") |
| 26 | + set(COMPONENT_PRIV_INCLUDEDIRS "include/driver") |
11 | 27 |
|
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") |
17 | 32 |
|
18 | | -target_link_libraries(${COMPONENT_NAME} "-u call_user_start") |
| 33 | + register_component() |
19 | 34 |
|
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") |
21 | 40 |
|
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) |
46 | 67 |
|
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) |
51 | 81 |
|
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() |
56 | 83 |
|
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