Skip to content

Commit

Permalink
Merge pull request #484 from bitcraze/ataffanel/bootloader_version_check
Browse files Browse the repository at this point in the history
Fix bootloader version check
  • Loading branch information
gemenerik authored Oct 10, 2024
2 parents 5840274 + c25bf38 commit 0e37042
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cflib/bootloader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
from typing import Optional
from typing import Tuple

from packaging.version import Version

from .boottypes import BootVersion
from .boottypes import TargetTypes
from .cloader import Cloader
Expand Down Expand Up @@ -202,10 +204,10 @@ def flash(self, filename: str, targets: List[Target], cf=None, enable_console_lo
update_contains_nrf_sd = any(x.target.type == 'bootloader+softdevice' for x in flash_artifacts)
current_nrf_bl_version = None
if self._cload.targets[TargetTypes.NRF51].version is not None:
current_nrf_bl_version = str(self._cload.targets[TargetTypes.NRF51].version)
provided_nrf_bl_version = self._get_provided_nrf51_bl_version(flash_artifacts)
current_nrf_bl_version = Version(str(self._cload.targets[TargetTypes.NRF51].version))
provided_nrf_bl_version = Version(self._get_provided_nrf51_bl_version(flash_artifacts))

print('nRF51 has: {} and requires {} and upgrade provides {}. Current bootloader version is [{}] but upgrade '
print('nRF51 has: {} and requires {} and upgrade provides {}. Current bootloader version is [{}] and upgrade '
'provides [{}]'.format(
current_nrf_sd_version, required_nrf_sd_version, provided_nrf_sd_version,
current_nrf_bl_version, provided_nrf_bl_version)
Expand Down Expand Up @@ -252,6 +254,8 @@ def flash(self, filename: str, targets: List[Target], cf=None, enable_console_lo
print('Reconnected to new bootloader')
self._cload.check_link_and_get_info()
self._cload.request_info_update(TargetTypes.NRF51)
else:
print('No need to flash nRF soft device')

# Remove the softdevice+bootloader from the list of artifacts to flash
flash_artifacts = [a for a in flash_artifacts if a.target.type !=
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'libusb-package~=1.0',
'scipy~=1.7',
'numpy~=1.20',
'packaging~=24.0',
],

# $ pip install -e .[dev]
Expand Down

0 comments on commit 0e37042

Please sign in to comment.