From 72c0f5019f6ffe73caf680720feff2a518526746 Mon Sep 17 00:00:00 2001 From: Francesco Pham <francesco.pham@huawei.com> Date: Tue, 20 Dec 2022 16:10:38 +0100 Subject: [PATCH] zephyr-kernel: add patch to enable shell/console over USB (CDC ACM) adding patch `0003-philosophers-set-overlay-to-enable-shell-console-ove.patch` to enable shell-console over USB for zephyr-philosophers sample application. currently shell and console is not working via USB, instead one have to use the UART interface and use a serial to USB cable to access the arduino shell. This is a regression because in Jasmine console over usb was working. The regression was introduced from upstream: https://github.com/zephyrproject-rtos/zephyr/pull/44023/commits/69707dfb4bd91b513fb3e1503d76265c857f18b7#diff-93ba35382d86f5dce92d22c0f8c1a2649ba17786dca3bff30c5b760cbe8b9128 Using this overlay configuration, enabling CONFIG_USB_DEVICE_STACK and calling usb_enable() we are able to access the arduino shell using the USB port of the Arduino Nano board. This patch is only applied to the zephyr-philosophers sample application. Relate-to: https://gitlab.eclipse.org/eclipse/oniro-core/meta-zephyr/-/issues/33 Signed-off-by: Francesco Pham <francesco.pham@huawei.com> --- ...-overlay-to-enable-shell-console-ove.patch | 87 +++++++++++++++++++ ...-to-enable-shell-console-ove.patch.license | 3 + .../zephyr-kernel/zephyr-kernel-src.inc | 1 + 3 files changed, 91 insertions(+) create mode 100644 meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch create mode 100644 meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch.license diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch new file mode 100644 index 0000000..575c856 --- /dev/null +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch @@ -0,0 +1,87 @@ +From 6edf39b04355260b5340a94d2471a6cfe12c8ab8 Mon Sep 17 00:00:00 2001 +From: Francesco Pham <francesco.pham@huawei.com> +Date: Tue, 20 Dec 2022 15:21:12 +0100 +Subject: [PATCH] philosophers: set overlay to enable shell/console over USB + (CDC ACM) + +currently shell and console is not working via USB, instead one have to use +the UART interface and use a serial to USB cable to access the arduino shell. +This is a regression because in Jasmine console over usb was working. +The regression was introduced from upstream: +https://github.com/zephyrproject-rtos/zephyr/pull/44023/commits/69707dfb4bd91b513fb3e1503d76265c857f18b7#diff-93ba35382d86f5dce92d22c0f8c1a2649ba17786dca3bff30c5b760cbe8b9128 + +Using this overlay configuration, enabling CONFIG_USB_DEVICE_STACK and calling +usb_enable() we are able to access the arduino shell using the USB port of +the arduino. This patch is only applied to the zephyr-philosophers sample application. + +Relate-to: https://gitlab.eclipse.org/eclipse/oniro-core/meta-zephyr/-/issues/33 + +Upstream status: inappropriate [Oniro specific] + +Signed-off-by: Francesco Pham <francesco.pham@huawei.com> + +--- + .../boards/arduino_nano_33_ble.overlay | 19 +++++++++++++++++++ + samples/philosophers/prj.conf | 2 ++ + samples/philosophers/src/main.c | 5 +++++ + 3 files changed, 26 insertions(+) + create mode 100644 samples/philosophers/boards/arduino_nano_33_ble.overlay + +diff --git a/samples/philosophers/boards/arduino_nano_33_ble.overlay b/samples/philosophers/boards/arduino_nano_33_ble.overlay +new file mode 100644 +index 0000000000..a04c008eb4 +--- /dev/null ++++ b/samples/philosophers/boards/arduino_nano_33_ble.overlay +@@ -0,0 +1,19 @@ ++/* ++ * SPDX-FileCopyrightText: Huawei Inc. ++ * ++ * SPDX-License-Identifier: Apache-2.0 ++ */ ++ ++/ { ++ chosen { ++ zephyr,console = &cdc_acm_uart0; ++ zephyr,shell-uart = &cdc_acm_uart0; ++ }; ++}; ++ ++&zephyr_udc0 { ++ cdc_acm_uart0: cdc_acm_uart0 { ++ compatible = "zephyr,cdc-acm-uart"; ++ label = "CDC_ACM_0"; ++ }; ++}; +diff --git a/samples/philosophers/prj.conf b/samples/philosophers/prj.conf +index 0d5b435dd4..2808d82118 100644 +--- a/samples/philosophers/prj.conf ++++ b/samples/philosophers/prj.conf +@@ -8,3 +8,5 @@ CONFIG_MP_NUM_CPUS=1 + + #Enable thread awareness for debugging tools supporting it + CONFIG_DEBUG_THREAD_INFO=y ++ ++CONFIG_USB_DEVICE_STACK=y +diff --git a/samples/philosophers/src/main.c b/samples/philosophers/src/main.c +index 02b42ef5bb..fb960c7ca7 100644 +--- a/samples/philosophers/src/main.c ++++ b/samples/philosophers/src/main.c +@@ -36,6 +36,7 @@ + */ + + #include <zephyr/zephyr.h> ++#include <zephyr/usb/usb_device.h> + + #if defined(CONFIG_STDOUT_CONSOLE) + #include <stdio.h> +@@ -251,6 +252,10 @@ static void display_demo_description(void) + + void main(void) + { ++ if (usb_enable(NULL)) { ++ return; ++ } ++ + display_demo_description(); + #if CONFIG_TIMESLICING + k_sched_time_slice_set(5000, 0); diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch.license b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch.license new file mode 100644 index 0000000..a24394e --- /dev/null +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0003-philosophers-set-overlay-to-enable-shell-console-ove.patch.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: MIT diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src.inc index 0769017..00e872d 100644 --- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src.inc +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-src.inc @@ -52,6 +52,7 @@ SRC_URI = "\ git://github.com/zephyrproject-rtos/lz4.git;protocol=https;nobranch=1;destsuffix=git/modules/lib/lz4;name=lz4 \ git://github.com/zephyrproject-rtos/tflite-micro.git;protocol=https;nobranch=1;destsuffix=git/modules/lib/tflite-micro;name=tflite-micro \ file://0001-cmake-add-yocto-toolchain.patch \ + file://0003-philosophers-set-overlay-to-enable-shell-console-ove.patch \ " S = "${WORKDIR}/git" -- GitLab