1menu "ESP32S2-specific"
2    # TODO: this component simply shouldn't be included
3    # in the build at the CMake level, but this is currently
4    # not working so we just hide all items here
5    visible if IDF_TARGET_ESP32S2
6
7    choice ESP32S2_DEFAULT_CPU_FREQ_MHZ
8        prompt "CPU frequency"
9        default ESP32S2_DEFAULT_CPU_FREQ_160 if !IDF_ENV_FPGA
10        default ESP32S2_DEFAULT_CPU_FREQ_FPGA if IDF_ENV_FPGA
11        help
12            CPU frequency to be set on application startup.
13
14        config ESP32S2_DEFAULT_CPU_FREQ_FPGA
15            depends on IDF_ENV_FPGA
16            bool "FPGA"
17        config ESP32S2_DEFAULT_CPU_FREQ_80
18            bool "80 MHz"
19        config ESP32S2_DEFAULT_CPU_FREQ_160
20            bool "160 MHz"
21        config ESP32S2_DEFAULT_CPU_FREQ_240
22            bool "240 MHz"
23    endchoice
24
25    config ESP32S2_DEFAULT_CPU_FREQ_MHZ
26        int
27        default 40 if IDF_ENV_FPGA
28        default 80 if ESP32S2_DEFAULT_CPU_FREQ_80
29        default 160 if ESP32S2_DEFAULT_CPU_FREQ_160
30        default 240 if ESP32S2_DEFAULT_CPU_FREQ_240
31
32    menu "Cache config"
33
34        choice ESP32S2_INSTRUCTION_CACHE_SIZE
35            prompt "Instruction cache size"
36            default ESP32S2_INSTRUCTION_CACHE_8KB
37            help
38                Instruction cache size to be set on application startup.
39                If you use 8KB instruction cache rather than 16KB instruction cache,
40                then the other 8KB will be added to the heap.
41
42            config ESP32S2_INSTRUCTION_CACHE_8KB
43                bool "8KB"
44            config ESP32S2_INSTRUCTION_CACHE_16KB
45                bool "16KB"
46        endchoice
47
48        choice ESP32S2_INSTRUCTION_CACHE_LINE_SIZE
49            prompt "Instruction cache line size"
50            default ESP32S2_INSTRUCTION_CACHE_LINE_32B
51            help
52                Instruction cache line size to be set on application startup.
53
54            config ESP32S2_INSTRUCTION_CACHE_LINE_16B
55                bool "16 Bytes"
56            config ESP32S2_INSTRUCTION_CACHE_LINE_32B
57                bool "32 Bytes"
58        endchoice
59
60        choice ESP32S2_DATA_CACHE_SIZE
61            prompt "Data cache size"
62            default ESP32S2_DATA_CACHE_0KB if !ESP32S2_SPIRAM_SUPPORT
63            default ESP32S2_DATA_CACHE_8KB if ESP32S2_SPIRAM_SUPPORT
64            help
65                Data cache size to be set on application startup.
66                If you use 0KB data cache, the other 16KB will be added to the heap
67                If you use 8KB data cache rather than 16KB data cache, the other 8KB will be added to the heap
68
69            config ESP32S2_DATA_CACHE_0KB
70                depends on !ESP32S2_SPIRAM_SUPPORT
71                bool "0KB"
72            config ESP32S2_DATA_CACHE_8KB
73                bool "8KB"
74            config ESP32S2_DATA_CACHE_16KB
75                bool "16KB"
76        endchoice
77
78        choice ESP32S2_DATA_CACHE_LINE_SIZE
79            prompt "Data cache line size"
80            default ESP32S2_DATA_CACHE_LINE_32B
81            help
82                Data cache line size to be set on application startup.
83
84            config ESP32S2_DATA_CACHE_LINE_16B
85                bool "16 Bytes"
86            config ESP32S2_DATA_CACHE_LINE_32B
87                bool "32 Bytes"
88        endchoice
89
90        config ESP32S2_INSTRUCTION_CACHE_WRAP
91            bool "Enable instruction cache wrap"
92            default "n"
93            help
94                If enabled, instruction cache will use wrap mode to read spi flash (maybe spiram).
95                The wrap length equals to INSTRUCTION_CACHE_LINE_SIZE.
96                However, it depends on complex conditions.
97
98        config ESP32S2_DATA_CACHE_WRAP
99            bool "Enable data cache wrap"
100            default "n"
101            help
102                If enabled, data cache will use wrap mode to read spiram (maybe spi flash).
103                The wrap length equals to DATA_CACHE_LINE_SIZE.
104                However, it depends on complex conditions.
105
106    endmenu  # Cache config
107
108    # Note: to support SPIRAM across multiple chips, check CONFIG_SPIRAM
109    # instead
110    config ESP32S2_SPIRAM_SUPPORT
111        bool "Support for external, SPI-connected RAM"
112        default "n"
113        select SPIRAM
114        help
115            This enables support for an external SPI RAM chip, connected in parallel with the
116            main SPI flash chip.
117
118    menu "SPI RAM config"
119        depends on ESP32S2_SPIRAM_SUPPORT
120
121        choice SPIRAM_TYPE
122            prompt "Type of SPI RAM chip in use"
123            default SPIRAM_TYPE_AUTO
124
125            config SPIRAM_TYPE_AUTO
126                bool "Auto-detect"
127
128            config SPIRAM_TYPE_ESPPSRAM16
129                bool "ESP-PSRAM16 or APS1604"
130
131            config SPIRAM_TYPE_ESPPSRAM32
132                bool "ESP-PSRAM32 or IS25WP032"
133
134            config SPIRAM_TYPE_ESPPSRAM64
135                bool "ESP-PSRAM64 or LY68L6400"
136        endchoice
137
138        config SPIRAM_SIZE
139            int
140            default -1 if SPIRAM_TYPE_AUTO
141            default 2097152 if SPIRAM_TYPE_ESPPSRAM16
142            default 4194304 if SPIRAM_TYPE_ESPPSRAM32
143            default 8388608 if SPIRAM_TYPE_ESPPSRAM64
144            default 0
145
146        menu "PSRAM clock and cs IO for ESP32S2"
147            depends on ESP32S2_SPIRAM_SUPPORT
148            config DEFAULT_PSRAM_CLK_IO
149                int "PSRAM CLK IO number"
150                range 0 33
151                default 30
152                help
153                    The PSRAM CLOCK IO can be any unused GPIO, user can config it based on hardware design.
154
155            config DEFAULT_PSRAM_CS_IO
156                int "PSRAM CS IO number"
157                range 0 33
158                default 26
159                help
160                    The PSRAM CS IO can be any unused GPIO, user can config it based on hardware design.
161        endmenu
162        config SPIRAM_FETCH_INSTRUCTIONS
163            bool "Cache fetch instructions from SPI RAM"
164            default n
165            help
166                If enabled, instruction in flash will be copied into SPIRAM.
167                If SPIRAM_RODATA also enabled,
168                you can run the instruction when erasing or programming the flash.
169
170        config SPIRAM_RODATA
171            bool "Cache load read only data from SPI RAM"
172            default n
173            help
174                If enabled, radata in flash will be copied into SPIRAM.
175                If SPIRAM_FETCH_INSTRUCTIONS also enabled,
176                you can run the instruction when erasing or programming the flash.
177
178        choice SPIRAM_SPEED
179            prompt "Set RAM clock speed"
180            default SPIRAM_SPEED_40M
181            help
182                Select the speed for the SPI RAM chip.
183
184            config SPIRAM_SPEED_80M
185                bool "80MHz clock speed"
186            config SPIRAM_SPEED_40M
187                bool "40Mhz clock speed"
188            config SPIRAM_SPEED_26M
189                bool "26Mhz clock speed"
190            config SPIRAM_SPEED_20M
191                bool "20Mhz clock speed"
192        endchoice
193
194        # insert non-chip-specific items here
195        source "$IDF_PATH/components/esp_common/Kconfig.spiram.common"
196
197    endmenu
198
199    config ESP32S2_MEMMAP_TRACEMEM
200        bool
201        default "n"
202
203    config ESP32S2_MEMMAP_TRACEMEM_TWOBANKS
204        bool
205        default "n"
206
207    config ESP32S2_TRAX
208        bool "Use TRAX tracing feature"
209        default "n"
210        select ESP32S2_MEMMAP_TRACEMEM
211        help
212            The ESP32S2 contains a feature which allows you to trace the execution path the processor
213            has taken through the program. This is stored in a chunk of 32K (16K for single-processor)
214            of memory that can't be used for general purposes anymore. Disable this if you do not know
215            what this is.
216
217    config ESP32S2_TRACEMEM_RESERVE_DRAM
218        hex
219        default 0x8000 if ESP32S2_MEMMAP_TRACEMEM && ESP32S2_MEMMAP_TRACEMEM_TWOBANKS
220        default 0x4000 if ESP32S2_MEMMAP_TRACEMEM && !ESP32S2_MEMMAP_TRACEMEM_TWOBANKS
221        default 0x0
222
223
224    choice ESP32S2_UNIVERSAL_MAC_ADDRESSES
225        bool "Number of universally administered (by IEEE) MAC address"
226        default ESP32S2_UNIVERSAL_MAC_ADDRESSES_TWO
227        help
228            Configure the number of universally administered (by IEEE) MAC addresses.
229            During initialization, MAC addresses for each network interface are generated or derived from a
230            single base MAC address.
231            If the number of universal MAC addresses is Two, all interfaces (WiFi station, WiFi softap) receive a
232            universally administered MAC address. They are generated sequentially by adding 0, and 1 (respectively)
233            to the final octet of the base MAC address. If the number of universal MAC addresses is one,
234            only WiFi station receives a universally administered MAC address.
235            It's generated by adding 0 to the base MAC address.
236            The WiFi softap receives local MAC addresses. It's derived from the universal WiFi station MAC addresses.
237            When using the default (Espressif-assigned) base MAC address, either setting can be used. When using
238            a custom universal MAC address range, the correct setting will depend on the allocation of MAC
239            addresses in this range (either 1 or 2 per device.)
240
241        config ESP32S2_UNIVERSAL_MAC_ADDRESSES_ONE
242            bool "One"
243            select ESP_MAC_ADDR_UNIVERSE_WIFI_STA
244        config ESP32S2_UNIVERSAL_MAC_ADDRESSES_TWO
245            bool "Two"
246            select ESP_MAC_ADDR_UNIVERSE_WIFI_STA
247            select ESP_MAC_ADDR_UNIVERSE_WIFI_AP
248    endchoice
249
250    config ESP32S2_UNIVERSAL_MAC_ADDRESSES
251        int
252        default 1 if ESP32S2_UNIVERSAL_MAC_ADDRESSES_ONE
253        default 2 if ESP32S2_UNIVERSAL_MAC_ADDRESSES_TWO
254
255    config ESP32S2_ULP_COPROC_ENABLED
256        bool "Enable Ultra Low Power (ULP) Coprocessor"
257        default "n"
258        help
259            Set to 'y' if you plan to load a firmware for the coprocessor.
260
261            If this option is enabled, further coprocessor configuration will appear in the Components menu.
262
263    config ESP32S2_ULP_COPROC_RESERVE_MEM
264        int
265        prompt "RTC slow memory reserved for coprocessor" if ESP32S2_ULP_COPROC_ENABLED
266        default 2048 if ESP32S2_ULP_COPROC_ENABLED
267        range 32 8192 if ESP32S2_ULP_COPROC_ENABLED
268        default 0 if !ESP32S2_ULP_COPROC_ENABLED
269        range 0 0 if !ESP32S2_ULP_COPROC_ENABLED
270        help
271            Bytes of memory to reserve for ULP coprocessor firmware & data.
272
273            Data is reserved at the beginning of RTC slow memory.
274
275    config ESP32S2_ULP_COPROC_RISCV
276        bool "Enable RISC-V as ULP coprocessor"
277        depends on ESP32S2_ULP_COPROC_ENABLED
278        default n
279        help
280            Set this to y to use the RISC-V coprocessor instead of the FSM-ULP.
281
282    config ESP32S2_DEBUG_OCDAWARE
283        bool "Make exception and panic handlers JTAG/OCD aware"
284        default y
285        select FREERTOS_DEBUG_OCDAWARE
286        help
287            The FreeRTOS panic and unhandled exception handers can detect a JTAG OCD debugger and
288            instead of panicking, have the debugger stop on the offending instruction.
289
290    config ESP32S2_DEBUG_STUBS_ENABLE
291        bool "OpenOCD debug stubs"
292        default COMPILER_OPTIMIZATION_LEVEL_DEBUG
293        depends on !ESP32S2_TRAX
294        help
295            Debug stubs are used by OpenOCD to execute pre-compiled onboard code which does some useful debugging,
296            e.g. GCOV data dump.
297
298    config ESP32S2_BROWNOUT_DET
299        bool "Hardware brownout detect & reset"
300        default y
301        help
302            The ESP32-S2 has a built-in brownout detector which can detect if the voltage is lower than
303            a specific value. If this happens, it will reset the chip in order to prevent unintended
304            behaviour.
305
306    choice ESP32S2_BROWNOUT_DET_LVL_SEL
307        prompt "Brownout voltage level"
308        depends on ESP32S2_BROWNOUT_DET
309        default ESP32S2_BROWNOUT_DET_LVL_SEL_7
310        help
311            The brownout detector will reset the chip when the supply voltage is approximately
312            below this level. Note that there may be some variation of brownout voltage level
313            between each ESP3-S2 chip.
314
315            #The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
316            #of the brownout threshold levels.
317        config ESP32S2_BROWNOUT_DET_LVL_SEL_7
318            bool "2.44V"
319        config ESP32S2_BROWNOUT_DET_LVL_SEL_6
320            bool "2.56V"
321        config ESP32S2_BROWNOUT_DET_LVL_SEL_5
322            bool "2.67V"
323        config ESP32S2_BROWNOUT_DET_LVL_SEL_4
324            bool "2.84V"
325        config ESP32S2_BROWNOUT_DET_LVL_SEL_3
326            bool "2.98V"
327        config ESP32S2_BROWNOUT_DET_LVL_SEL_2
328            bool "3.19V"
329        config ESP32S2_BROWNOUT_DET_LVL_SEL_1
330            bool "3.30V"
331    endchoice
332
333    config ESP32S2_BROWNOUT_DET_LVL
334        int
335        default 1 if ESP32S2_BROWNOUT_DET_LVL_SEL_1
336        default 2 if ESP32S2_BROWNOUT_DET_LVL_SEL_2
337        default 3 if ESP32S2_BROWNOUT_DET_LVL_SEL_3
338        default 4 if ESP32S2_BROWNOUT_DET_LVL_SEL_4
339        default 5 if ESP32S2_BROWNOUT_DET_LVL_SEL_5
340        default 6 if ESP32S2_BROWNOUT_DET_LVL_SEL_6
341        default 7 if ESP32S2_BROWNOUT_DET_LVL_SEL_7
342
343
344        # Note about the use of "FRC1" name: currently FRC1 timer is not used for
345        # high resolution timekeeping anymore. Instead the esp_timer API, implemented
346        # using FRC2 timer, is used.
347        # FRC1 name in the option name is kept for compatibility.
348    choice ESP32S2_TIME_SYSCALL
349        prompt "Timers used for gettimeofday function"
350        default ESP32S2_TIME_SYSCALL_USE_RTC_FRC1
351        help
352            This setting defines which hardware timers are used to
353            implement 'gettimeofday' and 'time' functions in C library.
354
355            - If both high-resolution and RTC timers are used, timekeeping will
356              continue in deep sleep. Time will be reported at 1 microsecond
357              resolution. This is the default, and the recommended option.
358            - If only high-resolution timer is used, gettimeofday will
359              provide time at microsecond resolution.
360              Time will not be preserved when going into deep sleep mode.
361            - If only RTC timer is used, timekeeping will continue in
362              deep sleep, but time will be measured at 6.(6) microsecond
363              resolution. Also the gettimeofday function itself may take
364              longer to run.
365            - If no timers are used, gettimeofday and time functions
366              return -1 and set errno to ENOSYS.
367            - When RTC is used for timekeeping, two RTC_STORE registers are
368              used to keep time in deep sleep mode.
369
370        config ESP32S2_TIME_SYSCALL_USE_RTC_FRC1
371            bool "RTC and high-resolution timer"
372            select ESP_TIME_FUNCS_USE_RTC_TIMER
373            select ESP_TIME_FUNCS_USE_ESP_TIMER
374        config ESP32S2_TIME_SYSCALL_USE_RTC
375            bool "RTC"
376            select ESP_TIME_FUNCS_USE_RTC_TIMER
377        config ESP32S2_TIME_SYSCALL_USE_FRC1
378            bool "High-resolution timer"
379            select ESP_TIME_FUNCS_USE_ESP_TIMER
380        config ESP32S2_TIME_SYSCALL_USE_NONE
381            bool "None"
382            select ESP_TIME_FUNCS_USE_NONE
383    endchoice
384
385    choice ESP32S2_RTC_CLK_SRC
386        prompt "RTC clock source"
387        default ESP32S2_RTC_CLK_SRC_INT_RC
388        help
389            Choose which clock is used as RTC clock source.
390
391            - "Internal 90kHz oscillator" option provides lowest deep sleep current
392              consumption, and does not require extra external components. However
393              frequency stability with respect to temperature is poor, so time may
394              drift in deep/light sleep modes.
395            - "External 32kHz crystal" provides better frequency stability, at the
396              expense of slightly higher (1uA) deep sleep current consumption.
397            - "External 32kHz oscillator" allows using 32kHz clock generated by an
398              external circuit. In this case, external clock signal must be connected
399              to 32K_XN pin. Amplitude should be <1.2V in case of sine wave signal,
400              and <1V in case of square wave signal. Common mode voltage should be
401              0.1 < Vcm < 0.5Vamp, where Vamp is the signal amplitude.
402              Additionally, 1nF capacitor must be connected between 32K_XP pin and
403              ground. 32K_XP pin can not be used as a GPIO in this case.
404            - "Internal 8MHz oscillator divided by 256" option results in higher
405              deep sleep current (by 5uA) but has better frequency stability than
406              the internal 90kHz oscillator. It does not require external components.
407
408        config ESP32S2_RTC_CLK_SRC_INT_RC
409            bool "Internal 90kHz RC oscillator"
410        config ESP32S2_RTC_CLK_SRC_EXT_CRYS
411            bool "External 32kHz crystal"
412            select ESP_SYSTEM_RTC_EXT_XTAL
413        config ESP32S2_RTC_CLK_SRC_EXT_OSC
414            bool "External 32kHz oscillator at 32K_XN pin"
415        config ESP32S2_RTC_CLK_SRC_INT_8MD256
416            bool "Internal 8MHz oscillator, divided by 256 (~32kHz)"
417    endchoice
418
419    config ESP32S2_RTC_CLK_CAL_CYCLES
420        int "Number of cycles for RTC_SLOW_CLK calibration"
421        default 3000 if ESP32S2_RTC_CLK_SRC_EXT_CRYS || ESP32S2_RTC_CLK_SRC_EXT_OSC || ESP32S2_RTC_CLK_SRC_INT_8MD256
422        default 576 if ESP32S2_RTC_CLK_SRC_INT_RC
423        range 0 125000
424        help
425            When the startup code initializes RTC_SLOW_CLK, it can perform
426            calibration by comparing the RTC_SLOW_CLK frequency with main XTAL
427            frequency. This option sets the number of RTC_SLOW_CLK cycles measured
428            by the calibration routine. Higher numbers increase calibration
429            precision, which may be important for applications which spend a lot of
430            time in deep sleep. Lower numbers reduce startup time.
431
432            When this option is set to 0, clock calibration will not be performed at
433            startup, and approximate clock frequencies will be assumed:
434
435            - 90000 Hz if internal RC oscillator is used as clock source. For this use value 1024.
436            - 32768 Hz if the 32k crystal oscillator is used. For this use value 3000 or more.
437              In case more value will help improve the definition of the launch of the crystal.
438              If the crystal could not start, it will be switched to internal RC.
439
440    config ESP32S2_RTC_XTAL_CAL_RETRY
441        int "Number of attempts to repeat 32k XTAL calibration"
442        default 3
443        depends on ESP32S2_RTC_CLK_SRC_EXT_CRYS
444        help
445            Number of attempts to repeat 32k XTAL calibration
446            before giving up and switching to the internal RC.
447            Increase this option if the 32k crystal oscillator
448            does not start and switches to internal RC.
449
450    config ESP32S2_NO_BLOBS
451        bool "No Binary Blobs"
452        depends on !BT_ENABLED
453        default n
454        help
455            If enabled, this disables the linking of binary libraries in the application build. Note
456            that after enabling this Wi-Fi/Bluetooth will not work.
457
458    config ESP32S2_KEEP_USB_ALIVE
459        bool "Keep USB peripheral enabled at start up" if !ESP_CONSOLE_USB_CDC
460        default y if ESP_CONSOLE_USB_CDC
461        help
462            During the application initialization process, all the peripherals except UARTs and timers
463            are reset. Enable this option to keep USB peripheral enabled.
464            This option is automatically enabled if "USB CDC" console is selected.
465
466    config ESP32S2_RTCDATA_IN_FAST_MEM
467        bool "Place RTC_DATA_ATTR and RTC_RODATA_ATTR variables into RTC fast memory segment"
468        default n
469        help
470            This option allows to place .rtc_data and .rtc_rodata sections into
471            RTC fast memory segment to free the slow memory region for ULP programs.
472
473    config ESP32S2_USE_FIXED_STATIC_RAM_SIZE
474        bool "Use fixed static RAM size"
475        default n
476        help
477            If this option is disabled, the DRAM part of the heap starts right after the .bss section,
478            within the dram0_0 region. As a result, adding or removing some static variables
479            will change the available heap size.
480
481            If this option is enabled, the DRAM part of the heap starts right after the dram0_0 region,
482            where its length is set with ESP32S2_FIXED_STATIC_RAM_SIZE
483
484    config ESP32S2_FIXED_STATIC_RAM_SIZE
485        hex "Fixed Static RAM size"
486        default 0x10000
487        range 0 0x34000
488        depends on ESP32S2_USE_FIXED_STATIC_RAM_SIZE
489        help
490            RAM size dedicated for static variables (.data & .bss sections).
491
492endmenu  # ESP32S2-Specific
493