diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0076045b6..c10a65dd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/package_core.yml b/.github/workflows/package_core.yml index dc3f91c21..1645d148b 100644 --- a/.github/workflows/package_core.yml +++ b/.github/workflows/package_core.yml @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/.gitignore b/.gitignore index 5c3ff0e6e..972e0d839 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ /distrib/ /firmwares/* /venv/ +/boards.local.txt + llext-edk/ cflags.txt cxxflags.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 47fd59e7e..8f54d2afe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,13 @@ # 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}) @@ -7,14 +15,30 @@ if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_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-' 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() diff --git a/README.gsoc.md b/README.gsoc.md index 2d2309097..b40655fd5 100644 --- a/README.gsoc.md +++ b/README.gsoc.md @@ -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 ///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) diff --git a/README.md b/README.md index e07568ab1..c35ea3399 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/boards.txt b/boards.txt index 639e54262..5cdbabb87 100644 --- a/boards.txt +++ b/boards.txt @@ -1,3 +1,21 @@ + +########################################################################################## + +# NOTE: +# +# The following board-specific properties are auto-generated by 'build.sh' +# and saved in 'boards.local.txt'. VALUES IN THIS FILE WILL HAVE NO EFFECT. +# +# - build.architecture +# - build.float-abi +# - build.fpu +# - build.mcu +# - upload.address +# - upload.maximum_data_size +# - upload.maximum_size + +########################################################################################## + menu.debug=Debug menu.link_mode=Link mode menu.flash_mode=Flash mode @@ -17,21 +35,15 @@ giga.menu.debug.true.build.zsk_args.debug=-debug giga.menu.link_mode.dynamic=Dynamic giga.menu.link_mode.static=Static giga.menu.link_mode.static.build.link_mode=static -giga.menu.link_mode.static.upload.extension=bin-zsk.bin giga.build.zephyr_target=arduino_giga_r1//m7 giga.build.zephyr_args=--shield arduino_giga_display_shield giga.build.zephyr_hals=hal_stm32 hal_infineon +giga.build.zephyr_toolchain=arm-zephyr-eabi giga.build.variant=arduino_giga_r1_stm32h747xx_m7 giga.build.artifact=zephyr_main -giga.build.mcu=cortex-m7 -giga.build.fpu=-mfpu=fpv5-d16 -giga.build.architecture=cortex-m7 -giga.build.float-abi=-mfloat-abi=softfp -giga.build.extra_flags= giga.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -giga.build.architecture=cortex-m7 giga.build.board=GIGA giga.vid.0=0x2341 giga.pid.0=0x0066 @@ -48,13 +60,6 @@ giga.upload.interface=0 giga.upload.use_1200bps_touch=true giga.upload.wait_for_upload_port=true giga.upload.native_usb=true -giga.upload.maximum_size=1966080 -giga.upload.maximum_data_size=523624 - -giga.upload.address=0x080E0000 - -giga.upload.maximum_size=786432 -giga.upload.maximum_data_size=523624 giga.bootloader.tool=dfu-util giga.bootloader.tool.default=dfu-util @@ -85,21 +90,15 @@ nano33ble.menu.debug.true.build.zsk_args.debug=-debug nano33ble.menu.link_mode.dynamic=Dynamic nano33ble.menu.link_mode.static=Static nano33ble.menu.link_mode.static.build.link_mode=static -nano33ble.menu.link_mode.static.upload.extension=bin-zsk.bin nano33ble.build.zephyr_target=arduino_nano_33_ble//sense nano33ble.build.zephyr_args= nano33ble.build.zephyr_hals=hal_nordic +nano33ble.build.zephyr_toolchain=arm-zephyr-eabi nano33ble.build.artifact=zephyr_main nano33ble.build.variant=arduino_nano_33_ble_nrf52840_sense -nano33ble.build.mcu=cortex-m4 -nano33ble.build.fpu=-mfpu=fpv4-sp-d16 -nano33ble.build.architecture=cortex-m4 -nano33ble.build.float-abi=-mfloat-abi=hard -nano33ble.build.extra_flags= nano33ble.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -nano33ble.build.architecture=cortex-m4 nano33ble.build.board=NANO33BLE nano33ble.vid.0=0x2341 nano33ble.pid.0=0x035a @@ -116,12 +115,6 @@ nano33ble.upload.interface=0 nano33ble.upload.use_1200bps_touch=true nano33ble.upload.wait_for_upload_port=true nano33ble.upload.native_usb=true -nano33ble.upload.maximum_size=1966080 -nano33ble.upload.maximum_data_size=523624 -nano33ble.upload.address=0xD0000 - -nano33ble.upload.maximum_size=786432 -nano33ble.upload.maximum_data_size=523624 nano33ble.bootloader.tool=bossac nano33ble.bootloader.tool.default=bossac @@ -151,20 +144,14 @@ ek_ra8d1.menu.debug.true.build.zsk_args.debug=-debug ek_ra8d1.menu.link_mode.dynamic=Dynamic ek_ra8d1.menu.link_mode.static=Static ek_ra8d1.menu.link_mode.static.build.link_mode=static -ek_ra8d1.menu.link_mode.static.upload.extension=bin-zsk.bin ek_ra8d1.build.zephyr_target=ek_ra8d1 ek_ra8d1.build.zephyr_args= ek_ra8d1.build.zephyr_hals=hal_renesas +ek_ra8d1.build.zephyr_toolchain=arm-zephyr-eabi ek_ra8d1.build.variant=ek_ra8d1_r7fa8d1bhecbd -ek_ra8d1.build.mcu=cortex-m85+nomve -ek_ra8d1.build.fpu=-mfpu=fpv5-d16 -ek_ra8d1.build.architecture=cortex-m85+nomve -ek_ra8d1.build.float-abi=-mfloat-abi=hard -ek_ra8d1.build.extra_flags= ek_ra8d1.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -ek_ra8d1.build.architecture=cortex-m85+nomve ek_ra8d1.build.board=EK_RA8D1 #ek_ra8d1.recipe.hooks.objcopy.postobjcopy.4.pattern=cp {build.variant.path}/flasher.jlink "{build.path}/flasher.jlink" @@ -185,9 +172,6 @@ ek_ra8d1.upload.interface=0 ek_ra8d1.upload.use_1200bps_touch=false ek_ra8d1.upload.wait_for_upload_port=false ek_ra8d1.upload.native_usb=true -ek_ra8d1.upload.maximum_size=1966080 -ek_ra8d1.upload.maximum_data_size=523624 -ek_ra8d1.upload.address=0x2032000 ek_ra8d1.upload.target=R7FA8D1AH ek_ra8d1.bootloader.tool=pyocd @@ -210,25 +194,19 @@ frdm_mcxn947.menu.debug.true.build.zsk_args.debug=-debug frdm_mcxn947.menu.link_mode.dynamic=Dynamic frdm_mcxn947.menu.link_mode.static=Static frdm_mcxn947.menu.link_mode.static.build.link_mode=static -frdm_mcxn947.menu.link_mode.static.upload.extension=bin-zsk.bin frdm_mcxn947.build.zephyr_target=frdm_mcxn947//cpu0 frdm_mcxn947.build.zephyr_args= frdm_mcxn947.build.zephyr_hals=hal_nxp +frdm_mcxn947.build.zephyr_toolchain=arm-zephyr-eabi frdm_mcxn947.build.variant=frdm_mcxn947_mcxn947_cpu0 -frdm_mcxn947.build.mcu=cortex-m33 -frdm_mcxn947.build.fpu=-mfpu=fpv5-sp-d16 -frdm_mcxn947.build.architecture=cortex-m33 -frdm_mcxn947.build.float-abi=-mfloat-abi=hard -frdm_mcxn947.build.extra_flags= frdm_mcxn947.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit frdm_mcxn947.build.board=FRDM_MCXN947 frdm_mcxn947.vid.0=0x1fc9 frdm_mcxn947.pid.0=0x0143 frdm_mcxn947.upload_port.0.vid=0x1fc9 frdm_mcxn947.upload_port.0.pid=0x0143 -frdm_mcxn947.upload.address=0x100F0000 frdm_mcxn947.upload.target=mcxn947vdf frdm_mcxn947.upload.tool=pyocd @@ -241,8 +219,6 @@ frdm_mcxn947.upload.interface=0 frdm_mcxn947.upload.use_1200bps_touch=false frdm_mcxn947.upload.wait_for_upload_port=false frdm_mcxn947.upload.native_usb=true -frdm_mcxn947.upload.maximum_size=1966080 -frdm_mcxn947.upload.maximum_data_size=523624 frdm_mcxn947.bootloader.tool=pyocd frdm_mcxn947.bootloader.tool.default=pyocd @@ -264,21 +240,15 @@ portentah7.menu.debug.true.build.zsk_args.debug=-debug portentah7.menu.link_mode.dynamic=Dynamic portentah7.menu.link_mode.static=Static portentah7.menu.link_mode.static.build.link_mode=static -portentah7.menu.link_mode.static.upload.extension=bin-zsk.bin portentah7.build.zephyr_target=arduino_portenta_h7@1.0.0//m7 portentah7.build.zephyr_args= portentah7.build.zephyr_hals=hal_stm32 hal_infineon +portentah7.build.zephyr_toolchain=arm-zephyr-eabi portentah7.build.artifact=zephyr_main portentah7.build.variant=arduino_portenta_h7_stm32h747xx_m7 -portentah7.build.mcu=cortex-m7 -portentah7.build.fpu=-mfpu=fpv5-d16 -portentah7.build.architecture=cortex-m7 -portentah7.build.float-abi=-mfloat-abi=softfp -portentah7.build.extra_flags= portentah7.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -portentah7.build.architecture=cortex-m7 portentah7.build.board=PORTENTA_H7_M7 portentah7.vid.0=0x2341 portentah7.pid.0=0x005b @@ -295,13 +265,6 @@ portentah7.upload.interface=0 portentah7.upload.use_1200bps_touch=true portentah7.upload.wait_for_upload_port=true portentah7.upload.native_usb=true -portentah7.upload.maximum_size=1966080 -portentah7.upload.maximum_data_size=523624 - -portentah7.upload.address=0x080E0000 - -portentah7.upload.maximum_size=786432 -portentah7.upload.maximum_data_size=523624 portentah7.bootloader.tool=dfu-util portentah7.bootloader.tool.default=dfu-util @@ -332,25 +295,19 @@ frdm_rw612.menu.debug.true.build.zsk_args.debug=-debug frdm_rw612.menu.link_mode.dynamic=Dynamic frdm_rw612.menu.link_mode.static=Static frdm_rw612.menu.link_mode.static.build.link_mode=static -frdm_rw612.menu.link_mode.static.upload.extension=bin-zsk.bin frdm_rw612.build.zephyr_target=frdm_rw612 frdm_rw612.build.zephyr_args= frdm_rw612.build.zephyr_hals=hal_stm32 +frdm_rw612.build.zephyr_toolchain=arm-zephyr-eabi frdm_rw612.build.variant=frdm_rw612_rw612 -frdm_rw612.build.mcu=cortex-m33+nodsp -frdm_rw612.build.fpu=-mfpu=fpv5-sp-d16 -frdm_rw612.build.architecture=cortex-m33+nodsp -frdm_rw612.build.float-abi=-mfloat-abi=hard -frdm_rw612.build.extra_flags= frdm_rw612.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit frdm_rw612.build.board=FRDM_RW612 frdm_rw612.vid.0=0x1fc9 frdm_rw612.pid.0=0x0143 frdm_rw612.upload_port.0.vid=0x1fc9 frdm_rw612.upload_port.0.pid=0x0143 -frdm_rw612.upload.address=0x18323000 frdm_rw612.upload.target=rw612 frdm_rw612.upload.tool=pyocd @@ -363,8 +320,6 @@ frdm_rw612.upload.interface=0 frdm_rw612.upload.use_1200bps_touch=false frdm_rw612.upload.wait_for_upload_port=false frdm_rw612.upload.native_usb=true -frdm_rw612.upload.maximum_size=1966080 -frdm_rw612.upload.maximum_data_size=523624 frdm_rw612.bootloader.tool=pyocd frdm_rw612.bootloader.tool.default=pyocd @@ -381,21 +336,15 @@ niclasense.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/ niclasense.menu.link_mode.dynamic=Dynamic niclasense.menu.link_mode.static=Static niclasense.menu.link_mode.static.build.link_mode=static -niclasense.menu.link_mode.static.upload.extension=bin-zsk.bin niclasense.build.zephyr_target=arduino_nicla_sense_me niclasense.build.zephyr_args= niclasense.build.zephyr_hals=hal_nordic +niclasense.build.zephyr_toolchain=arm-zephyr-eabi niclasense.build.artifact=zephyr_main niclasense.build.variant=arduino_nicla_sense_me_nrf52832 -niclasense.build.mcu=cortex-m4 -niclasense.build.fpu=-mfpu=fpv4-sp-d16 -niclasense.build.architecture=cortex-m4 -niclasense.build.float-abi=-mfloat-abi=hard -niclasense.build.extra_flags= niclasense.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -niclasense.build.architecture=cortex-m4 niclasense.build.board=NICLA_SENSE_ME niclasense.vid.0=0x2341 niclasense.pid.0=0x0360 @@ -413,14 +362,8 @@ niclasense.upload.interface=0 niclasense.upload.use_1200bps_touch=false niclasense.upload.wait_for_upload_port=false niclasense.upload.native_usb=false -niclasense.upload.maximum_size=1966080 -niclasense.upload.maximum_data_size=523624 -niclasense.upload.address=0x70000 niclasense.upload.target=nrf52 -niclasense.upload.maximum_size=786432 -niclasense.upload.maximum_data_size=523624 - niclasense.bootloader.tool=openocd niclasense.bootloader.tool.default=openocd niclasense.bootloader.vid=0x2341 @@ -450,19 +393,14 @@ portentac33.menu.debug.true.build.zsk_args.debug=-debug portentac33.menu.link_mode.dynamic=Dynamic portentac33.menu.link_mode.static=Static portentac33.menu.link_mode.static.build.link_mode=static -portentac33.menu.link_mode.static.upload.extension=bin-zsk.bin portentac33.build.zephyr_target=arduino_portenta_c33 portentac33.build.zephyr_args= portentac33.build.zephyr_hals=hal_renesas nanopb +portentac33.build.zephyr_toolchain=arm-zephyr-eabi portentac33.build.artifact=zephyr_main portentac33.build.variant=arduino_portenta_c33_r7fa6m5bh3cfc -portentac33.build.mcu=cortex-m33 -portentac33.build.fpu=-mfpu=fpv5-sp-d16 -portentac33.build.architecture=cortex-m33 -portentac33.build.float-abi=-mfloat-abi=hard -portentac33.build.extra_flags= portentac33.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit portentac33.build.board=PORTENTA_C33 portentac33.vid.0=0x2341 @@ -481,9 +419,6 @@ portentac33.upload.interface=1 portentac33.upload.use_1200bps_touch=true portentac33.upload.wait_for_upload_port=false portentac33.upload.native_usb=true -portentac33.upload.maximum_size=1966080 -portentac33.upload.maximum_data_size=523624 -portentac33.upload.address=0x100000 portentac33.upload.dfuse=-Q -w portentac33.bootloader.tool=dfu-util @@ -507,21 +442,15 @@ opta.menu.debug.true.build.zsk_args.debug=-debug opta.menu.link_mode.dynamic=Dynamic opta.menu.link_mode.static=Static opta.menu.link_mode.static.build.link_mode=static -opta.menu.link_mode.static.upload.extension=bin-zsk.bin opta.build.zephyr_target=arduino_opta//m7 opta.build.zephyr_args= opta.build.zephyr_hals=hal_stm32 hal_infineon +opta.build.zephyr_toolchain=arm-zephyr-eabi opta.build.artifact=zephyr_main opta.build.variant=arduino_opta_stm32h747xx_m7 -opta.build.mcu=cortex-m7 -opta.build.fpu=-mfpu=fpv5-d16 -opta.build.architecture=cortex-m7 -opta.build.float-abi=-mfloat-abi=softfp -opta.build.extra_flags= opta.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -opta.build.architecture=cortex-m7 opta.build.board=OPTA opta.vid.0=0x2341 opta.pid.0=0x0064 @@ -538,13 +467,6 @@ opta.upload.interface=0 opta.upload.use_1200bps_touch=true opta.upload.wait_for_upload_port=true opta.upload.native_usb=true -opta.upload.maximum_size=1966080 -opta.upload.maximum_data_size=523624 - -opta.upload.address=0x080E0000 - -opta.upload.maximum_size=786432 -opta.upload.maximum_data_size=523624 opta.bootloader.tool=dfu-util opta.bootloader.tool.default=dfu-util @@ -571,21 +493,15 @@ nano_matter.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/ nano_matter.menu.link_mode.dynamic=Dynamic nano_matter.menu.link_mode.static=Static nano_matter.menu.link_mode.static.build.link_mode=static -nano_matter.menu.link_mode.static.upload.extension=bin-zsk.bin nano_matter.build.zephyr_target=arduino_nano_matter nano_matter.build.zephyr_args= nano_matter.build.zephyr_hals=hal_silabs +nano_matter.build.zephyr_toolchain=arm-zephyr-eabi nano_matter.build.artifact=zephyr_main nano_matter.build.variant=arduino_nano_matter_mgm240sd22vna -nano_matter.build.mcu=cortex-m33 -nano_matter.build.fpu=-mfpu=fpv4-sp-d16 -nano_matter.build.architecture=cortex-m33 -nano_matter.build.float-abi=-mfloat-abi=hard -nano_matter.build.extra_flags= nano_matter.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit -nano_matter.build.architecture=cortex-m33 nano_matter.build.board=ARDUINO_NANO_MATTER nano_matter.vid.0=0x2341 nano_matter.pid.0=0x0072 @@ -596,9 +512,6 @@ nano_matter.upload.tool=openocd nano_matter.upload.tool.default=openocd nano_matter.upload.config=-f target/efm32s2_g23.cfg nano_matter.upload.programmer=-f interface/cmsis-dap.cfg -nano_matter.upload.maximum_data_size=262144 -nano_matter.upload.maximum_size=1572864 -nano_matter.upload.address=0x080C4000 nano_matter.upload.protocol=SWD nano_matter.upload.setup_command= nano_matter.upload.use_1200bps_touch=false @@ -636,7 +549,6 @@ unoq.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/ unoq.menu.link_mode.dynamic=Dynamic unoq.menu.link_mode.static=Static unoq.menu.link_mode.static.build.link_mode=static -unoq.menu.link_mode.static.upload.extension=bin-zsk.bin unoq.menu.flash_mode.flash=Flash unoq.menu.flash_mode.flash.openocd_cfg=flash_sketch.cfg @@ -651,23 +563,15 @@ unoq.build.zephyr_args= unoq.build.variant=arduino_uno_q_stm32u585xx unoq.build.artifact=zephyr_unoq unoq.build.subarch=zephyr -unoq.build.mcu=cortex-m33 -unoq.build.fpu=-mfpu=fpv5-sp-d16 -unoq.build.architecture=cortex-m33 -unoq.compiler.zephyr.arch.define= -unoq.build.float-abi=-mfloat-abi=hard -unoq.build.extra_flags= unoq.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit unoq.build.board=UNO_Q unoq.build.zephyr_hals=hal_stm32 -unoq.compiler.zephyr.arch.define= -unoq.compiler.zephyr= +unoq.build.zephyr_toolchain=arm-zephyr-eabi unoq.vid.0=0x2341 unoq.pid.0=0x0078 unoq.upload_port.0.vid=0x2341 unoq.upload_port.0.pid=0x0078 -unoq.upload.address=0x8100000 unoq.upload.target=stm32u585zitxq unoq.upload.tool=remoteocd @@ -681,8 +585,6 @@ unoq.upload.interface=0 unoq.upload.use_1200bps_touch=false unoq.upload.wait_for_upload_port=false unoq.upload.native_usb=true -unoq.upload.maximum_size=1966080 -unoq.upload.maximum_data_size=523624 unoq.bootloader.tool=remoteocd unoq.bootloader.tool.default=remoteocd diff --git a/cores/CMakeLists.txt b/cores/CMakeLists.txt index 3ce59d21d..626fe6b12 100644 --- a/cores/CMakeLists.txt +++ b/cores/CMakeLists.txt @@ -1,15 +1,3 @@ # SPDX-License-Identifier: Apache-2.0 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() diff --git a/cores/arduino/api b/cores/arduino/api deleted file mode 120000 index d32ec6953..000000000 --- a/cores/arduino/api +++ /dev/null @@ -1 +0,0 @@ -../../../modules/lib/ArduinoCore-API/api/ \ No newline at end of file diff --git a/expand.py b/expand.py new file mode 100755 index 000000000..7066f06b0 --- /dev/null +++ b/expand.py @@ -0,0 +1,314 @@ +#!/usr/bin/env python3 +import argparse +import fnmatch +import os +import re +import platform +import shlex +import sys + +# 'compiler.ar.flags' +# 'compiler.c.elf.flags' +# 'compiler.c.flags' +# 'compiler.cpp.extra_flags' +# 'compiler.cpp.flags' +# 'compiler.libraries.ldflags' +# 'compiler.optimization_flags' +# 'serial.port' +# 'serial.port.file' + +ARDUINO_VARS=set([ + 'archive_file', + 'archive_file_path', + 'build.arch', + 'build.board', + 'build.board.platform.path', + 'build.core.path', + 'build.core.platform.path', + 'build.extra_flags', + 'build.fqbn', + 'build.library_discovery_phase', + 'build.path', + 'build.project_name', + 'build.source.path', + 'build.system.path', + 'build.variant.path', + 'config.path', + 'directories.data', + 'directories.user', + 'extra.time.dst', + 'extra.time.local', + 'extra.time.utc', + 'extra.time.zone', + '_id', + 'ide_version', + 'includes', + 'object_file', + 'object_files', + 'preprocessed_file_path', + 'program.verbose', + 'program.verify', + 'runtime.tools.*.path', + 'runtime.hardware.path', + 'runtime.ide.path', + 'runtime.ide.version', + 'runtime.os', + 'runtime.platform.path', + 'runtime.tools.*.path', + 'runtime.use_core_platform_path_for_runtime_platform_path', + 'sketch_path', + 'software', + 'source_file', + 'upload.field.*', + 'upload.maximum_data_size', + 'upload.maximum_size', + 'upload.params.quiet', + 'upload.params.verbose', + 'upload.port.*', + 'upload.verbose', + 'upload.verify', +]) + +class ArduinoPlatformExpander: + def __init__(self, platform_path, boards_path): + self.platform_data = self._parse_file(platform_path) + self.boards_data = self._parse_file(boards_path) + + # Standard system variables normally provided by the IDE/CLI + self.system_vars = { + } + + def _detect_os(self): + sys_platform = platform.system().lower() + if sys_platform == "windows": + return "windows" + elif sys_platform == "darwin": + return "macosx" + else: + return "linux" + + def _parse_file(self, filepath): + """ + Parses a .txt file (key=value) into a dictionary. + Ignores comments (#) and empty lines. + """ + data = {} + if not os.path.exists(filepath): + print(f"Warning: File {filepath} not found.") + return data + + with open(filepath, 'r', encoding='utf-8') as f: + for line in f: + line = line.strip() + if not line or line.startswith('#'): + continue + + if '=' in line: + key, value = line.split('=', 1) + data[key.strip()] = value.strip() + return data + + def _apply_os_overrides(self, data, os): + """ + Looks for keys ending in .linux, .windows, .macosx and overrides the base key. + """ + if not os: + os = self._detect_os() + suffix = "." + os + + overrides = {} + for key, value in data.items(): + if key.endswith(suffix): + base_key = key[:-len(suffix)] + overrides[base_key] = value + + data.update(overrides) + return data + + def list_boards(self): + """Returns a list of available board identifiers.""" + boards = set() + for key in self.boards_data: + if "." in key: + boards.add(key.split('.')[0]) + return sorted(list(boards)) + + def list_menus(self, board_id): + """Returns available menu options for a specific board.""" + menus = {} + prefix = f"{board_id}.menu." + for key, value in self.boards_data.items(): + if key.startswith(prefix): + # Format: board.menu.menu_id.election_id=Label + parts = key[len(prefix):].split('.') + if len(parts) >= 2: + menu_id = parts[0] + selection_id = parts[1] + # We usually want the label, which is the value of this specific key + # if the key ends there. + if len(parts) == 2: + if menu_id not in menus: menus[menu_id] = [] + menus[menu_id].append((selection_id, value)) + return menus + + def expand_vars(self, board_id, menu_selections=None, os=None): + """ + Main logic to expand variables for a specific board configuration. + + 1. Load global platform.txt variables. + 2. Merge system variables. + 3. Load board-specific variables (stripping board_id). + 4. Load menu-specific variables (stripping menu prefixes). + 5. Apply OS overrides. + 6. Recursively resolve {variables}. + """ + if menu_selections is None: + menu_selections = {} + + # 1. Start with platform global definitions + context = self.platform_data.copy() + + # 2. Add System variables + context.update(self.system_vars) + + # 3. Merge Board specific properties + # Format: board_id.property=value -> property=value + board_prefix = f"{board_id}." + for key, value in self.boards_data.items(): + if key.startswith(board_prefix): + # We strip the board prefix to make it a global property in this context + # e.g. 'uno.build.mcu' becomes 'build.mcu' + clean_key = key[len(board_prefix):] + + # Check if this is a menu definition (we ignore definitions of menus themselves here, + # we only want the properties that result from a menu selection) + if not clean_key.startswith("menu."): + context[clean_key] = value + + # 4. Merge Menu selections + # Format: board_id.menu.menu_id.selection_id.property=value -> property=value + for menu_id, selection_id in menu_selections.items(): + menu_prefix = f"{board_id}.menu.{menu_id}.{selection_id}." + for key, value in self.boards_data.items(): + if key.startswith(menu_prefix): + clean_key = key[len(menu_prefix):] + context[clean_key] = value + + # 5. Apply OS Overrides (e.g., tools.x.path.windows overrides tools.x.path) + context = self._apply_os_overrides(context, os) + + # 6. Recursive Variable Expansion + return self._recursive_expansion(context) + + def _recursive_expansion(self, context): + """ + Resolves {key} references until no changes occur. + """ + # Regex to find {variable} + var_pattern = re.compile(r'\{([\w\.\-_]+)\}') + + used_context = set() + while True: + changes_made = False + missing_vars = set() + for key, value in context.items(): + if value is None: continue + + # Find all {vars} in the current value + matches = var_pattern.findall(value) + + if not matches: + continue + + new_value = value + for match in matches: + if match in context: + used_context.add(match) + # Replace {match} with its value from context + # We use a safe replacement to avoid regex injection issues + replace_val = context[match] + new_value = new_value.replace(f"{{{match}}}", replace_val) + changes_made = True + else: + missing_vars.add(match) + + if changes_made: + context[key] = new_value + + if not changes_made: + break + + return context, used_context, missing_vars + +# ========================================== +# Example Usage +# ========================================== +if __name__ == "__main__": + + # parse arguments + parser = argparse.ArgumentParser(description="Expand Arduino platform and board configurations.") + parser.add_argument("board", help="Board identifier to expand.") + parser.add_argument("selections", nargs="*", help="Selection for menu options.") + parser.add_argument("--os", choices=["windows", "linux", "macosx"], help="Override OS (windows, linux, macosx).") + parser.add_argument("--unused", "-u", action="store_true", help="Show variables that were defined but not used in the final expansion.") + parser.add_argument("--verbose", "-v", action="store_true", help="List each argument of each variable") + args = parser.parse_args() + + # Initialize + expander = ArduinoPlatformExpander("platform.txt", "boards.txt") + + if args.board not in expander.list_boards(): + print(f"Error: Board '{args.board}' not found.") + print("Available Boards:", expander.list_boards()) + sys.exit(1) + + board_menus = expander.list_menus(args.board) + menu_selections = {} + for selection in args.selections: + if '=' not in selection: + print(f"Invalid selection format: {selection}. Expected format is menu_id=selection_id.") + sys.exit(1) + + menu_id, selection_id = selection.split('=', 1) + if menu_id not in board_menus: + print(f"Error: Menu '{menu_id}' not found for board '{args.board}'.") + print(f"Menus for {args.board}:", board_menus) + sys.exit(1) + if selection_id not in [ m[0] for m in board_menus[menu_id] ]: + print(f"Error: Selection '{selection_id}' not found for menu '{menu_id}' on board '{args.board}'.") + print(f"Available selections for {menu_id}:", [ m[0] for m in board_menus[menu_id] ]) + sys.exit(1) + + menu_selections[menu_id] = selection_id + + # Expand + exp_vars, used_vars, missing_vars = expander.expand_vars(args.board, menu_selections, os=args.os) + + print(f"#\n# {args.board} {menu_selections}\n#\n") + + if args.unused: + unused_vars = set(exp_vars.keys()) - used_vars + + print(f"# Unused variables:\n#") + for k in sorted(unused_vars): + print(f"# {k}={exp_vars[k]}") + print() + + print(f"# Unset variables:\n#") + for k in sorted(missing_vars): + for pattern in ARDUINO_VARS: + if fnmatch.fnmatch(k, pattern): + break + else: + print(f"# {k}") + print() + + if args.verbose: + for k in sorted(exp_vars): + lexer = shlex.shlex(exp_vars[k], posix=False) + lexer.whitespace_split = True + for tok in lexer: + print(f"{k} {tok}") + else: + for k in sorted(exp_vars): + print(f"{k}={exp_vars[k]}") diff --git a/extra/bootstrap.sh b/extra/bootstrap.sh index ef3d48929..9b7e60e1f 100755 --- a/extra/bootstrap.sh +++ b/extra/bootstrap.sh @@ -1,24 +1,21 @@ #!/bin/bash -# + # Copyright (c) Arduino s.r.l. and/or its affiliated companies # SPDX-License-Identifier: Apache-2.0 -set -e +# Initialize the Zephyr workspace from a cleanly cloned ArduinoCore-zephyr +# repository, fetching only the necessary modules and blobs for the supported +# boards. -log_msg() { - if [ -n $GITHUB_WORKSPACE ] ; then - echo "::$1::$2" - else - echo " - $2" - fi -} +. $(dirname $0)/functions if [ ! -f platform.txt ]; then echo Launch this script from the root core folder as ./extra/bootstrap.sh exit 2 fi -NEEDED_HALS=$(grep 'build.zephyr_hals=' boards.txt | cut -d '=' -f 2 | xargs -n 1 echo | sort -u | xargs echo) +NEEDED_HALS=$(get_unique_values_from_text_file boards.txt 'build.zephyr_hals') +NEEDED_TOOLCHAINS=$(get_unique_values_from_text_file boards.txt 'build.zephyr_toolchain') HAL_FILTER="-hal_.*" for hal in $NEEDED_HALS; do @@ -36,13 +33,14 @@ west init -l . west config manifest.project-filter -- "$HAL_FILTER" west update "$@" west zephyr-export -pip install -r ../zephyr/scripts/requirements-base.txt +west packages pip --install log_msg "endgroup" -log_msg "group" "Installing Zephyr SDK 0.16.8" -west sdk install --version 0.16.8 -t arm-zephyr-eabi +log_msg "group" "Installing Zephyr SDK 0.16.8: $NEEDED_TOOLCHAINS" +west sdk install --version 0.16.8 -t $NEEDED_TOOLCHAINS log_msg "endgroup" +NEEDED_HALS="arduino-api $NEEDED_HALS" log_msg "group" "Fetching blobs for: $NEEDED_HALS" west blobs fetch $NEEDED_HALS log_msg "endgroup" diff --git a/extra/build.sh b/extra/build.sh index e490e1c3f..47c4017d9 100755 --- a/extra/build.sh +++ b/extra/build.sh @@ -3,7 +3,11 @@ # Copyright (c) Arduino s.r.l. and/or its affiliated companies # SPDX-License-Identifier: Apache-2.0 -set -e +# Build the loader for the given target, extract the generated EDK files to the +# variants/ directory, and update Arduino-specific files. Once the process is +# complete, the board can be properly used in the Arduino IDE by choosing this + +. $(dirname $0)/functions source venv/bin/activate @@ -45,18 +49,25 @@ fi chosen_board=$(extra/get_board_details.sh | jq -cr ".[] | select(.board == \"$1\") // empty") if ! [ -z "$chosen_board" ]; then # found, use the target and args from there + board=$(jq -cr '.board' <<< "$chosen_board") target=$(jq -cr '.target' <<< "$chosen_board") args=$(jq -cr '.args' <<< "$chosen_board") + + # Check for debug flag and append + if [ x$2 == x"--debug" ]; then + args="$args -- -DEXTRA_CONF_FILE=../extra/debug.conf" + fi else # expect Zephyr-compatible target and args target=$1 shift args="$*" -fi - -# Check for debug flag and append -if [ x$2 == x"--debug" ]; then - args="$args -- -DEXTRA_CONF_FILE=../extra/debug.conf" + chosen_board=$(extra/get_board_details.sh | jq -cr ".[] | select(.target == \"$target\") // empty") + if [ ! -z "$chosen_board" ]; then + board=$(jq -cr '.board' <<< "$chosen_board") + else + log_msg warning "No board for '$target' defined in 'boards.txt'. A proper definition is required to use the core." + fi fi echo @@ -116,3 +127,43 @@ extra/gen_provides.py "${BUILD_DIR}/zephyr/zephyr.elf" -LF \ "random=__wrap_random" > ${VARIANT_DIR}/syms-static.ld cmake -P extra/gen_arduino_files.cmake $variant + +# update properties on boards.local.txt from the generated files +if [ ! -z "$board" ]; then + + if [ ! -f boards.local.txt ] ; then + cat << EOF > boards.local.txt +######################################################################################### +# +# AUTO GENERATED FILE - DO NOT EDIT +# This file is manipulated by extra/build.sh; manual changes may be overwritten. +# +######################################################################################### + +EOF + fi + + # sketch load address: start of sketch partition, hex (exact) + CODE_ADDR=$(get_value_from_text_file variants/${variant}/syms-static.ld '_sketch_start') + update_text_file_field boards.local.txt "upload.address" $CODE_ADDR + + # maximum sketch size: size of sketch partition, decimal (exact limit) + CODE_SIZE=$(( $(get_value_from_text_file variants/${variant}/syms-static.ld boards.local.txt '_sketch_max_size') )) + update_text_file_field boards.local.txt "upload.maximum_size" $CODE_SIZE + + # maximum data size: configured LLEXT heap size, decimal (larger bound, real limit is smaller) + DATA_SIZE=$(( 1024*$(get_value_from_text_file firmwares/zephyr-${variant}.config 'CONFIG_LLEXT_HEAP_SIZE') )) + update_text_file_field boards.local.txt "upload.maximum_data_size" $DATA_SIZE + + # machine fields (do not specifiy leading -) + MACH_CPU=$(get_value_from_text_file variants/${variant}/machine_flags.txt 'mcpu') + [ -z "$MACH_CPU" ] && MACH_CPU=$(get_value_from_text_file variants/${variant}/machine_flags.txt 'march') + [ -z "$MACH_CPU" ] || update_text_file_field boards.local.txt "build.architecture" $MACH_CPU + [ -z "$MACH_CPU" ] || update_text_file_field boards.local.txt "build.mcu" $MACH_CPU + + MACH_FPU=$(get_value_from_text_file variants/${variant}/machine_flags.txt 'mfpu') + [ -z "$MACH_FPU" ] || update_text_file_field boards.local.txt "build.fpu" $MACH_FPU + + MACH_FABI=$(get_value_from_text_file variants/${variant}/machine_flags.txt 'mfloat-abi') + [ -z "$MACH_FABI" ] || update_text_file_field boards.local.txt "build.float-abi" $MACH_FABI +fi diff --git a/extra/build_all.sh b/extra/build_all.sh index edd9cbb56..83ed16a40 100755 --- a/extra/build_all.sh +++ b/extra/build_all.sh @@ -3,6 +3,8 @@ # Copyright (c) Arduino s.r.l. and/or its affiliated companies # SPDX-License-Identifier: Apache-2.0 +. $(dirname "$0")/functions + FORCE=false while getopts "hf" opt; do @@ -35,18 +37,13 @@ while read -r item; do target=$(jq -cr '.target' <<< "$item") args=$(jq -cr '.args // ""' <<< "$item") - if [ -z "$GITHUB_STEP_SUMMARY" ] ; then - echo && echo - echo "${board} (${variant})" - echo "${board} (${variant})" | sed -e 's/./=/g' - else - echo "::group::=== ${subarch}:${board} (${variant}) ===" - fi - - ./extra/build.sh "$target" $args + log_msg group "=== ${subarch}:${board} (${variant}) ===" + ./extra/build.sh $board result=$? final_result=$((final_result | result)) + log_msg endgroup + if [ -z "$GITHUB_STEP_SUMMARY" ] ; then echo echo "${variant} result: $result" diff --git a/extra/functions b/extra/functions new file mode 100644 index 000000000..fdb3b973c --- /dev/null +++ b/extra/functions @@ -0,0 +1,62 @@ +# Copyright ARDUINO SRL (https://www.arduino.cc) +# SPDX-License-Identifier: Apache-2.0 + +# Sourced common preamble for bash scripts in this folder + +set -e + +# Log messages in a format suitable for both GitHub Actions and local execution +# Usage: log_msg +log_msg() { + local level="$1" + local msg="$2" + + if [ -z "$GITHUB_WORKSPACE" ] ; then + case "$level" in + error) echo "ERROR: $msg" ; echo ;; + warning) echo "WARNING: $msg" ;; + notice) echo "INFO: $msg" ;; + group) echo ; echo "$msg" ; echo $(echo "$msg" | sed -e 's/./-/g') ; echo ;; + endgroup) ;; + esac + else + echo "::$1::$2" + fi +} + +# Get the value of a field from a text file with lines in the rough format "field=value"; +# also handles lines such as "PROVIDE(field=value);" in linker script files +# Usage: get_value_from_text_file +get_value_from_text_file() { + local file=$1 + local field=$2 + + grep -E "^[^#]*\<${field//./\\./}\>\s*=" $file | tail -n 1 | cut -d '=' -f 2- | tr -d '); ' +} + +# Get all unique values for a field from a text file with lines in the rough format "field=value". +# Useful to extract all values for a property across multiple boards from a file like boards.txt. +# Usage: get_unique_values_from_text_file +get_unique_values_from_text_file() { + local file="$1" + local field="$2" + + grep -E "^[^#]*\<${field//./\\./}\>\s*=" $file | cut -d '=' -f 2- | xargs -n 1 echo | sort -u | xargs echo +} + +# Update a field in a text file with "field=value" lines; if the field is not present, +# it is added at the end of the file. +# Usage: update_text_file_field +update_text_file_field() { + local file=$1 + local field=$2 + local value=$3 + local full_field_name="${board}.${field}" + local match_regexp="^${full_field_name//./\\.}" # escape dots, match start of line + + if grep -qE "${match_regexp}" boards.local.txt; then + sed -i -e "s/${match_regexp}=.*/${full_field_name}=${value}/" boards.local.txt + else + echo "${full_field_name}=${value}" >> boards.local.txt + fi +} diff --git a/extra/gen_arduino_files.cmake b/extra/gen_arduino_files.cmake index 7c21a11fb..02a60909c 100644 --- a/extra/gen_arduino_files.cmake +++ b/extra/gen_arduino_files.cmake @@ -48,6 +48,11 @@ foreach(variant ${VARIANTS}) # exclude other problematic macros shared between C and C++ list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "-fdiagnostics-color=always") + # get machine flags (-msomething) in a separate list + set(LLEXT_MACHINE_FLAGS ${LLEXT_BASE_CFLAGS}) + list(FILTER LLEXT_MACHINE_FLAGS INCLUDE REGEX "^-m.*") + list(FILTER LLEXT_BASE_CFLAGS EXCLUDE REGEX "^-m.*") + # (temp) generate C++ flags from C flags set(LLEXT_BASE_CXXFLAGS ${LLEXT_BASE_CFLAGS}) list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-Wno-pointer-sign") @@ -55,10 +60,12 @@ foreach(variant ${VARIANTS}) list(FILTER LLEXT_BASE_CXXFLAGS EXCLUDE REGEX "-std=c.*") # save flag files + list(JOIN LLEXT_MACHINE_FLAGS "\n" EDK_MACHINE_FLAGS) + file(WRITE ${dir}/machine_flags.txt "${EDK_MACHINE_FLAGS}") + 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() diff --git a/extra/package_core.sh b/extra/package_core.sh index 2a6f31500..920a2258b 100755 --- a/extra/package_core.sh +++ b/extra/package_core.sh @@ -5,7 +5,8 @@ # Package the core into a distributable tar.bz2 archive. -set -e +. $(dirname $0)/functions + RET=0 if [ -z "$1" ]; then @@ -22,14 +23,6 @@ ARTIFACT=$1 VERSION=$2 OUTPUT_FILE=${3:-distrib/${ARTIFACT}-${VERSION}.tar.bz2} -log_msg() { - if [ -n $GITHUB_WORKSPACE ] ; then - echo "::$1::$2" - else - echo "$2" - fi -} - # we use variants for include because we filter on file paths # and boards for exclude because we want to remove matching lines in boards.txt BOARD_DETAILS=$(extra/get_board_details.sh) @@ -49,30 +42,11 @@ log_msg group "Packaging ${ARTIFACT_NAME:-all variants} ($(basename $OUTPUT_FILE # create a temporary boards.txt file with the correct list of boards TEMP_BOARDS=$(mktemp -p . | sed 's/\.\///') -cat boards.txt >> $TEMP_BOARDS +cat boards.txt boards.local.txt >> $TEMP_BOARDS for board in $EXCLUDED_BOARDS ; do # remove (even commented) lines for excluded boards sed -i "/^\(\s*#\s*\)\?${board}\./d" $TEMP_BOARDS done -# set proper maximum sizes for included variants -# and test that the load address matches the build -for variant in $INCLUDED_VARIANTS ; do - board=$(echo ${BOARD_DETAILS} | jq -cr "map(select(.variant == \"${variant}\")) | .[0].board") - # maximum sketch size: size of sketch partition (exact limit) - # maximum data size: configured LLEXT heap size (larger bound, real limit is smaller) - CODE_SIZE=$(( $(cat variants/${variant}/syms-static.ld | grep '\<_sketch_max_size\>' | cut -d '=' -f 2 | tr -d ');') )) - DATA_SIZE=$(( 1024*$(cat firmwares/zephyr-${variant}.config | grep 'LLEXT_HEAP_SIZE' | cut -d '=' -f 2) )) - sed -i -e "s/^${board}\.upload\.maximum_size=.*/${board}.upload.maximum_size=${CODE_SIZE}/" $TEMP_BOARDS - sed -i -e "s/^${board}\.upload\.maximum_data_size=.*/${board}.upload.maximum_data_size=${DATA_SIZE}/" $TEMP_BOARDS - - # load address: must match the one used in the linker script - CODE_ADDR=$(cat variants/${variant}/syms-static.ld | grep '\<_sketch_load_addr\>' | cut -d '=' -f 2 | tr -d ');') - BOARDS_ADDR=$(grep "/^${board}\.upload\.address=.*/" $TEMP_BOARDS | cut -d '=' -f 2) - if [ "${CODE_ADDR,,}" != "${BOARDS_ADDR,,}" ] ; then - log_msg error "boards.txt: '${board}.upload.address' should be ${CODE_ADDR,,}" - RET=3 - fi -done # remove multiple empty lines sed -i '/^$/N;/^\n$/D' $TEMP_BOARDS diff --git a/extra/package_tool.sh b/extra/package_tool.sh index 7cf080a5f..09aa9a597 100755 --- a/extra/package_tool.sh +++ b/extra/package_tool.sh @@ -3,7 +3,7 @@ # Copyright (c) Arduino s.r.l. and/or its affiliated companies # SPDX-License-Identifier: Apache-2.0 -set -e +. $(dirname $0)/functions TOOL_DIR=$(readlink -f ${1:-.}) TOOL_NAME=$(basename $TOOL_DIR) @@ -55,20 +55,25 @@ build_for_arch() { local build_file="$TOOL_NAME$app_ext" local package_file="$tool_stem-$plat$pkg_ext" - echo "Building $TOOL_NAME for $os/$arch ($plat)" + log_msg group "Building $TOOL_NAME for $os/$arch ($plat)" + mkdir -p "$build_dir" (cd $BASE_DIR/extra/$TOOL_NAME && GOOS="$os" GOARCH="$arch" go build -o "$build_dir/$build_file") (cd "$tool_stem" && $pkg_cmd "$package_file" $plat/) hash_file $plat "$package_file" > $build_dir.json + + log_msg endgroup } build_json() { + log_msg group "Building JSON manifest for $TOOL_NAME $VERSION" temp_file=$(mktemp) echo "{ \"packages\": [ { \"tools\": [ { \"name\": \"$TOOL_NAME\", \"version\": \"$VERSION\", \"systems\":" > $temp_file ls $DIR/$TOOL_NAME-$VERSION/*.json | sort | xargs cat | jq -s . >> $temp_file echo "} ] } ] }" >> $temp_file jq . $temp_file > $DIR/$TOOL_NAME-$VERSION.json rm -f $temp_file $DIR/$TOOL_NAME-$VERSION/*.json + log_msg endgroup } build_for_arch "linux" "amd64" "x86_64-linux-gnu" diff --git a/install.sh b/install.sh deleted file mode 100755 index 30c7ef590..000000000 --- a/install.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -set -e; - -printf '%s\n' "Before running this script, make sure of the following:" -printf '%s\n' "1. You have zephyr installed properly on your system." -printf '%s\n' "2. Updated west.yml in zephyr and run west update to pull this module in proper location." -printf '%s\n' "If you meet the above criteria, please enter [yY]Yes and if not, then [nN]No." -read answer; - -if [ "$answer" != "${answer#[Yy]}" ] ;then - printf '%s\n' "Yes"; -else - printf '%s\n' "No"; - exit 1; -fi - -API_FOLDER=~/.ArduinoCore-API -if [ ! -d "$API_FOLDER" ] ; then - printf '%s\n' "Cloning ArduinoCore API in $API_FOLDER"; - git clone git@github.com:arduino/ArduinoCore-API ~/.ArduinoCore-API; -else - printf '%s\n' "API Folder already exists, skipping clone..."; -fi - -printf '%s\n' "Linking..."; -ln -sf ~/.ArduinoCore-API/api cores/arduino/. ; - -printf '%s\n' "Module Successfully setup..."; - diff --git a/platform.txt b/platform.txt index ee295bd0a..842940173 100644 --- a/platform.txt +++ b/platform.txt @@ -17,13 +17,13 @@ compiler.warning_flags.all=-Wall -Wextra compiler.path={build.compiler_path} compiler.c.cmd={build.crossprefix}gcc -compiler.c.flags=-g -Os -c {compiler.define} {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" -fdata-sections -ffunction-sections -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} +compiler.c.flags=-g -Os -c {compiler.define} {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.machine_flags_file}" "@{compiler.zephyr.cflags_file}" {compiler.zephyr.common_flags} -MMD compiler.c.elf.cmd={build.crossprefix}g++ -compiler.c.elf.flags=-Wl,--gc-sections -mcpu={build.mcu} {build.float-abi} {build.fpu} -std=gnu++17 +compiler.c.elf.flags=-Wl,--gc-sections "@{compiler.zephyr.machine_flags_file}" -std=gnu++17 compiler.S.cmd={build.crossprefix}g++ -compiler.S.flags=-c -x assembler-with-cpp -mcpu={build.mcu} {build.fpu} +compiler.S.flags=-c -x assembler-with-cpp "@{compiler.zephyr.machine_flags_file}" compiler.cpp.cmd={build.crossprefix}g++ -compiler.cpp.flags=-g -Os -std=gnu++17 -c {compiler.define} {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cxxflags_file}" {compiler.zephyr.common_ldflags} {compiler.zephyr.extra_ldflags} {compiler.zephyr.common_cxxflags} {compiler.zephyr.extra_cxxflags} -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} +compiler.cpp.flags=-g -Os -std=gnu++17 -c {compiler.define} {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.machine_flags_file}" "@{compiler.zephyr.cxxflags_file}" {compiler.zephyr.common_flags} {compiler.zephyr.common_cxxflags} -MMD compiler.ar.cmd={build.crossprefix}ar compiler.ar.flags=rcs compiler.objcopy.cmd= @@ -37,24 +37,24 @@ compiler.size.cmd={build.crossprefix}size compiler.define=-D_PICOLIBC_CTYPE_SMALL=1 compiler.zephyr.includes_file={build.variant.path}/includes.txt +compiler.zephyr.machine_flags_file={build.variant.path}/machine_flags.txt compiler.zephyr.cflags_file={build.variant.path}/cflags.txt compiler.zephyr.cxxflags_file={build.variant.path}/cxxflags.txt compiler.zephyr.macros="-imacros{build.variant.path}/llext-edk/include/zephyr/include/generated/zephyr/autoconf.h" "-imacros{build.variant.path}/llext-edk/include/zephyr/include/zephyr/toolchain/zephyr_stdint.h" -compiler.zephyr.common_cxxflags=-fno-exceptions -fno-rtti -fdata-sections -ffunction-sections -fno-unwind-tables -compiler.zephyr.common_ldflags=-fno-exceptions -fno-rtti -fno-threadsafe-statics -fno-unwind-tables -fno-use-cxa-atexit -lstdc++ -lsupc++ -lnosys -nostdlib - -compiler.zephyr.extra_cxxflags= -compiler.zephyr.extra_ldflags=-lstdc++ -lsupc++ -lm +compiler.zephyr.common_flags=-fdata-sections -ffunction-sections +compiler.zephyr.common_cxxflags=-fno-exceptions -fno-rtti -fno-unwind-tables +compiler.zephyr.common_ldflags=-fno-threadsafe-statics -fno-use-cxa-atexit -lstdc++ -lsupc++ -lm -lnosys -nostdlib # these can be overriden in boards.txt -build.extra_flags= -build.extra_ldflags= build.link_mode=dynamic build.boot_mode=wait -upload.extension=elf-zsk.bin + +upload.extension-dynamic=elf-zsk.bin +upload.extension-static=bin-zsk.bin +upload.extension={upload.extension-{build.link_mode}} build.ldscript.path={runtime.platform.path}/variants/_ldscripts -build.link_command="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" "-L{build.variant.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {build.extra_flags} {build.extra_ldflags} {compiler.zephyr.common_ldflags} --specs=nano.specs --specs=nosys.specs {compiler.ldflags} {object_files} -Wl,--start-group "{build.path}/{archive_file}" {compiler.zephyr.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group {build.link_args.{build.link_mode}} +build.link_command="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" "-L{build.variant.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.zephyr.common_ldflags} --specs=nano.specs --specs=nosys.specs {compiler.ldflags} {object_files} -Wl,--start-group "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group {build.link_args.{build.link_mode}} build.check_command-dynamic={build.link_command} {build.link_args.check-dynamic} -o "{build.path}/{build.project_name}_check.tmp" build.check_command-static=true @@ -85,9 +85,16 @@ compiler.c.elf.extra_flags= compiler.S.extra_flags= compiler.cpp.extra_flags= compiler.ar.extra_flags= -compiler.objcopy.eep.extra_flags= compiler.elf2hex.extra_flags= +# These can be overridden in platform.local.txt +compiler.c.board_flags= +compiler.c.elf.board_flags= +compiler.S.board_flags= +compiler.cpp.board_flags= +compiler.ar.board_flags= +compiler.elf2hex.board_flags= + # {build.library_discovery_phase} is set to 1 by the builder during library discovery. # (this is available since arduino-builder>=1.5.5, keeping the default here for backward compatiblity) build.library_discovery_phase=0 @@ -107,13 +114,13 @@ build.zip.pattern={recipe.size.pattern} # ----------------------- ## Compile c files -recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_ARCH_ZEPHYR {build.library_discovery_phase_flag} {build.extra_flags} {build.extra_ldflags} {compiler.c.extra_flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "-iprefix{build.variant.path}" "@{compiler.zephyr.includes_file}" -o "{object_file}" "{source_file}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_ARCH_ZEPHYR {build.library_discovery_phase_flag} {compiler.c.extra_flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" {includes} "-iprefix{build.variant.path}" "@{compiler.zephyr.includes_file}" -o "{object_file}" "{source_file}" ## Compile c++ files -recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_ARCH_ZEPHYR {build.library_discovery_phase_flag} {includes} {build.extra_flags} {build.extra_ldflags} {compiler.cpp.extra_flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" "-iprefix{build.variant.path}" "@{compiler.zephyr.includes_file}" "{source_file}" -o "{object_file}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_ARCH_ZEPHYR {build.library_discovery_phase_flag} {includes} {compiler.cpp.extra_flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" "-iprefix{build.variant.path}" "@{compiler.zephyr.includes_file}" "{source_file}" -o "{object_file}" ## Compile asm files -recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_ARCH_ZEPHYR {includes} {build.extra_flags} {build.extra_ldflags} {compiler.cpp.extra_flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" "-iprefix{build.variant.path}" "@{compiler.zephyr.includes_file}" "{source_file}" -o "{object_file}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_ARCH_ZEPHYR {includes} {compiler.cpp.extra_flags} "-I{build.core.path}/api/deprecated" "-I{build.core.path}/api/deprecated-avr-comp" "-iprefix{build.variant.path}" "@{compiler.zephyr.includes_file}" "{source_file}" -o "{object_file}" ## Create archives recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" diff --git a/west.yml b/west.yml index e8b1b3103..7929ba60f 100644 --- a/west.yml +++ b/west.yml @@ -42,8 +42,3 @@ manifest: # the 'manifest.project-filter' config. Enable all Zephyr HALs with: # # west config -d manifest.project-filter - - - name: ArduinoCore-API - path: modules/lib/ArduinoCore-API - revision: master - url: https://github.com/arduino/ArduinoCore-API diff --git a/zephyr/blobs/ArduinoCore-API/.gitignore b/zephyr/blobs/ArduinoCore-API/.gitignore new file mode 100644 index 000000000..335ec9573 --- /dev/null +++ b/zephyr/blobs/ArduinoCore-API/.gitignore @@ -0,0 +1 @@ +*.tar.gz diff --git a/zephyr/blobs/ArduinoCore-API/LICENSE b/zephyr/blobs/ArduinoCore-API/LICENSE new file mode 100644 index 000000000..c6487f4fd --- /dev/null +++ b/zephyr/blobs/ArduinoCore-API/LICENSE @@ -0,0 +1,176 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + +GNU LESSER GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/zephyr/module.yml b/zephyr/module.yml index 9b9b1ca8c..4a221c2c7 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -5,3 +5,13 @@ build: kconfig: Kconfig samples: - samples +blobs: + - path: ArduinoCore-API/ArduinoCore-API-1.5.2.tar.gz + sha256: 2c76d4dcea29d1d093d821804dcc1ccd83d172ef0d359d7c651cdbba6e6bfa57 + type: lib + version: '1.5.2' + license-path: zephyr/blobs/ArduinoCore-API/LICENSE + click-through: true + url: https://github.com/arduino/ArduinoCore-API/archive/refs/tags/1.5.2.tar.gz + description: "Arduino API archive" + doc-url: https://raw.githubusercontent.com/arduino/ArduinoCore-API/refs/tags/1.5.2/README.md