From c25bf38efecd573182c38dd4f014033c19c6131d Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Thu, 10 Oct 2024 14:22:45 +0200 Subject: [PATCH] Fix bootloader version check --- cflib/bootloader/__init__.py | 10 +++++++--- setup.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cflib/bootloader/__init__.py b/cflib/bootloader/__init__.py index 14ba1bf5a..4d723b04d 100644 --- a/cflib/bootloader/__init__.py +++ b/cflib/bootloader/__init__.py @@ -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 @@ -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) @@ -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 != diff --git a/setup.py b/setup.py index ebfbc8c28..aae527cdd 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ 'libusb-package~=1.0', 'scipy~=1.7', 'numpy~=1.20', + 'packaging~=24.0', ], # $ pip install -e .[dev]