Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions boards/nrf52840_dongle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"build": {
"core": "nRF5",
"cpu": "cortex-m4",
"f_cpu": "64000000L",
"mcu": "nrf52840",
"variant": "nRF52840DONGLE",
"zephyr": {
"variant": "nrf52840dongle_nrf52840"
}
},
"connectivity": [
"bluetooth"
],
"debug": {
"jlink_device": "nRF52840_xxAA",
"svd_path": "nrf52840.svd"
},
"frameworks": [
"zephyr"
],
"name": "Nordic nRF52840 Dongle",
"upload": {
"maximum_ram_size": 262144,
"maximum_size": 1048576,
"protocol": "nrfutil",
"protocols": [
"nrfutil"
]
},
"url": "https://www.nordicsemi.com/Products/Development-hardware/nRF52840-Dongle",
"vendor": "Nordic"
}

44 changes: 42 additions & 2 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
use_adafruit = board.get(
"build.bsp.name", "nrf5") == "adafruit" and "arduino" in env.get("PIOFRAMEWORK", [])

target_dongle = board.get("build.variant") == "nRF52840DONGLE"

env.Replace(
AR="arm-none-eabi-ar",
AS="arm-none-eabi-as",
Expand Down Expand Up @@ -171,6 +173,28 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
)
)

if target_dongle:
env.Append(
BUILDERS=dict(
PackageDfu=Builder(
action=env.VerboseAction(" ".join([
"nrfutil",
"pkg",
"generate",
"--hw-version",
"52",
"--sd-req",
"0x00",
"--application-version",
"0",
"--application",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".zip"
)
)
)

if not env.get("PIOFRAMEWORK"):
env.SConscript("frameworks/_bare.py")
Expand Down Expand Up @@ -198,7 +222,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
target_firm = env.MergeHex(
join("$BUILD_DIR", "${PROGNAME}"),
env.ElfToHex(join("$BUILD_DIR", "userfirmware"), target_elf))
elif "nrfutil" == upload_protocol and use_adafruit:
elif "nrfutil" == upload_protocol and (use_adafruit or target_dongle):
target_firm = env.PackageDfu(
join("$BUILD_DIR", "${PROGNAME}"),
env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf))
Expand Down Expand Up @@ -318,7 +342,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
)
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]

elif upload_protocol == "nrfutil":
elif upload_protocol == "nrfutil" and use_adafruit:
env.Replace(
UPLOADER=join(platform.get_package_dir(
"tool-adafruit-nrfutil") or "", "adafruit-nrfutil.py"),
Expand All @@ -338,6 +362,22 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
]

elif upload_protocol == "nrfutil" and target_dongle:
env.Replace(
UPLOADER="nrfutil",
UPLOADERFLAGS=[
"dfu",
"serial",
"-p",
"$UPLOAD_PORT"
],
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -pkg $SOURCE'
)
upload_actions = [
env.VerboseAction(BeforeUpload, "Looking for upload port..."),
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
]

elif upload_protocol == "sam-ba":
env.Replace(
UPLOADER="bossac",
Expand Down