Giter VIP home page Giter VIP logo

gsoc-2022-arduino-core's Introduction

GSoC 2022 Project: Arduino Core API module for Zephyr

The Arduino Core API module for zephyr leverages the power of Zephyr under an Arduino-C++ style abtraction layer thus helping zephyr new-comers to start using it without worrying about learning about new APIs and libraries. See the project documentation folder for detailed documentation on these topics:

Adding Arduino Core API to Zephyr

  • Pre requisites: It is assumed that you have zephyrproject configured and installed on your system as per the official Get Started Guide. The recommended path to install is ~/zephyrproject as specified in the guide. If you have zephyr installed in a custom path you may need to make changes to the CMakeLists.txt file in the sample code directory when building these samples.

  • Add following entry to west.yml file in manifest/projects subtree of Zephyr:

# Arduino API repository.
- name: Arduino-Core-Zephyr
  path: modules/lib/Arduino-Zephyr-API
  revision: main
  url: https://github.com/zephyrproject-rtos/gsoc-2022-arduino-core
  • Then, clone the repository by running
west update
  • Note: For Linux users only there exists an install.sh script in this project that can be run to quickly link the ArduinoCore-API to this module. If you are able to run that script successfully then you can skip the next steps.

  • To "complete" the core you need to copy or symlink the api folder from the ArduinoCore-API repo to the target's cores/arduino folder:

$ git clone [email protected]:arduino/ArduinoCore-API # Any location
$ ln -s /<your>/<location>/ArduinoCore-API/api cores/arduino/.

The cores folder can be found at ~/zephyrproject/modules/lib/Arduino-Zephyr-API/cores.

Known Bug(s):

NOTE: You can skip this step as well if you ran install.sh.

  • While compiling with the ArduinoCore-API WCharacter.h produces many errors. The include of that file needs to be deleted from cores/arduino/api/ArduinoAPI.h (it is unused in this port.) We are looking into resolving the issue.

Maintainers:

License

Please note that the current license is Apache 2. Previously it was LGPL 2.1 but after careful review it was determined that no LGPL code or derivates was used and the more permissive license was chosen.

Additional Links

gsoc-2022-arduino-core's People

Contributors

ayush1325 avatar beriberikix avatar ddeletic avatar dhruvag2000 avatar soburi avatar szczys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gsoc-2022-arduino-core's Issues

Serial.print fails

The wrapper for Serial.print(val >> i & 1, BIN); and Serial.print(i, HEX); is probably missing which causes build failures.

zephyr build warnings: zephyr.h is deprecated, include <zephyr/kernel.h> instead

Whenever I try to build a sample using latest zephyr, I get a bunch of the following errors:

/home/dhruva/zephyrproject/zephyr/include/zephyr/zephyr.h:13:2: warning: #warning "<zephyr/zephyr.h> is deprecated, include <zephyr/kernel.h> instead" [-Wcpp]
   13 | #warning "<zephyr/zephyr.h> is deprecated, include <zephyr/kernel.h> instead"
      |  ^~~~~~~
[51/164] Building CXX object zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj
In file included from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/./Arduino.h:10,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp:7:
/home/dhruva/zephyrproject/zephyr/include/zephyr/zephyr.h:13:2: warning: #warning "<zephyr/zephyr.h> is deprecated, include <zephyr/kernel.h> instead" [-Wcpp]
   13 | #warning "<zephyr/zephyr.h> is deprecated, include <zephyr/kernel.h> instead"

Autogenerate board support

Note: this is currently out of scope for the GSoC season due to the time required to implement but I'm leaving this here for future contributions.

Arduino cores call each board a "variant" and place board-specific files in the variants folder. These files, plus specifying them in the boards.txt (see #10,) is what let's the Arduino tools know how to build, flash and generally interact with a board.

In the Zephyr world, a lot of that information is encapsulated in files like a board's device tree. It is theoretically possible to use this information to partially (or fully?) autogenerate Arduino variants and boards.txt. There are many libraries out there, but for example lopper is a common Python library to manipulate DTS files.

Add support for TI cc3220sf_launchxl

Zephyr RTOS already seems to have decent enough support for the CCS3220 Launchpad which is an MCU from Texas Instruments.

This will be a beneficial addition to this project because we currently only have samples using the arduino nano header and none of the other style of headers.

This way we will get to explore how to add custom board support as well

Improve Documentation

The Docs folder has already been created in #20 but it is mostly written in markdown.

In future it may be better to shift to Sphinx as it will look more professional and organised. Github also can build these docs and publish them on a website. See sphinx: github pages

Integrate with the Arduino IDE / CLI

Note: this is currently out of scope for the GSoC season due to the time required to implement but I'm leaving this here for future contributions.

One of the key features of the Arduino ecosystem is the integrated development environment, with the most well-known being the classic Java-based IDE (others exist, like a new IDE, Web editor and CLI.) The IDE does many things, including downloading new Cores, new boards and the necessary tools to program and debug boards. When completely new targets are added (like this Zephyr one,) Arduino calls these "platforms" and tools can use a series of metadata files in order to facilitate these capabilities (like fetching new boards.) While there is no porting guide, much of the details are captured in the CLI "Platform Specification" page.

Per the guide there are 3 key .txt files:

  • platform.txt contains definitions for the CPU architecture used (compiler, build process parameters, tools used for upload, etc.)
  • boards.txt contains definitions for the boards (board name, parameters for building and uploading sketches, etc.)
  • programmers.txt contains definitions for external programmers (typically used to burn bootloaders or sketches on a blank CPU/board)

For reference, see the mbed core's platform.txt, boards.txt & programmers.txt.

The biggest challenge/unknown is packaging up and distributing the tools needed by zephyr for programming and debugging. For an initial integration would could push the responsibility of installing dependencies on to the user. They would need to place dependencies at well-known locations that would be hardcoded in the platform.txt/programmers.txt. But for a seamless developer experience, we would want the Arduino IDE to automatically download and install all the tools needed by Zephyr. The question is how far do we go? Take a look at the Getting Started guide; there are build system deps like CMake & Device Tree, compilers like the SDK-NG and west/pip packages. It's unclear what should be packaged and how. One data point is that the Nordic nRF Connect for Desktop does distribute their SDK with all its dependencies, so it is theoretically possible.

Implementing EEPROM library

We must implement the EEPROM library to keep it compatible with standard AVR Arduino.
Where the EEPROM library implementation does not even have actual EEPROM, it should work with various non-volatile memory such as flash to keep compatibility.

i2c-support breaks build of other samples

The issue has been located, it's because the use of some Kconfigs that are not enabled or specified in the other samples.

build fails as below:

└─❯ west build -p -b arduino_nano_33_ble samples/blinky_arduino     -DZEPHYR_EXTRA_MODULES=/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core
-- west build: making build dir /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/samples/blinky_arduino
-- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.4") found components: Interpreter
-- Cache files will be written to: /home/dhruva/.cache/zephyr
-- Zephyr version: 3.1.99 (/home/dhruva/zephyrproject/zephyr)
-- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
-- Board: arduino_nano_33_ble
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.14.2 (/home/dhruva/zephyr-sdk-0.14.2)
-- Found dtc: /home/dhruva/zephyr-sdk-0.14.2/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found toolchain: zephyr 0.14.2 (/home/dhruva/zephyr-sdk-0.14.2)
-- Found BOARD.dts: /home/dhruva/zephyrproject/zephyr/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble.dts
-- Found devicetree overlay: /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/variants/ARDUINO_NANO_33_BLE/arduino_nano_33_ble.overlay
-- Generated zephyr.dts: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/dts.cmake
Parsing /home/dhruva/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/dhruva/zephyrproject/zephyr/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig'
Merged configuration '/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/samples/blinky_arduino/prj.conf'
Configuration saved to '/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/.config'
Kconfig header saved to '/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build
-- west build: building application
[1/174] Preparing syscall dependency handling

[3/174] Generating include/generated/version.h
-- Zephyr version: 3.1.99 (/home/dhruva/zephyrproject/zephyr), build: zephyr-v3.1.0-3162-gbe1380cc51bd
[164/174] Linking CXX executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/zephyr_pre0.map
: && ccache /home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-g++   zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -Wl,-T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/posix/liblib__posix.a  zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  zephyr/boards/arm/arduino_nano_33_ble/libboards__arm__arduino_nano_33_ble.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/thumb/v7e-m/nofp"  -L/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -no-pie  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn && cd /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr && /usr/bin/cmake -E echo
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(Wire.cpp.obj): in function `arduino::ZephyrI2C::peek()':
/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/libraries/Wire/Wire.cpp:86: undefined reference to `ring_buf_peek'
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(Wire.cpp.obj): in function `arduino::ZephyrI2C::read()':
/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/libraries/Wire/Wire.cpp:69: undefined reference to `ring_buf_peek'
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/libraries/Wire/Wire.cpp:70: undefined reference to `ring_buf_get'
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(Wire.cpp.obj): in function `arduino::ZephyrI2C::endTransmission(bool)':
/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/libraries/Wire/Wire.cpp:26: undefined reference to `__device_dts_ord_79'
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(Wire.cpp.obj): in function `arduino::ZephyrI2C::requestFrom(unsigned char, unsigned int, bool)':
/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/libraries/Wire/Wire.cpp:40: undefined reference to `ring_buf_put'
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/libraries/Wire/Wire.cpp:44: undefined reference to `__device_dts_ord_79'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

build fails for arduino nano 33 iot

west build -p -b arduino_nano_33_iot samples/blinky_arduino failed for other samples as well with following errors:

[76/160] Building CXX object zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj 
ccache /home/dhruva/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-g++ -DKERNEL -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/dhruva/zephyrproject/zephyr/kernel/include -I/home/dhruva/zephyrproject/zephyr/arch/arm/include -I/home/dhruva/zephyrproject/zephyr/include -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build/zephyr/include/generated -I/home/dhruva/zephyrproject/zephyr/soc/arm/atmel_sam0/samd21 -I/home/dhruva/zephyrproject/zephyr/drivers -I/home/dhruva/zephyrproject/zephyr/soc/arm/atmel_sam0/common/. -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/. -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/../../variants -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/variants/. -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/variants/arduino_nano_33_iot -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/libraries/Wire/. -I/home/dhruva/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/dhruva/zephyrproject/modules/hal/atmel/include -I/home/dhruva/zephyrproject/modules/hal/atmel/asf/sam0/include/samd21 -I/home/dhruva/zephyrproject/zephyr/modules/hal_nxp/. -isystem /home/dhruva/zephyrproject/zephyr/lib/libc/minimal/include -isystem /home/dhruva/zephyrproject/zephyr/subsys/cpp/include -isystem /home/dhruva/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem /home/dhruva/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -fno-strict-aliasing -Os -fcheck-new -std=c++11 -Wno-register -fno-exceptions -fno-rtti -imacros /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m0plus -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/dhruva/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/samples/blinky_arduino=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/dhruva/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/dhruva/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -nostdinc -nostdinc++ -Wno-unused-variable -Wno-comment -MD -MT zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj -MF zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj.d -o zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj -c /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp
In file included from /home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain/gcc.h:88,
                 from /home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain.h:50,
                 from /home/dhruva/zephyrproject/zephyr/lib/libc/minimal/include/string.h:13,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/./api/String.h:28,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/./api/IPAddress.h:24,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/./api/ArduinoAPI.h:30,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/./Arduino.h:7,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp:7:
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:104:39: error: '__device_dts_ord_DT_N_NODELABEL_i2c0_ORD' was not declared in this scope
  104 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
      |                                       ^~~~~~~~~
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:274:37: note: in expansion of macro 'DEVICE_NAME_GET'
  274 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
      |                                     ^~~~~~~~~~~~~~~
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:292:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  292 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/variants/arduino_nano_33_iot/arduino_nano_33_iot_pinmap.h:86:39: note: in expansion of macro 'DEVICE_DT_GET'
   86 | const static struct device *i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c0));
      |                                       ^~~~~~~~~~~~~
[79/160] Building C object zephyr/drivers/interrupt_controller/CMakeFiles/drivers__interrupt_controller.dir/intc_sam0_eic.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build

@beriberikix since you have the board and also added the variant can you please take a look at this?

Check that this module defaults to "not selected" in KConfig

When building a project that does not use the Arduino API Module, it is still selected and built:

ZEPHYR_ARDUINO_API_MODULE(=y)                                                                                                                                                 
menu "arduino-api (/home/mike/compile/golioth-zephyr-workspace/modules/lib/Arduino-Zephyr-API)" 

We should check that the KConfig for this symbol defaults to n

To reproduce

  1. Go to the zephyr drectory
  2. west build -b arduino_nano_33_ble samples/basic/minimal/ -p
  3. Build will fail with devicetree errors
  4. west build -t menuconfig
  5. /arduino will pull up a search that shows the Arduino API Module is enabled but it should not be.

samples: threads: build fails with DT related errors

The threads sample throws a huge bunch of errors like:

/home/dhruva/zephyrproject/zephyr/include/zephyr/devicetree.h:81:17: error: 'DT_N_S_zephyr_user_P_d21_gpios_IDX_0_VAL_pin' was not declared in this scope; did you mean 'DT_N_S_zephyr_user_P_pull_up_gpios_IDX_0_VAL_pin'?
   81 | #define DT_ROOT DT_N
      |                 ^~~~

Builds fail if variant does not have any GPIOs

Add conditional compilation for all relevant GPIO implementations, so that in the absence of GPIOs the builds don't just fail.
This will especially help in adding variants like am62x_m4 that don't yet have GPIO support.

CI Improvements: Add build tests for all variants

Add all the existing variants for github CI to build and test so build failures on any platform can be caught early.
This will require additions to the .github/workflows/build.yml file.

Tasks

building external library fails with yield not implemented errors

Fix is to just:

diff --git a/cores/arduino/zephyrCommon.cpp b/cores/arduino/zephyrCommon.cpp
index a9c053b..7e47fcc 100644
--- a/cores/arduino/zephyrCommon.cpp
+++ b/cores/arduino/zephyrCommon.cpp
@@ -6,6 +6,9 @@

 #include "Arduino.h"

+void yield(void) {}
+//empty
+
 /*
  *  The ACTIVE_HIGH flag is set so that A low physical
  *  level on the pin will be interpreted as value 0.

nrf52840dk build failure

The nrf52840dk build fails for all samples with following errors:

-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/dhruva/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Configuring done (1.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build
-- west build: building application
[1/179] Preparing syscall dependency handling

[2/179] Generating include/generated/version.h
-- Zephyr version: 3.4.99 (/home/dhruva/zephyrproject/zephyr), build: v3.4.0-1121-g76663444c1fa
[53/179] Building CXX object zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp.obj 
/home/dhruva/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-g++ -DKERNEL -DNRF52840_XXAA -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/dhruva/zephyrproject/zephyr/kernel/include -I/home/dhruva/zephyrproject/zephyr/arch/arm/include -I/home/dhruva/zephyrproject/zephyr/include -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build/zephyr/include/generated -I/home/dhruva/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf52 -I/home/dhruva/zephyrproject/zephyr/soc/arm/nordic_nrf/common/. -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/. -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/../../variants -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/variants/. -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/variants/nrf52840dk_nrf52840 -I/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/libraries/Wire/. -I/home/dhruva/zephyrproject/modules/lib/acpica/../../zephyr/include -I/home/dhruva/zephyrproject/modules/lib/acpica/.. -I/home/dhruva/zephyrproject/modules/lib/acpica/source/include -I/home/dhruva/zephyrproject/modules/lib/acpica/source/include/platform -I/home/dhruva/zephyrproject/modules/lib/acpica/source/compiler -I/home/dhruva/zephyrproject/modules/lib/acpica/generate/zephyr -I/home/dhruva/zephyrproject/modules/lib/acpica/source/tools/acpiexec -I/home/dhruva/zephyrproject/modules/lib/acpica/source/tools/acpidump -I/home/dhruva/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/dhruva/zephyrproject/modules/hal/nordic/nrfx -I/home/dhruva/zephyrproject/modules/hal/nordic/nrfx/drivers/include -I/home/dhruva/zephyrproject/modules/hal/nordic/nrfx/mdk -I/home/dhruva/zephyrproject/zephyr/modules/hal_nordic/nrfx/. -I/home/dhruva/zephyrproject/modules/debug/segger/SEGGER -I/home/dhruva/zephyrproject/modules/debug/segger/Config -I/home/dhruva/zephyrproject/zephyr/modules/segger/. -isystem /home/dhruva/zephyrproject/zephyr/lib/libc/minimal/include -isystem /home/dhruva/zephyrproject/zephyr/lib/cpp/minimal/include -isystem /home/dhruva/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem /home/dhruva/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -fno-strict-aliasing -Os -fcheck-new -std=c++11 -fno-exceptions -fno-rtti -imacros /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/dhruva/zephyr-sdk-0.16.1/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/samples/hello_arduino=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/dhruva/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/dhruva/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -nostdinc -nostdinc++ -Wno-unused-variable -Wno-comment -MD -MT zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp.obj -MF zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp.obj.d -o zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp.obj -c /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp
In file included from /home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain/gcc.h:92,
                 from /home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain.h:50,
                 from /home/dhruva/zephyrproject/zephyr/include/zephyr/sys/time_units.h:10,
                 from /home/dhruva/zephyrproject/zephyr/include/zephyr/sys/util.h:579,
                 from /home/dhruva/zephyrproject/zephyr/include/zephyr/devicetree.h:25,
                 from /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp:7:
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_118' was not declared in this scope; did you mean '__device_dts_ord_18'?
   85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                         ^~~~~~~~~
/home/dhruva/zephyrproject/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:85:33: note: in expansion of macro '_CONCAT'
   85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                 ^~~~~~~
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:211:37: note: in expansion of macro 'DEVICE_NAME_GET'
  211 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
      |                                     ^~~~~~~~~~~~~~~
/home/dhruva/zephyrproject/zephyr/include/zephyr/device.h:228:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  228 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrSerial.cpp:191:30: note: in expansion of macro 'DEVICE_DT_GET'
  191 | arduino::ZephyrSerial Serial(DEVICE_DT_GET(DT_NODELABEL(arduino_serial)));
      |                              ^~~~~~~~~~~~~
[62/179] Building CXX object zephyr/CMakeFiles/zephyr.dir/home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/cores/arduino/zephyrCommon.cpp.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/dhruva/zephyrproject/modules/lib/Arduino-Zephyr-API/build
west build -p -b nrf52840dk_nrf52840 samples/hello_arduino  7.96s user 1.11s system 265% cpu 3.420 total

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.