diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index ec2d27c..89efa05 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/freedom-e-sdk_freertos-blinky" - "examples/freedom-e-sdk_freertos-blinky-system-view" diff --git a/builder/main.py b/builder/main.py index cedcf28..d876c77 100644 --- a/builder/main.py +++ b/builder/main.py @@ -129,7 +129,7 @@ def _jlink_cmd_script(env, source): UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe", UPLOADERFLAGS=[ "-device", env.BoardConfig().get("debug", {}).get("jlink_device"), - "-speed", "1000", + "-speed", env.GetProjectOption("debug_speed", "4000"), "-if", "JTAG", "-jtagconf", "-1,-1", "-autoconnect", "1", @@ -158,6 +158,10 @@ def _jlink_cmd_script(env, source): ] tool_args.extend( debug_tools.get(upload_protocol).get("server").get("arguments", [])) + if env.GetProjectOption("debug_speed"): + tool_args.extend( + ["-c", "adapter_khz %s" % env.GetProjectOption("debug_speed")] + ) tool_args.extend([ "-c", "program {$SOURCE} %s verify; shutdown;" % board_config.get("upload").get("flash_start", "") 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/examples/zephyr-synchronization/src/main.c b/examples/zephyr-synchronization/src/main.c index d6905d0..fb60a2e 100644 --- a/examples/zephyr-synchronization/src/main.c +++ b/examples/zephyr-synchronization/src/main.c @@ -36,22 +36,31 @@ void helloLoop(const char *my_name, struct k_sem *my_sem, struct k_sem *other_sem) { const char *tname; + uint8_t cpu; + struct k_thread *current_thread; while (1) { /* take my semaphore */ k_sem_take(my_sem, K_FOREVER); + current_thread = k_current_get(); + tname = k_thread_name_get(current_thread); +#if CONFIG_SMP + cpu = arch_curr_cpu()->id; +#else + cpu = 0; +#endif /* say "hello" */ - tname = k_thread_name_get(k_current_get()); - if (tname != NULL && tname[0] != '\0') { - printk("%s: Hello World from %s!\n", - tname, CONFIG_BOARD); + if (tname == NULL) { + printk("%s: Hello World from cpu %d on %s!\n", + my_name, cpu, CONFIG_BOARD); } else { - printk("%s: Hello World from %s!\n", - my_name, CONFIG_BOARD); + printk("%s: Hello World from cpu %d on %s!\n", + tname, cpu, CONFIG_BOARD); } /* wait a while, then let other thread have a turn */ + k_busy_wait(100000); k_msleep(SLEEPTIME); k_sem_give(other_sem); } @@ -89,9 +98,14 @@ void threadA(void *dummy1, void *dummy2, void *dummy3) /* spawn threadB */ k_tid_t tid = k_thread_create(&threadB_data, threadB_stack_area, STACKSIZE, threadB, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, K_FOREVER); k_thread_name_set(tid, "thread_b"); +#if CONFIG_SCHED_CPU_MASK + k_thread_cpu_mask_disable(&threadB_data, 1); + k_thread_cpu_mask_enable(&threadB_data, 0); +#endif + k_thread_start(&threadB_data); /* invoke routine to ping-pong hello messages with threadB */ helloLoop(__func__, &threadA_sem, &threadB_sem); diff --git a/examples/zephyr-synchronization/zephyr/prj.conf b/examples/zephyr-synchronization/zephyr/prj.conf index fb9f4cd..f31f3e0 100644 --- a/examples/zephyr-synchronization/zephyr/prj.conf +++ b/examples/zephyr-synchronization/zephyr/prj.conf @@ -1,3 +1,3 @@ CONFIG_STDOUT_CONSOLE=y # enable to use thread names -#CONFIG_THREAD_NAME=y +CONFIG_THREAD_NAME=y diff --git a/platform.json b/platform.json index eb5b2d2..0b64494 100644 --- a/platform.json +++ b/platform.json @@ -5,9 +5,9 @@ "homepage": "https://sifive.com", "license": "Apache-2.0", "keywords": [ - "dev-platform", - "SiFive", - "RISC-V" + "dev-platform", + "SiFive", + "RISC-V" ], "engines": { "platformio": "^5" @@ -16,7 +16,7 @@ "type": "git", "url": "https://github.com/platformio/platform-sifive.git" }, - "version": "3.0.1", + "version": "4.0.0", "frameworks": { "freedom-e-sdk": { "package": "framework-freedom-e-sdk", @@ -52,7 +52,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~2.20400.0" + "version": "~2.20500.0" }, "framework-zephyr-canopennode": { "optional": true, @@ -62,47 +62,47 @@ "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-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, @@ -112,12 +112,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, @@ -137,12 +142,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-openocd-riscv": { "optional": true, diff --git a/platform.py b/platform.py index 417fc06..bdeb8a9 100644 --- a/platform.py +++ b/platform.py @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os.path import isfile, join -from platform import system +import copy +import os +import platform from platformio.managers.platform import PlatformBase from platformio.util import get_systype @@ -28,7 +29,7 @@ def configure_default_packages(self, variables, targets): "tool-cmake", "tool-dtc", "tool-ninja"): self.packages[p]["optional"] = False if "windows" not in get_systype(): - self.packages['tool-gperf']['optional'] = False + self.packages["tool-gperf"]["optional"] = False upload_protocol = variables.get( "upload_protocol", @@ -36,7 +37,7 @@ def configure_default_packages(self, variables, targets): "upload.protocol", "")) if upload_protocol == "renode" and "debug" not in targets: - self.packages['tool-renode']['type'] = "uploader" + self.packages["tool-renode"]["type"] = "uploader" return PlatformBase.configure_default_packages(self, variables, targets) @@ -56,7 +57,7 @@ def _add_default_debug_tools(self, board): upload_protocols = board.manifest.get("upload", {}).get("protocols", []) if "tools" not in debug: - debug['tools'] = {} + debug["tools"] = {} tools = ("jlink", "qemu", "renode", "ftdi", "minimodule", "olimex-arm-usb-tiny-h", "olimex-arm-usb-ocd-h", @@ -65,25 +66,24 @@ def _add_default_debug_tools(self, board): if tool in ("qemu", "renode"): if not debug.get("%s_machine" % tool): continue - elif (tool not in upload_protocols or tool in debug['tools']): + elif (tool not in upload_protocols or tool in debug["tools"]): continue if tool == "jlink": assert debug.get("jlink_device"), ( "Missed J-Link Device ID for %s" % board.id) - debug['tools'][tool] = { + debug["tools"][tool] = { "server": { "package": "tool-jlink", "arguments": [ "-singlerun", "-if", "JTAG", "-select", "USB", - "-speed", "1000", "-jtagconf", "-1,-1", "-device", debug.get("jlink_device"), "-port", "2331" ], "executable": ("JLinkGDBServerCL.exe" - if system() == "Windows" else + if platform.system() == "Windows" else "JLinkGDBServer") }, "onboard": tool in debug.get("onboard_tools", []) @@ -91,7 +91,7 @@ def _add_default_debug_tools(self, board): elif tool == "qemu": machine64bit = "64" in board.get("build.mabi") - debug['tools'][tool] = { + debug["tools"][tool] = { "server": { "package": "tool-qemu-riscv", "arguments": [ @@ -109,17 +109,17 @@ def _add_default_debug_tools(self, board): elif tool == "renode": assert debug.get("renode_machine"), ( "Missing Renode machine ID for %s" % board.id) - debug['tools'][tool] = { + debug["tools"][tool] = { "server": { "package": "tool-renode", "arguments": [ "--disable-xwt", - "-e", "include @%s" % join( + "-e", "include @%s" % os.path.join( "scripts", "single-node", debug.get("renode_machine")), "-e", "machine StartGdbServer 3333 True" ], "executable": ("bin/Renode" - if system() == "Windows" else + if platform.system() == "Windows" else "renode"), "ready_pattern": "GDB server with all CPUs started on port" @@ -131,20 +131,20 @@ def _add_default_debug_tools(self, board): "-s", "$PACKAGE_DIR/share/openocd/scripts" ] sdk_dir = self.get_package_dir("framework-freedom-e-sdk") - board_cfg = join( + board_cfg = os.path.join( sdk_dir or "", "bsp", "sifive-%s" % board.id, "openocd.cfg") - if isfile(board_cfg): + if os.path.isfile(board_cfg): server_args.extend(["-f", board_cfg]) elif board.id == "e310-arty": server_args.extend([ - "-f", join("interface", "ftdi", "%s.cfg" % ( + "-f", os.path.join("interface", "ftdi", "%s.cfg" % ( "arty-onboard-ftdi" if tool == "ftdi" else tool)), - "-f", join( + "-f", os.path.join( sdk_dir or "", "bsp", "freedom-e310-arty", "openocd.cfg") ]) else: assert "Unknown debug configuration", board.id - debug['tools'][tool] = { + debug["tools"][tool] = { "server": { "package": "tool-openocd-riscv", "executable": "bin/openocd", @@ -154,5 +154,21 @@ def _add_default_debug_tools(self, board): "init_cmds": debug.get("init_cmds", None) } - board.manifest['debug'] = debug + 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_khz %s" % adapter_speed] + ) + elif "jlink" in server_executable: + debug_options["server"]["arguments"].extend( + ["-speed", adapter_speed] + ) + + return debug_options