Skip to content

Commit 045afd4

Browse files
committed
hal: Add ULP component
Add ULP component based on a2f420a36ecf8cd19b443adde1d75e5eaecc6309 Signed-off-by: Lucas Tamborrino <[email protected]>
1 parent 202c595 commit 045afd4

File tree

171 files changed

+18445
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+18445
-0
lines changed

components/ulp/CMakeLists.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
idf_build_get_property(target IDF_TARGET)
2+
3+
if(${target} STREQUAL "linux")
4+
return() # This component is not supported by the POSIX/Linux simulator
5+
endif()
6+
7+
set(srcs "")
8+
set(includes "")
9+
10+
if(CONFIG_ULP_COPROC_ENABLED OR CONFIG_IDF_DOC_BUILD)
11+
list(APPEND includes
12+
ulp_common/include)
13+
endif()
14+
15+
if(CONFIG_ULP_COPROC_TYPE_FSM OR (CONFIG_IDF_DOC_BUILD AND CONFIG_SOC_ULP_FSM_SUPPORTED))
16+
list(APPEND includes
17+
ulp_fsm/include
18+
ulp_fsm/include/${target})
19+
endif()
20+
21+
if(CONFIG_ULP_COPROC_TYPE_RISCV OR CONFIG_IDF_DOC_BUILD)
22+
list(APPEND includes
23+
ulp_riscv/include
24+
ulp_riscv/shared/include)
25+
endif()
26+
27+
if(CONFIG_ULP_COPROC_TYPE_LP_CORE OR CONFIG_IDF_DOC_BUILD)
28+
list(APPEND includes
29+
lp_core/include
30+
lp_core/shared/include)
31+
endif()
32+
33+
if(CONFIG_ULP_COPROC_TYPE_FSM OR CONFIG_ULP_COPROC_TYPE_RISCV)
34+
35+
list(APPEND srcs
36+
"ulp_common/ulp_common.c"
37+
"ulp_common/ulp_adc.c")
38+
39+
if(CONFIG_ULP_COPROC_TYPE_FSM)
40+
list(APPEND srcs
41+
"ulp_fsm/ulp.c"
42+
"ulp_fsm/ulp_macro.c")
43+
44+
elseif(CONFIG_ULP_COPROC_TYPE_RISCV)
45+
list(APPEND srcs
46+
"ulp_riscv/ulp_riscv.c"
47+
"ulp_riscv/ulp_riscv_lock.c"
48+
"ulp_riscv/ulp_riscv_i2c.c")
49+
endif()
50+
endif()
51+
52+
if(CONFIG_ULP_COPROC_TYPE_LP_CORE)
53+
list(APPEND srcs
54+
"lp_core/lp_core.c"
55+
"lp_core/shared/ulp_lp_core_memory_shared.c"
56+
"lp_core/shared/ulp_lp_core_critical_section_shared.c")
57+
58+
if(CONFIG_SOC_ULP_LP_UART_SUPPORTED)
59+
list(APPEND srcs "lp_core/lp_core_uart.c")
60+
endif()
61+
62+
if(CONFIG_SOC_LP_I2C_SUPPORTED)
63+
list(APPEND srcs "lp_core/lp_core_i2c.c")
64+
endif()
65+
66+
if(CONFIG_SOC_LP_TIMER_SUPPORTED)
67+
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_timer_shared.c")
68+
endif()
69+
70+
if(CONFIG_SOC_LP_SPI_SUPPORTED)
71+
list(APPEND srcs "lp_core/lp_core_spi.c")
72+
endif()
73+
74+
if(CONFIG_SOC_LP_CORE_SUPPORT_ETM)
75+
list(APPEND srcs "lp_core/lp_core_etm.c")
76+
endif()
77+
78+
if(CONFIG_SOC_LP_ADC_SUPPORTED)
79+
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_adc_shared.c")
80+
endif()
81+
82+
if(CONFIG_SOC_LP_VAD_SUPPORTED)
83+
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_vad_shared.c")
84+
endif()
85+
endif()
86+
87+
idf_component_register(SRCS ${srcs}
88+
INCLUDE_DIRS ${includes}
89+
REQUIRES driver esp_adc)

components/ulp/Kconfig

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
menu "Ultra Low Power (ULP) Co-processor"
2+
depends on (SOC_ULP_SUPPORTED || SOC_RISCV_COPROC_SUPPORTED || SOC_LP_CORE_SUPPORTED)
3+
4+
config ULP_COPROC_ENABLED
5+
bool "Enable Ultra Low Power (ULP) Co-processor"
6+
default "n"
7+
help
8+
Enable this feature if you plan to use the ULP Co-processor.
9+
Once this option is enabled, further ULP co-processor configuration will appear in the menu.
10+
11+
choice ULP_COPROC_TYPE
12+
prompt "ULP Co-processor type"
13+
depends on ULP_COPROC_ENABLED
14+
default ULP_COPROC_TYPE_RISCV if (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3)
15+
help
16+
Choose the ULP Coprocessor type: ULP FSM (Finite State Machine) or ULP RISC-V.
17+
18+
config ULP_COPROC_TYPE_FSM
19+
bool "ULP FSM (Finite State Machine)"
20+
depends on SOC_ULP_FSM_SUPPORTED
21+
config ULP_COPROC_TYPE_RISCV
22+
bool "ULP RISC-V"
23+
depends on SOC_RISCV_COPROC_SUPPORTED
24+
config ULP_COPROC_TYPE_LP_CORE
25+
bool "LP core RISC-V"
26+
depends on SOC_LP_CORE_SUPPORTED
27+
endchoice
28+
29+
config ULP_COPROC_RESERVE_MEM
30+
int
31+
prompt "RTC slow memory reserved for coprocessor"
32+
depends on ULP_COPROC_ENABLED
33+
default 512 if IDF_TARGET_ESP32
34+
default 4096 if !IDF_TARGET_ESP32
35+
range 32 8176 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
36+
range 32 16352 if IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32C6
37+
range 32 31088 if IDF_TARGET_ESP32P4 # Some memory are reserved for ROM/RTC reserved
38+
help
39+
Bytes of memory to reserve for ULP Co-processor firmware & data.
40+
Data is reserved at the beginning of RTC slow memory.
41+
42+
43+
menu "ULP RISC-V Settings"
44+
depends on ULP_COPROC_TYPE_RISCV
45+
46+
config ULP_RISCV_INTERRUPT_ENABLE
47+
bool
48+
prompt "Enable ULP RISC-V interrupts"
49+
default "n"
50+
help
51+
Turn on this setting to enabled interrupts on the ULP RISC-V core.
52+
53+
config ULP_RISCV_UART_BAUDRATE
54+
int
55+
prompt "Baudrate used by the bitbanged ULP RISC-V UART driver"
56+
default 9600
57+
help
58+
The accuracy of the bitbanged UART driver is limited, it is not
59+
recommend to increase the value above 19200.
60+
61+
config ULP_RISCV_I2C_RW_TIMEOUT
62+
int
63+
prompt "Set timeout for ULP RISC-V I2C transaction timeout in ticks."
64+
default 500
65+
range -1 4294967295
66+
help
67+
Set the ULP RISC-V I2C read/write timeout. Set this value to -1
68+
if the ULP RISC-V I2C read and write APIs should wait forever.
69+
Please note that the tick rate of the ULP co-processor would be
70+
different than the OS tick rate of the main core and therefore
71+
can have different timeout value depending on which core the API
72+
is invoked on.
73+
endmenu
74+
75+
config ULP_SHARED_MEM
76+
depends on ULP_COPROC_TYPE_LP_CORE
77+
hex
78+
default 0x10
79+
help
80+
Size of the shared memory defined in ulp_lp_core_memory_shared.c.
81+
Size should be kept in-sync with the size of the struct defined there.
82+
83+
config ULP_ROM_PRINT_ENABLE
84+
depends on ULP_COPROC_TYPE_LP_CORE && ESP_ROM_HAS_LP_ROM
85+
bool
86+
prompt "Enable print utilities from LP ROM"
87+
default "y"
88+
help
89+
Set this option to enable printf functionality from LP ROM. This option
90+
can help reduce the LP core binary size by not linking printf functionality
91+
from RAM code.
92+
Note: For LP ROM prints to work properly, make sure that the LP core boots
93+
from the LP ROM.
94+
95+
menu "ULP Debugging Options"
96+
config ULP_PANIC_OUTPUT_ENABLE
97+
depends on ULP_COPROC_TYPE_LP_CORE && SOC_ULP_LP_UART_SUPPORTED
98+
bool
99+
prompt "Enable panic handler which outputs over LP UART"
100+
default "y" if IDF_TARGET_ESP32P4
101+
help
102+
Set this option to enable panic handler functionality. If this option is
103+
enabled then the LP Core will output a panic dump over LP UART,
104+
similar to what the main core does. Output depends on LP UART already being
105+
initialized and configured.
106+
Disabling this option will reduce the LP core binary size by not
107+
linking in panic handler functionality.
108+
109+
config ULP_HP_UART_CONSOLE_PRINT
110+
depends on ULP_COPROC_TYPE_LP_CORE
111+
bool
112+
prompt "Route lp_core_printf to the console HP-UART"
113+
help
114+
Set this option to route lp_core_printf to the console HP-UART.
115+
This allows you to easily view print outputs from the LP core, without
116+
having to connect to the LP-UART. This option comes with the following
117+
limitations:
118+
119+
1. There is no mutual exclusion between the HP-Core and the LP-Core accessing
120+
the HP-UART, which means that if both cores are logging heavily the output
121+
strings might get mangled together.
122+
2. The HP-UART can only work while the HP-Core is running, which means that
123+
if the HP-Core is in deep sleep, the LP-Core will not be able to print to the
124+
console HP-UART.
125+
126+
Due to these limitations it is only recommended to use this option for easy debugging.
127+
For more serious use-cases you should use the LP-UART.
128+
129+
config ULP_NORESET_UNDER_DEBUG
130+
bool "Avoid resetting LP core when debugger is attached"
131+
depends on ULP_COPROC_TYPE_LP_CORE
132+
default "y"
133+
help
134+
Enable this feature to avoid resetting LP core in sleep mode when debugger is attached,
135+
otherwise configured HW breakpoints and dcsr.ebreak* bits will be missed.
136+
This is a workaround until it will be fixed in HW.
137+
138+
endmenu
139+
140+
endmenu # Ultra Low Power (ULP) Co-processor

components/ulp/cmake/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
include(${IDF_PATH}/tools/cmake/idf.cmake)
4+
project(${ULP_APP_NAME})
5+
add_executable(${ULP_APP_NAME})
6+
7+
include(IDFULPProject)
8+
9+
ulp_apply_default_options(${ULP_APP_NAME})
10+
ulp_apply_default_sources(${ULP_APP_NAME})
11+
ulp_add_build_binary_targets(${ULP_APP_NAME})

0 commit comments

Comments
 (0)