Skip to content
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

test pr to run CI #85

Merged
merged 29 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aa0fca4
Nano 33 BLE - enable the SPI1 sensors
KurtE Feb 5, 2025
03a7fce
Add call to initVariant in main move ble sense to variant.cpp
KurtE Mar 5, 2025
e831260
GIGA: Remove Arduino pins 11-13 from PWM list to fix SPI1
KurtE Feb 2, 2025
8428b9a
Comment out pins we removed to allow SPI1 to work
KurtE Mar 5, 2025
587b322
Merge pull request #65 from KurtE/GIGA_M7_fix_spi5
facchinm Mar 6, 2025
7fdcd38
Merge pull request #67 from KurtE/nano_sense_spi1_enable_pin
facchinm Mar 6, 2025
ac05eb3
Merge remote-tracking branch 'origin/fully_linked' into arduino
pillo79 Mar 21, 2025
87f323b
platform: common extension mapping
pillo79 Mar 4, 2025
43f2d5a
boards: merge common zephyr flags to platform.txt
pillo79 Mar 4, 2025
e48e3af
variants: generate cflags.txt and includes.txt from llext-edk
pillo79 Mar 4, 2025
887577b
build.sh: get the variant name from the Zephyr build system
pillo79 Mar 13, 2025
55eeab3
llext_exports: remove dropped net_buf_get
pillo79 Mar 20, 2025
a255a36
main: fix enable_shell_usb warnings
pillo79 Mar 20, 2025
751d5f6
loader: enable the Arduino API module
pillo79 Mar 20, 2025
a81cbb0
west: use post_4.1 branch for zephyr
pillo79 Mar 20, 2025
d1f9c0d
boards.txt: fix prelinked flag for post_build_tool
facchinm Mar 21, 2025
77ce198
loader: fix loading of prelinked sketch
facchinm Mar 21, 2025
f6effd0
bootstrap: export Zephyr install directory
pillo79 Mar 21, 2025
5477b89
mass rebuild
pillo79 Mar 24, 2025
0ba9bf0
variants: fix multiple USB definition issues
pillo79 Mar 24, 2025
804ccc1
nano33ble: disable stack canaries
facchinm Mar 26, 2025
3bb2f23
SocketWrapper: start restucturing lib
facchinm Mar 26, 2025
30f1330
gh: fix usage as module
facchinm Mar 26, 2025
ec9326e
Ethernet: compile only if enabled in dts
facchinm Mar 26, 2025
45a735b
loader: fix offset for CONFIG_LLEXT_STORAGE_WRITABLE
facchinm Mar 26, 2025
33706ae
loader: add exports for wifiAP
facchinm Mar 26, 2025
253cde8
rw612: enable wifi AP support
facchinm Mar 26, 2025
e85a95d
platform.txt: provide clean BOARDNAME defines
facchinm Mar 26, 2025
79fc9e2
loader: move dhcp server in own ifdef
facchinm Mar 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
29 changes: 12 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,29 @@ jobs:
container: zephyrprojectrtos/ci:latest
env:
CMAKE_PREFIX_PATH: /opt/toolchains
PR_NUMBER: ${{ github.event.number }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ArduinoCore-zephyr

- name: Initialize
working-directory: ArduinoCore-zephyr
run: |
mkdir build && cd build
west init -m https://github.com/arduino/ArduinoCore-zephyr.git
west init -m https://github.com/${{ github.repository }}
cd modules/lib/ArduinoCore-zephyr/
git fetch origin ${{ github.ref }}
git checkout FETCH_HEAD
cd -
west update
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: ArduinoCore-zephyr/build
working-directory: build
run: |
west build -p -b arduino_nano_33_ble//sense ../samples/fade
west build -p -b arduino_nano_33_ble//sense modules/lib/ArduinoCore-zephyr/samples/fade

- name: Build i2cdemo
working-directory: ArduinoCore-zephyr/build
working-directory: build
run: |
west build -p -b ek_ra8d1 ../samples/i2cdemo
west build -p -b ek_ra8d1 modules/lib/ArduinoCore-zephyr/samples/i2cdemo

- name: Build adc
working-directory: ArduinoCore-zephyr/build
working-directory: build
run: |
west build -p -b arduino_nano_33_ble//sense ../samples/analog_input
west build -p -b arduino_nano_33_ble/nrf52840/sense modules/lib/ArduinoCore-zephyr/samples/analog_input
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (CONFIG_ARDUINO_API)
endif()
endif()

if (CONFIG_ARDUINO_API)
if (CONFIG_ARDUINO_API AND NOT CONFIG_LLEXT)
add_subdirectory(cores)
add_subdirectory(libraries)
zephyr_include_directories(${variant_dir})
Expand Down
122 changes: 24 additions & 98 deletions boards.txt

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion cores/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(arduino)
add_subdirectory(arduino)

zephyr_include_directories(../../ArduinoCore-API/)

if(NOT DEFINED ARDUINO_BUILD_PATH)
zephyr_sources(../../ArduinoCore-API/api/CanMsg.cpp)
zephyr_sources(../../ArduinoCore-API/api/CanMsgRingbuffer.cpp)
zephyr_sources(../../ArduinoCore-API/api/Common.cpp)
zephyr_sources(../../ArduinoCore-API/api/IPAddress.cpp)
zephyr_sources(../../ArduinoCore-API/api/Print.cpp)
zephyr_sources(../../ArduinoCore-API/api/Stream.cpp)
zephyr_sources(../../ArduinoCore-API/api/String.cpp)
endif()
8 changes: 0 additions & 8 deletions cores/arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ zephyr_sources(zephyrCommon.cpp)
zephyr_sources(USB.cpp)
zephyr_sources(itoa.cpp)

zephyr_sources(api/CanMsg.cpp)
zephyr_sources(api/CanMsgRingbuffer.cpp)
zephyr_sources(api/Common.cpp)
zephyr_sources(api/IPAddress.cpp)
zephyr_sources(api/Print.cpp)
zephyr_sources(api/Stream.cpp)
zephyr_sources(api/String.cpp)

if(DEFINED CONFIG_ARDUINO_ENTRY)
zephyr_sources(main.cpp)
zephyr_sources(threads.cpp)
Expand Down
9 changes: 9 additions & 0 deletions cores/arduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
void start_static_threads();
#endif


// This function will be overwriten by most variants.
void __attribute__((weak))initVariant(void) {

}


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

initVariant();

#ifdef CONFIG_MULTITHREADING
start_static_threads();
#endif
Expand Down
3 changes: 2 additions & 1 deletion extra/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ source venv/bin/activate
pip install west
west init -l .
west update
west zephyr-export
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
west blobs fetch hal_nxp
101 changes: 68 additions & 33 deletions extra/build.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,84 @@
if [ x$ZEPHYR_SDK_INSTALL_DIR == x"" ]; then
export ZEPHYR_SDK_INSTALL_DIR=/ssd/zephyr-sdk-0.16.8/
fi
#!/bin/bash

set -e

board=$1
variant=$2
third_arg=$3
extra_args=""
if [ x$ZEPHYR_SDK_INSTALL_DIR == x"" ]; then
SDK_PATH=$(west sdk list | grep path | tail -n 1 | cut -d ':' -f 2 | tr -d ' ')
if [ x$SDK_PATH == x ]; then
echo "ZEPHYR_SDK_INSTALL_DIR not set and no SDK found"
exit 1
fi
echo "ZEPHYR_SDK_INSTALL_DIR not set, using $SDK_PATH"
export ZEPHYR_SDK_INSTALL_DIR=${SDK_PATH}
fi

if [[ $# -eq 0 ]]; then
board=arduino_giga_r1//m7
variant=arduino_giga_r1_m7
board=arduino_giga_r1//m7
else
board=$1
shift
fi

source venv/bin/activate

if [ "$third_arg" != "" ]; then
extra_args="--shield $third_arg"
fi
ZEPHYR_BASE=$(west topdir)/zephyr

(west build loader -b $board -p $extra_args && west build -t llext-edk)
(tar xfp build/zephyr/llext-edk.tar.xz --directory variants/$variant/)
# Get the variant name (NORMALIZED_BOARD_TARGET in Zephyr)
tmpdir=$(mktemp -d)
variant=$(cmake -DBOARD=$board -P extra/get_variant_name.cmake | grep 'VARIANT=' | cut -d '=' -f 2)
rm -rf ${tmpdir}

(cp build/zephyr/zephyr.elf firmwares/zephyr-$variant.elf)
if [ -f build/zephyr/zephyr.bin ]; then
cp build/zephyr/zephyr.bin firmwares/zephyr-$variant.bin
elif [ -f build/zephyr/zephyr.hex ]; then
cp build/zephyr/zephyr.hex firmwares/zephyr-$variant.hex
if [ -z "${variant}" ] ; then
echo "Failed to get variant name from '$board'"
exit 1
fi

echo && echo && echo
echo ${variant}
echo ${variant} | sed -e 's/./=/g'
echo

# Build the loader
BUILD_DIR=build/${variant}
VARIANT_DIR=variants/${variant}
rm -rf ${BUILD_DIR}
west build -d ${BUILD_DIR} -b ${board} loader -t llext-edk $*

# Extract the generated EDK tarball and copy it to the variant directory
mkdir -p ${VARIANT_DIR} firmwares
(set -e ; cd ${BUILD_DIR} && rm -rf llext-edk && tar xf zephyr/llext-edk.tar.Z)
rsync -a --delete ${BUILD_DIR}/llext-edk ${VARIANT_DIR}/

# remove all inline comments in macro definitions
# (especially from devicetree_generated.h and sys/util_internal.h)
line_preproc_ok='^\s*#\s*(if|else|elif|endif)' # match conditional preproc lines
line_comment_only='^\s*\/\*' # match lines starting with comment
line_continuation='\\$' # match lines ending with '\'
c_comment='\s*\/\*.*?\*\/' # match C-style comments and any preceding space
perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find ${VARIANT_DIR}/llext-edk/include/ -type f)
for ext in elf bin hex; do
rm -f firmwares/zephyr-$variant.$ext
if [ -f ${BUILD_DIR}/zephyr/zephyr.$ext ]; then
cp ${BUILD_DIR}/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext
fi
done

# Generate the provides.ld file for linked builds
echo "Exporting provides.ld"
READELF=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > variants/$variant/provides.ld
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> variants/$variant/provides.ld
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> variants/$variant/provides.ld
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> variants/$variant/provides.ld
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> variants/$variant/provides.ld
cat build/zephyr/zephyr.map | grep __device_dts_ord | grep -v rodata | grep -v llext_const_symbol | awk -F' ' '{print "PROVIDE("$2" = "$1");"}' >> variants/$variant/provides.ld
TEXT_START=`cat loader/boards/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"`
echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> variants/$variant/provides.ld

sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' variants/$variant/provides.ld
sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' variants/$variant/provides.ld
sed -i 's/PROVIDE(realloc =/PROVIDE(__wrap_realloc =/g' variants/$variant/provides.ld
sed -i 's/PROVIDE(calloc =/PROVIDE(__wrap_calloc =/g' variants/$variant/provides.ld
sed -i 's/PROVIDE(random =/PROVIDE(__wrap_random =/g' variants/$variant/provides.ld
$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > ${VARIANT_DIR}/provides.ld
$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld
$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld
$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld
$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld
cat ${BUILD_DIR}/zephyr/zephyr.map | grep __device_dts_ord | grep -v rodata | grep -v llext_const_symbol | awk -F' ' '{print "PROVIDE("$2" = "$1");"}' >> ${VARIANT_DIR}/provides.ld
TEXT_START=`cat variants/$variant/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"`
echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> ${VARIANT_DIR}/provides.ld

sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' ${VARIANT_DIR}/provides.ld
sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' ${VARIANT_DIR}/provides.ld
sed -i 's/PROVIDE(realloc =/PROVIDE(__wrap_realloc =/g' ${VARIANT_DIR}/provides.ld
sed -i 's/PROVIDE(calloc =/PROVIDE(__wrap_calloc =/g' ${VARIANT_DIR}/provides.ld
sed -i 's/PROVIDE(random =/PROVIDE(__wrap_random =/g' ${VARIANT_DIR}/provides.ld

cmake -P extra/gen_arduino_files.cmake $variant
15 changes: 8 additions & 7 deletions extra/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

set -e

./extra/build.sh arduino_giga_r1//m7 arduino_giga_r1_m7 giga_display_shield
./extra/build.sh arduino_nano_33_ble//sense arduino_nano_33_ble_sense
./extra/build.sh arduino_portenta_h7//m7 arduino_portenta_h7
./extra/build.sh ek_ra8d1 ek_ra8d1
./extra/build.sh frdm_mcxn947/mcxn947/cpu0 frdm_mcxn947_mcxn947_cpu0
./extra/build.sh frdm_rw612 frdm_rw612
./extra/build.sh arduino_portenta_c33 arduino_portenta_c33
./extra/build.sh arduino_giga_r1//m7 --shield giga_display_shield
./extra/build.sh arduino_nano_33_ble//sense
./extra/build.sh arduino_nicla_sense_me
./extra/build.sh arduino_portenta_c33
./extra/build.sh [email protected]//m7
./extra/build.sh ek_ra8d1
./extra/build.sh frdm_mcxn947/mcxn947/cpu0
./extra/build.sh frdm_rw612
61 changes: 61 additions & 0 deletions extra/gen_arduino_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# get root dir for the project
cmake_path(SET TOP_DIR NORMALIZE ${CMAKE_CURRENT_LIST_DIR}/..)

# get list of variants to be applied
if(CMAKE_ARGC GREATER 3)
# cmake -P <script> <variant> ...
foreach(index RANGE 4 ${CMAKE_ARGC})
math(EXPR index "${index} - 1")
list(APPEND VARIANTS "${CMAKE_ARGV${index}}")
endforeach()
list(TRANSFORM VARIANTS REPLACE "/$" "")
list(TRANSFORM VARIANTS REPLACE ".*/" "")
else()
# build for all valid variants
file(GLOB VARIANTS RELATIVE ${TOP_DIR}/variants variants/*)
list(REMOVE_ITEM VARIANTS llext linked)
endif()

foreach(variant ${VARIANTS})
if(NOT IS_DIRECTORY variants/${variant})
continue()
endif()

cmake_path(SET dir ${TOP_DIR}/variants/${variant})
if(NOT EXISTS ${dir}/llext-edk/cmake.cflags)
continue()
endif()

message(STATUS "Processing ${variant}")
include(${dir}/llext-edk/cmake.cflags)

list(TRANSFORM LLEXT_ALL_INCLUDE_CFLAGS REPLACE "-I${dir}" "-iwithprefixbefore")
list(JOIN LLEXT_ALL_INCLUDE_CFLAGS "\n" EDK_INCLUDES)
file(WRITE ${dir}/includes.txt "${EDK_INCLUDES}")

# exclude -imacros entries in platform from the list, make sure no others are present
list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-imacros.*autoconf.h")
list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-imacros.*zephyr_stdint.h")
set(other_imacros "${LLEXT_BASE_CFLAGS}")
list(FILTER other_imacros INCLUDE REGEX "-imacros.*")
if(other_imacros)
message(FATAL_ERROR "Unexpected -imacros in LLEXT_BASE_CFLAGS: ${other_imacros}")
endif()

# exclude other problematic macros shared between C and C++
list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-fdiagnostics-color=always")

# (temp) generate C++ flags from C flags
set(LLEXT_BASE_CXXFLAGS ${LLEXT_BASE_CFLAGS})
list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-Wno-pointer-sign")
list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-Werror=implicit-int")
list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-std=c.*")

# save flag files
list(JOIN LLEXT_BASE_CFLAGS "\n" EDK_CFLAGS)
file(WRITE ${dir}/cflags.txt "${EDK_CFLAGS}")


list(JOIN LLEXT_BASE_CXXFLAGS "\n" EDK_CXXFLAGS)
file(WRITE ${dir}/cxxflags.txt "${EDK_CXXFLAGS}")
endforeach()
11 changes: 11 additions & 0 deletions extra/get_variant_name.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2025 Arduino SA
# SPDX-License-Identifier: Apache-2.0

#
# Generate NORMALIZED_BOARD_TARGET from BOARD via the Zephyr build system
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
message(STATUS "VARIANT=${NORMALIZED_BOARD_TARGET}")
4 changes: 2 additions & 2 deletions extra/post_build_tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func main() {
var output = flag.String("output", "", "Output to a specific file (default: add .dfu suffix)")
var output = flag.String("output", "", "Output to a specific file (default: add -zsk.bin suffix)")
var debug = flag.Bool("debug", false, "Enable debugging mode")
var linked = flag.Bool("prelinked", false, "Provided file has already been linked to Zephyr")
var force = flag.Bool("force", false, "Ignore safety checks and overwrite the header")
Expand Down Expand Up @@ -85,7 +85,7 @@ func main() {
// Create a new filename for the copy
newFilename := *output
if newFilename == "" {
newFilename = filename + ".dfu"
newFilename = filename + "-zsk.bin"
}

// Write the new content to the new file
Expand Down
Binary file added extra/post_build_tool/zephyr-post-build-tool
Binary file not shown.
Binary file removed firmwares/zephyr-arduino_giga_r1_m7.bin
Binary file not shown.
Binary file removed firmwares/zephyr-arduino_giga_r1_m7.elf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading