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_hw_support/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    config ESP32S2_ULP_COPROC_ENABLED
225        bool "Enable Ultra Low Power (ULP) Coprocessor"
226        default "n"
227        help
228            Set to 'y' if you plan to load a firmware for the coprocessor.
229
230            If this option is enabled, further coprocessor configuration will appear in the Components menu.
231
232    config ESP32S2_ULP_COPROC_RESERVE_MEM
233        int
234        prompt "RTC slow memory reserved for coprocessor" if ESP32S2_ULP_COPROC_ENABLED
235        default 2048 if ESP32S2_ULP_COPROC_ENABLED
236        range 32 8176 if ESP32S2_ULP_COPROC_ENABLED
237        default 0 if !ESP32S2_ULP_COPROC_ENABLED
238        range 0 0 if !ESP32S2_ULP_COPROC_ENABLED
239        help
240            Bytes of memory to reserve for ULP coprocessor firmware & data.
241
242            Data is reserved at the beginning of RTC slow memory.
243
244    config ESP32S2_ULP_COPROC_RISCV
245        bool "Enable RISC-V as ULP coprocessor"
246        depends on ESP32S2_ULP_COPROC_ENABLED
247        default n
248        help
249            Set this to y to use the RISC-V coprocessor instead of the FSM-ULP.
250
251    config ESP32S2_DEBUG_OCDAWARE
252        bool "Make exception and panic handlers JTAG/OCD aware"
253        default y
254        select FREERTOS_DEBUG_OCDAWARE
255        help
256            The FreeRTOS panic and unhandled exception handers can detect a JTAG OCD debugger and
257            instead of panicking, have the debugger stop on the offending instruction.
258
259    config ESP32S2_BROWNOUT_DET
260        bool "Hardware brownout detect & reset"
261        depends on !IDF_ENV_FPGA
262        default y
263        help
264            The ESP32-S2 has a built-in brownout detector which can detect if the voltage is lower than
265            a specific value. If this happens, it will reset the chip in order to prevent unintended
266            behaviour.
267
268    choice ESP32S2_BROWNOUT_DET_LVL_SEL
269        prompt "Brownout voltage level"
270        depends on ESP32S2_BROWNOUT_DET
271        default ESP32S2_BROWNOUT_DET_LVL_SEL_7
272        help
273            The brownout detector will reset the chip when the supply voltage is approximately
274            below this level. Note that there may be some variation of brownout voltage level
275            between each ESP3-S2 chip.
276
277            #The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
278            #of the brownout threshold levels.
279        config ESP32S2_BROWNOUT_DET_LVL_SEL_7
280            bool "2.44V"
281        config ESP32S2_BROWNOUT_DET_LVL_SEL_6
282            bool "2.56V"
283        config ESP32S2_BROWNOUT_DET_LVL_SEL_5
284            bool "2.67V"
285        config ESP32S2_BROWNOUT_DET_LVL_SEL_4
286            bool "2.84V"
287        config ESP32S2_BROWNOUT_DET_LVL_SEL_3
288            bool "2.98V"
289        config ESP32S2_BROWNOUT_DET_LVL_SEL_2
290            bool "3.19V"
291        config ESP32S2_BROWNOUT_DET_LVL_SEL_1
292            bool "3.30V"
293    endchoice
294
295    config ESP32S2_BROWNOUT_DET_LVL
296        int
297        default 1 if ESP32S2_BROWNOUT_DET_LVL_SEL_1
298        default 2 if ESP32S2_BROWNOUT_DET_LVL_SEL_2
299        default 3 if ESP32S2_BROWNOUT_DET_LVL_SEL_3
300        default 4 if ESP32S2_BROWNOUT_DET_LVL_SEL_4
301        default 5 if ESP32S2_BROWNOUT_DET_LVL_SEL_5
302        default 6 if ESP32S2_BROWNOUT_DET_LVL_SEL_6
303        default 7 if ESP32S2_BROWNOUT_DET_LVL_SEL_7
304
305
306        # Note about the use of "FRC1" name: currently FRC1 timer is not used for
307        # high resolution timekeeping anymore. Instead the esp_timer API, implemented
308        # using FRC2 timer, is used.
309        # FRC1 name in the option name is kept for compatibility.
310    choice ESP32S2_TIME_SYSCALL
311        prompt "Timers used for gettimeofday function"
312        default ESP32S2_TIME_SYSCALL_USE_RTC_FRC1
313        help
314            This setting defines which hardware timers are used to
315            implement 'gettimeofday' and 'time' functions in C library.
316
317            - If both high-resolution and RTC timers are used, timekeeping will
318              continue in deep sleep. Time will be reported at 1 microsecond
319              resolution. This is the default, and the recommended option.
320            - If only high-resolution timer is used, gettimeofday will
321              provide time at microsecond resolution.
322              Time will not be preserved when going into deep sleep mode.
323            - If only RTC timer is used, timekeeping will continue in
324              deep sleep, but time will be measured at 6.(6) microsecond
325              resolution. Also the gettimeofday function itself may take
326              longer to run.
327            - If no timers are used, gettimeofday and time functions
328              return -1 and set errno to ENOSYS.
329            - When RTC is used for timekeeping, two RTC_STORE registers are
330              used to keep time in deep sleep mode.
331
332        config ESP32S2_TIME_SYSCALL_USE_RTC_FRC1
333            bool "RTC and high-resolution timer"
334            select ESP_TIME_FUNCS_USE_RTC_TIMER
335            select ESP_TIME_FUNCS_USE_ESP_TIMER
336        config ESP32S2_TIME_SYSCALL_USE_RTC
337            bool "RTC"
338            select ESP_TIME_FUNCS_USE_RTC_TIMER
339        config ESP32S2_TIME_SYSCALL_USE_FRC1
340            bool "High-resolution timer"
341            select ESP_TIME_FUNCS_USE_ESP_TIMER
342        config ESP32S2_TIME_SYSCALL_USE_NONE
343            bool "None"
344            select ESP_TIME_FUNCS_USE_NONE
345    endchoice
346
347    choice ESP32S2_RTC_CLK_SRC
348        prompt "RTC clock source"
349        default ESP32S2_RTC_CLK_SRC_INT_RC
350        help
351            Choose which clock is used as RTC clock source.
352
353            - "Internal 90kHz oscillator" option provides lowest deep sleep current
354              consumption, and does not require extra external components. However
355              frequency stability with respect to temperature is poor, so time may
356              drift in deep/light sleep modes.
357            - "External 32kHz crystal" provides better frequency stability, at the
358              expense of slightly higher (1uA) deep sleep current consumption.
359            - "External 32kHz oscillator" allows using 32kHz clock generated by an
360              external circuit. In this case, external clock signal must be connected
361              to 32K_XN pin. Amplitude should be <1.2V in case of sine wave signal,
362              and <1V in case of square wave signal. Common mode voltage should be
363              0.1 < Vcm < 0.5Vamp, where Vamp is the signal amplitude.
364              Additionally, 1nF capacitor must be connected between 32K_XP pin and
365              ground. 32K_XP pin can not be used as a GPIO in this case.
366            - "Internal 8MHz oscillator divided by 256" option results in higher
367              deep sleep current (by 5uA) but has better frequency stability than
368              the internal 90kHz oscillator. It does not require external components.
369
370        config ESP32S2_RTC_CLK_SRC_INT_RC
371            bool "Internal 90kHz RC oscillator"
372        config ESP32S2_RTC_CLK_SRC_EXT_CRYS
373            bool "External 32kHz crystal"
374            select ESP_SYSTEM_RTC_EXT_XTAL
375        config ESP32S2_RTC_CLK_SRC_EXT_OSC
376            bool "External 32kHz oscillator at 32K_XN pin"
377            select ESP_SYSTEM_RTC_EXT_OSC
378        config ESP32S2_RTC_CLK_SRC_INT_8MD256
379            bool "Internal 8MHz oscillator, divided by 256 (~32kHz)"
380    endchoice
381
382    config ESP32S2_RTC_CLK_CAL_CYCLES
383        int "Number of cycles for RTC_SLOW_CLK calibration"
384        default 3000 if ESP32S2_RTC_CLK_SRC_EXT_CRYS || ESP32S2_RTC_CLK_SRC_EXT_OSC || ESP32S2_RTC_CLK_SRC_INT_8MD256
385        default 576 if ESP32S2_RTC_CLK_SRC_INT_RC
386        range 0 125000
387        help
388            When the startup code initializes RTC_SLOW_CLK, it can perform
389            calibration by comparing the RTC_SLOW_CLK frequency with main XTAL
390            frequency. This option sets the number of RTC_SLOW_CLK cycles measured
391            by the calibration routine. Higher numbers increase calibration
392            precision, which may be important for applications which spend a lot of
393            time in deep sleep. Lower numbers reduce startup time.
394
395            When this option is set to 0, clock calibration will not be performed at
396            startup, and approximate clock frequencies will be assumed:
397
398            - 90000 Hz if internal RC oscillator is used as clock source. For this use value 1024.
399            - 32768 Hz if the 32k crystal oscillator is used. For this use value 3000 or more.
400              In case more value will help improve the definition of the launch of the crystal.
401              If the crystal could not start, it will be switched to internal RC.
402
403    config ESP32S2_RTC_XTAL_CAL_RETRY
404        int "Number of attempts to repeat 32k XTAL calibration"
405        default 3
406        depends on ESP32S2_RTC_CLK_SRC_EXT_CRYS
407        help
408            Number of attempts to repeat 32k XTAL calibration
409            before giving up and switching to the internal RC.
410            Increase this option if the 32k crystal oscillator
411            does not start and switches to internal RC.
412
413    config ESP32S2_NO_BLOBS
414        bool "No Binary Blobs"
415        depends on !BT_ENABLED
416        default n
417        help
418            If enabled, this disables the linking of binary libraries in the application build. Note
419            that after enabling this Wi-Fi/Bluetooth will not work.
420
421    config ESP32S2_KEEP_USB_ALIVE
422        bool "Keep USB peripheral enabled at start up" if !ESP_CONSOLE_USB_CDC
423        default y if ESP_CONSOLE_USB_CDC
424        help
425            During the application initialization process, all the peripherals except UARTs and timers
426            are reset. Enable this option to keep USB peripheral enabled.
427            This option is automatically enabled if "USB CDC" console is selected.
428
429    config ESP32S2_RTCDATA_IN_FAST_MEM
430        bool "Place RTC_DATA_ATTR and RTC_RODATA_ATTR variables into RTC fast memory segment"
431        default n
432        help
433            This option allows to place .rtc_data and .rtc_rodata sections into
434            RTC fast memory segment to free the slow memory region for ULP programs.
435
436    config ESP32S2_USE_FIXED_STATIC_RAM_SIZE
437        bool "Use fixed static RAM size"
438        default n
439        help
440            If this option is disabled, the DRAM part of the heap starts right after the .bss section,
441            within the dram0_0 region. As a result, adding or removing some static variables
442            will change the available heap size.
443
444            If this option is enabled, the DRAM part of the heap starts right after the dram0_0 region,
445            where its length is set with ESP32S2_FIXED_STATIC_RAM_SIZE
446
447    config ESP32S2_FIXED_STATIC_RAM_SIZE
448        hex "Fixed Static RAM size"
449        default 0x10000
450        range 0 0x34000
451        depends on ESP32S2_USE_FIXED_STATIC_RAM_SIZE
452        help
453            RAM size dedicated for static variables (.data & .bss sections).
454
455endmenu  # ESP32S2-Specific
456