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