Skip to content

Commit ac05eb3

Browse files
committed
Merge remote-tracking branch 'origin/fully_linked' into arduino
* origin/fully_linked: Arduino.h: fix DIGITAL_PIN_EXISTS macro to avoid comment expansion issues gh: test sketch compilation after packaging core loader: fix rw612 and ek_ra8 SerialUSB: create SerialUSB object only if CONFIG_USB_CDC_ACM=y core: use the new postbuild tool post-build: rework to use empty area in ELF header or add it in binaries loader: cleanups post-build: refactor to use flag package west.yml: use arduino remote build.sh: fix shields parameter portenta_c33: rebuild loader loader: move cache config to be board specific usb: start supporting USB_DEVICE_STACK_NEXT c33: rebuild loader zephyrClient: fix SSL overload wip: c33 wip: linked build mass rebuild build_all: add c33 c33: add artifacts boards: add portenta c33 platform: dfu-util: allow skipping dfuse c33: fix pwm in loader TEMP: get rid of serialEvent serial: add missing include fixme: add bootloader reflasher for c33 targets: add portenta c33 loader: enable USB only for legacy stack loader: fix ringbuffer exports west.yml: use merged branch temp: fix display/camera coexistence giga: update branch to support display shield
2 parents 7fdcd38 + 1eade10 commit ac05eb3

File tree

3,865 files changed

+1242348
-84298
lines changed

Some content is hidden

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

3,865 files changed

+1242348
-84298
lines changed

.github/workflows/package_core.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,24 @@ jobs:
3030
with:
3131
name: Core
3232
path: arduino-core-zephyr-llext*
33+
34+
- name: Create Blink sketch
35+
run: |
36+
mkdir extra/Blink/
37+
wget https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino
38+
mv Blink.ino extra/Blink/
39+
40+
- name: Compile Blink
41+
uses: arduino/compile-sketches@main
42+
with:
43+
fqbn: arduino:zephyr:giga
44+
platforms: |
45+
# Use Board Manager to install the latest release of Arduino Zephyr Boards to get the toolchain
46+
- name: "arduino:zephyr"
47+
source-url: "https://downloads.arduino.cc/packages/package_zephyr_index.json"
48+
- source-path: "./"
49+
name: "arduino:zephyr"
50+
sketch-paths: |
51+
extra/Blink
52+
verbose: 'false'
53+
enable-deltas-report: 'false'

Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,23 @@ config ARDUINO_ENTRY
3131
default y
3232

3333
endif
34+
35+
if USB_DEVICE_STACK_NEXT
36+
37+
config USB_DEVICE_PRODUCT
38+
string "USB Device Product"
39+
default "Arduino Generic board"
40+
41+
config USB_DEVICE_MANUFACTURER
42+
string "USB Device Manufacturer"
43+
default "Arduino"
44+
45+
config USB_DEVICE_VID
46+
hex "USB Device Vendor ID"
47+
default 0x2341
48+
49+
config USB_DEVICE_PID
50+
hex "USB Device Product ID"
51+
default 0x0001
52+
53+
endif

boards.txt

Lines changed: 89 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
menu.debug=Mode
1+
menu.debug=Debug
2+
menu.mode=Mode
23

34
giga.name=Arduino Giga R1
45
giga.build.core=arduino
@@ -8,8 +9,8 @@ giga.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
89
giga.menu.debug.false=Standard
910
giga.menu.debug.true=Debug
1011

11-
giga.menu.debug.false.post_build_arg=
12-
giga.menu.debug.true.post_build_arg=debug
12+
giga.menu.debug.false.postbuild_debug=
13+
giga.menu.debug.true.postbuild_debug=-debug
1314

1415
giga.build.variant=arduino_giga_r1_m7
1516
giga.build.mcu=cortex-m7
@@ -81,8 +82,8 @@ nano33ble.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
8182
nano33ble.menu.debug.false=Standard
8283
nano33ble.menu.debug.true=Debug
8384

84-
nano33ble.menu.debug.false.post_build_arg=
85-
nano33ble.menu.debug.true.post_build_arg=debug
85+
nano33ble.menu.debug.false.postbuild_debug=
86+
nano33ble.menu.debug.true.postbuild_debug=-debug
8687

8788
nano33ble.build.variant=arduino_nano_33_ble_sense
8889
nano33ble.build.mcu=cortex-m4
@@ -151,8 +152,8 @@ ek_ra8d1.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
151152
ek_ra8d1.menu.debug.false=Standard
152153
ek_ra8d1.menu.debug.true=Debug
153154

154-
ek_ra8d1.menu.debug.false.post_build_arg=
155-
ek_ra8d1.menu.debug.true.post_build_arg=debug
155+
ek_ra8d1.menu.debug.false.postbuild_debug=
156+
ek_ra8d1.menu.debug.true.postbuild_debug=-debug
156157

157158
ek_ra8d1.build.variant=ek_ra8d1
158159
ek_ra8d1.build.mcu=cortex-m85+nomve
@@ -217,8 +218,8 @@ frdm_mcxn947.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin
217218
frdm_mcxn947.menu.debug.false=Standard
218219
frdm_mcxn947.menu.debug.true=Debug
219220

220-
frdm_mcxn947.menu.debug.false.post_build_arg=
221-
frdm_mcxn947.menu.debug.true.post_build_arg=debug
221+
frdm_mcxn947.menu.debug.false.postbuild_debug=
222+
frdm_mcxn947.menu.debug.true.postbuild_debug=-debug
222223

223224
frdm_mcxn947.build.variant=frdm_mcxn947_mcxn947_cpu0
224225
frdm_mcxn947.build.mcu=cortex-m33
@@ -277,8 +278,8 @@ portentah7.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
277278
portentah7.menu.debug.false=Standard
278279
portentah7.menu.debug.true=Debug
279280

280-
portentah7.menu.debug.false.post_build_arg=
281-
portentah7.menu.debug.true.post_build_arg=debug
281+
portentah7.menu.debug.false.postbuild_debug=
282+
portentah7.menu.debug.true.postbuild_debug=-debug
282283

283284
portentah7.build.variant=arduino_portenta_h7
284285
portentah7.build.mcu=cortex-m7
@@ -349,8 +350,8 @@ frdm_rw612.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
349350
frdm_rw612.menu.debug.false=Standard
350351
frdm_rw612.menu.debug.true=Debug
351352

352-
frdm_rw612.menu.debug.false.post_build_arg=
353-
frdm_rw612.menu.debug.true.post_build_arg=debug
353+
frdm_rw612.menu.debug.false.postbuild_debug=
354+
frdm_rw612.menu.debug.true.postbuild_debug=-debug
354355

355356
frdm_rw612.build.variant=frdm_rw612
356357
frdm_rw612.build.mcu=cortex-m33+nodsp
@@ -408,8 +409,8 @@ niclasense.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
408409
niclasense.menu.debug.false=Standard
409410
niclasense.menu.debug.true=Debug
410411

411-
niclasense.menu.debug.false.post_build_arg=
412-
niclasense.menu.debug.true.post_build_arg=debug
412+
niclasense.menu.debug.false.postbuild_debug=
413+
niclasense.menu.debug.true.postbuild_debug=-debug
413414

414415
niclasense.build.variant=arduino_nicla_sense_me
415416
niclasense.build.mcu=cortex-m4
@@ -472,3 +473,76 @@ niclasense.debug.server.openocd.scripts.0=interface/{programmer.protocol}.cfg
472473
niclasense.debug.server.openocd.scripts.1={programmer.transport_script}
473474
niclasense.debug.server.openocd.scripts.2=target/nrf52.cfg
474475
niclasense.debug.cortex-debug.custom.request=attach
476+
477+
478+
##########################################################################################
479+
480+
portentac33.name=Portenta C33
481+
portentac33.build.core=arduino
482+
portentac33.build.crossprefix=arm-zephyr-eabi-
483+
portentac33.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
484+
485+
portentac33.menu.debug.false=Standard
486+
portentac33.menu.debug.true=Debug
487+
488+
portentac33.menu.debug.false.postbuild_debug=
489+
portentac33.menu.debug.true.postbuild_debug=-debug
490+
491+
portentac33.menu.mode.llext=llext
492+
portentac33.menu.mode.linked=linked
493+
494+
portentac33.menu.mode.linked.build.extra_extra_ldflags=-lc -lm -lgcc -L{build.variant.path} -Wl,--wrap=random -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=malloc -Wl,--wrap=realloc
495+
portentac33.menu.mode.linked.build.llext_link_flags=
496+
portentac33.menu.mode.linked.build.suffix=_linked
497+
portentac33.menu.mode.linked.build.ldscript={runtime.platform.path}/variants/linked/linker_script.ld
498+
portentac33.menu.mode.linked.upload.extension=bin.dfu
499+
portentac33.menu.mode.linked.postbuild_mode=-linked
500+
501+
portentac33.build.variant=arduino_portenta_c33
502+
portentac33.build.mcu=cortex-m33
503+
portentac33.build.fpu=-mfpu=fpv5-sp-d16
504+
portentac33.build.architecture=cortex-m33
505+
portentac33.compiler.zephyr.arch.define=
506+
507+
portentac33.build.board={build.variant}
508+
509+
portentac33.build.float-abi=-mfloat-abi=hard
510+
portentac33.build.extra_flags=
511+
portentac33.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
512+
portentac33.build.board=arduino_portenta_c33
513+
portentac33.build.extra_ldflags=
514+
portentac33.compiler.zephyr.arch.define=
515+
portentac33.compiler.zephyr.defines=-DLL_EXTENSION_BUILD -DCONFIG_ARDUINO_API_SERIAL_BUFFER_SIZE=256 -DKERNEL -DK_HEAP_MEM_POOL_SIZE=122880 -DNDEBUG -DPICOLIBC_DOUBLE_PRINTF_SCANF -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -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
516+
portentac33.compiler.zephyr.ldflags=-fno-exceptions -fno-rtti -fno-threadsafe-statics -fno-unwind-tables -fno-use-cxa-atexit
517+
portentac33.compiler.zephyr.cflags=-fno-strict-aliasing -fno-printf-return-value -fno-common -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop --specs=picolibc.specs -D_POSIX_THREADS -mlong-calls -nodefaultlibs
518+
portentac33.compiler.zephyr.cxxflags={compiler.zephyr.ldflags} -fdata-sections -ffunction-sections -fno-unwind-tables -fno-strict-aliasing -fno-printf-return-value -fno-common -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop --specs=picolibc.specs -D_POSIX_THREADS -mlong-calls -nodefaultlibs
519+
portentac33.compiler.zephyr.includes={build.variant.path}/includes.txt
520+
portentac33.compiler.zephyr.extra_ldflags=-lstdc++ -lsupc++ -lnosys -nostdlib {build.extra_extra_ldflags}
521+
portentac33.compiler.zephyr=
522+
portentac33.vid.0=0x2341
523+
portentac33.pid.0=0x0068
524+
portentac33.upload_port.0.vid=0x2341
525+
portentac33.upload_port.0.pid=0x0068
526+
portentac33.upload.target=portentac33
527+
528+
portentac33.upload.tool=dfu-util
529+
portentac33.upload.tool.default=dfu-util
530+
portentac33.upload.protocol=
531+
portentac33.upload.transport=
532+
portentac33.upload.vid=0x2341
533+
portentac33.upload.pid=0x0368
534+
portentac33.upload.interface=1
535+
portentac33.upload.use_1200bps_touch=true
536+
portentac33.upload.wait_for_upload_port=false
537+
portentac33.upload.native_usb=true
538+
portentac33.upload.maximum_size=1966080
539+
portentac33.upload.maximum_data_size=523624
540+
portentac33.upload.address=0x100000
541+
portentac33.upload.dfuse=-Q
542+
543+
portentac33.bootloader.tool=dfu-util
544+
portentac33.bootloader.tool.default=dfu-util
545+
portentac33.bootloader.file=zephyr-arduino_portenta_c33.bin
546+
portentac33.bootloader.interface=0
547+
portentac33.bootloader.address=0x10000
548+
portentac33.bootloader.dfuse=-Q

cores/arduino/Arduino.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
#include <math.h>
1818

1919
#if DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios) > 0
20+
/* Note: DT_REG_ADDR needs an expanded argument or it will not work properly */
21+
#define DIGITAL_PIN_MATCHES(dev_pha, pin, dev, num) \
22+
(((dev == DT_REG_ADDR(dev_pha)) && (num == pin)) ? 1 : 0)
2023
#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \
21-
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && \
22-
(num == DT_PHA_BY_IDX(n, p, i, pin))) \
23-
? 1 \
24-
: 0)
24+
DIGITAL_PIN_MATCHES(DT_PHANDLE_BY_IDX(n, p, i), DT_PHA_BY_IDX(n, p, i, pin), dev, num)
2525

2626
/* Check all pins are defined only once */
2727
#define DIGITAL_PIN_CHECK_UNIQUE(i, _) \
@@ -142,4 +142,4 @@ void analogWriteResolution(int bits);
142142
// Allow namespace-less operations if Arduino.h is included
143143
using namespace arduino;
144144

145-
#endif // __cplusplus
145+
#endif // __cplusplus

cores/arduino/SerialUSB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ class SerialUSB_ : public ZephyrSerial {
3131
};
3232
} // namespace arduino
3333

34-
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
34+
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && (CONFIG_USB_CDC_ACM || CONFIG_USBD_CDC_ACM_CLASS))
3535
extern arduino::SerialUSB_ Serial;
3636
#endif

cores/arduino/USB.cpp

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <zephyr/usb/usb_device.h>
1111
#include <SerialUSB.h>
1212

13-
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
13+
#if ((DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm)) && (CONFIG_USB_CDC_ACM || CONFIG_USBD_CDC_ACM_CLASS))
1414
const struct device *const usb_dev = DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), cdc_acm, 0));
1515

1616
void usb_status_cb(enum usb_dc_status_code cb_status, const uint8_t *param) {
@@ -40,6 +40,58 @@ static void _baudChangeHandler(const struct device *dev, uint32_t rate)
4040
}
4141
}
4242

43+
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
44+
45+
extern "C" {
46+
#include <zephyr/usb/usbd.h>
47+
struct usbd_context *usbd_init_device(usbd_msg_cb_t msg_cb);
48+
}
49+
50+
struct usbd_context *_usbd;
51+
52+
int usb_disable() {
53+
return usbd_disable(_usbd);
54+
}
55+
56+
static void usbd_next_cb(struct usbd_context *const ctx, const struct usbd_msg *msg)
57+
{
58+
if (usbd_can_detect_vbus(ctx)) {
59+
if (msg->type == USBD_MSG_VBUS_READY) {
60+
usbd_enable(ctx);
61+
}
62+
63+
if (msg->type == USBD_MSG_VBUS_REMOVED) {
64+
usbd_disable(ctx);
65+
}
66+
}
67+
68+
if (msg->type == USBD_MSG_CDC_ACM_LINE_CODING) {
69+
uint32_t baudrate;
70+
uart_line_ctrl_get(ctx->dev, UART_LINE_CTRL_BAUD_RATE, &baudrate);
71+
_baudChangeHandler(nullptr, baudrate);
72+
}
73+
}
74+
75+
static int enable_usb_device_next(void)
76+
{
77+
int err;
78+
79+
//_usbd = usbd_init_device(usbd_next_cb);
80+
_usbd = usbd_init_device(nullptr);
81+
if (_usbd == NULL) {
82+
return -ENODEV;
83+
}
84+
85+
if (!usbd_can_detect_vbus(_usbd)) {
86+
err = usbd_enable(_usbd);
87+
if (err) {
88+
return err;
89+
}
90+
}
91+
return 0;
92+
}
93+
#endif /* defined(CONFIG_USB_DEVICE_STACK_NEXT) */
94+
4395
void arduino::SerialUSB_::_baudChangeDispatch(struct k_timer *timer) {
4496
arduino::SerialUSB_* dev = (arduino::SerialUSB_*)k_timer_user_data_get(timer);
4597
dev->_baudChangeHandler();
@@ -48,6 +100,7 @@ void arduino::SerialUSB_::_baudChangeDispatch(struct k_timer *timer) {
48100

49101
void arduino::SerialUSB_::begin(unsigned long baudrate, uint16_t config) {
50102
if (!started) {
103+
#ifndef CONFIG_USB_DEVICE_STACK_NEXT
51104
usb_enable(NULL);
52105
#ifndef CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT
53106
k_timer_init(&baud_timer, SerialUSB_::_baudChangeDispatch, NULL);
@@ -56,6 +109,9 @@ void arduino::SerialUSB_::begin(unsigned long baudrate, uint16_t config) {
56109
#else
57110
cdc_acm_dte_rate_callback_set(usb_dev, ::_baudChangeHandler);
58111
#endif
112+
#else
113+
enable_usb_device_next();
114+
#endif
59115
ZephyrSerial::begin(baudrate, config);
60116
started = true;
61117
}

0 commit comments

Comments
 (0)