From b715281d3d9f3fc19ccfeb4a5fa8eaa6367bb920 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Mon, 21 Aug 2023 20:15:38 +0900 Subject: [PATCH 1/6] zephyrSerial: Fix misdetection arduino_serial1 DT_NODE_EXISTS value is true even if the status is disabled, so it caused misdetection. Use DT_NODE_HAS_STATUS to detect the status of the arduino_serial1 node is ok. Signed-off-by: TOKITA Hiroshi --- cores/arduino/zephyrSerial.cpp | 2 +- cores/arduino/zephyrSerial.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/arduino/zephyrSerial.cpp b/cores/arduino/zephyrSerial.cpp index f9d79f1c4..d25682679 100644 --- a/cores/arduino/zephyrSerial.cpp +++ b/cores/arduino/zephyrSerial.cpp @@ -186,7 +186,7 @@ arduino::ZephyrSerial Serial(DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), serials, DECLARE_SERIAL_N) #endif // PROP_LEN(serials) > 1 -#elif DT_NODE_EXISTS(DT_NODELABEL(arduino_serial)) +#elif DT_NODE_HAS_STATUS(DT_NODELABEL(arduino_serial), okay) /* If serials node is not defined, tries to use arduino_serial */ arduino::ZephyrSerial Serial(DEVICE_DT_GET(DT_NODELABEL(arduino_serial))); #else diff --git a/cores/arduino/zephyrSerial.h b/cores/arduino/zephyrSerial.h index 72703504c..b62e54f64 100644 --- a/cores/arduino/zephyrSerial.h +++ b/cores/arduino/zephyrSerial.h @@ -92,7 +92,7 @@ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), serials, DECLARE_EXTERN_SERIAL_N) #undef EXTERN_SERIAL_N #undef SERIAL_DEFINED_0 #endif -#elif DT_NODE_EXISTS(DT_NODELABEL(arduino_serial)) +#elif DT_NODE_HAS_STATUS(DT_NODELABEL(arduino_serial), okay) extern arduino::ZephyrSerial Serial; #else extern arduino::ZephyrSerialStub Serial; From 057eb71ed85e2de4b7ee640212ab0e50eeab99b9 Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Sat, 16 Sep 2023 23:04:42 +0530 Subject: [PATCH 2/6] workflow: Fix the PR review CI Improving checkpatch to function properly, as it earlier did not catch errors properly. One such incident was brought to light when a missing SOB went undetected. Ensure that such errors are caught when the PRs are raised itself. Signed-off-by: Dhruva Gole --- .github/workflows/checkpatch.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/checkpatch.yml b/.github/workflows/checkpatch.yml index f2a407a14..c3cba500a 100644 --- a/.github/workflows/checkpatch.yml +++ b/.github/workflows/checkpatch.yml @@ -1,6 +1,6 @@ # This is a basic workflow to help you get started with Actions -name: CI +name: checkpatch review # Controls when the workflow will run on: @@ -15,15 +15,16 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on + my_review: + name: checkpatch review runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - name: checkpatch.pl PR review - uses: webispy/checkpatch-action@v8 + - name: 'Calculate PR commits + 1' + run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: ${{ env.PR_FETCH_DEPTH }} + - name: Run checkpatch review + uses: webispy/checkpatch-action@v9 From 10f4816ebd26e16eba3e0021ff01b8343586b6d7 Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Sat, 30 Sep 2023 23:11:59 +0530 Subject: [PATCH 3/6] Kconfig: Remove redundant CPLUSPLUS Get rid of the redundant imply CPLUSPLUS from Kconfig Signed-off-by: Dhruva Gole --- Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/Kconfig b/Kconfig index 4fcf7746e..ebc5f1b76 100644 --- a/Kconfig +++ b/Kconfig @@ -8,7 +8,6 @@ config ARDUINO_API bool "ARDUINO_API" imply CPLUSPLUS imply GPIO - imply CPLUSPLUS imply I2C imply NEWLIB_LIBC_FLOAT_PRINTF imply CBPRINTF_FP_SUPPORT From e2a18d03b1e960a06ecedce20baed3dcc30214cb Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Sun, 1 Oct 2023 00:00:57 +0530 Subject: [PATCH 4/6] variants: Add native_posix variant support Add support for native_posix in limited capacity Signed-off-by: Dhruva Gole --- variants/native_posix/native_posix.overlay | 7 +++++++ variants/native_posix/native_posix_pinmap.h | 12 ++++++++++++ variants/variants.h | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 variants/native_posix/native_posix.overlay create mode 100644 variants/native_posix/native_posix_pinmap.h diff --git a/variants/native_posix/native_posix.overlay b/variants/native_posix/native_posix.overlay new file mode 100644 index 000000000..b4a80ad36 --- /dev/null +++ b/variants/native_posix/native_posix.overlay @@ -0,0 +1,7 @@ +/ { + zephyr,user { + digital-pin-gpios = <&gpio0 0 0>; + serial = <&uart0>; + i2cs = <&i2c0>; + }; +}; diff --git a/variants/native_posix/native_posix_pinmap.h b/variants/native_posix/native_posix_pinmap.h new file mode 100644 index 000000000..e554d29f9 --- /dev/null +++ b/variants/native_posix/native_posix_pinmap.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2022 Dhruva Gole + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* All the pins that are 100 + x are gpio1 pins and < 100 are in gpio0 */ +#pragma once +#include +#include +#include + diff --git a/variants/variants.h b/variants/variants.h index 9b7bc7dc0..e27084e20 100644 --- a/variants/variants.h +++ b/variants/variants.h @@ -23,6 +23,9 @@ #ifdef CONFIG_BOARD_CC3220SF_LAUNCHXL #include "cc3220sf_launchxl_pinmap.h" #endif // CONFIG_BOARD_CC3220SF_LAUNCHXL +#ifdef CONFIG_BOARD_NATIVE_POSIX +#include "native_posix_pinmap.h" +#endif // CONFIG_BOARD_NATIVE_POSIX #define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \ (((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && \ From 04c18210e41f84f1c0a0a76cf760cbe907c7e06b Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Sun, 1 Oct 2023 00:02:27 +0530 Subject: [PATCH 5/6] HACK: Get native_posix to build Get native_posix to build somehow and work as a POC. Need to work on additional support Signed-off-by: Dhruva Gole --- Kconfig | 4 ++-- variants/native_posix/native_posix_pinmap.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Kconfig b/Kconfig index ebc5f1b76..99989f691 100644 --- a/Kconfig +++ b/Kconfig @@ -6,13 +6,13 @@ config ARDUINO_API bool "ARDUINO_API" - imply CPLUSPLUS + # imply CPLUSPLUS imply GPIO imply I2C imply NEWLIB_LIBC_FLOAT_PRINTF imply CBPRINTF_FP_SUPPORT imply RING_BUFFER - select UART_INTERRUPT_DRIVEN + # select UART_INTERRUPT_DRIVEN default n if ARDUINO_API diff --git a/variants/native_posix/native_posix_pinmap.h b/variants/native_posix/native_posix_pinmap.h index e554d29f9..48517b4dc 100644 --- a/variants/native_posix/native_posix_pinmap.h +++ b/variants/native_posix/native_posix_pinmap.h @@ -8,5 +8,6 @@ #pragma once #include #include +#include #include From eb80233cbfea03c5b9c857b549fa33f708c709cf Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Wed, 11 Oct 2023 23:35:01 +0530 Subject: [PATCH 6/6] sample: Hello arduino: VS Code and gdb demo Demo VS Code and gdb step through code and build with a single button click! Signed-off-by: Dhruva Gole --- samples/hello_arduino/.vscode/launch.json | 19 +++++++++++ samples/hello_arduino/.vscode/settings.json | 11 +++++++ samples/hello_arduino/.vscode/tasks.json | 36 +++++++++++++++++++++ samples/hello_arduino/prj.conf | 5 ++- 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 samples/hello_arduino/.vscode/launch.json create mode 100644 samples/hello_arduino/.vscode/settings.json create mode 100644 samples/hello_arduino/.vscode/tasks.json diff --git a/samples/hello_arduino/.vscode/launch.json b/samples/hello_arduino/.vscode/launch.json new file mode 100644 index 000000000..b75d95df3 --- /dev/null +++ b/samples/hello_arduino/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "device": "native_posix", + "cwd": "${workspaceFolder}", + "program": "/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/samples/hello_arduino/build/zephyr/zephyr.exe", + "request": "launch", + "type": "cppdbg", + "runToEntryPoint": "main", + "gdbPath": "/usr/bin/gdb", + "preLaunchTask": "West Build" + }, + ] +} \ No newline at end of file diff --git a/samples/hello_arduino/.vscode/settings.json b/samples/hello_arduino/.vscode/settings.json new file mode 100644 index 000000000..c22a78306 --- /dev/null +++ b/samples/hello_arduino/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + // Hush CMake + "cmake.configureOnOpen": false, + + // IntelliSense + "C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json", + + // File Associations + "files.associations": { + } +} \ No newline at end of file diff --git a/samples/hello_arduino/.vscode/tasks.json b/samples/hello_arduino/.vscode/tasks.json new file mode 100644 index 000000000..8bb53dd19 --- /dev/null +++ b/samples/hello_arduino/.vscode/tasks.json @@ -0,0 +1,36 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "West Build", + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "linux": { + "command": "/home/dhruva/zephyrproject/.venv/bin/west" + }, + "args": [ + "build", + "-p", + "always", + "-b", + "native_posix" + ], + "problemMatcher": [ + "$gcc" + ] + + } + ], + "inputs": [ + { + "id": "board", + "type": "promptString", + "default": "native_posix", + "description": "See https://docs.zephyrproject.org/latest/boards/index.html" + }, + ] + +} \ No newline at end of file diff --git a/samples/hello_arduino/prj.conf b/samples/hello_arduino/prj.conf index df5e26f70..e2f8ca50e 100644 --- a/samples/hello_arduino/prj.conf +++ b/samples/hello_arduino/prj.conf @@ -1,2 +1,5 @@ CONFIG_CPLUSPLUS=y -CONFIG_ARDUINO_API=y \ No newline at end of file +CONFIG_ARDUINO_API=y +# CONFIG_ZTEST=y +# CONFIG_ZTEST_NEW_API=y +