Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ jobs:
run: |
echo EXTRA_ZEPHYR_MODULES="$(pwd)/$MODULE_PATH" >> $GITHUB_ENV

- name: Fetch the Arduino API
run: |
west blobs --auto-accept fetch arduino-api

- name: Build fade
run: |
west build -p -b arduino_nano_33_ble//sense $MODULE_PATH/samples/fade
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/package_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ jobs:
echo "SUB_ARCHES=$(jq -c 'map(.subarch) | unique' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
# Archive the build environment for later jobs
(cd && tar cphf - .cmake work zephyr-sdk-* | zstd > build-env.tar.zstd)
# The API is only needed for packaging, not for building, so it's separate
tar cphf - cores/arduino/api | zstd > arduino-api.tar.zstd

- name: Archive build environment
uses: actions/upload-artifact@v4
Expand All @@ -91,13 +89,6 @@ jobs:
path: ~/build-env.tar.zstd
retention-days: 1

- name: Archive API snapshot
uses: actions/upload-artifact@v4
with:
name: arduino-api
path: arduino-api.tar.zstd
retention-days: 1



# Extract the build environment and compile the loader project for each board
Expand Down Expand Up @@ -183,9 +174,12 @@ jobs:

# Preprare an archive of the built binaries (and build dir on failure)
[ "${{ job.status }}" == "failure" ] && FULL_BUILD_DIR="build/${{ matrix.variant }}/"
sed -e '/^#/d' boards.local.txt > boards.local_${{ matrix.variant }}.txt
tar chf - \
firmwares/*${{ matrix.variant }}* \
variants/${{ matrix.variant }}/ \
cores/arduino/api/ \
boards.local_${{ matrix.variant }}.txt \
${FULL_BUILD_DIR} \
| zstd > binaries-${ARTIFACT_TAG}.tar.zstd

Expand Down Expand Up @@ -237,12 +231,6 @@ jobs:
persist-credentials: false
fetch-tags: true

# Get the API snapshot
- uses: actions/download-artifact@v4
with:
path: .
name: arduino-api

# Get all built binaries
- uses: actions/download-artifact@v4
with:
Expand All @@ -252,12 +240,12 @@ jobs:

- name: Package core
run: |
# Extract the API snapshot and board binaries in place
rm -f cores/arduino/api # remove broken symlink
tar --use-compress-program=unzstd -xpf arduino-api.tar.zstd
# Extract the board binaries in place
# (each will also include the same copy of the API)
for f in binaries-*.tar.zstd ; do
tar --use-compress-program=unzstd -xpf $f
done
cat $(ls boards.local_*.txt | sort) >> boards.local.txt
# Create the core artifact for this set of boards
./extra/package_core.sh ${{ matrix.artifact }} ${CORE_TAG} distrib/${CORE_ARTIFACT}.tar.bz2

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/distrib/
/firmwares/*
/venv/
/boards.local.txt

llext-edk/
cflags.txt
cxxflags.txt
Expand Down
34 changes: 29 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
# SPDX-License-Identifier: Apache-2.0

# Do nothing unless the Arduino API is enabled in the Zephyr project
if(NOT CONFIG_ARDUINO_API)
return()
endif()

# Keep this in sync with zephyr/module.yml
set(ARDUINO_API_BLOB_VERSION 1.5.2)

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/${NORMALIZED_BOARD_TARGET})
set(variant_dir variants/${NORMALIZED_BOARD_TARGET})
else()
if (CONFIG_ARDUINO_API)
message(FATAL_ERROR "Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}")
endif()

# API archives embed an 'ArduinoCore-API-<version>' directory
set(ARDUINO_API_BLOB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zephyr/blobs/ArduinoCore-API/)
set(ARDUINO_API_BLOB_DIR ${ARDUINO_API_BLOB_ROOT_DIR}/ArduinoCore-API-${ARDUINO_API_BLOB_VERSION})
set(ARDUINO_API_BLOB_ARCHIVE ${ARDUINO_API_BLOB_DIR}.tar.gz)

if(NOT EXISTS ${ARDUINO_API_BLOB_ARCHIVE})
message(FATAL_ERROR "Arduino API ${ARDUINO_API_BLOB_VERSION} must be downloaded with 'west blobs fetch'.")
endif()

if (CONFIG_ARDUINO_API AND NOT CONFIG_LLEXT)
add_subdirectory(cores)
add_subdirectory(libraries)
zephyr_include_directories(${variant_dir})
if(NOT IS_DIRECTORY ${ARDUINO_API_BLOB_DIR})
file(ARCHIVE_EXTRACT
INPUT ${ARDUINO_API_BLOB_ARCHIVE}
DESTINATION ${ARDUINO_API_BLOB_ROOT_DIR}
PATTERNS */api/* # only extract the 'api' directory from the archive
)
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/cores/arduino/api)
file(COPY ${ARDUINO_API_BLOB_DIR}/api DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/cores/arduino)
endif()

if (NOT CONFIG_LLEXT_EDK)
add_subdirectory(cores)
add_subdirectory(libraries)
zephyr_include_directories(${variant_dir})
endif()
12 changes: 2 additions & 10 deletions README.gsoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,11 @@ The **Arduino Core API** module for zephyr leverages the power of Zephyr under a
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.
* You also need to fetch the ArduinoCore-API sources using the following command:

* To "complete" the core you need to copy or symlink the api folder from the [ArduinoCore-API](https://github.com/arduino/ArduinoCore-API.git) repo to the target's ``cores/arduino`` folder:
```sh
$ git clone git@github.com:arduino/ArduinoCore-API # Any location
$ ln -s /<your>/<location>/ArduinoCore-API/api cores/arduino/.
west blobs fetch arduino-api
```
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``.

**Maintainers**:
- [DhruvaG2000](https://github.com/DhruvaG2000)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ There are pros and cons to both strategies:
1) Builds on the native Windows file system are relatively very slow, but once done, you can use the results directly within the Arduino IDE.
2) Builds on WSL's file system are a lot faster, however, you need to copy the resulting build back to somewhere in your Windows directory structure. Use this location in the Arduino IDE as mentioned below in the [Using the Core in Arduino IDE/CLI](#using-the-core-in-arduino-idecli) section.

After `bootstrap.sh` has completed, you may also have to update the `cores\arduino\api` link to the path of the ArduinoCore-API's `api` folder.

### Run the ```bootstrap``` script
```bash
cd ArduinoCore-zephyr
Expand Down
Loading
Loading