Skip to content

gh: try to fix zephyr project action #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 24, 2025
Merged
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
31 changes: 14 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,30 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
path: Arduino-Zephyr-API
path: ArduinoCore-zephyr

- name: Initialize
working-directory: Arduino-Zephyr-API
working-directory: ArduinoCore-zephyr
run: |
west init -m https://github.com/zephyrproject-rtos/gsoc-2022-arduino-core.git
mkdir build && cd build
west init -m https://github.com/arduino/ArduinoCore-zephyr.git
west update
git clone https://github.com/arduino/ArduinoCore-API.git ArduinoCore-API
cp -r ArduinoCore-API/api modules/lib/Arduino-Zephyr-API/cores/arduino/.
rm -rf modules/lib/ArduinoCore-zephyr/*
cp -r ../* modules/lib/ArduinoCore-zephyr || true
rm modules/lib/ArduinoCore-zephyr/cores/arduino/api
cp -r modules/lib/ArduinoCore-API/api modules/lib/ArduinoCore-zephyr/cores/arduino/api

- name: Build fade
working-directory: Arduino-Zephyr-API
working-directory: ArduinoCore-zephyr/build
run: |
west build -p -b arduino_nano_33_ble_sense samples/fade
west build -p -b arduino_nano_33_ble//sense ../samples/fade

- name: Build i2cdemo
working-directory: Arduino-Zephyr-API
working-directory: ArduinoCore-zephyr/build
run: |
west build -p -b arduino_nano_33_ble_sense samples/i2cdemo
west build -p -b ek_ra8d1 ../samples/i2cdemo

- name: Build adc
working-directory: Arduino-Zephyr-API
working-directory: ArduinoCore-zephyr/build
run: |
west build -p -b beagleconnect_freedom samples/analog_input

- name: Archive firmware
uses: actions/upload-artifact@v3
with:
name: firmware
path: Arduino-Zephyr-API/build/zephyr/zephyr.*
west build -p -b arduino_nano_33_ble//sense ../samples/analog_input
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# SPDX-License-Identifier: Apache-2.0

string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")

if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${BOARD})
set(variant_dir variants/${BOARD})
elseif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${BOARD}${NORMALIZED_BOARD_QUALIFIERS})
set(variant_dir variants/${BOARD}${NORMALIZED_BOARD_QUALIFIERS})
elseif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${NORMALIZED_BOARD_TARGET})
set(variant_dir variants/${NORMALIZED_BOARD_TARGET})
else()
message(INFO "Variant dir not found: variants/${BOARD}, variants/${BOARD}${NORMALIZED_BOARD_QUALIFIERS}")
if (CONFIG_ARDUINO_API)
message(FATAL_ERROR "Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}")
endif()
endif()

if (CONFIG_ARDUINO_API)
Expand Down
2 changes: 2 additions & 0 deletions cores/arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if(NOT DEFINED ARDUINO_BUILD_PATH)

zephyr_sources(zephyrSerial.cpp)
zephyr_sources(zephyrCommon.cpp)
zephyr_sources(USB.cpp)
zephyr_sources(itoa.cpp)

if(DEFINED CONFIG_ARDUINO_ENTRY)
zephyr_sources(main.cpp)
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/SerialUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class SerialUSB_ : public ZephyrSerial {
};
} // namespace arduino

#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm)
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
extern arduino::SerialUSB_ Serial;
#endif
12 changes: 1 addition & 11 deletions cores/arduino/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

// Make PluggableUSB link happy
#include "api/PluggableUSB.h"

static uint8_t _epBuffer[1];
void* epBuffer(unsigned int n) {
return &_epBuffer[n];
};

arduino::PluggableUSB_::PluggableUSB_() {}

#include <zephyr/devicetree.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/uart/cdc_acm.h>
#include <zephyr/usb/usb_device.h>
#include <SerialUSB.h>

#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm)
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
const struct device *const usb_dev = DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), cdc_acm, 0));

void usb_status_cb(enum usb_dc_status_code cb_status, const uint8_t *param) {
Expand Down
4 changes: 3 additions & 1 deletion cores/arduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
#endif

int main(void) {
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) || DT_NODE_HAS_PROP(DT_PATH(zephyr_user), serials)
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
Serial.begin(115200);
#endif
setup();

for (;;) {
loop();
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM) || DT_NODE_HAS_PROP(DT_PATH(zephyr_user), serials)
if (arduino::serialEventRun) arduino::serialEventRun();
#endif
}

return 0;
Expand Down
9 changes: 7 additions & 2 deletions cores/arduino/zephyrSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,16 @@ void arduino::ZephyrSerial::flush() {
}
}

#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm))
#define FIRST_UART_INDEX 1
#else
#define FIRST_UART_INDEX 0
#endif

#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), serials)
#if !DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm)
#if !(DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
// If CDC USB, use that object as Serial (and SerialUSB)
arduino::ZephyrSerial Serial(DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), serials, 0)));
arduino::ZephyrSerial Serial(DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), serials, FIRST_UART_INDEX)));
#endif
#if (DT_PROP_LEN(DT_PATH(zephyr_user), serials) > 1)
#define ARDUINO_SERIAL_DEFINED_0 1
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/zephyrSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ZephyrSerial : public HardwareSerial
} // namespace arduino

#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), serials)
#if !DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm)
#if !(DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
// If CDC USB, use that object as Serial (and SerialUSB)
extern arduino::ZephyrSerial Serial;
#endif
Expand Down
3 changes: 3 additions & 0 deletions extra/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ west init -l .
west update
pip install -r ../zephyr/scripts/requirements-base.txt
# download slim toolchain from https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.8

# add here the required blobs based on supported platforms
west blobs fetch hal_nxp
5 changes: 4 additions & 1 deletion samples/analog_input/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(analog_input)
Expand Down
5 changes: 4 additions & 1 deletion samples/attach_interrupt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(attach_interrupt)
Expand Down
5 changes: 4 additions & 1 deletion samples/blinky_arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(blinky)
Expand Down
5 changes: 4 additions & 1 deletion samples/button_press_led/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(blinky)
Expand Down
5 changes: 4 additions & 1 deletion samples/fade/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(fade)
Expand Down
5 changes: 4 additions & 1 deletion samples/hello_arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world)
Expand Down
5 changes: 4 additions & 1 deletion samples/i2cdemo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(blinky)
Expand Down
5 changes: 4 additions & 1 deletion samples/serial_event/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(serial_event)
Expand Down
5 changes: 4 additions & 1 deletion samples/spi_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(spi_controller)
Expand Down
5 changes: 4 additions & 1 deletion samples/threads_arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
cmake_minimum_required(VERSION 3.20.0)

cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}")
string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/ArduinoCore-zephyr/loader/boards/${NORMALIZED_BOARD_TARGET}.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(threads)
Expand Down
Loading