Skip to content

Commit 2f96a1a

Browse files
authored
Merge pull request #85 from pillo79/fully_linked
test pr to run CI
2 parents 1eade10 + 79fc9e2 commit 2f96a1a

File tree

21,535 files changed

+6513732
-6455330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

21,535 files changed

+6513732
-6455330
lines changed

Diff for: .github/workflows/build.yml

+12-17
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,29 @@ jobs:
88
container: zephyrprojectrtos/ci:latest
99
env:
1010
CMAKE_PREFIX_PATH: /opt/toolchains
11+
PR_NUMBER: ${{ github.event.number }}
1112
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
with:
15-
path: ArduinoCore-zephyr
16-
1713
- name: Initialize
18-
working-directory: ArduinoCore-zephyr
1914
run: |
2015
mkdir build && cd build
21-
west init -m https://github.com/arduino/ArduinoCore-zephyr.git
16+
west init -m https://github.com/${{ github.repository }}
17+
cd modules/lib/ArduinoCore-zephyr/
18+
git fetch origin ${{ github.ref }}
19+
git checkout FETCH_HEAD
20+
cd -
2221
west update
23-
rm -rf modules/lib/ArduinoCore-zephyr/*
24-
cp -r ../* modules/lib/ArduinoCore-zephyr || true
25-
rm modules/lib/ArduinoCore-zephyr/cores/arduino/api
26-
cp -r modules/lib/ArduinoCore-API/api modules/lib/ArduinoCore-zephyr/cores/arduino/api
2722
2823
- name: Build fade
29-
working-directory: ArduinoCore-zephyr/build
24+
working-directory: build
3025
run: |
31-
west build -p -b arduino_nano_33_ble//sense ../samples/fade
26+
west build -p -b arduino_nano_33_ble//sense modules/lib/ArduinoCore-zephyr/samples/fade
3227
3328
- name: Build i2cdemo
34-
working-directory: ArduinoCore-zephyr/build
29+
working-directory: build
3530
run: |
36-
west build -p -b ek_ra8d1 ../samples/i2cdemo
31+
west build -p -b ek_ra8d1 modules/lib/ArduinoCore-zephyr/samples/i2cdemo
3732
3833
- name: Build adc
39-
working-directory: ArduinoCore-zephyr/build
34+
working-directory: build
4035
run: |
41-
west build -p -b arduino_nano_33_ble//sense ../samples/analog_input
36+
west build -p -b arduino_nano_33_ble/nrf52840/sense modules/lib/ArduinoCore-zephyr/samples/analog_input

Diff for: CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (CONFIG_ARDUINO_API)
1212
endif()
1313
endif()
1414

15-
if (CONFIG_ARDUINO_API)
15+
if (CONFIG_ARDUINO_API AND NOT CONFIG_LLEXT)
1616
add_subdirectory(cores)
1717
add_subdirectory(libraries)
1818
zephyr_include_directories(${variant_dir})

Diff for: boards.txt

+24-98
Large diffs are not rendered by default.

Diff for: cores/CMakeLists.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
add_subdirectory(arduino)
3+
add_subdirectory(arduino)
4+
5+
zephyr_include_directories(../../ArduinoCore-API/)
6+
7+
if(NOT DEFINED ARDUINO_BUILD_PATH)
8+
zephyr_sources(../../ArduinoCore-API/api/CanMsg.cpp)
9+
zephyr_sources(../../ArduinoCore-API/api/CanMsgRingbuffer.cpp)
10+
zephyr_sources(../../ArduinoCore-API/api/Common.cpp)
11+
zephyr_sources(../../ArduinoCore-API/api/IPAddress.cpp)
12+
zephyr_sources(../../ArduinoCore-API/api/Print.cpp)
13+
zephyr_sources(../../ArduinoCore-API/api/Stream.cpp)
14+
zephyr_sources(../../ArduinoCore-API/api/String.cpp)
15+
endif()

Diff for: cores/arduino/CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ zephyr_sources(zephyrCommon.cpp)
99
zephyr_sources(USB.cpp)
1010
zephyr_sources(itoa.cpp)
1111

12-
zephyr_sources(api/CanMsg.cpp)
13-
zephyr_sources(api/CanMsgRingbuffer.cpp)
14-
zephyr_sources(api/Common.cpp)
15-
zephyr_sources(api/IPAddress.cpp)
16-
zephyr_sources(api/Print.cpp)
17-
zephyr_sources(api/Stream.cpp)
18-
zephyr_sources(api/String.cpp)
19-
2012
if(DEFINED CONFIG_ARDUINO_ENTRY)
2113
zephyr_sources(main.cpp)
2214
zephyr_sources(threads.cpp)

Diff for: cores/arduino/main.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@
1515
void start_static_threads();
1616
#endif
1717

18+
19+
// This function will be overwriten by most variants.
20+
void __attribute__((weak))initVariant(void) {
21+
22+
}
23+
24+
1825
int main(void) {
1926
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
2027
Serial.begin(115200);
2128
#endif
2229

30+
initVariant();
31+
2332
#ifdef CONFIG_MULTITHREADING
2433
start_static_threads();
2534
#endif

Diff for: extra/bootstrap.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ source venv/bin/activate
1010
pip install west
1111
west init -l .
1212
west update
13+
west zephyr-export
1314
pip install -r ../zephyr/scripts/requirements-base.txt
1415
# download slim toolchain from https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.8
1516

1617
# add here the required blobs based on supported platforms
17-
west blobs fetch hal_nxp
18+
west blobs fetch hal_nxp

Diff for: extra/build.sh

+68-33
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,84 @@
1-
if [ x$ZEPHYR_SDK_INSTALL_DIR == x"" ]; then
2-
export ZEPHYR_SDK_INSTALL_DIR=/ssd/zephyr-sdk-0.16.8/
3-
fi
1+
#!/bin/bash
42

53
set -e
64

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

1215
if [[ $# -eq 0 ]]; then
13-
board=arduino_giga_r1//m7
14-
variant=arduino_giga_r1_m7
16+
board=arduino_giga_r1//m7
17+
else
18+
board=$1
19+
shift
1520
fi
1621

1722
source venv/bin/activate
1823

19-
if [ "$third_arg" != "" ]; then
20-
extra_args="--shield $third_arg"
21-
fi
24+
ZEPHYR_BASE=$(west topdir)/zephyr
2225

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

26-
(cp build/zephyr/zephyr.elf firmwares/zephyr-$variant.elf)
27-
if [ -f build/zephyr/zephyr.bin ]; then
28-
cp build/zephyr/zephyr.bin firmwares/zephyr-$variant.bin
29-
elif [ -f build/zephyr/zephyr.hex ]; then
30-
cp build/zephyr/zephyr.hex firmwares/zephyr-$variant.hex
31+
if [ -z "${variant}" ] ; then
32+
echo "Failed to get variant name from '$board'"
33+
exit 1
3134
fi
3235

36+
echo && echo && echo
37+
echo ${variant}
38+
echo ${variant} | sed -e 's/./=/g'
39+
echo
40+
41+
# Build the loader
42+
BUILD_DIR=build/${variant}
43+
VARIANT_DIR=variants/${variant}
44+
rm -rf ${BUILD_DIR}
45+
west build -d ${BUILD_DIR} -b ${board} loader -t llext-edk $*
46+
47+
# Extract the generated EDK tarball and copy it to the variant directory
48+
mkdir -p ${VARIANT_DIR} firmwares
49+
(set -e ; cd ${BUILD_DIR} && rm -rf llext-edk && tar xf zephyr/llext-edk.tar.Z)
50+
rsync -a --delete ${BUILD_DIR}/llext-edk ${VARIANT_DIR}/
51+
52+
# remove all inline comments in macro definitions
53+
# (especially from devicetree_generated.h and sys/util_internal.h)
54+
line_preproc_ok='^\s*#\s*(if|else|elif|endif)' # match conditional preproc lines
55+
line_comment_only='^\s*\/\*' # match lines starting with comment
56+
line_continuation='\\$' # match lines ending with '\'
57+
c_comment='\s*\/\*.*?\*\/' # match C-style comments and any preceding space
58+
perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find ${VARIANT_DIR}/llext-edk/include/ -type f)
59+
for ext in elf bin hex; do
60+
rm -f firmwares/zephyr-$variant.$ext
61+
if [ -f ${BUILD_DIR}/zephyr/zephyr.$ext ]; then
62+
cp ${BUILD_DIR}/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext
63+
fi
64+
done
65+
3366
# Generate the provides.ld file for linked builds
3467
echo "Exporting provides.ld"
3568
READELF=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf
36-
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > variants/$variant/provides.ld
37-
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> variants/$variant/provides.ld
38-
$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
39-
$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> variants/$variant/provides.ld
40-
$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
41-
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
42-
TEXT_START=`cat loader/boards/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"`
43-
echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> variants/$variant/provides.ld
44-
45-
sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' variants/$variant/provides.ld
46-
sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' variants/$variant/provides.ld
47-
sed -i 's/PROVIDE(realloc =/PROVIDE(__wrap_realloc =/g' variants/$variant/provides.ld
48-
sed -i 's/PROVIDE(calloc =/PROVIDE(__wrap_calloc =/g' variants/$variant/provides.ld
49-
sed -i 's/PROVIDE(random =/PROVIDE(__wrap_random =/g' variants/$variant/provides.ld
69+
$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > ${VARIANT_DIR}/provides.ld
70+
$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
71+
$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
72+
$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
73+
$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
74+
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
75+
TEXT_START=`cat variants/$variant/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"`
76+
echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> ${VARIANT_DIR}/provides.ld
77+
78+
sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' ${VARIANT_DIR}/provides.ld
79+
sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' ${VARIANT_DIR}/provides.ld
80+
sed -i 's/PROVIDE(realloc =/PROVIDE(__wrap_realloc =/g' ${VARIANT_DIR}/provides.ld
81+
sed -i 's/PROVIDE(calloc =/PROVIDE(__wrap_calloc =/g' ${VARIANT_DIR}/provides.ld
82+
sed -i 's/PROVIDE(random =/PROVIDE(__wrap_random =/g' ${VARIANT_DIR}/provides.ld
83+
84+
cmake -P extra/gen_arduino_files.cmake $variant

Diff for: extra/build_all.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
set -e
44

5-
./extra/build.sh arduino_giga_r1//m7 arduino_giga_r1_m7 giga_display_shield
6-
./extra/build.sh arduino_nano_33_ble//sense arduino_nano_33_ble_sense
7-
./extra/build.sh arduino_portenta_h7//m7 arduino_portenta_h7
8-
./extra/build.sh ek_ra8d1 ek_ra8d1
9-
./extra/build.sh frdm_mcxn947/mcxn947/cpu0 frdm_mcxn947_mcxn947_cpu0
10-
./extra/build.sh frdm_rw612 frdm_rw612
11-
./extra/build.sh arduino_portenta_c33 arduino_portenta_c33
5+
./extra/build.sh arduino_giga_r1//m7 --shield giga_display_shield
6+
./extra/build.sh arduino_nano_33_ble//sense
7+
./extra/build.sh arduino_nicla_sense_me
8+
./extra/build.sh arduino_portenta_c33
9+
./extra/build.sh [email protected]//m7
10+
./extra/build.sh ek_ra8d1
11+
./extra/build.sh frdm_mcxn947/mcxn947/cpu0
12+
./extra/build.sh frdm_rw612

Diff for: extra/gen_arduino_files.cmake

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# get root dir for the project
2+
cmake_path(SET TOP_DIR NORMALIZE ${CMAKE_CURRENT_LIST_DIR}/..)
3+
4+
# get list of variants to be applied
5+
if(CMAKE_ARGC GREATER 3)
6+
# cmake -P <script> <variant> ...
7+
foreach(index RANGE 4 ${CMAKE_ARGC})
8+
math(EXPR index "${index} - 1")
9+
list(APPEND VARIANTS "${CMAKE_ARGV${index}}")
10+
endforeach()
11+
list(TRANSFORM VARIANTS REPLACE "/$" "")
12+
list(TRANSFORM VARIANTS REPLACE ".*/" "")
13+
else()
14+
# build for all valid variants
15+
file(GLOB VARIANTS RELATIVE ${TOP_DIR}/variants variants/*)
16+
list(REMOVE_ITEM VARIANTS llext linked)
17+
endif()
18+
19+
foreach(variant ${VARIANTS})
20+
if(NOT IS_DIRECTORY variants/${variant})
21+
continue()
22+
endif()
23+
24+
cmake_path(SET dir ${TOP_DIR}/variants/${variant})
25+
if(NOT EXISTS ${dir}/llext-edk/cmake.cflags)
26+
continue()
27+
endif()
28+
29+
message(STATUS "Processing ${variant}")
30+
include(${dir}/llext-edk/cmake.cflags)
31+
32+
list(TRANSFORM LLEXT_ALL_INCLUDE_CFLAGS REPLACE "-I${dir}" "-iwithprefixbefore")
33+
list(JOIN LLEXT_ALL_INCLUDE_CFLAGS "\n" EDK_INCLUDES)
34+
file(WRITE ${dir}/includes.txt "${EDK_INCLUDES}")
35+
36+
# exclude -imacros entries in platform from the list, make sure no others are present
37+
list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-imacros.*autoconf.h")
38+
list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-imacros.*zephyr_stdint.h")
39+
set(other_imacros "${LLEXT_BASE_CFLAGS}")
40+
list(FILTER other_imacros INCLUDE REGEX "-imacros.*")
41+
if(other_imacros)
42+
message(FATAL_ERROR "Unexpected -imacros in LLEXT_BASE_CFLAGS: ${other_imacros}")
43+
endif()
44+
45+
# exclude other problematic macros shared between C and C++
46+
list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-fdiagnostics-color=always")
47+
48+
# (temp) generate C++ flags from C flags
49+
set(LLEXT_BASE_CXXFLAGS ${LLEXT_BASE_CFLAGS})
50+
list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-Wno-pointer-sign")
51+
list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-Werror=implicit-int")
52+
list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-std=c.*")
53+
54+
# save flag files
55+
list(JOIN LLEXT_BASE_CFLAGS "\n" EDK_CFLAGS)
56+
file(WRITE ${dir}/cflags.txt "${EDK_CFLAGS}")
57+
58+
59+
list(JOIN LLEXT_BASE_CXXFLAGS "\n" EDK_CXXFLAGS)
60+
file(WRITE ${dir}/cxxflags.txt "${EDK_CXXFLAGS}")
61+
endforeach()

Diff for: extra/get_variant_name.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (C) 2025 Arduino SA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
#
5+
# Generate NORMALIZED_BOARD_TARGET from BOARD via the Zephyr build system
6+
#
7+
8+
cmake_minimum_required(VERSION 3.20.0)
9+
10+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
11+
message(STATUS "VARIANT=${NORMALIZED_BOARD_TARGET}")

Diff for: extra/post_build_tool/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

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

9191
// Write the new content to the new file

Diff for: extra/post_build_tool/zephyr-post-build-tool

2.41 MB
Binary file not shown.

Diff for: firmwares/zephyr-arduino_giga_r1_m7.bin

-176 KB
Binary file not shown.

Diff for: firmwares/zephyr-arduino_giga_r1_m7.elf

-2.84 MB
Binary file not shown.

Diff for: firmwares/zephyr-arduino_giga_r1_stm32h747xx_m7.bin

178 KB
Binary file not shown.

Diff for: firmwares/zephyr-arduino_giga_r1_stm32h747xx_m7.elf

2.88 MB
Binary file not shown.

0 commit comments

Comments
 (0)