@@ -124,9 +124,11 @@ def __init__(self,
124
124
disable_ble : bool = False ,
125
125
enable_thread : bool = False ,
126
126
enable_wifi : bool = False ,
127
- disable_ipv4 : bool = False ,
128
127
enable_shell : bool = False ,
129
- enable_ota : bool = False ):
128
+ enable_ota : bool = False ,
129
+ enable_factory_data_build : bool = False ,
130
+ disable_pairing_autostart : bool = False ,
131
+ board_variant = None ):
130
132
super (NxpBuilder , self ).__init__ (
131
133
root = app .BuildRoot (root , board , os_env ),
132
134
runner = runner )
@@ -142,12 +144,14 @@ def __init__(self,
142
144
self .enable_lit = enable_lit
143
145
self .enable_rotating_id = enable_rotating_id
144
146
self .has_sw_version_2 = has_sw_version_2
145
- self .disable_ipv4 = disable_ipv4
146
147
self .disable_ble = disable_ble
147
148
self .enable_thread = enable_thread
148
149
self .enable_wifi = enable_wifi
149
150
self .enable_ota = enable_ota
150
151
self .enable_shell = enable_shell
152
+ self .enable_factory_data_build = enable_factory_data_build
153
+ self .disable_pairing_autostart = disable_pairing_autostart
154
+ self .board_variant = board_variant
151
155
152
156
def GnBuildArgs (self ):
153
157
args = []
@@ -199,18 +203,54 @@ def GnBuildArgs(self):
199
203
200
204
return args
201
205
202
- def WestBuildArgs (self ):
203
- args = []
206
+ def CmakeBuildFlags (self ):
207
+ flags = []
204
208
if self .enable_factory_data :
205
- args .append ('-DFILE_SUFFIX=fdata' )
209
+ if self .os_env == NxpOsUsed .ZEPHYR :
210
+ flags .append ('-DFILE_SUFFIX=fdata' )
211
+ else :
212
+ flags .append ("-DCONFIG_CHIP_FACTORY_DATA=true" )
206
213
207
214
if self .has_sw_version_2 :
208
- args .append ('-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2' )
215
+ flags .append ("-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2" )
216
+ flags .append ("-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING=\" 2.0\" " )
217
+
218
+ if self .enable_ota :
219
+ flags .append ("-DCONFIG_CHIP_OTA_REQUESTOR=true" )
220
+ if self .os_env == NxpOsUsed .FREERTOS and self .board == NxpBoard .RW61X :
221
+ flags .append ("-DCONFIG_BOOTLOADER_MCUBOOT=true" )
209
222
210
- build_args = " -- " + " " .join (args ) if len (args ) > 0 else ""
211
- return build_args
223
+ if self .disable_ble :
224
+ flags .append ("-DCONFIG_BT=false" )
225
+
226
+ if self .enable_wifi :
227
+ flags .append ('-DCONFIG_CHIP_WIFI=true' )
228
+
229
+ if self .enable_thread :
230
+ flags .append ("-DCONFIG_NET_L2_OPENTHREAD=true -DCONFIG_CHIP_IPV4=false" )
231
+
232
+ if self .enable_factory_data_build :
233
+ # Generate the factory data binary
234
+ flags .append ("-DCONFIG_CHIP_FACTORY_DATA_BUILD=true -DCONFIG_CHIP_FACTORY_DATA=true" )
235
+
236
+ if self .enable_shell :
237
+ flags .append ("-DCONFIG_CHIP_LIB_SHELL=true" )
238
+
239
+ if not self .disable_pairing_autostart :
240
+ flags .append ('-DCONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=true' )
241
+
242
+ if self .board_variant :
243
+ if self .board == NxpBoard .RW61X :
244
+ flag_board_variant = "-DCONFIG_BOARD_VARIANT=\" %s\" " % self .board_variant
245
+
246
+ flags .append (flag_board_variant )
247
+
248
+ build_flags = " " .join (flags ) if len (flags ) > 0 else ""
249
+
250
+ return build_flags
212
251
213
252
def generate (self ):
253
+ build_flags = self .CmakeBuildFlags ()
214
254
if self .os_env == NxpOsUsed .ZEPHYR :
215
255
if 'ZEPHYR_NXP_SDK_INSTALL_DIR' in os .environ :
216
256
cmd = 'export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_NXP_SDK_INSTALL_DIR"\n '
@@ -220,14 +260,13 @@ def generate(self):
220
260
cmd += 'export ZEPHYR_BASE="$ZEPHYR_NXP_BASE"\n '
221
261
else :
222
262
raise Exception ("ZEPHYR_NXP_BASE need to be set" )
223
- build_args = self .WestBuildArgs ()
224
263
cmd += '''
225
- west build -p --cmake-only -b {board_name} -d {out_folder} {example_folder} {build_args }
264
+ west build -p --cmake-only -b {board_name} -d {out_folder} {example_folder} {build_flags }
226
265
''' .format (
227
266
board_name = self .board .Name (self .os_env ),
228
267
out_folder = self .output_dir ,
229
268
example_folder = self .app .BuildRoot (self .code_root , self .board , self .os_env ),
230
- build_args = build_args ).strip ()
269
+ build_flags = build_flags ).strip ()
231
270
self ._Execute (['bash' , '-c' , cmd ], title = 'Generating ' + self .identifier )
232
271
else :
233
272
cmd = ''
@@ -243,29 +282,40 @@ def generate(self):
243
282
cmd += 'export NXP_K32W0_SDK_ROOT="' + str (p .sdk_storage_location_abspath ) + '" \n '
244
283
elif p .sdk_name == 'common' :
245
284
cmd += 'export NXP_SDK_ROOT="' + str (p .sdk_storage_location_abspath ) + '" \n '
246
- # add empty space at the end to avoid concatenation issue when there is no --args
247
- cmd += 'gn gen --check --fail-on-unused-args --export-compile-commands --root=%s ' % self .root
248
285
249
- extra_args = []
286
+ if self .board == NxpBoard .RW61X :
287
+ cmd += '''
288
+ cmake -GNinja {build_flags} -H{example_folder} -B{out_folder}
289
+ ''' .format (
290
+ build_flags = build_flags ,
291
+ example_folder = self .app .BuildRoot (self .code_root , self .board , self .os_env ),
292
+ out_folder = self .output_dir ).strip ()
293
+ self ._Execute (['bash' , '-c' , cmd ], title = 'Generating ' + self .identifier )
250
294
251
- if self .options .pw_command_launcher :
252
- extra_args .append ('pw_command_launcher="%s"' % self .options .pw_command_launcher )
295
+ else :
296
+ # add empty space at the end to avoid concatenation issue when there is no --args
297
+ cmd += 'gn gen --check --fail-on-unused-args --export-compile-commands --root=%s ' % self .root
253
298
254
- if self .options .enable_link_map_file :
255
- extra_args .append ('chip_generate_link_map_file=true' )
299
+ extra_args = []
300
+
301
+ if self .options .pw_command_launcher :
302
+ extra_args .append ('pw_command_launcher="%s"' % self .options .pw_command_launcher )
303
+
304
+ if self .options .enable_link_map_file :
305
+ extra_args .append ('chip_generate_link_map_file=true' )
256
306
257
- if self .options .pregen_dir :
258
- extra_args .append ('chip_code_pre_generated_directory="%s"' % self .options .pregen_dir )
307
+ if self .options .pregen_dir :
308
+ extra_args .append ('chip_code_pre_generated_directory="%s"' % self .options .pregen_dir )
259
309
260
- extra_args .extend (self .GnBuildArgs () or [])
261
- if extra_args :
262
- cmd += ' --args="%s' % ' ' .join (extra_args ) + '" '
310
+ extra_args .extend (self .GnBuildArgs () or [])
311
+ if extra_args :
312
+ cmd += ' --args="%s' % ' ' .join (extra_args ) + '" '
263
313
264
- cmd += self .output_dir
314
+ cmd += self .output_dir
265
315
266
- title = 'Generating ' + self .identifier
316
+ title = 'Generating ' + self .identifier
267
317
268
- self ._Execute (['bash' , '-c' , cmd ], title = title )
318
+ self ._Execute (['bash' , '-c' , cmd ], title = title )
269
319
270
320
def build_outputs (self ):
271
321
name = 'chip-%s-%s' % (self .board .Name (self .os_env ), self .app .NameSuffix ())
0 commit comments