diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 91af090..bb5f55e 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-16.04, windows-latest, macos-latest] - python-version: [2.7, 3.7] + python-version: [3.7] example: - "examples/arduino-blink" - "examples/arduino-ble-led" diff --git a/boards/nrf51_dk.json b/boards/nrf51_dk.json index d858bf0..b138b79 100644 --- a/boards/nrf51_dk.json +++ b/boards/nrf51_dk.json @@ -10,7 +10,7 @@ "mcu": "nrf51822", "variant": "PCA1000X", "zephyr": { - "variant": "nrf51_pca10028" + "variant": "nrf51dk_nrf51422" } }, "connectivity": [ diff --git a/boards/nrf51_dongle.json b/boards/nrf51_dongle.json index 17485b4..f7fe651 100644 --- a/boards/nrf51_dongle.json +++ b/boards/nrf51_dongle.json @@ -10,7 +10,7 @@ "mcu": "nrf51822", "variant": "nRF51Dongle", "zephyr": { - "variant": "nrf51_pca10031" + "variant": "nrf51dongle_nrf51422" } }, "connectivity": [ diff --git a/builder/main.py b/builder/main.py index 031fc1d..e5437ec 100644 --- a/builder/main.py +++ b/builder/main.py @@ -206,7 +206,7 @@ def _jlink_cmd_script(env, source): UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe", UPLOADERFLAGS=[ "-device", board.get("debug", {}).get("jlink_device"), - "-speed", "4000", + "-speed", env.GetProjectOption("debug_speed", "4000"), "-if", ("jtag" if upload_protocol == "jlink-jtag" else "swd"), "-autoconnect", "1", "-NoGui", "1" @@ -221,6 +221,10 @@ def _jlink_cmd_script(env, source): ] openocd_args.extend( debug_tools.get(upload_protocol).get("server").get("arguments", [])) + if env.GetProjectOption("debug_speed"): + openocd_args.extend( + ["-c", "adapter speed %s" % env.GetProjectOption("debug_speed")] + ) openocd_args.extend([ "-c", "program {$SOURCE} %s verify reset; shutdown;" % board.get("upload.offset_address", "") diff --git a/examples/zephyr-ble-eddystone/src/main.c b/examples/zephyr-ble-eddystone/src/main.c index 405fb45..cfc8f83 100644 --- a/examples/zephyr-ble-eddystone/src/main.c +++ b/examples/zephyr-ble-eddystone/src/main.c @@ -426,16 +426,27 @@ static ssize_t read_adv_data(struct bt_conn *conn, static int eds_slot_restart(struct eds_slot *slot, uint8_t type) { int err; + char addr_s[BT_ADDR_LE_STR_LEN]; + bt_addr_le_t addr = {0}; /* Restart advertising */ bt_le_adv_stop(); if (type == EDS_TYPE_NONE) { + struct bt_le_oob oob; + /* Restore connectable if slot */ + if (bt_le_oob_get_local(BT_ID_DEFAULT, &oob) == 0) { + addr = oob.addr; + } + err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0); } else { - err = bt_le_adv_start(BT_LE_ADV_NCONN_NAME, slot->ad, + size_t count = 1; + + bt_id_get(&addr, &count); + err = bt_le_adv_start(BT_LE_ADV_NCONN_IDENTITY, slot->ad, ARRAY_SIZE(slot->ad), NULL, 0); } @@ -444,6 +455,9 @@ static int eds_slot_restart(struct eds_slot *slot, uint8_t type) return err; } + bt_addr_le_to_str(&addr, addr_s, sizeof(addr_s)); + printk("Advertising as %s\n", addr_s); + slot->type = type; return 0; @@ -619,6 +633,9 @@ BT_GATT_SERVICE_DEFINE(eds_svc, static void bt_ready(int err) { + char addr_s[BT_ADDR_LE_STR_LEN]; + struct bt_le_oob oob; + if (err) { printk("Bluetooth init failed (err %d)\n", err); return; @@ -633,6 +650,11 @@ static void bt_ready(int err) return; } + /* Restore connectable if slot */ + bt_le_oob_get_local(BT_ID_DEFAULT, &oob); + bt_addr_le_to_str(&oob.addr, addr_s, sizeof(addr_s)); + printk("Initial advertising as %s\n", addr_s); + k_delayed_work_submit(&idle_work, EDS_IDLE_TIMEOUT); printk("Configuration mode: waiting connections...\n"); @@ -641,7 +663,7 @@ static void bt_ready(int err) static void idle_timeout(struct k_work *work) { if (eds_slots[eds_active_slot].type == EDS_TYPE_NONE) { - printk("Switching to Beacon mode.\n"); + printk("Switching to Beacon mode %u.\n", eds_active_slot); eds_slot_restart(&eds_slots[eds_active_slot], EDS_TYPE_URL); } } diff --git a/examples/zephyr-blink/src/main.c b/examples/zephyr-blink/src/main.c index d625f26..e2fbfd3 100644 --- a/examples/zephyr-blink/src/main.c +++ b/examples/zephyr-blink/src/main.c @@ -9,7 +9,6 @@ #include #include - /* 1000 msec = 1 sec */ #define SLEEP_TIME_MS 1000 @@ -19,25 +18,20 @@ #if DT_NODE_HAS_STATUS(LED0_NODE, okay) #define LED0 DT_GPIO_LABEL(LED0_NODE, gpios) #define PIN DT_GPIO_PIN(LED0_NODE, gpios) -#if DT_PHA_HAS_CELL(LED0_NODE, gpios, flags) #define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) -#endif #else /* A build error here means your board isn't set up to blink an LED. */ #error "Unsupported board: led0 devicetree alias is not defined" #define LED0 "" #define PIN 0 -#endif - -#ifndef FLAGS #define FLAGS 0 #endif void main(void) { - struct device *dev; + const struct device *dev; bool led_is_on = true; - int ret = 0; + int ret; dev = device_get_binding(LED0); if (dev == NULL) { diff --git a/platform.json b/platform.json index 4db2df0..5e0e996 100644 --- a/platform.json +++ b/platform.json @@ -5,11 +5,11 @@ "homepage": "https://www.nordicsemi.com/eng/Products/nRF51-Series-SoC", "license": "Apache-2.0", "keywords": [ - "dev-platform", - "ARM", - "Cortex-M", - "Nordic Semiconductor", - "nRF51" + "dev-platform", + "ARM", + "Cortex-M", + "Nordic Semiconductor", + "nRF51" ], "engines": { "platformio": "^5" @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/platformio/platform-nordicnrf51.git" }, - "version": "6.1.0", + "version": "7.0.0", "frameworks": { "arduino": { "package": "framework-arduinonordicnrf5", @@ -37,7 +37,10 @@ "toolchain-gccarmnoneeabi": { "type": "toolchain", "owner": "platformio", - "version": ">=1.60301.0,<1.80000.0" + "version": ">=1.60301.0,<1.80000.0", + "optionalVersions": [ + "~1.80201.0" + ] }, "framework-arduinonordicnrf5": { "type": "framework", @@ -55,12 +58,12 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~2.20400.0" + "version": "~2.20500.0" }, "framework-zephyr-cmsis": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.542b2296e6" + "version": "0.0.0-alpha+sha.c3bd2094f9" }, "framework-zephyr-canopennode": { "optional": true, @@ -70,52 +73,52 @@ "framework-zephyr-civetweb": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.99129c5efc" + "version": "0.0.0-alpha+sha.e6903b80c0" }, "framework-zephyr-fatfs": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.13697783bf" + "version": "0.0.0-alpha+sha.1d1fcc725a" }, "framework-zephyr-hal-nordic": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.d8a6ea9695" + "version": "0.0.0-alpha+sha.f0d54d8449" }, "framework-zephyr-hal-st": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.5b3ec3e182" + "version": "0.0.0-alpha+sha.b52fdbf4b6" }, "framework-zephyr-libmetal": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.0b23894a04" + "version": "0.0.0-alpha+sha.9d4ee2c3cf" }, "framework-zephyr-lvgl": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.928b61c7c8" + "version": "0.0.0-alpha+sha.31acbaa36e" }, "framework-zephyr-mbedtls": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.aef137b1af" + "version": "0.0.0-alpha+sha.24d84ecff1" }, "framework-zephyr-mcuboot": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.a5d79cf8cc" + "version": "0.0.0-alpha+sha.3fc59410b6" }, "framework-zephyr-mcumgr": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.5051f9d900" + "version": "0.0.0-alpha+sha.43845e883f" }, "framework-zephyr-open-amp": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.724f7e2a45" + "version": "0.0.0-alpha+sha.de1b85a130" }, "framework-zephyr-loramac-node": { "optional": true, @@ -125,12 +128,17 @@ "framework-zephyr-openthread": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.07f430dac6" + "version": "0.0.0-alpha+sha.1d668284a0" }, "framework-zephyr-segger": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.874d9e9696" + "version": "0.0.0-alpha+sha.38c79a447e" + }, + "framework-zephyr-sof": { + "optional": true, + "owner": "platformio", + "version": "0.0.0-alpha+sha.b5b772dd61" }, "framework-zephyr-tinycbor": { "optional": true, @@ -150,12 +158,17 @@ "framework-zephyr-mipi-sys-t": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.957d46bc3c" + "version": "0.0.0-alpha+sha.75e671550a" + }, + "framework-zephyr-tfm-mcuboot": { + "optional": true, + "owner": "platformio", + "version": "1.7.0-rc1" }, "framework-zephyr-trusted-firmware-m": { "optional": true, "owner": "platformio", - "version": "0.0.0-alpha+sha.143df67555" + "version": "0.0.0-alpha+sha.96340fb6c0" }, "tool-sreccat": { "owner": "platformio", diff --git a/platform.py b/platform.py index 914a677..c6d8e1f 100644 --- a/platform.py +++ b/platform.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from platform import system +import copy +import platform from platformio.managers.platform import PlatformBase from platformio.util import get_systype @@ -31,9 +32,9 @@ def configure_default_packages(self, variables, targets): if p.startswith("framework-zephyr-") or p in ( "tool-cmake", "tool-dtc", "tool-ninja"): self.packages[p]["optional"] = False - self.packages['toolchain-gccarmnoneeabi']['version'] = "~1.80201.0" + self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0" if "windows" not in get_systype(): - self.packages['tool-gperf']['optional'] = False + self.packages["tool-gperf"]["optional"] = False # configure J-LINK tool jlink_conds = [ @@ -69,15 +70,15 @@ def _add_default_debug_tools(self, board): upload_protocols = board.manifest.get("upload", {}).get( "protocols", []) if "tools" not in debug: - debug['tools'] = {} + debug["tools"] = {} # J-Link / ST-Link / BlackMagic Probe / CMSIS-DAP for link in ("blackmagic", "jlink", "stlink", "cmsis-dap"): - if link not in upload_protocols or link in debug['tools']: + if link not in upload_protocols or link in debug["tools"]: continue if link == "blackmagic": - debug['tools']['blackmagic'] = { + debug["tools"]["blackmagic"] = { "hwids": [["0x1d50", "0x6018"]], "require_debug_port": True } @@ -85,7 +86,7 @@ def _add_default_debug_tools(self, board): elif link == "jlink": assert debug.get("jlink_device"), ( "Missed J-Link Device ID for %s" % board.id) - debug['tools'][link] = { + debug["tools"][link] = { "server": { "package": "tool-jlink", "arguments": [ @@ -96,7 +97,7 @@ def _add_default_debug_tools(self, board): "-port", "2331" ], "executable": ("JLinkGDBServerCL.exe" - if system() == "Windows" else + if platform.system() == "Windows" else "JLinkGDBServer") } } @@ -112,7 +113,7 @@ def _add_default_debug_tools(self, board): "transport select hla_swd; set WORKAREASIZE 0x4000" ]) server_args.extend(["-f", "target/nrf51.cfg"]) - debug['tools'][link] = { + debug["tools"][link] = { "server": { "package": "tool-openocd", "executable": "bin/openocd", @@ -120,8 +121,24 @@ def _add_default_debug_tools(self, board): } } - debug['tools'][link]['onboard'] = link in debug.get("onboard_tools", []) - debug['tools'][link]['default'] = link in debug.get("default_tools", []) + debug["tools"][link]["onboard"] = link in debug.get("onboard_tools", []) + debug["tools"][link]["default"] = link in debug.get("default_tools", []) board.manifest['debug'] = debug return board + + def configure_debug_options(self, initial_debug_options, ide_data): + debug_options = copy.deepcopy(initial_debug_options) + server_executable = debug_options["server"]["executable"].lower() + adapter_speed = initial_debug_options.get("speed") + if adapter_speed: + if "openocd" in server_executable: + debug_options["server"]["arguments"].extend( + ["-c", "adapter speed %s" % adapter_speed] + ) + elif "jlink" in server_executable: + debug_options["server"]["arguments"].extend( + ["-speed", adapter_speed] + ) + + return debug_options