From e3612be519de8c8d10b96bdda6d5b90de0f542ec Mon Sep 17 00:00:00 2001
From: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
Date: Wed, 4 May 2022 17:15:09 +0200
Subject: [PATCH] zephyr-kernel: don't call zephyr_library() twice
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The patch enabling the ACM0 console adds a call to zephyr_library() that
with certain Kconfig option can be called twice leading to build failures.
Remove the duplicate.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
Suggested-by: Eilís Ní Fhlannagáin <elizabeth.flanagan@huawei.com>
---
 ...able-the-USB-ACM0-console-by-default.patch | 31 +++++++++++--------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-console-enable-the-USB-ACM0-console-by-default.patch b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-console-enable-the-USB-ACM0-console-by-default.patch
index 98c525c..183b5a6 100644
--- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-console-enable-the-USB-ACM0-console-by-default.patch
+++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-console-enable-the-USB-ACM0-console-by-default.patch
@@ -1,4 +1,4 @@
-From e64879dc1cc0c4f6999874a96c24c9272958fee8 Mon Sep 17 00:00:00 2001
+From d644a7d002bd308926e5080a21101b057e2dbc27 Mon Sep 17 00:00:00 2001
 From: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
 Date: Thu, 27 Jan 2022 10:26:41 +0100
 Subject: [PATCH] console: enable the USB ACM0 console by default
@@ -6,27 +6,32 @@ Subject: [PATCH] console: enable the USB ACM0 console by default
 Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
 Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
 ---
- boards/arm/arduino_nano_33_ble/CMakeLists.txt |  3 +++
+ boards/arm/arduino_nano_33_ble/CMakeLists.txt |  3 ++-
  .../arduino_nano_33_ble.dts                   |  9 +++++++
  .../arduino_nano_33_ble_defconfig             |  6 +++++
  .../src/init_usb_cdc_acm.c                    | 25 +++++++++++++++++++
  subsys/shell/backends/shell_uart.c            |  2 +-
- 5 files changed, 44 insertions(+), 1 deletion(-)
+ 5 files changed, 43 insertions(+), 2 deletions(-)
  create mode 100644 boards/arm/arduino_nano_33_ble/src/init_usb_cdc_acm.c
 
 diff --git a/boards/arm/arduino_nano_33_ble/CMakeLists.txt b/boards/arm/arduino_nano_33_ble/CMakeLists.txt
-index 9e885f42ab8..37495cb885c 100644
+index 9e885f42ab..a40f17b396 100644
 --- a/boards/arm/arduino_nano_33_ble/CMakeLists.txt
 +++ b/boards/arm/arduino_nano_33_ble/CMakeLists.txt
-@@ -11,3 +11,6 @@ if(CONFIG_BOARD_ARDUINO_NANO_33_BLE_INIT_SENSORS)
+@@ -5,9 +5,10 @@ add_library(arduino_nano_33_ble_pins INTERFACE)
+ target_include_directories(arduino_nano_33_ble_pins 
+         INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/inc/")
+ 
++zephyr_library()
++zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/init_usb_cdc_acm.c")
+ 
+ if(CONFIG_BOARD_ARDUINO_NANO_33_BLE_INIT_SENSORS)
+-  zephyr_library()
    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")
 diff --git a/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble.dts b/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble.dts
-index 7e509086d27..aa769b87f0c 100644
+index 7e509086d2..aa769b87f0 100644
 --- a/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble.dts
 +++ b/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble.dts
 @@ -34,6 +34,10 @@
@@ -53,7 +58,7 @@ index 7e509086d27..aa769b87f0c 100644
  // All PWM's should be enaled
  &pwm0 {
 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 5fbe4ccdfb0..3e3c51635dc 100644
+index 5fbe4ccdfb..3e3c51635d 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
 @@ -18,3 +18,9 @@ CONFIG_BOOTLOADER_BOSSA_LEGACY=y
@@ -68,7 +73,7 @@ index 5fbe4ccdfb0..3e3c51635dc 100644
 +CONFIG_BOARD_ARDUINO_NANO_33_BLE_EN_USB_CONSOLE=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 00000000000..a429cc5c8ca
+index 0000000000..a429cc5c8c
 --- /dev/null
 +++ b/boards/arm/arduino_nano_33_ble/src/init_usb_cdc_acm.c
 @@ -0,0 +1,25 @@
@@ -98,7 +103,7 @@ index 00000000000..a429cc5c8ca
 +}
 +SYS_INIT(board_internal_usb_cdc_acm_init, APPLICATION, 99);
 diff --git a/subsys/shell/backends/shell_uart.c b/subsys/shell/backends/shell_uart.c
-index 18f26db7638..cda2baf3643 100644
+index 18f26db763..cda2baf364 100644
 --- a/subsys/shell/backends/shell_uart.c
 +++ b/subsys/shell/backends/shell_uart.c
 @@ -335,7 +335,7 @@ static int enable_shell_uart(const struct device *arg)
@@ -111,5 +116,5 @@ index 18f26db7638..cda2baf3643 100644
  
  const struct shell *shell_backend_uart_get_ptr(void)
 -- 
-2.25.1
+2.34.1
 
-- 
GitLab