28
28
FRAMEWORK_DIR = platform .get_package_dir ("framework-espidf" )
29
29
BUILD_DIR = ulp_env .subst ("$BUILD_DIR" )
30
30
ULP_BUILD_DIR = os .path .join (
31
- BUILD_DIR , "esp-idf" , project_config ["name" ].replace ("__idf_" , "" ), "ulp_main"
31
+ BUILD_DIR ,
32
+ "esp-idf" ,
33
+ project_config ["name" ].replace ("__idf_" , "" ),
34
+ "ulp_main" ,
32
35
)
33
36
34
37
35
38
def prepare_ulp_env_vars (env ):
36
39
ulp_env .PrependENVPath ("IDF_PATH" , FRAMEWORK_DIR )
37
40
38
41
toolchain_path = platform .get_package_dir (
39
- "toolchain-xtensa-esp-elf"
40
- if "arduino" not in env .subst ("$PIOFRAMEWORK" )
41
- else "toolchain-xtensa-%s" % idf_variant
42
+ "toolchain-riscv32-esp"
43
+ if idf_variant in ("esp32c3" , "esp32c6" )
44
+ else (
45
+ (
46
+ "toolchain-xtensa-esp-elf"
47
+ if "arduino" not in env .subst ("$PIOFRAMEWORK" )
48
+ else "toolchain-xtensa-%s" % idf_variant
49
+ )
50
+ )
42
51
)
43
52
44
53
additional_packages = [
@@ -72,9 +81,9 @@ def get_component_includes(target_config):
72
81
if source ["path" ].endswith ("ulp_main.bin.S" ):
73
82
return [
74
83
inc ["path" ]
75
- for inc in target_config ["compileGroups" ][source [ "compileGroupIndex" ]][
76
- "includes"
77
- ]
84
+ for inc in target_config ["compileGroups" ][
85
+ source [ "compileGroupIndex" ]
86
+ ][ "includes" ]
78
87
]
79
88
80
89
return [os .path .join (BUILD_DIR , "config" )]
@@ -85,29 +94,62 @@ def _generate_ulp_configuration_action(env, target, source):
85
94
riscv_ulp_enabled = sdk_config .get ("ULP_COPROC_TYPE_RISCV" , False )
86
95
87
96
cmd = (
88
- os .path .join (platform .get_package_dir ("tool-cmake" ), "bin" , "cmake" ),
97
+ os .path .join (
98
+ platform .get_package_dir ("tool-cmake" ), "bin" , "cmake"
99
+ ),
89
100
"-DCMAKE_GENERATOR=Ninja" ,
90
101
"-DCMAKE_TOOLCHAIN_FILE="
91
102
+ os .path .join (
92
103
FRAMEWORK_DIR ,
93
104
"components" ,
94
105
"ulp" ,
95
106
"cmake" ,
96
- "toolchain-%sulp%s.cmake"
97
- % (
98
- "" if riscv_ulp_enabled else idf_variant + "-" ,
99
- "-riscv" if riscv_ulp_enabled else "" ,
107
+ (
108
+ "toolchain-lp-core-riscv.cmake"
109
+ if sdk_config .get ("ULP_COPROC_TYPE_LP_CORE" , False )
110
+ else "toolchain-%sulp%s.cmake"
111
+ % (
112
+ "" if riscv_ulp_enabled else idf_variant + "-" ,
113
+ "-riscv" if riscv_ulp_enabled else "" ,
114
+ )
100
115
),
101
116
),
102
- "-DULP_S_SOURCES=%s" % ";" .join ([fs .to_unix_path (s .get_abspath ()) for s in source ]),
117
+ "-DULP_S_SOURCES=%s"
118
+ % ";" .join ([fs .to_unix_path (s .get_abspath ()) for s in source ]),
103
119
"-DULP_APP_NAME=ulp_main" ,
104
- "-DCOMPONENT_DIR=" + os .path .join (ulp_env .subst ("$PROJECT_DIR" ), "ulp" ),
105
- "-DCOMPONENT_INCLUDES=%s" % ";" .join (get_component_includes (target_config )),
120
+ "-DCOMPONENT_DIR="
121
+ + os .path .join (ulp_env .subst ("$PROJECT_DIR" ), "ulp" ),
122
+ "-DCOMPONENT_INCLUDES=%s"
123
+ % ";" .join (get_component_includes (target_config )),
106
124
"-DIDF_TARGET=%s" % idf_variant ,
107
125
"-DIDF_PATH=" + fs .to_unix_path (FRAMEWORK_DIR ),
108
- "-DSDKCONFIG_HEADER=" + os .path .join (BUILD_DIR , "config" , "sdkconfig.h" ),
126
+ "-DSDKCONFIG_HEADER="
127
+ + os .path .join (BUILD_DIR , "config" , "sdkconfig.h" ),
109
128
"-DPYTHON=" + env .subst ("$PYTHONEXE" ),
110
- "-DSDKCONFIG_CMAKE=" + os .path .join (BUILD_DIR , "config" , "sdkconfig.cmake" ),
129
+ "-DSDKCONFIG_CMAKE="
130
+ + os .path .join (BUILD_DIR , "config" , "sdkconfig.cmake" ),
131
+ "-DULP_COCPU_IS_RISCV="
132
+ + (
133
+ "ON"
134
+ if idf_variant in ("esp32s2" , "esp32s3" )
135
+ and sdk_config .get ("ULP_COPROC_TYPE_RISCV" , False )
136
+ else ""
137
+ ),
138
+ "-DULP_COCPU_IS_LP_CORE="
139
+ + (
140
+ "ON"
141
+ if sdk_config .get ("ULP_COPROC_TYPE_LP_CORE" , False )
142
+ else ""
143
+ ),
144
+ "-DESP_ROM_HAS_LP_ROM="
145
+ + (
146
+ "ON"
147
+ if sdk_config .get ("ESP_ROM_HAS_LP_ROM" , False )
148
+ else ""
149
+ ),
150
+ "-DCMAKE_MODULE_PATH="
151
+ + fs .to_unix_path (
152
+ os .path .join (FRAMEWORK_DIR , "components" , "ulp" , "cmake" )),
111
153
"-GNinja" ,
112
154
"-B" ,
113
155
ULP_BUILD_DIR ,
@@ -152,7 +194,9 @@ def compile_ulp_binary():
152
194
os .path .join (ULP_BUILD_DIR , "ulp_main.bin" ),
153
195
],
154
196
None ,
155
- ulp_binary_env .VerboseAction (" " .join (cmd ), "Generating ULP project files $TARGETS" ),
197
+ ulp_binary_env .VerboseAction (
198
+ " " .join (cmd ), "Generating ULP project files $TARGETS"
199
+ ),
156
200
)
157
201
158
202
@@ -164,14 +208,20 @@ def generate_ulp_assembly():
164
208
"-DFILE_TYPE=BINARY" ,
165
209
"-P" ,
166
210
os .path .join (
167
- FRAMEWORK_DIR , "tools" , "cmake" , "scripts" , "data_file_embed_asm.cmake"
211
+ FRAMEWORK_DIR ,
212
+ "tools" ,
213
+ "cmake" ,
214
+ "scripts" ,
215
+ "data_file_embed_asm.cmake" ,
168
216
),
169
217
)
170
218
171
219
return ulp_env .Command (
172
220
os .path .join (BUILD_DIR , "ulp_main.bin.S" ),
173
221
os .path .join (ULP_BUILD_DIR , "ulp_main.bin" ),
174
- ulp_env .VerboseAction (" " .join (cmd ), "Generating ULP assembly file $TARGET" ),
222
+ ulp_env .VerboseAction (
223
+ " " .join (cmd ), "Generating ULP assembly file $TARGET"
224
+ ),
175
225
)
176
226
177
227
0 commit comments