diff --git a/boards.txt b/boards.txt index fbfbd13f..b36a45f8 100644 --- a/boards.txt +++ b/boards.txt @@ -14,7 +14,7 @@ giga.menu.debug.true.postbuild_debug=-debug giga.build.zephyr_target=arduino_giga_r1//m7 giga.build.zephyr_args=--shield arduino_giga_display_shield -giga.build.zephyr_hals=hal_stm32 +giga.build.zephyr_hals=hal_stm32 hal_infineon giga.build.variant=arduino_giga_r1_stm32h747xx_m7 giga.build.mcu=cortex-m7 giga.build.fpu=-mfpu=fpv5-d16 @@ -456,7 +456,7 @@ portentac33.menu.mode.linked.postbuild_mode=-prelinked portentac33.build.zephyr_target=arduino_portenta_c33 portentac33.build.zephyr_args= -portentac33.build.zephyr_hals=hal_renesas +portentac33.build.zephyr_hals=hal_renesas nanopb portentac33.build.variant=arduino_portenta_c33_r7fa6m5bh3cfc portentac33.build.mcu=cortex-m33 portentac33.build.fpu=-mfpu=fpv5-sp-d16 diff --git a/cores/arduino/abi.cpp b/cores/arduino/abi.cpp index 5c030cd3..2a44e605 100644 --- a/cores/arduino/abi.cpp +++ b/cores/arduino/abi.cpp @@ -12,9 +12,15 @@ extern "C" int __cxa_atexit(void (*func) (void *), void * arg, void * dso_handle (void)func; (void)arg; (void)dso_handle; // unused return 0; } +extern "C" int atexit(void (*func)(void)) { + (void)func; + return 0; +} namespace std { void __throw_length_error(const char* __s __attribute__((unused))) {} + void __throw_bad_alloc() {} + void __throw_bad_function_call() {} }; extern "C" int strcmp(const char* s1, const char* s2) { @@ -25,3 +31,5 @@ extern "C" int strcmp(const char* s1, const char* s2) { } return *(const unsigned char*)s1 - *(const unsigned char*)s2; } + +extern "C" void* __dso_handle = (void*) &__dso_handle; diff --git a/extra/bootstrap.sh b/extra/bootstrap.sh index b074c971..7fcfbee9 100755 --- a/extra/bootstrap.sh +++ b/extra/bootstrap.sh @@ -14,14 +14,11 @@ done python3 -m venv venv source venv/bin/activate -pip install west +pip install west protobuf grpcio-tools west init -l . west config manifest.project-filter -- "$HAL_FILTER" west update "$@" west zephyr-export pip install -r ../zephyr/scripts/requirements-base.txt west sdk install --version 0.17.0 -t arm-zephyr-eabi - -for hal in $NEEDED_HALS; do - west blobs fetch $hal -done +west blobs fetch $NEEDED_HALS diff --git a/extra/build.sh b/extra/build.sh index 6d7d63f1..90321ee5 100755 --- a/extra/build.sh +++ b/extra/build.sh @@ -92,14 +92,16 @@ done # Generate the provides.ld file for linked builds echo "Exporting provides.ld" READELF=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf -$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > ${VARIANT_DIR}/provides.ld -$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld -$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld -$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld -$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld +GDB=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > ${VARIANT_DIR}/provides.ld +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld cat ${BUILD_DIR}/zephyr/zephyr.map | grep __device_dts_ord | grep -v rodata | grep -v llext_const_symbol | awk -F' ' '{print "PROVIDE("$2" = "$1");"}' >> ${VARIANT_DIR}/provides.ld -TEXT_START=`cat variants/$variant/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"` -echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> ${VARIANT_DIR}/provides.ld +#TEXT_START=`cat variants/$variant/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"` +TEXT_START=`$GDB --quiet -ex "p/x sketch_base_addr" ${BUILD_DIR}/zephyr/zephyr.elf -ex "exit" | grep "= 0x" | cut -f 2 -d"="` +echo "PROVIDE(_sketch_start = $TEXT_START);" >> ${VARIANT_DIR}/provides.ld sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' ${VARIANT_DIR}/provides.ld sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' ${VARIANT_DIR}/provides.ld diff --git a/loader/llext_exports.c b/loader/llext_exports.c index f6f8c85e..f1370a92 100644 --- a/loader/llext_exports.c +++ b/loader/llext_exports.c @@ -118,6 +118,9 @@ FORCE_EXPORT_SYM(net_buf_simple_pull); FORCE_EXPORT_SYM(net_buf_simple_add_mem); FORCE_EXPORT_SYM(net_buf_simple_pull_mem); FORCE_EXPORT_SYM(net_buf_unref); +#if defined(CONFIG_BT_HCI_SETUP) +FORCE_EXPORT_SYM(bt_h4_vnd_setup); +#endif #endif #if defined(CONFIG_STACK_CANARIES) @@ -227,8 +230,13 @@ FORCE_EXPORT_SYM(__aeabi_uidivmod); FORCE_EXPORT_SYM(__aeabi_dcmpeq); FORCE_EXPORT_SYM(__aeabi_d2iz); FORCE_EXPORT_SYM(__aeabi_f2d); +FORCE_EXPORT_SYM(__aeabi_ul2d); +FORCE_EXPORT_SYM(__aeabi_l2f); FORCE_EXPORT_SYM(__aeabi_idivmod); FORCE_EXPORT_SYM(__aeabi_ldivmod); FORCE_EXPORT_SYM(__aeabi_ul2f); FORCE_EXPORT_SYM(__aeabi_dcmpge); + +#if defined (CONFIG_CPP) FORCE_EXPORT_SYM(__cxa_pure_virtual); +#endif \ No newline at end of file diff --git a/loader/main.c b/loader/main.c index 21897530..f348f1da 100644 --- a/loader/main.c +++ b/loader/main.c @@ -64,6 +64,9 @@ void llext_entry(void *arg0, void *arg1, void *arg2) } #endif /* CONFIG_USERSPACE */ +__attribute__((retain)) const uintptr_t sketch_base_addr = DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(user_sketch))) + + DT_REG_ADDR(DT_NODELABEL(user_sketch)); + static int loader(const struct shell *sh) { const struct flash_area *fa; diff --git a/loader/prj.conf b/loader/prj.conf index 8249d3fc..084b0b6c 100644 --- a/loader/prj.conf +++ b/loader/prj.conf @@ -42,4 +42,6 @@ CONFIG_FLASH_MAP=y CONFIG_CPP=y CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y CONFIG_REQUIRES_FULL_LIBC=y +CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/platform.txt b/platform.txt index 889d0e94..a85a76de 100644 --- a/platform.txt +++ b/platform.txt @@ -19,11 +19,11 @@ compiler.path={build.compiler_path} compiler.c.cmd={build.crossprefix}gcc compiler.c.flags=-g -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" {compiler.zephyr.arch.define} -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} compiler.c.elf.cmd={build.crossprefix}g++ -compiler.c.elf.flags={build.llext_link_flags} -Wl,--gc-sections -mcpu={build.mcu} {build.float-abi} {build.fpu} -std=c++17 +compiler.c.elf.flags={build.llext_link_flags} -Wl,--gc-sections -mcpu={build.mcu} {build.float-abi} {build.fpu} -std=gnu++17 compiler.S.cmd={build.crossprefix}g++ compiler.S.flags=-c -x assembler-with-cpp -mcpu={build.mcu} {build.fpu} compiler.cpp.cmd={build.crossprefix}g++ -compiler.cpp.flags=-g -Os -std=c++17 -c {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} {compiler.zephyr.arch.define} -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} +compiler.cpp.flags=-g -Os -std=gnu++17 -c {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} {compiler.zephyr.arch.define} -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} compiler.ar.cmd={build.crossprefix}ar compiler.ar.flags=rcs compiler.objcopy.cmd= @@ -44,7 +44,7 @@ compiler.zephyr.common_cxxflags=-fdata-sections -ffunction-sections -fno-unwind- 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= +compiler.zephyr.extra_ldflags=-lstdc++ -lsupc++ # this can be overriden in boards.txt build.extra_flags= @@ -99,7 +99,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DARDUIN recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" ## Combine gc-sections, archives, and objects -recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {build.extra_flags} {build.extra_ldflags} {compiler.zephyr.common_ldflags} "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=picolibc.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}_debug.elf" {object_files} "{build.path}/{archive_file}" {compiler.zephyr} {compiler.zephyr.extra_ldflags} {compiler.libraries.ldflags} +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {build.extra_flags} {build.extra_ldflags} {compiler.zephyr.common_ldflags} "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=picolibc.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}_debug.elf" {object_files} -Wl,--start-group "{build.path}/{archive_file}" {compiler.zephyr} {compiler.zephyr.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group recipe.hooks.linking.postlink.1.pattern="{compiler.path}{build.crossprefix}strip" --strip-debug "{build.path}/{build.project_name}_debug.elf" -o "{build.path}/{build.project_name}.elf" ## Create eeprom diff --git a/variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.conf b/variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.conf index 1305dea1..14f73783 100644 --- a/variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.conf +++ b/variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.conf @@ -48,3 +48,20 @@ CONFIG_DISPLAY=y CONFIG_INPUT=y CONFIG_STM32_LTDC_FB_USE_SHARED_MULTI_HEAP=y CONFIG_STM32_LTDC_FB_SMH_ATTRIBUTE=2 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_HCI_RAW_H4=y +CONFIG_BT_HCI_RAW_H4_ENABLE=y +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_CMD_TX_SIZE=255 +CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255 +CONFIG_BT_MAX_CONN=4 +CONFIG_BT_CTLR_ADV_EXT=y +CONFIG_BT_CTLR_ADV_PERIODIC=y +CONFIG_BT_CTLR_DTM_HCI=y +CONFIG_CYW4343W_MURATA_1DX=y +CONFIG_BT_HCI_DRIVER_LOG_LEVEL_DBG=y +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 +CONFIG_BT_RX_STACK_SIZE=4096 +CONFIG_BT_HCI_TX_STACK_SIZE=4096 diff --git a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf index 4ba7d164..b9f799e7 100644 --- a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf +++ b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf @@ -25,8 +25,13 @@ CONFIG_ARM_MPU=n CONFIG_SHELL_STACK_SIZE=32768 CONFIG_MAIN_STACK_SIZE=32768 CONFIG_LLEXT_HEAP_SIZE=128 +CONFIG_HEAP_MEM_POOL_SIZE=65536 +CONFIG_ISR_STACK_SIZE=8192 +CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=8192 +CONFIG_IDLE_STACK_SIZE=8192 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192 -CONFIG_ADC=n +CONFIG_ADC=y CONFIG_PWM=y CONFIG_NET_CORE_LOG_LEVEL_DBG=y @@ -56,6 +61,11 @@ CONFIG_NET_TX_STACK_SIZE=8192 CONFIG_NET_RX_STACK_SIZE=8192 CONFIG_NET_TCP_WORKQ_STACK_SIZE=8192 CONFIG_NET_MGMT_EVENT_STACK_SIZE=8192 +CONFIG_NET_MGMT_EVENT_MONITOR_STACK_SIZE=8192 +CONFIG_NET_SOCKETS_SERVICE_STACK_SIZE=8192 +CONFIG_ETH_RA_RX_THREAD_STACK_SIZE=8192 +CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=8192 + CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y CONFIG_POSIX_API=y @@ -68,3 +78,26 @@ CONFIG_MBEDTLS_HEAP_SIZE=60000 CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=7168 CONFIG_MBEDTLS_HASH_ALL_ENABLED=y CONFIG_MBEDTLS_CMAC=y + +CONFIG_WIFI=y +CONFIG_WIFI_ESP_HOSTED=y +CONFIG_NANOPB=y +CONFIG_NET_CONFIG_AUTO_INIT=n +CONFIG_NET_CONNECTION_MANAGER=y +CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES=2 +CONFIG_NET_L2_WIFI_SHELL=y +CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=32 + +CONFIG_NET_IF_MAX_IPV4_COUNT=3 +CONFIG_NET_IF_MAX_IPV6_COUNT=3 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_HCI_RAW_H4=y +CONFIG_BT_HCI_RAW_H4_ENABLE=y +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_CMD_TX_SIZE=255 +CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255 +CONFIG_BT_MAX_CONN=4 +CONFIG_BT_CTLR_ADV_EXT=y +CONFIG_BT_CTLR_ADV_PERIODIC=y \ No newline at end of file diff --git a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay index ebf65a91..25cbf973 100644 --- a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay +++ b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay @@ -78,7 +78,75 @@ pinctrl-names = "default"; }; +&adc0 { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + a7: channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a4: channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a3: channel@2 { + reg = <2>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a2: channel@4 { + reg = <4>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a1: channel@5 { + reg = <5>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a0: channel@6 { + reg = <6>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a6: channel@e { + reg = <14>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + a5: channel@f { + reg = <15>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; +}; / { zephyr,user { @@ -203,8 +271,26 @@ serials = <&board_cdc_acm_uart>, <&uart9>, <&uart7>, <&uart6>, <&uart5>; cdc-acm = <&board_cdc_acm_uart>; - i2cs = <&iic0>, <&iic1>; + i2cs = <&iic0>, <&iic1>, <&i2c3>; spis = <&spi1>; pwms = <&pwm6 1 PWM_HZ(25000000) PWM_POLARITY_NORMAL>; + + io-channels = <&adc0 6>, + <&adc0 5>, + <&adc0 4>, + <&adc0 2>, + <&adc0 1>, + <&adc0 13>, + <&adc0 12>, + <&adc0 0>; + + adc-pin-gpios = <&ioport0 6 0>, + <&ioport0 5 0>, + <&ioport0 4 0>, + <&ioport0 2 0>, + <&ioport0 1 0>, + <&ioport0 15 0>, + <&ioport0 14 0>, + <&ioport0 0 0>; }; }; diff --git a/west.yml b/west.yml index 98804454..16a78b2f 100644 --- a/west.yml +++ b/west.yml @@ -21,7 +21,7 @@ manifest: projects: - name: zephyr remote: arduino - revision: zephyr-arduino-20250520 + revision: zephyr-arduino-20250529 import: name-allowlist: - cmsis @@ -32,6 +32,7 @@ manifest: - segger - thrift - mcuboot + - nanopb - lvgl path-allowlist: - modules/hal/*