Skip to content
Snippets Groups Projects
Unverified Commit caee2476 authored by Andrei Gherzan's avatar Andrei Gherzan :penguin:
Browse files

zephyr-kernel: Drop the Arduino USB CDC patch

This patch is not applying to the new Zephyr version provided by
meta-zephyr. Also, the implementation needs changes based on discussions
with the Zephyr community. We will be reimplementing it as part of:

https://booting.oniroproject.org/distro/meta-zephyr/-/issues/16



In the meanwhile, drop this patch to avoid build issues.

Signed-off-by: Andrei Gherzan's avatarAndrei Gherzan <andrei.gherzan@huawei.com>
parent 3eb77fe5
No related branches found
No related tags found
No related merge requests found
diff --git a/boards/arm/arduino_nano_33_ble/CMakeLists.txt b/boards/arm/arduino_nano_33_ble/CMakeLists.txt
index 9e885f42ab..9ff0f80ab4 100644
--- a/boards/arm/arduino_nano_33_ble/CMakeLists.txt
+++ b/boards/arm/arduino_nano_33_ble/CMakeLists.txt
@@ -11,3 +11,7 @@ if(CONFIG_BOARD_ARDUINO_NANO_33_BLE_INIT_SENSORS)
zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/init_sensors.c")
target_link_libraries(${ZEPHYR_CURRENT_LIBRARY} PRIVATE arduino_nano_33_ble_pins)
endif()
+
+
+zephyr_library()
+zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/init_usb_cdc_acm.c")
\ No newline at end of file
diff --git a/boards/arm/arduino_nano_33_ble/Kconfig.board b/boards/arm/arduino_nano_33_ble/Kconfig.board
index 476a9123da..9dffe6ff69 100644
--- a/boards/arm/arduino_nano_33_ble/Kconfig.board
+++ b/boards/arm/arduino_nano_33_ble/Kconfig.board
@@ -18,3 +18,7 @@ config BOARD_ARDUINO_NANO_33_BLE_EN_USB_CONSOLE
config BOARD_ARDUINO_NANO_33_BLE_INIT_SENSORS
bool "Initializes the internal I2C sensors on the board"
depends on BOARD_ARDUINO_NANO_33_BLE
+
+config BOARD_ARDUINO_NANO_33_BLE_INIT_USB_CDC_ACM
+ bool "enable USB CDC_ACM interface after flashing"
+ depends on BOARD_ARDUINO_NANO_33_BLE
\ No newline at end of file
diff --git a/boards/arm/arduino_nano_33_ble/Kconfig.defconfig b/boards/arm/arduino_nano_33_ble/Kconfig.defconfig
index 937aba0014..8e27a1977f 100644
--- a/boards/arm/arduino_nano_33_ble/Kconfig.defconfig
+++ b/boards/arm/arduino_nano_33_ble/Kconfig.defconfig
@@ -10,6 +10,10 @@ config USB_NRFX
default y
config USB_DEVICE_STACK
default y
+config SERIAL
+ default USB_CDC_ACM
+config UART_INTERRUPT_DRIVEN
+ default USB_CDC_ACM
endif # USB
config BT_CTLR
diff --git a/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig b/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig
index ba8eeee931..5551c9cc3d 100644
--- a/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig
+++ b/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig
@@ -19,3 +19,16 @@ CONFIG_BOOTLOADER_BOSSA_LEGACY=y
# additional board options
CONFIG_GPIO_AS_PINRESET=y
+
+# Following configuration are need to enable virtual com port via USB CDC_ACM
+# This will enble console as well as shell on USB CDC_ACM
+CONFIG_USB=y
+CONFIG_USB_DEVICE_STACK=y
+CONFIG_USB_DEVICE_PRODUCT="zephyr application with CDC_ACM enabled"
+CONFIG_USB_UART_CONSOLE=y
+CONFIG_UART_LINE_CTRL=y
+CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0"
+CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"
+CONFIG_BOARD_ARDUINO_NANO_33_BLE_INIT_USB_CDC_ACM=y
+CONFIG_SHELL=y
+CONFIG_SHELL_BACKEND_SERIAL=y
diff --git a/boards/arm/arduino_nano_33_ble/src/init_usb_cdc_acm.c b/boards/arm/arduino_nano_33_ble/src/init_usb_cdc_acm.c
new file mode 100644
index 0000000000..856dc737b0
--- /dev/null
+++ b/boards/arm/arduino_nano_33_ble/src/init_usb_cdc_acm.c
@@ -0,0 +1,44 @@
+#include <usb/usb_device.h>
+#include <drivers/uart.h>
+
+#ifdef CONFIG_BOARD_ARDUINO_NANO_33_BLE_INIT_USB_CDC_ACM
+static int board_internal_usb_cdc_acm_init(const struct device *dev)
+{
+ ARG_UNUSED(dev);
+ uint64_t end = sys_clock_timeout_end_calc(K_MSEC(2000));
+ const struct device *device = device_get_binding(
+ CONFIG_UART_CONSOLE_ON_DEV_NAME);
+ uint32_t dtr = 0;
+
+ if (device == NULL) {
+ return -ENODEV;
+ }
+
+ if (usb_enable(NULL)) {
+ return -EIO;
+ }
+
+ /* Poll if the DTR flag was set, optional */
+ do {
+ int64_t remaining = end - sys_clock_tick_get();
+
+ if (remaining <= 0) {
+ return -EIO;
+ }
+
+ uart_line_ctrl_get(device, UART_LINE_CTRL_DTR, &dtr);
+ k_sleep(K_MSEC(100));
+ } while(!dtr);
+
+ if (strncmp(CONFIG_UART_CONSOLE_ON_DEV_NAME, "CDC_ACM_0",
+ strlen(CONFIG_UART_CONSOLE_ON_DEV_NAME))) {
+ printk("Error: Console device name is not USB ACM\n");
+
+ return -ENXIO;
+ }
+
+
+ return 0;
+}
+SYS_INIT(board_internal_usb_cdc_acm_init, APPLICATION, 32);
+#endif
diff --git a/subsys/shell/shell_uart.c b/subsys/shell/shell_uart.c
index de3987b558..1872249eee 100644
--- a/subsys/shell/shell_uart.c
+++ b/subsys/shell/shell_uart.c
@@ -312,7 +312,7 @@ static int enable_shell_uart(const struct device *arg)
return 0;
}
-SYS_INIT(enable_shell_uart, POST_KERNEL,
+SYS_INIT(enable_shell_uart, APPLICATION,
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY);
const struct shell *shell_backend_uart_get_ptr(void)
...@@ -50,7 +50,6 @@ SRC_URI = "\ ...@@ -50,7 +50,6 @@ SRC_URI = "\
git://github.com/zephyrproject-rtos/tinycrypt.git;protocol=https;nobranch=1;destsuffix=git/modules/crypto/tinycrypt;name=tinycrypt \ git://github.com/zephyrproject-rtos/tinycrypt.git;protocol=https;nobranch=1;destsuffix=git/modules/crypto/tinycrypt;name=tinycrypt \
git://github.com/zephyrproject-rtos/TraceRecorderSource.git;protocol=https;nobranch=1;destsuffix=git/modules/debug/TraceRecorder;name=TraceRecorder \ git://github.com/zephyrproject-rtos/TraceRecorderSource.git;protocol=https;nobranch=1;destsuffix=git/modules/debug/TraceRecorder;name=TraceRecorder \
git://github.com/zephyrproject-rtos/trusted-firmware-m.git;protocol=https;nobranch=1;destsuffix=git/modules/tee/tfm;name=tfm \ git://github.com/zephyrproject-rtos/trusted-firmware-m.git;protocol=https;nobranch=1;destsuffix=git/modules/tee/tfm;name=tfm \
file://arduino-usb-cdc-acm-enble.patch \
" "
S = "${WORKDIR}/git" 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