CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. idf_build_get_property(target IDF_TARGET)
  2. if(${target} STREQUAL "linux")
  3. idf_component_register(SRCS "linux/spi_flash_linux.c"
  4. INCLUDE_DIRS include
  5. PRIV_INCLUDE_DIRS include/spi_flash)
  6. return()
  7. endif()
  8. if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  9. set(srcs "spi_flash_wrap.c")
  10. set(priv_requires bootloader_support soc)
  11. else()
  12. set(srcs "flash_brownout_hook.c")
  13. if(CONFIG_SOC_SPI_MEM_SUPPORT_OPI_MODE)
  14. list(APPEND srcs "${target}/spi_flash_oct_flash_init.c")
  15. endif()
  16. if(CONFIG_SPI_FLASH_HPM_ON)
  17. list(APPEND srcs
  18. "spi_flash_hpm_enable.c")
  19. endif()
  20. # New implementation after IDF v4.0
  21. list(APPEND srcs
  22. "spi_flash_chip_drivers.c"
  23. "spi_flash_chip_generic.c"
  24. "spi_flash_chip_issi.c"
  25. "spi_flash_chip_mxic.c"
  26. "spi_flash_chip_gd.c"
  27. "spi_flash_chip_winbond.c"
  28. "spi_flash_chip_boya.c"
  29. "spi_flash_chip_mxic_opi.c"
  30. "spi_flash_chip_th.c"
  31. "memspi_host_driver.c")
  32. set(cache_srcs
  33. "cache_utils.c"
  34. "flash_mmap.c"
  35. "flash_ops.c"
  36. "spi_flash_wrap.c"
  37. )
  38. list(APPEND cache_srcs
  39. "esp_flash_api.c"
  40. "esp_flash_spi_init.c"
  41. "spi_flash_os_func_app.c"
  42. "spi_flash_os_func_noos.c")
  43. list(APPEND srcs ${cache_srcs})
  44. set(priv_requires bootloader_support app_update soc esp_mm
  45. esp_driver_gpio esp_driver_spi # TODO: IDF-8503 move spi_bus_lock to esp_hw_support component
  46. )
  47. endif()
  48. idf_component_register(SRCS "${srcs}"
  49. REQUIRES hal
  50. PRIV_REQUIRES "${priv_requires}"
  51. INCLUDE_DIRS include
  52. PRIV_INCLUDE_DIRS include/spi_flash
  53. LDFRAGMENTS linker.lf)
  54. # Avoid cache miss by unexpected inlineing when built by -Os
  55. set_source_files_properties(${cache_srcs} PROPERTIES COMPILE_FLAGS "-fno-inline-functions")
  56. if(CMAKE_C_COMPILER_ID MATCHES "GNU")
  57. # These flags are GCC specific
  58. set_property(SOURCE ${cache_srcs} APPEND_STRING PROPERTY COMPILE_FLAGS
  59. " -fno-inline-small-functions -fno-inline-functions-called-once")
  60. endif()
  61. if(NOT BOOTLOADER_BUILD AND NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  62. if(CONFIG_SPIRAM)
  63. # [refactor-todo]: requires "esp_psram" for few MMU usages in `flash_mmap.c`
  64. # will be replaced with MMU requirements
  65. idf_component_optional_requires(PRIVATE esp_psram)
  66. endif()
  67. endif()