Skip to content

Commit

Permalink
Add n-able-nrfutil to replace the deprecated nrfutil.
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Jun 20, 2024
1 parent fd9d12f commit 18b5118
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 0 additions & 5 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ def AfterUpload(target, source, env): # pylint: disable=W0613,W0621
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]

elif upload_protocol == "nrfutil":
try:
import nordicsemi
except ImportError:
env.Execute('$PYTHONEXE -m pip install -U --force-reinstall nrfutil==6.1.4')

env.Replace(
UPLOADER="nrfutil",
UPLOADERFLAGS=[
Expand Down
16 changes: 15 additions & 1 deletion platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#import copy
import os
import sys
import subprocess

from platformio.public import PlatformBase

Expand All @@ -26,6 +27,12 @@ class NablePlatform(PlatformBase):
def is_embedded(self):
return True

def install_package(self, package):
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-U", package])
except subprocess.CalledProcessError as e:
sys.stderr.write("Error: Could not install package '%s': %s\n" % (package, e))

def configure_default_packages(self, variables, targets):
upload_protocol = ""
board = variables.get("board")
Expand All @@ -41,6 +48,13 @@ def configure_default_packages(self, variables, targets):
if upload_protocol == "adafruit-nrfutil":
self.packages["tool-adafruit-nrfutil"]["optional"] = False

if upload_protocol == "nrfutil":
try:
import nordicsemi
except ImportError:
nrfutil_whl = os.path.join(self.get_dir(), "tools", "n_able_nrfutil-1.0.0-py3-none-any.whl")
self.install_package(nrfutil_whl)

# configure J-LINK tool
jlink_conds = [
"jlink" in variables.get(option, "")
Expand Down
Binary file added tools/n_able_nrfutil-1.0.0-py3-none-any.whl
Binary file not shown.

0 comments on commit 18b5118

Please sign in to comment.