1# SPDX-License-Identifier: Apache-2.0
2
3if(CONFIG_SOC_SERIES_ESP32C2)
4
5  zephyr_compile_options(-fstrict-volatile-bitfields)
6  zephyr_compile_definitions_ifndef(CONFIG_MCUBOOT CONFIG_APP_BUILD_USE_FLASH_SECTIONS)
7
8  zephyr_compile_definitions_ifndef(asm asm=__asm__)
9
10  zephyr_compile_definitions(CONFIG_IDF_TARGET_ARCH_RISCV)
11
12  if(CONFIG_MCUBOOT)
13    zephyr_compile_options(-fdump-rtl-expand)
14  endif()
15
16  zephyr_include_directories(
17    include
18    ../esp_shared/include
19    ../esp_shared/components/include
20    ../port/include
21    ../common/include
22
23    ../../components/efuse/include
24    ../../components/efuse/private_include
25    ../../components/efuse/${CONFIG_SOC_SERIES}/include
26    ../../components/efuse/${CONFIG_SOC_SERIES}/private_include
27
28    ../../components/esp_common/include
29
30    ../../components/esp_hw_support/dma
31    ../../components/esp_hw_support/include
32    ../../components/esp_hw_support/include/esp_private
33    ../../components/esp_hw_support/include/hal
34    ../../components/esp_hw_support/include/soc
35    ../../components/esp_hw_support/include/soc/${CONFIG_SOC_SERIES}
36    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}
37    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/private_include
38    ../../components/esp_hw_support/port/include
39    ../../components/esp_rom/${CONFIG_SOC_SERIES}
40    ../../components/esp_rom/${CONFIG_SOC_SERIES}/ld
41    ../../components/esp_rom/include/
42    ../../components/esp_rom/include/${CONFIG_SOC_SERIES}
43
44    ../../components/esp_system/include
45    ../../components/esp_system/include/esp_private
46    ../../components/esp_system/port/include
47    ../../components/esp_system/port/include/private/esp_private
48    ../../components/esp_system/port/include/private
49
50    ../../components/hal/${CONFIG_SOC_SERIES}/include
51    ../../components/hal/include
52    ../../components/hal/platform_port/include
53
54    ../../components/log/include
55
56    ../../components/soc/${CONFIG_SOC_SERIES}/include
57    ../../components/soc/${CONFIG_SOC_SERIES}/ld
58    ../../components/soc/include
59
60    ../../components/riscv/include
61    ../../components/riscv/include/esp_private
62
63    ../../components/esp_timer/include
64    ../../components/esp_timer/private_include
65
66    ../../components/driver/include
67    ../../components/driver/deprecated
68    ../../components/driver/gpio/include
69    ../../components/driver/uart/include
70    ../../components/driver/touch_sensor/include
71    ../../components/driver/spi/include
72
73    ../../components/spi_flash/include
74    ../../components/spi_flash/include/spi_flash
75
76    ../../components/esp_pm/include
77
78    ../../components/bootloader_support/include
79    ../../components/bootloader_support/private_include
80    ../../components/bootloader_support/bootloader_flash/include
81
82    ../../components/heap/include
83
84    ../../components/esp_mm/include
85
86    ../../components/esp_netif/include
87
88    ../../components/esp_coex/include
89    ../../components/esp_phy/include
90    ../../components/esp_phy/include/esp_private
91    ../../components/esp_phy/${CONFIG_SOC_SERIES}/include
92    ../../components/esp_wifi/include
93    ../../components/esp_event/include
94    ../../components/wpa_supplicant/esp_supplicant/src
95    ../../components/wpa_supplicant/esp_supplicant/include
96    ../../components/wpa_supplicant/include
97    ../../components/wpa_supplicant/include/esp_supplicant
98    ../../components/wpa_supplicant/port/include
99    ../../components/wpa_supplicant/src
100    ../../components/wpa_supplicant/src/crypto
101    ../../components/wpa_supplicant/src/utils
102    ../../components/wpa_supplicant/src/eap_peer
103    ../../components/mbedtls/port/include
104
105    ../port/include/boot
106  )
107
108  zephyr_link_libraries_ifdef(
109    CONFIG_SOC_ESP32C2_REV_2_0
110    gcc
111    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.eco4.ld
112  )
113
114  zephyr_link_libraries(
115    gcc
116    -T${CMAKE_CURRENT_SOURCE_DIR}/src/linker/${CONFIG_SOC_SERIES}.rom.alias.ld
117    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.ld
118    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.api.ld
119    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.libgcc.ld
120    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.newlib.ld
121    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.version.ld
122    -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/soc/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.peripherals.ld
123  )
124
125  zephyr_sources_ifdef(
126    CONFIG_COUNTER_TMR_ESP32
127    ../../components/hal/timer_hal.c
128  )
129
130  zephyr_sources_ifdef(
131    CONFIG_ESP32_SPIM
132    ../../components/hal/spi_hal.c
133    ../../components/hal/spi_hal_iram.c
134    ../../components/soc/lldesc.c
135    ../../components/hal/gdma_hal.c
136    )
137
138  if(CONFIG_SOC_FLASH_ESP32 OR NOT CONFIG_BOOTLOADER_MCUBOOT)
139    zephyr_sources(
140    ../../components/bootloader_support/src/flash_encrypt.c
141    ../../components/esp_hw_support/esp_gpio_reserve.c
142    ../../components/hal/cache_hal.c
143    ../../components/hal/mmu_hal.c
144    ../../components/hal/spi_flash_encrypt_hal_iram.c
145    ../../components/hal/spi_flash_hal.c
146    ../../components/hal/spi_flash_hal_iram.c
147    ../../components/hal/spi_flash_hal_gpspi.c
148    ../../components/spi_flash/esp_flash_api.c
149    ../../components/spi_flash/esp_flash_spi_init.c
150    ../../components/spi_flash/flash_mmap.c
151    ../../components/spi_flash/flash_ops.c
152    ../../components/spi_flash/memspi_host_driver.c
153    ../../components/spi_flash/spi_flash_chip_boya.c
154    ../../components/spi_flash/spi_flash_chip_drivers.c
155    ../../components/spi_flash/spi_flash_chip_gd.c
156    ../../components/spi_flash/spi_flash_chip_generic.c
157    ../../components/spi_flash/spi_flash_chip_issi.c
158    ../../components/spi_flash/spi_flash_chip_mxic.c
159    ../../components/spi_flash/spi_flash_chip_mxic_opi.c
160    ../../components/spi_flash/spi_flash_chip_th.c
161    ../../components/spi_flash/spi_flash_chip_winbond.c
162    ../../components/spi_flash/spi_flash_os_func_noos.c
163    ../../components/spi_flash/spi_flash_os_func_app.c
164    )
165  endif()
166
167  if(CONFIG_PM OR CONFIG_POWEROFF)
168  zephyr_sources(
169  ../../components/esp_hw_support/sleep_gpio.c
170  ../../components/esp_hw_support/sleep_event.c
171	../../components/driver/gpio/rtc_io.c
172	../../components/esp_hw_support/sleep_modem.c
173	../../components/hal/rtc_io_hal.c
174	../../components/driver/gpio/gpio.c
175	../../components/esp_hw_support/sleep_cpu.c
176	)
177  endif()
178
179  zephyr_sources_ifdef(
180    CONFIG_DMA_ESP32
181    ../../components/soc/lldesc.c
182    ../../components/hal/gdma_hal.c
183    )
184
185  if (CONFIG_MCUBOOT)
186    zephyr_sources(
187        ../port/boot/esp_image_loader.c
188        )
189  endif()
190
191  if (CONFIG_MCUBOOT OR NOT CONFIG_BOOTLOADER_MCUBOOT)
192    zephyr_include_directories(
193      ../../components/esp_rom/${CONFIG_SOC_SERIES}
194      )
195
196    zephyr_sources(
197      ../../components/bootloader_support/src/bootloader_clock_init.c
198      ../../components/hal/mpu_hal.c
199      ../../components/bootloader_support/bootloader_flash/src/flash_qio_mode.c
200      ../common/console_init.c
201      ../common/soc_init.c
202      )
203  endif()
204
205  zephyr_sources(
206
207    ../../components/soc/${CONFIG_SOC_SERIES}/gpio_periph.c
208
209    ../../components/esp_hw_support/cpu.c
210    ../../components/esp_hw_support/clk_ctrl_os.c
211    ../../components/esp_hw_support/esp_clk.c
212    ../../components/esp_hw_support/hw_random.c
213    ../../components/esp_hw_support/mac_addr.c
214    ../../components/esp_hw_support/periph_ctrl.c
215    ../../components/esp_hw_support/regi2c_ctrl.c
216    ../../components/esp_hw_support/sar_periph_ctrl_common.c
217    ../../components/esp_hw_support/port/esp_clk_tree_common.c
218    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/cpu_region_protect.c
219    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/esp_clk_tree.c
220    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/esp_cpu_intr.c
221    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/rtc_init.c
222    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/rtc_clk.c
223    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/rtc_clk_init.c
224    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/rtc_time.c
225    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/rtc_sleep.c
226    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/sar_periph_ctrl.c
227    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/systimer.c
228    ../../components/esp_hw_support/port/${CONFIG_SOC_SERIES}/cpu_region_protect.c
229
230    ../../components/esp_mm/esp_mmu_map.c
231    ../../components/esp_mm/port/${CONFIG_SOC_SERIES}/ext_mem_layout.c
232
233    ../../components/esp_rom/patches/esp_rom_crc.c
234    ../../components/esp_rom/patches/esp_rom_sys.c
235    ../../components/esp_rom/patches/esp_rom_uart.c
236    ../../components/esp_rom/patches/esp_rom_spiflash.c
237    ../../components/esp_rom/patches/esp_rom_efuse.c
238    ../../components/esp_rom/patches/esp_rom_gpio.c
239    ../../components/esp_rom/patches/esp_rom_systimer.c
240
241    ../../components/esp_system/port/soc/${CONFIG_SOC_SERIES}/clk.c
242    ../../components/esp_system/port/soc/${CONFIG_SOC_SERIES}/system_internal.c
243    ../../components/esp_system/port/soc/${CONFIG_SOC_SERIES}/reset_reason.c
244    ../../components/esp_system/esp_err.c
245
246    ../../components/esp_timer/src/ets_timer_legacy.c
247    ../../components/esp_timer/src/esp_timer.c
248    ../../components/esp_timer/src/esp_timer_impl_common.c
249    ../../components/esp_timer/src/esp_timer_impl_systimer.c
250
251    ../../components/hal/efuse_hal.c
252    ../../components/hal/cache_hal.c
253    ../../components/hal/mmu_hal.c
254    ../../components/hal/systimer_hal.c
255    ../../components/hal/wdt_hal_iram.c
256
257    ../../components/hal/${CONFIG_SOC_SERIES}/clk_tree_hal.c
258    ../../components/hal/${CONFIG_SOC_SERIES}/efuse_hal.c
259
260    ../../components/log/log_noos.c
261    ../../components/log/log.c
262
263
264    ../port/heap/heap_caps_zephyr.c
265    ../port/host_flash/cache_utils.c
266    ../../components/riscv/interrupt.c
267    ../port/bootloader/bootloader_flash.c
268
269    ../common/flash_init.c
270
271    src/stubs.c
272    src/soc_random.c
273    src/soc_init.c
274    src/soc_flash_init.c
275  )
276
277  zephyr_link_libraries_ifdef(CONFIG_NEWLIB_LIBC c)
278
279  zephyr_compile_definitions(ESP_PLATFORM)
280
281  zephyr_sources_ifdef(
282    CONFIG_UART_ESP32
283    ../../components/hal/uart_hal.c
284    ../../components/hal/uart_hal_iram.c
285    )
286
287  zephyr_sources_ifdef(
288    CONFIG_PWM_LED_ESP32
289    ../../components/hal/ledc_hal_iram.c
290    ../../components/hal/ledc_hal.c
291    )
292
293  zephyr_sources_ifdef(
294    CONFIG_ESP32_TEMP
295    ../../components/driver/deprecated/rtc_temperature_legacy.c
296    ../../components/soc//${CONFIG_SOC_SERIES}/temperature_sensor_periph.c
297    ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_rtc_calib.c
298    ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_table.c
299    ../../components/efuse/src/esp_efuse_api.c
300    ../../components/efuse/src/esp_efuse_utility.c
301    ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_utility.c
302    )
303
304  if (CONFIG_ADC_ESP32)
305    zephyr_include_directories(
306    ../../components/esp_adc/${CONFIG_SOC_SERIES}/include
307    ../../components/esp_adc/include
308    ../../components/esp_adc/interface
309    )
310
311    zephyr_sources(
312    ../../components/hal/adc_hal_common.c
313    ../../components/hal/adc_oneshot_hal.c
314    ../../components/esp_hw_support/adc_share_hw_ctrl.c
315    ../../components/hal/rtc_io_hal.c
316    ../../components/driver/gpio/rtc_io.c
317    ../../components/esp_adc/adc_cali.c
318    ../../components/esp_adc/${CONFIG_SOC_SERIES}/adc_cali_line_fitting.c
319    ../../components/soc/${CONFIG_SOC_SERIES}/adc_periph.c
320    ../../components/efuse/src/esp_efuse_api.c
321    ../../components/efuse/src/esp_efuse_utility.c
322    ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_rtc_calib.c
323    ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_table.c
324    ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_utility.c
325    )
326  endif()
327
328  ## shared WIFI/BT resources
329  if (CONFIG_BT OR CONFIG_WIFI_ESP32)
330    zephyr_sources(
331      ../../components/esp_phy/src/phy_init.c
332      ../../components/esp_phy/src/lib_printf.c
333      ../../components/esp_phy/src/phy_common.c
334      )
335
336    zephyr_sources(
337      ../../components/esp_hw_support/sleep_modes.c
338      ../../components/efuse/src/esp_efuse_utility.c
339      ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_table.c
340      ../../components/efuse/src/esp_efuse_api.c
341      ../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_utility.c
342      ../../components/efuse/src/efuse_controller/keys/without_key_purposes/one_key_block/esp_efuse_api_key.c
343      )
344
345    if (CONFIG_ESP32_SW_COEXIST_ENABLE)
346      if (CONFIG_BUILD_ONLY_NO_BLOBS)
347        zephyr_sources(
348          ../port/coex/coex_stubs.c
349          )
350      endif()
351
352      zephyr_link_libraries(
353        coexist
354          -L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/${CONFIG_SOC_SERIES}
355        )
356    endif()
357
358    zephyr_sources_ifdef(
359      CONFIG_BUILD_ONLY_NO_BLOBS
360      ../port/wifi/wifi_stubs.c
361      ../port/phy/phy_stubs.c
362      )
363
364    zephyr_link_libraries_ifndef(
365      CONFIG_BUILD_ONLY_NO_BLOBS
366      net80211
367      core
368      pp
369      phy
370      ## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
371      gcc
372        -L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/${CONFIG_SOC_SERIES}
373      )
374  endif()
375
376  ## BT definitions
377  if (CONFIG_BT)
378    zephyr_sources(src/bt/esp_bt_adapter.c)
379    zephyr_compile_definitions(CONFIG_BT_ENABLED)
380
381    zephyr_link_libraries(
382      ## ble
383      btbb
384      btdm_app
385        -L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/${CONFIG_SOC_SERIES}
386      )
387  endif()
388
389  ## WIFI definitions
390  if (CONFIG_WIFI_ESP32)
391
392    set(WPA_SUPPLICANT_COMPONENT_DIR "../../components/wpa_supplicant")
393    #TODO: Additional WPA supplicant feature like Enterprise mode etc. are yet to be supported.
394    set(WPA_SUPPLICANT_SRCS "../port/wifi/wpa_supplicant/os_xtensa.c"
395      "${WPA_SUPPLICANT_COMPONENT_DIR}/port/eloop.c"
396      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/ap_config.c"
397      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/ieee802_1x.c"
398      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/wpa_auth.c"
399      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/wpa_auth_ie.c"
400      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/pmksa_cache_auth.c"
401      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/sta_info.c"
402      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/ieee802_11.c"
403      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/ap/comeback_token.c"
404      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/sae.c"
405      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/dragonfly.c"
406      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/wpa_common.c"
407      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/bitfield.c"
408      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-siv.c"
409      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha256-kdf.c"
410      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/ccmp.c"
411      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-gcm.c"
412      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/crypto_ops.c"
413      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/dh_group5.c"
414      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/dh_groups.c"
415      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/ms_funcs.c"
416      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha1-tlsprf.c"
417      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha256-tlsprf.c"
418      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha384-tlsprf.c"
419      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha256-prf.c"
420      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha1-prf.c"
421      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha384-prf.c"
422      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/md4-internal.c"
423      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha1-tprf.c"
424      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/eap_common/eap_wsc_common.c"
425      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/ieee802_11_common.c"
426      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/eap_peer/chap.c"
427      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/eap_peer/eap.c"
428      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/eap_peer/eap_common.c"
429      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/eap_peer/mschapv2.c"
430      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/rsn_supp/pmksa_cache.c"
431      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/rsn_supp/wpa.c"
432      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/rsn_supp/wpa_ie.c"
433      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/common.c"
434      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/ext_password.c"
435      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/uuid.c"
436      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/wpabuf.c"
437      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/wpa_debug.c"
438      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/utils/json.c"
439      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps.c"
440      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps_attr_build.c"
441      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps_attr_parse.c"
442      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps_attr_process.c"
443      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps_common.c"
444      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps_dev_attr.c"
445      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/wps/wps_enrollee.c"
446      )
447
448    if(CONFIG_ESP32_WIFI_ENABLE_SAE_PK)
449      set(WPA_SUPPLICANT_SRCS ${WPA_SUPPLICANT_SRCS}
450        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/sae_pk.c"
451        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/bss.c"
452        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/common/scan.c"
453        "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_scan.c"
454        )
455    endif()
456
457    set(ESP_SUPPLICANT_SRCS "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_eap_client.c"
458      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_wpa2_api_port.c"
459      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_wpa_main.c"
460      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_wpas_glue.c"
461      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_common.c"
462      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_wps.c"
463      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_wpa3.c"
464      "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_owe.c"
465      )
466    if(CONFIG_ESP32_WIFI_SOFTAP_SUPPORT)
467        set(ESP_SUPPLICANT_SRCS ${ESP_SUPPLICANT_SRCS} "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/esp_hostap.c")
468    endif()
469
470    set(TLS_SRCS
471      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/asn1.c"
472      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/bignum.c"
473      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/pkcs1.c"
474      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/pkcs5.c"
475      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/pkcs8.c"
476      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/rsa.c"
477      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/tls_internal.c"
478      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_client.c"
479      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_client_read.c"
480      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_client_write.c"
481      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_common.c"
482      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_cred.c"
483      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_record.c"
484      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/tlsv1_client_ocsp.c"
485      "${WPA_SUPPLICANT_COMPONENT_DIR}/src/tls/x509v3.c"
486      )
487
488    if(CONFIG_ESP32_WIFI_MBEDTLS_CRYPTO)
489      set(CRYPTO_SRCS
490        "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/crypto/fastpbkdf2.c"
491        "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/crypto/crypto_mbedtls.c"
492        "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/crypto/crypto_mbedtls-bignum.c"
493        "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/crypto/crypto_mbedtls-rsa.c"
494        "${WPA_SUPPLICANT_COMPONENT_DIR}/esp_supplicant/src/crypto/crypto_mbedtls-ec.c"
495         # Add internal RC4 as RC4 has been removed from mbedtls
496         "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/rc4.c"
497        )
498        if(NOT CONFIG_MBEDTLS_CIPHER_DES_ENABLED)
499          set(CRYPTO_SRCS ${CRYPTO_SRCS} "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/des-internal.c")
500        endif()
501        # Enabling this only for WiFi is probably not a good idea since MbedTLS
502        # uses generic crypto init/update functions for this. That causes
503        # binary size increment since all the other enabled module
504        # functions will also linked in. Even after not using direct MbedTLS APIs
505        # for these, these API are still faster since these all will be using
506        # AES APIs which is using hardware AES blocks.
507        if(NOT CONFIG_MBEDTLS_MAC_CMAC_ENABLED)
508            set(CRYPTO_SRCS ${CRYPTO_SRCS} "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-omac1.c")
509        endif()
510        if(NOT CONFIG_MBEDTLS_NIST_KW_C)
511            set(CRYPTO_SRCS ${CRYPTO_SRCS}
512            "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-wrap.c"
513            "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-unwrap.c")
514        endif()
515        if(NOT CONFIG_MBEDTLS_NIST_KW_C OR NOT CONFIG_MBEDTLS_CMAC_C OR NOT CONFIG_MBEDTLS_CCM_C)
516            set(CRYPTO_SRCS ${CRYPTO_SRCS} "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-ccm.c")
517        endif()
518    else()
519      set(CRYPTO_SRCS
520        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/rc4.c"
521        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-ctr.c"
522        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-cbc.c"
523        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-ccm.c"
524        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-internal-dec.c"
525        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-internal-enc.c"
526        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-internal.c"
527        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-omac1.c"
528        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-unwrap.c"
529        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/aes-wrap.c"
530        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/crypto_internal-cipher.c"
531        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/crypto_internal-modexp.c"
532        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/crypto_internal-rsa.c"
533        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/crypto_internal.c"
534        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/des-internal.c"
535        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/md4-internal.c"
536        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/md5-internal.c"
537        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/md5.c"
538        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha1-internal.c"
539        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha1-pbkdf2.c"
540        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha1.c"
541        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha256-internal.c"
542        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha256.c"
543        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha384-internal.c"
544        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha512-internal.c"
545        "${WPA_SUPPLICANT_COMPONENT_DIR}/src/crypto/sha256.c"
546        )
547    endif()
548
549    zephyr_sources(
550      src/wifi/esp_wifi_adapter.c
551      src/coex/esp_coex_adapter.c
552      ../port/wifi/wifi_init.c
553      ${WPA_SUPPLICANT_SRCS}
554      ${ESP_SUPPLICANT_SRCS}
555      ${TLS_SRCS}
556      ${CRYPTO_SRCS}
557      )
558
559    zephyr_compile_definitions(
560      __ets__
561      ESP_SUPPLICANT
562      IEEE8021X_EAPOL
563      EAP_PEER_METHOD
564      EAP_MSCHAPv2
565      EAP_TTLS
566      EAP_TLS
567      EAP_PEAP
568      USE_WPA2_TASK
569      CONFIG_WPS
570      USE_WPS_TASK
571      CONFIG_ECC
572      CONFIG_IEEE80211W
573      CONFIG_SHA256
574      CONFIG_NO_RADIUS
575      CONFIG_CRYPTO_INTERNAL
576      )
577
578    zephyr_compile_definitions(CONFIG_ESP_WIFI_ENABLED)
579    zephyr_compile_definitions(CONFIG_SOC_WIFI_SUPPORTED)
580    zephyr_compile_definitions_ifdef(CONFIG_ESP32_WIFI_MBEDTLS_CRYPTO CONFIG_CRYPTO_MBEDTLS)
581    zephyr_compile_definitions_ifdef(CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE CONFIG_WPA3_SAE)
582    zephyr_compile_definitions_ifdef(CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA CONFIG_OWE_STA)
583    zephyr_compile_definitions_ifdef(CONFIG_ESP32_WIFI_ENABLE_SAE_PK CONFIG_SAE_PK)
584    zephyr_compile_definitions_ifdef(CONFIG_ESP32_WIFI_SOFTAP_SAE_SUPPORT CONFIG_SAE)
585
586    zephyr_link_libraries(mbedTLS)
587
588  endif()
589
590endif()
591