zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.85k stars 6.61k forks source link

bluetooth hci_usb sample not compiling #66056

Closed zero-pytagoras closed 11 months ago

zero-pytagoras commented 11 months ago

Describe the bug I am trying to use nRF52840-MDK as usb dongle and was suggested to use sample bluetooth project in this repo to create hex file and deploy to the board. I have setup dev environment and installed dependencies, yet it is failing with : -- Configuring incomplete, errors occurred!

To Reproduce Steps to reproduce the behavior:

git clone https://github.com/zephyrproject-rtos/zephyr.git ~/Projects/zephyr
cd Projects/zephyr/samples/bluetooth/hci_usb/
mkdir build && cd build
cmake -GNinja -DBOARD=nrf52840_mdk ..

Expected behavior get Ninja file

Impact not able to use the device

Logs and console output added to prj.conf these:

CONFIG_LOG=y
CONFIG_USB_DEVICE_LOG_LEVEL_DBG=y

but no logs are generated Yet here is the cmake output

-- Application: /home/asch/Projects/zephyr/samples/bluetooth/hci_usb
-- CMake version: 3.25.1
-- Found Python3: /home/asch/.local/share/virtualenvs/zephyr-i_1ptolU/bin/python (found suitable version "3.11.2", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /home/asch/.cache/zephyr
-- Zephyr version: 3.5.99 (/home/asch/Projects/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840_mdk
-- Found toolchain: gnuarmemb (/usr/local/bin/gcc-arm-none-eabi-10.3-2021.10/)
-- Found Dtc: /opt/zephyr-sdk/0.9/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/asch/Projects/zephyr/boards/arm/nrf52840_mdk/nrf52840_mdk.dts
-- Generated zephyr.dts: /home/asch/Projects/zephyr/samples/bluetooth/hci_usb/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/asch/Projects/zephyr/samples/bluetooth/hci_usb/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/asch/Projects/zephyr/samples/bluetooth/hci_usb/build/zephyr/dts.cmake

warning: HAS_NORDIC_DRIVERS (defined at modules/hal_nordic/Kconfig:7) has direct dependencies 0 with value n, but is currently being y-selected by the following symbols:
 - SOC_SERIES_NRF52X (defined at soc/arm/nordic_nrf/nrf52/Kconfig.series:6), with value y, direct dependencies <choice> (value: y), and select condition <choice> (value: y)

warning: TINYCRYPT (defined at soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw40z4:21, soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw41z4:30, modules/Kconfig.tinycrypt:9) has direct dependencies (SOC_MKW40Z4 && SOC_SERIES_KINETIS_KWX) || (ENTROPY_GENERATOR && SOC_MKW41Z4 && SOC_SERIES_KINETIS_KWX) || ZEPHYR_TINYCRYPT_MODULE with value n, but is currently being y-selected by the following symbols:
 - BT_RPA (defined at subsys/bluetooth/common/Kconfig:255), with value y, direct dependencies BT_HCI && BT (value: y), and select condition BT_HCI && BT (value: y)

warning: HAS_CMSIS_CORE (defined at modules/cmsis/Kconfig:7) has direct dependencies 0 with value n, but is currently being y-selected by the following symbols:
 - CPU_CORTEX_M (defined at arch/arm/core/Kconfig:6), with value y, direct dependencies ARM (value: y), and select condition ARM (value: y)

warning: HAS_NRFX (defined at modules/hal_nordic/nrfx/Kconfig:4) has direct dependencies 0 with value n, but is currently being y-selected by the following symbols:
 - SOC_SERIES_NRF52X (defined at soc/arm/nordic_nrf/nrf52/Kconfig.series:6), with value y, direct dependencies <choice> (value: y), and select condition <choice> (value: y)

warning: NRFX_CLOCK (defined at modules/hal_nordic/nrfx/Kconfig:16) has direct dependencies HAS_NRFX && 0 with value n, but is currently being y-selected by the following symbols:
 - CLOCK_CONTROL_NRF (defined at drivers/clock_control/Kconfig.nrf:13), with value y, direct dependencies DT_HAS_NORDIC_NRF_CLOCK_ENABLED && CLOCK_CONTROL (value: y), and select condition !CLOCK_CONTROL_NRF_FORCE_ALT && DT_HAS_NORDIC_NRF_CLOCK_ENABLED && CLOCK_CONTROL (value: y)

warning: NRFX_GPIOTE (defined at modules/hal_nordic/nrfx/Kconfig:65) has direct dependencies HAS_NRFX && 0 with value n, but is currently being y-selected by the following symbols:
 - GPIO_NRFX (defined at drivers/gpio/Kconfig.nrfx:4), with value y, direct dependencies DT_HAS_NORDIC_NRF_GPIO_ENABLED && GPIO (value: y), and select condition DT_HAS_NORDIC_NRF_GPIO_ENABLED && GPIO (value: y)

warning: NRFX_POWER (defined at modules/hal_nordic/nrfx/Kconfig:115) has direct dependencies HAS_NRFX && 0 with value n, but is currently being y-selected by the following symbols:
 - USB_NRFX (defined at drivers/usb/device/Kconfig:103), with value y, direct dependencies DT_HAS_NORDIC_NRF_USBD_ENABLED && USB_DEVICE_DRIVER (value: y), and select condition DT_HAS_NORDIC_NRF_USBD_ENABLED && USB_DEVICE_DRIVER (value: y)

warning: NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED (defined at modules/hal_nordic/nrfx/Kconfig:20) has direct dependencies NRFX_CLOCK && HAS_NRFX && 0 with value n, but is currently being y-selected by the following symbols:
 - CLOCK_CONTROL_NRF_K32SRC_XTAL (defined at drivers/clock_control/Kconfig.nrf:36), with value y, direct dependencies <choice CLOCK_CONTROL_NRF_SOURCE> (value: y), and select condition !SOC_SERIES_BSIM_NRFXX && !CLOCK_CONTROL_NRF_FORCE_ALT && <choice CLOCK_CONTROL_NRF_SOURCE> (value: y)
Parsing /home/asch/Projects/zephyr/Kconfig
Loaded configuration '/home/asch/Projects/zephyr/boards/arm/nrf52840_mdk/nrf52840_mdk_defconfig'
Merged configuration '/home/asch/Projects/zephyr/samples/bluetooth/hci_usb/prj.conf'

error: Aborting due to Kconfig warnings

CMake Error at /home/asch/Projects/zephyr/cmake/modules/kconfig.cmake:355 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  /home/asch/Projects/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  /home/asch/Projects/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/asch/Projects/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:4 (find_package)

-- Configuring incomplete, errors occurred!

Environment (please complete the following information):

Additional context I am trying to use nrf52840 as usb dongle for bluetooth5 BLE long range communication. one of nordic community forum chains suggested to use hci_usb as use case

github-actions[bot] commented 11 months ago

Hi @zero-pytagoras! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

Ballen7 commented 11 months ago

It compiles fine for me. I suggest you follow this guide for setting up your enviroment and trying again.

https://docs.zephyrproject.org/latest/develop/getting_started/index.html

zero-pytagoras commented 11 months ago

Hi @Ballen7 Reinstalled the toolchain and sdk several times, still getting the error:

west build -p always -b nrf52840_mdk samples/basic/blinky
-- west build: making build dir /home/asch/Projects/zephyrproject/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/asch/Projects/zephyrproject/samples/basic/blinky
-- CMake version: 3.27.7
-- Found Python3: /home/asch/Projects/zephyrproject/.venv/bin/python3 (found suitable version "3.11.2", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /home/asch/.cache/zephyr
-- Zephyr version: 3.5.99 (/home/asch/Projects/zephyrproject/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840_mdk
-- Found toolchain: gnuarmemb (/home/asch/zephyr-sdk-0.16.4)
CMake Error at /home/asch/Projects/zephyrproject/zephyr/cmake/compiler/gcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: gnuarmemb

  Internal variables:

  CROSS_COMPILE: /home/asch/zephyr-sdk-0.16.4/bin/arm-none-eabi-

  TOOLCHAIN_HOME: /home/asch/zephyr-sdk-0.16.4

Call Stack (most recent call first):
  /home/asch/Projects/zephyrproject/zephyr/cmake/modules/FindHostTools.cmake:107 (include)
  /home/asch/Projects/zephyrproject/zephyr/cmake/modules/dts.cmake:9 (find_package)
  /home/asch/Projects/zephyrproject/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  /home/asch/Projects/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/asch/Projects/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:4 (find_package)

-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/home/asch/Projects/zephyrproject/.venv/bin/python3 -B/home/asch/Projects/zephyrproject/build -GNinja -DBOARD=nrf52840_mdk -S/home/asch/Projects/zephyrproject/samples/basic/blinky
thedjnK commented 11 months ago

Why have you set it to gnuarmemb?

zero-pytagoras commented 11 months ago

I didn't - it sets it by its own way. I've completely reinstalled the system and followed the tutorial mentioned above

thedjnK commented 11 months ago

I didn't - it sets it by its own way. I've completely reinstalled the system and followed the tutorial mentioned above

It does not, a warning would be shown in your configure log if it was not set:

-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK

To use gnuarmemb means you have set both ZEPHYR_TOOLCHAIN_VARIANT and GNUARMEMB_TOOLCHAIN_PATH

Ballen7 commented 11 months ago

Sense it is a Nordic chip you need to use ncs not zephyr ....

west init -m https://github.com/nrfconnect/sdk-nrf.git --mr main ~/ncs
cd ~/ncs
west update
cd ~/ncs/zephyr/samples/bluetooth/hci_usb/
west build -b nrf52840_mdk
zero-pytagoras commented 11 months ago

Hi @Ballen7, Thanks - it worked like a charm ... Appreciate your help !!! Mind suggesting how can I fix the MAC address issue ?

$ hcitool dev
Devices:
    hci1    00:00:00:00:00:00
    hci0    7C:B5:66:65:CE:52
Ballen7 commented 11 months ago

@zero-pytagoras What OS are you trying to use it with? On Ubuntu it gets recongized it right away for me.

zero-pytagoras commented 11 months ago

@Ballen7 Debian12, and i am testing it also on arm device with debian9. on my laptop, where i compile and flash, it shows the device and even can be used with bluetoothctl, but the mac is still zeros. on other device it registers the usb, but claims it as nameless and bluetooth don't recognizes the arm device.