1# SPDX-License-Identifier: Apache-2.0
2
3if(CONFIG_SOC_SERIES_ESP32S3)
4
5  zephyr_compile_options(-Wno-unused-variable -Wno-maybe-uninitialized)
6
7  zephyr_include_directories(
8    include
9    include/bt
10    include/crypto
11    ../esp_shared/include
12    ../esp_shared/include/adc
13    ../esp_shared/include/wifi
14    ../esp_shared/components/include
15    ../../components/hal/esp32s3/include
16    ../../components/hal/include
17    ../../components/hal/platform_port/include
18    ../../components/esp_hw_support/include/soc
19    ../../components/esp_hw_support/port/esp32s3
20    ../../components/esp_hw_support/port/esp32s3/private_include
21    ../../components/esp_hw_support/include
22    ../../components/esp_common/include
23    ../../components/esp_pm/include
24    ../../components/esp_rom/include
25    ../../components/esp_rom/include/esp32s3/rom
26    ../../components/esp_rom/esp32s3/ld
27    ../../components/esp32s3/include
28    ../../components/soc/esp32s3/include
29    ../../components/soc/esp32s3/include/soc
30    ../../components/xtensa/include
31    ../../components/xtensa/esp32s3/include
32    ../../components/soc/include/soc
33    ../../components/soc/include
34    ../../components/soc/src/esp32s3/include
35    ../../components/driver/include
36    ../../components/driver/esp32s3/include
37    ../../components/esp_phy/include
38    ../../components/esp_phy/include
39    ../../components/esp_phy/esp32s3/include
40    ../../components/esp_wifi/include
41    ../../components/efuse/include
42    ../../components/efuse/private_include
43    ../../components/efuse/esp32s3/include
44    ../../components/efuse/esp32s3/private_include
45    ../../components/esp_system/include
46    ../../components/esp_system/port/include
47    ../../components/esp_system/port/public_compat
48    ../../components/esp_wifi/esp32s3/include
49    ../../components/esp_timer/include
50    ../../components/esp_timer/private_include
51    ../../components/esp_netif/include
52    ../../components/esp_event/include
53    ../../components/log/include
54    ../../components/wpa_supplicant/esp_supplicant/src
55    ../../components/wpa_supplicant/esp_supplicant/include
56    ../../components/wpa_supplicant/include
57    ../../components/wpa_supplicant/include/esp_supplicant
58    ../../components/wpa_supplicant/port/include
59    ../../components/wpa_supplicant/src
60    ../../components/wpa_supplicant/src/crypto
61    ../../components/wpa_supplicant/src/utils
62    ../../components/wpa_supplicant/src/eap_peer
63    ../../components/spi_flash/include
64    ../../components/spi_flash/include/spi_flash
65    ../../components/spi_flash/private_include
66    ../../components/bootloader_support/include
67    ../../components/bootloader_support/include_bootloader
68    ../../components/heap/include
69    ../../components/mbedtls/port/include
70    )
71
72  zephyr_link_libraries(
73    gcc
74      -T${CMAKE_CURRENT_SOURCE_DIR}/src/linker/esp32s3.rom.alias.ld
75      -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/esp32s3/ld/esp32s3.rom.ld
76      -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld
77      -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld
78      -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld
79      -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/esp32s3/ld/esp32s3.rom.version.ld
80      -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/soc/esp32s3/ld/esp32s3.peripherals.ld
81    )
82
83  zephyr_compile_definitions(ESP_PLATFORM)
84
85  zephyr_link_libraries_ifdef(
86    CONFIG_HEAP_MEM_POOL_SIZE
87    gcc
88    "-Wl,--wrap=k_calloc"
89    "-Wl,--wrap=k_malloc"
90    )
91
92  zephyr_sources_ifdef(
93    CONFIG_SOC_FLASH_ESP32
94    ../esp_shared/src/host_flash/cache_utils.c
95    ../../components/spi_flash/flash_mmap.c
96    ../../components/spi_flash/esp32s3/spi_flash_rom_patch.c
97    ../../components/spi_flash/flash_ops.c
98    ../../components/spi_flash/esp32s3/flash_ops_esp32s3.c
99    )
100
101  zephyr_compile_definitions(
102    CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
103    CONFIG_SPI_FLASH_USE_LEGACY_IMPL
104    )
105
106  zephyr_sources_ifdef(
107    CONFIG_UART_ESP32
108    ../../components/hal/uart_hal.c
109    ../../components/hal/uart_hal_iram.c
110    )
111
112  zephyr_sources_ifdef(
113    CONFIG_ESP32_SPIM
114    ../../components/hal/spi_hal.c
115    ../../components/hal/spi_hal_iram.c
116    ../../components/soc/lldesc.c
117    ../../components/soc/esp32s3/spi_periph.c
118    ../../components/hal/gdma_hal.c
119    )
120
121  zephyr_library_sources_ifdef(CONFIG_COUNTER_TMR_ESP32 ../../components/hal/timer_hal.c)
122
123  zephyr_sources_ifdef(
124    CONFIG_I2C_ESP32
125    ../../components/hal/i2c_hal_iram.c
126    ../../components/hal/i2c_hal.c
127    )
128
129  zephyr_sources_ifdef(
130    CONFIG_I2S_ESP32
131    ../../components/hal/i2s_hal.c
132    )
133
134  zephyr_library_sources_ifdef(CONFIG_WDT_ESP32 ../../components/hal/wdt_hal_iram.c)
135
136  zephyr_sources_ifdef(
137    CONFIG_PWM_LED_ESP32
138    ../../components/soc/esp32s3/ledc_periph.c
139    ../../components/hal/ledc_hal_iram.c
140    ../../components/hal/ledc_hal.c
141    )
142
143  zephyr_sources_ifdef(
144    CONFIG_MCPWM_ESP32
145    ../../components/hal/mcpwm_hal.c
146    )
147
148  zephyr_sources_ifdef(
149    CONFIG_PCNT_ESP32
150    ../../components/hal/pcnt_hal.c
151    )
152
153  zephyr_sources_ifdef(
154    CONFIG_ADC_ESP32
155    ../../components/hal/adc_hal.c
156    ../esp_shared/components/driver/adc_common.c
157    ../esp_shared/components/driver/rtc_io_hal.c
158    ../esp_shared/components/driver/rtc_io.c
159    ../esp_shared/components/esp_adc_cal/esp_adc_cal_common.c
160    src/esp_adc_cal/esp_adc_cal.c
161    )
162
163  zephyr_sources_ifdef(
164    CONFIG_DMA_ESP32
165    ../../components/soc/lldesc.c
166    ../../components/hal/gdma_hal.c
167    )
168
169  zephyr_sources_ifdef(
170    CONFIG_INPUT_ESP32_TOUCH_SENSOR
171    ../esp_shared/components/driver/rtc_io_hal.c
172    ../esp_shared/components/driver/rtc_io.c
173    ../../components/soc/esp32s3/touch_sensor_periph.c
174    ../../components/hal/esp32s3/touch_sensor_hal.c
175    ../../components/hal/touch_sensor_hal.c
176    )
177
178  zephyr_sources_ifdef(
179    CONFIG_ESP32_TEMP
180    ../../components/driver/esp32s3/rtc_tempsensor.c
181    )
182
183  zephyr_sources_ifdef(
184    CONFIG_ESP_SPIRAM
185    ../esp_shared/src/host_flash/cache_utils.c
186    ../../components/spi_flash/flash_ops.c
187    ../../components/esp_hw_support/port/esp32s3/spiram.c
188    ../../components/esp_hw_support/port/esp32s3/spiram_psram.c
189    ../../components/bootloader_support/src/bootloader_common.c
190    )
191
192  if (CONFIG_MCUBOOT)
193    zephyr_include_directories(
194      ../../components/esp_rom/esp32s3
195      ../esp_shared/include/boot
196      )
197
198    zephyr_sources(
199      ../../components/bootloader_support/src/esp32s3/bootloader_soc.c
200      ../../components/bootloader_support/src/bootloader_efuse_esp32s3.c
201      ../../components/bootloader_support/src/bootloader_flash.c
202      ../../components/bootloader_support/src/bootloader_flash_config_esp32s3.c
203      ../../components/bootloader_support/src/bootloader_mem.c
204      ../../components/bootloader_support/src/bootloader_clock_init.c
205      ../../components/bootloader_support/src/bootloader_console.c
206      ../../components/bootloader_support/src/bootloader_random.c
207      ../../components/bootloader_support/src/bootloader_random_esp32s3.c
208      ../../components/esp_hw_support/cpu_util.c
209      ../../components/esp_rom/patches/esp_rom_uart.c
210      ../../components/esp_rom/patches/esp_rom_sys.c
211      ../../components/hal/mpu_hal.c
212      ../../components/hal/soc_hal.c
213      ../esp_shared/src/boot/esp_loader.c
214      ../esp_shared/src/boot/bootloader_wdt.c
215      ../esp_shared/src/boot/bootloader_init_common.c
216      src/boot/bootloader_init.c
217      )
218  endif()
219
220  zephyr_sources(
221    ../../components/esp_hw_support/regi2c_ctrl.c
222    ../../components/soc/esp32s3/adc_periph.c
223    ../../components/soc/esp32s3/gpio_periph.c
224    ../../components/soc/esp32s3/rtc_io_periph.c
225    ../../components/spi_flash/spi_flash_timing_tuning.c
226    ../../components/spi_flash/esp32s3/spi_timing_config.c
227    ../../components/esp_hw_support/cpu_util.c
228    ../../components/esp_hw_support/port/esp32s3/dport_access.c
229    ../../components/esp_hw_support/esp_clk.c
230    ../../components/esp_hw_support/port/esp32s3/rtc_clk.c
231    ../../components/esp_hw_support/port/esp32s3/rtc_init.c
232    ../../components/esp_hw_support/port/esp32s3/rtc_time.c
233    ../../components/esp_hw_support/port/esp32s3/rtc_clk_init.c
234    ../../components/esp_hw_support/port/esp32s3/rtc_sleep.c
235    ../../components/esp_hw_support/mac_addr.c
236    ../../components/esp_rom/patches/esp_rom_uart.c
237    ../../components/esp_system/port/soc/esp32s3/clk.c
238    ../../components/esp_system/port/soc/esp32s3/reset_reason.c
239    ../../components/driver/periph_ctrl.c
240    ../../components/hal/cpu_hal.c
241    ../../components/hal/interrupt_controller_hal.c
242    ../../components/hal/esp32s3/interrupt_descriptor_table.c
243    ../../components/esp_timer/src/ets_timer_legacy.c
244    ../../components/esp_timer/src/esp_timer.c
245    ../../components/esp_timer/src/esp_timer_impl_systimer.c
246    ../../components/hal/systimer_hal.c
247    ../../components/driver/periph_ctrl.c
248    ../../components/log/log_noos.c
249    ../../components/log/log.c
250    ../../components/efuse/esp32s3/esp_efuse_fields.c
251    ../../components/efuse/esp32s3/esp_efuse_table.c
252    ../../components/efuse/esp32s3/esp_efuse_rtc_calib.c
253    ../../components/efuse/esp32s3/esp_efuse_utility.c
254    ../../components/efuse/esp32s3/esp_efuse_rtc_calib.c
255    ../../components/efuse/src/esp_efuse_api.c
256    ../../components/efuse/src/esp_efuse_api_key_esp32xx.c
257    ../../components/efuse/src/esp_efuse_utility.c
258    ../esp_shared/src/common/esp_system_api.c
259    ../esp_shared/src/common/heap_caps.c
260    src/stubs.c
261    )
262
263  ## shared WIFI/BT resources
264  if (CONFIG_BT OR CONFIG_WIFI_ESP32)
265    zephyr_sources(
266      ../../components/esp_phy/src/phy_init.c
267      ../../components/esp_phy/src/lib_printf.c
268      )
269
270    zephyr_link_libraries(
271      net80211
272      core
273      pp
274      coexist
275      phy
276      ## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
277      gcc
278        -L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32s3
279      )
280
281  endif()
282
283  ## BT definitions
284  if (CONFIG_BT)
285    zephyr_sources(
286      src/bt/esp_bt_adapter.c
287      )
288
289    zephyr_compile_definitions(
290      CONFIG_BT_ENABLED
291      )
292
293    zephyr_link_libraries(
294      ## ble
295      btbb
296      btdm_app
297      coexist
298        -L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32s3
299      )
300
301  endif()
302
303    ## WIFI definitions
304  if (CONFIG_WIFI_ESP32)
305    #TODO: Additional WPA supplicant feature like Enterprise mode etc. are yet to be supported.
306    set(WPA_SUPPLICANT_SRCS "src/wpa_supplicant/port/os_xtensa.c"
307                       "../../components/wpa_supplicant/src/ap/ap_config.c"
308                       "../../components/wpa_supplicant/src/ap/ieee802_1x.c"
309                       "../../components/wpa_supplicant/src/ap/wpa_auth.c"
310                       "../../components/wpa_supplicant/src/ap/wpa_auth_ie.c"
311                       "../../components/wpa_supplicant/src/common/sae.c"
312                       "../../components/wpa_supplicant/src/common/wpa_common.c"
313                       "../../components/wpa_supplicant/src/crypto/aes-ctr.c"
314                       "../../components/wpa_supplicant/src/crypto/aes-siv.c"
315                       "../../components/wpa_supplicant/src/crypto/sha256-kdf.c"
316                       "../../components/wpa_supplicant/src/crypto/sha256-prf.c"
317                       "../../components/wpa_supplicant/src/crypto/aes-cbc.c"
318                       "../../components/wpa_supplicant/src/crypto/aes-ccm.c"
319                       "../../components/wpa_supplicant/src/crypto/aes-internal-dec.c"
320                       "../../components/wpa_supplicant/src/crypto/aes-internal-enc.c"
321                       "../../components/wpa_supplicant/src/crypto/aes-internal.c"
322                       "../../components/wpa_supplicant/src/crypto/aes-omac1.c"
323                       "../../components/wpa_supplicant/src/crypto/aes-unwrap.c"
324                       "../../components/wpa_supplicant/src/crypto/aes-wrap.c"
325                       "../../components/wpa_supplicant/src/crypto/aes-omac1.c"
326                       "../../components/wpa_supplicant/src/crypto/sha256-tlsprf.c"
327                       "../../components/wpa_supplicant/src/tls/bignum.c"
328                       "../../components/wpa_supplicant/src/crypto/ccmp.c"
329                       "../../components/wpa_supplicant/src/crypto/crypto_mbedtls-bignum.c"
330                       "../../components/wpa_supplicant/src/crypto/crypto_mbedtls-ec.c"
331                       "../../components/wpa_supplicant/src/crypto/crypto_ops.c"
332                       "../../components/wpa_supplicant/src/crypto/crypto_internal-cipher.c"
333                       "../../components/wpa_supplicant/src/crypto/crypto_internal-modexp.c"
334                       "../../components/wpa_supplicant/src/crypto/crypto_internal-rsa.c"
335                       "../../components/wpa_supplicant/src/crypto/crypto_internal.c"
336                       "../../components/wpa_supplicant/src/crypto/des-internal.c"
337                       "../../components/wpa_supplicant/src/crypto/dh_group5.c"
338                       "../../components/wpa_supplicant/src/crypto/dh_groups.c"
339                       "../../components/wpa_supplicant/src/crypto/md4-internal.c"
340                       "../../components/wpa_supplicant/src/crypto/md5-internal.c"
341                       "../../components/wpa_supplicant/src/crypto/md5.c"
342                       "../../components/wpa_supplicant/src/crypto/ms_funcs.c"
343                       "../../components/wpa_supplicant/src/crypto/rc4.c"
344                       "../../components/wpa_supplicant/src/crypto/sha1-internal.c"
345                       "../../components/wpa_supplicant/src/crypto/sha1-pbkdf2.c"
346                       "../../components/wpa_supplicant/src/crypto/sha1-prf.c"
347                       "../../components/wpa_supplicant/src/crypto/sha1.c"
348                       "../../components/wpa_supplicant/src/crypto/sha256-internal.c"
349                       "../../components/wpa_supplicant/src/crypto/sha256.c"
350                       "../../components/wpa_supplicant/src/eap_peer/eap.c"
351                       "../../components/wpa_supplicant/src/eap_peer/eap_common.c"
352                       "../../components/wpa_supplicant/esp_supplicant/src/esp_hostap.c"
353                       "../../components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c"
354                       "../../components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c"
355                       "../../components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c"
356                       "../../components/wpa_supplicant/src/rsn_supp/pmksa_cache.c"
357                       "../../components/wpa_supplicant/src/rsn_supp/wpa.c"
358                       "../../components/wpa_supplicant/src/rsn_supp/wpa_ie.c"
359                       "../../components/wpa_supplicant/src/utils/common.c"
360                       "../../components/wpa_supplicant/src/utils/ext_password.c"
361                       "../../components/wpa_supplicant/src/utils/uuid.c"
362                       "../../components/wpa_supplicant/src/utils/wpabuf.c"
363                       "../../components/wpa_supplicant/src/utils/wpa_debug.c"
364                       "../../components/wpa_supplicant/src/utils/json.c"
365                       )
366
367    zephyr_sources(
368      src/wifi/esp_wifi_adapter.c
369      ${WPA_SUPPLICANT_SRCS}
370      )
371
372    zephyr_compile_definitions(
373      __ets__
374      ESP_SUPPLICANT
375      IEEE8021X_EAPOL
376      EAP_PEER_METHOD
377      EAP_MSCHAPv2
378      EAP_TTLS
379      EAP_TLS
380      EAP_PEAP
381      EAP_FAST
382      USE_WPA2_TASK
383      ESPRESSIF_USE
384      ESP32_WORKAROUND
385      CONFIG_ECC
386      CONFIG_IEEE80211W
387      CONFIG_SHA256
388      CONFIG_DPP
389      CONFIG_WNM
390      )
391
392    zephyr_link_libraries(
393      mbedTLS
394      )
395
396  endif()
397
398  zephyr_link_libraries_ifdef(CONFIG_NEWLIB_LIBC c)
399
400endif()
401