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