Skip to content
Snippets Groups Projects
Commit 72c0f501 authored by Francesco Pham's avatar Francesco Pham
Browse files

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: #33



Signed-off-by: default avatarFrancesco Pham <francesco.pham@huawei.com>
parent 146fd256
No related branches found
No related tags found
1 merge request!32Draft: zephyr-kernel: add patch to enable shell/console over USB
Pipeline #13651 canceled
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);
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: MIT
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment