Skip to content

Commit dc0d606

Browse files
authored
Merge pull request #580 from bitcraze/rik/single-bin-multi-target
Enhance target handling in Bootloader to support multiple targets
2 parents 22b794d + 5897611 commit dc0d606

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

cflib/bootloader/__init__.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,27 @@ def _get_flash_artifacts_from_zip(self, filename):
398398
# Handle version 1 of manifest where prerequisites for nRF soft-devices are not specified
399399
requires = [] if 'requires' not in metadata else metadata['requires']
400400
provides = [] if 'provides' not in metadata else metadata['provides']
401-
if len(requires) == 0 and metadata['target'] == 'nrf51' and metadata['type'] == 'fw':
402-
requires.append('sd-s110')
403-
# If there is no requires for the nRF51 fw target then we also need the legacy s110
404-
# so add this to the file list afterwards
405-
add_legacy_nRF51_s110 = True
406-
407-
target = Target(metadata['platform'], metadata['target'], metadata['type'],
408-
provides, requires)
409-
flash_artifacts.append(FlashArtifact(content, target, metadata['release']))
401+
402+
# Support both single target (string) and multiple targets (list)
403+
target_value = metadata['target']
404+
target_list = target_value if isinstance(target_value, list) else [target_value]
405+
406+
for target_name in target_list:
407+
logger.debug('Processing target: {}'.format(target_name))
408+
# Create copies for each target to avoid shared mutable state
409+
target_requires = requires.copy()
410+
target_provides = provides.copy()
411+
412+
# Check for legacy nRF51 requirement
413+
if len(target_requires) == 0 and target_name == 'nrf51' and metadata['type'] == 'fw':
414+
target_requires.append('sd-s110')
415+
# If there is no requires for the nRF51 fw target then we also need the legacy s110
416+
# so add this to the file list afterwards
417+
add_legacy_nRF51_s110 = True
418+
419+
target = Target(metadata['platform'], target_name, metadata['type'],
420+
target_provides, target_requires)
421+
flash_artifacts.append(FlashArtifact(content, target, metadata['release']))
410422

411423
if add_legacy_nRF51_s110:
412424
print('Legacy format detected for manifest, adding s110+bl binary from distro')

0 commit comments

Comments
 (0)