From ac9a6667f306dc7f14078cecb96bbb540e0c9207 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 23 May 2025 10:54:50 +0200 Subject: [PATCH 01/10] portentac33: enable wifi and bluetooth --- boards.txt | 2 +- .../arduino_portenta_c33_r7fa6m5bh3cfc.conf | 33 +++++++++++++++++++ west.yml | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index fbfbd13f..2eac80cb 100644 --- a/boards.txt +++ b/boards.txt @@ -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/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf index 4ba7d164..e0ef6dd1 100644 --- a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf +++ b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf @@ -25,6 +25,11 @@ 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_PWM=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/west.yml b/west.yml index 98804454..10f8f803 100644 --- a/west.yml +++ b/west.yml @@ -32,6 +32,7 @@ manifest: - segger - thrift - mcuboot + - nanopb - lvgl path-allowlist: - modules/hal/* From db46c99d5d6aa7abded0b39984e11dfa15fd12a8 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 23 May 2025 12:09:01 +0200 Subject: [PATCH 02/10] giga: enable bluetooth Not working yet --- boards.txt | 2 +- loader/llext_exports.c | 3 +++ .../arduino_giga_r1_stm32h747xx_m7.conf | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index 2eac80cb..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 diff --git a/loader/llext_exports.c b/loader/llext_exports.c index f6f8c85e..f1885bd5 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) 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 From 16ebba80ba1b85c27927f761f5bb7e67508de06c Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 23 May 2025 17:59:40 +0200 Subject: [PATCH 03/10] update west.yml --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 10f8f803..8b0a0a20 100644 --- a/west.yml +++ b/west.yml @@ -21,7 +21,7 @@ manifest: projects: - name: zephyr remote: arduino - revision: zephyr-arduino-20250520 + revision: zephyr-arduino-20250523 import: name-allowlist: - cmsis From db0b9d244542eb0613571d4411bb6608b3d1faf0 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Mon, 26 May 2025 13:02:12 +0200 Subject: [PATCH 04/10] bootstrap.sh: also install protobuf and grpcio-tools in venv --- extra/bootstrap.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 From f4fca85df711f45fa46746d37d79281dc1092431 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 29 May 2025 17:20:38 +0200 Subject: [PATCH 05/10] portenta_c33: enable adc --- .../arduino_portenta_c33_r7fa6m5bh3cfc.conf | 2 +- ...arduino_portenta_c33_r7fa6m5bh3cfc.overlay | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) 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 e0ef6dd1..b9f799e7 100644 --- a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf +++ b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf @@ -31,7 +31,7 @@ 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 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..420ef062 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 { @@ -206,5 +274,23 @@ i2cs = <&iic0>, <&iic1>; 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>; }; }; From ed1727e80d5c528bbada95627302a49feddedf3f Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 29 May 2025 17:52:14 +0200 Subject: [PATCH 06/10] west.yml: use zephyr-arduino-20250529 branch --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 8b0a0a20..16a78b2f 100644 --- a/west.yml +++ b/west.yml @@ -21,7 +21,7 @@ manifest: projects: - name: zephyr remote: arduino - revision: zephyr-arduino-20250523 + revision: zephyr-arduino-20250529 import: name-allowlist: - cmsis From 736d3ac8f031f05d249cc4a66ddae16d8f62a010 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 29 May 2025 17:53:38 +0200 Subject: [PATCH 07/10] portenta_c33: i2c: add sci3 interface --- .../arduino_portenta_c33_r7fa6m5bh3cfc.overlay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 420ef062..25cbf973 100644 --- a/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay +++ b/variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay @@ -271,7 +271,7 @@ 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>; From b2dcb5fe378e3b69b586ee081b5dbbc961a5d1b7 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 28 May 2025 15:51:14 +0200 Subject: [PATCH 08/10] loader: impl: add some libc/::std functions --- cores/arduino/abi.cpp | 6 ++++++ loader/llext_exports.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/cores/arduino/abi.cpp b/cores/arduino/abi.cpp index 5c030cd3..e6700a7e 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) { diff --git a/loader/llext_exports.c b/loader/llext_exports.c index f1885bd5..0073aeef 100644 --- a/loader/llext_exports.c +++ b/loader/llext_exports.c @@ -230,6 +230,8 @@ 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); From 768bbb42d9c75446a998355b56b08a1ce67770b0 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 4 Jun 2025 14:23:36 +0200 Subject: [PATCH 09/10] loader: correct _sketch_start for linked builds --- extra/build.sh | 6 ++++-- loader/main.c | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/extra/build.sh b/extra/build.sh index 6d7d63f1..0c390fd2 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 +GDB=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb $READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > ${VARIANT_DIR}/provides.ld $READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld $READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld $READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld $READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld cat ${BUILD_DIR}/zephyr/zephyr.map | grep __device_dts_ord | grep -v rodata | grep -v llext_const_symbol | awk -F' ' '{print "PROVIDE("$2" = "$1");"}' >> ${VARIANT_DIR}/provides.ld -TEXT_START=`cat variants/$variant/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"` -echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> ${VARIANT_DIR}/provides.ld +#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/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; From 0091cab46386a946ee49a52a4e8787a306b5a895 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Mon, 16 Jun 2025 15:30:59 +0200 Subject: [PATCH 10/10] c33: fix missing std:: functionality at link time --- cores/arduino/abi.cpp | 2 ++ extra/build.sh | 10 +++++----- loader/llext_exports.c | 3 +++ loader/prj.conf | 2 ++ platform.txt | 8 ++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cores/arduino/abi.cpp b/cores/arduino/abi.cpp index e6700a7e..2a44e605 100644 --- a/cores/arduino/abi.cpp +++ b/cores/arduino/abi.cpp @@ -31,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/build.sh b/extra/build.sh index 0c390fd2..90321ee5 100755 --- a/extra/build.sh +++ b/extra/build.sh @@ -93,11 +93,11 @@ done echo "Exporting provides.ld" READELF=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf GDB=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb -$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 +$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"{"` TEXT_START=`$GDB --quiet -ex "p/x sketch_base_addr" ${BUILD_DIR}/zephyr/zephyr.elf -ex "exit" | grep "= 0x" | cut -f 2 -d"="` diff --git a/loader/llext_exports.c b/loader/llext_exports.c index 0073aeef..f1370a92 100644 --- a/loader/llext_exports.c +++ b/loader/llext_exports.c @@ -236,4 +236,7 @@ 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/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