Skip to content

Commit 18b5118

Browse files
committed
Add n-able-nrfutil to replace the deprecated nrfutil.
1 parent fd9d12f commit 18b5118

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

builder/main.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,6 @@ def AfterUpload(target, source, env): # pylint: disable=W0613,W0621
248248
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
249249

250250
elif upload_protocol == "nrfutil":
251-
try:
252-
import nordicsemi
253-
except ImportError:
254-
env.Execute('$PYTHONEXE -m pip install -U --force-reinstall nrfutil==6.1.4')
255-
256251
env.Replace(
257252
UPLOADER="nrfutil",
258253
UPLOADERFLAGS=[

platform.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
#import copy
15+
import os
1616
import sys
17+
import subprocess
1718

1819
from platformio.public import PlatformBase
1920

@@ -26,6 +27,12 @@ class NablePlatform(PlatformBase):
2627
def is_embedded(self):
2728
return True
2829

30+
def install_package(self, package):
31+
try:
32+
subprocess.check_call([sys.executable, "-m", "pip", "install", "-U", package])
33+
except subprocess.CalledProcessError as e:
34+
sys.stderr.write("Error: Could not install package '%s': %s\n" % (package, e))
35+
2936
def configure_default_packages(self, variables, targets):
3037
upload_protocol = ""
3138
board = variables.get("board")
@@ -41,6 +48,13 @@ def configure_default_packages(self, variables, targets):
4148
if upload_protocol == "adafruit-nrfutil":
4249
self.packages["tool-adafruit-nrfutil"]["optional"] = False
4350

51+
if upload_protocol == "nrfutil":
52+
try:
53+
import nordicsemi
54+
except ImportError:
55+
nrfutil_whl = os.path.join(self.get_dir(), "tools", "n_able_nrfutil-1.0.0-py3-none-any.whl")
56+
self.install_package(nrfutil_whl)
57+
4458
# configure J-LINK tool
4559
jlink_conds = [
4660
"jlink" in variables.get(option, "")
861 KB
Binary file not shown.

0 commit comments

Comments
 (0)