8000 Enable WiFi on C33 and BLE on C33/Giga by facchinm · Pull Request #130 · arduino/ArduinoCore-zephyr · GitHub
[go: up one dir, main page]

Skip to content

Enable WiFi on C33 and BLE on C33/Giga #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: arduino
Choose a base branch
from

Conversation

facchinm
Copy link
Member

Giga still not working, investigation in progress.
As always, refer to https://github.com/facchinm/ArduinoBLE/tree/zephyr_hci to test BLE

@mjs513
Copy link
mjs513 commented May 23, 2025

@facchinm
just checked out PR and tried rebuilding for the giga and got a bunch of undefined references:

/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4_ifx_cyw43xxx.c.obj): in function `bt_h4_vnd_setup':
/home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:255: undefined reference to `bt_hci_cmd_send_sync'
/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4_ifx_cyw43xxx.c.obj): in function `bt_firmware_download':
/home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:160: undefined reference to `bt_hci_cmd_send_sync'
/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:175: undefined reference to `bt_hci_cmd_create'
/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:185: undefined reference to `bt_hci_cmd_send_sync'
/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4_ifx_cyw43xxx.c.obj): in function `bt_h4_vnd_setup':
/home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:221: undefined reference to `brcm_patch_ram_length'
/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:221: undefined reference to `brcm_patchram_buf'
/home/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:286: undefined reference to `bt_hci_cmd_send_sync'

@mjs513
Copy link
mjs513 commented May 23, 2025

Quick update - did a west update and managed to get it to build but then:

warning: HW_STACK_PROTECTION (defined at soc/nxp/s32/s32k1/Kconfig.defconfig:20, arch/Kconfig:285)
was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies:
((SOC_SERIES_S32K1 && SOC_FAMILY_NXP_S32) || ARCH_HAS_STACK_PROTECTION) (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_HW_STACK_PROTECTION and/or look up
HW_STACK_PROTECTION in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: BT_HCI_TX_STACK_SIZE (defined at subsys/bluetooth/host/Kconfig:46) was assigned the value
'4096' but got the value '512'. See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_HCI_TX_STACK_SIZE and/or look up
BT_HCI_TX_STACK_SIZE in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: BT_CTLR_ADV_EXT (defined at subsys/bluetooth/controller/Kconfig:739) was assigned the value
'y' but got the value 'n'. Check these unsatisfied dependencies: BT_CTLR_ADV_EXT_SUPPORT (=n),
HAS_BT_CTLR (=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_CTLR_ADV_EXT
and/or look up BT_CTLR_ADV_EXT in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.


warning: BT_CTLR_ADV_PERIODIC (defined at subsys/bluetooth/controller/Kconfig:779) was assigned the
value 'y' but got the value 'n'. Check these unsatisfied dependencies: BT_CTLR_ADV_PERIODIC_SUPPORT
(=n), BT_CTLR_ADV_EXT (=n), HAS_BT_CTLR (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_CTLR_ADV_PERIODIC and/or look up
BT_CTLR_ADV_PERIODIC in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: BT_CTLR_DTM_HCI (defined at subsys/bluetooth/controller/Kconfig.dtm:14) was assigned the
value 'y' but got the value 'n'. Check these unsatisfied dependencies: BT_CTLR_DTM_HCI_SUPPORT (=n),
HAS_BT_CTLR (=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_CTLR_DTM_HCI
and/or look up BT_CTLR_DTM_HCI in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.

and

-- Zephyr version: 4.1.99 (/home/my_new_zephyr_folder/zephyr), build: v3.7.0-16675-g008d154d8bd8
[162/293] Building C object zephyr/drivers/bluetooth...les/drivers__bluetooth.dir/hci/h4_ifx_cyw43xxx.c.obj
/home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c: In function 'bt_h4_vnd_setup':
/home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:220:18: warning: unused variable fw_download_speed' [-Wunused-variable]
  220 |         uint32_t fw_download_speed = DT_INST_PROP_OR(0, fw_download_speed, default_uart_speed);
      |                  ^~~~~~~~~~~~~~~~~
/home/my_new_zephyr_folder/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:219:18: warning: unused variable hci_operation_speed' [-Wunused-variable]
  219 |         uint32_t hci_operation_speed = DT_INST_PROP_OR(0, hci_operation_speed, default_uart_speed);
      |                  ^~~~~~~~~~~~~~~~~~~

Just to let you know :)

@mjs513
Copy link
mjs513 commented May 23, 2025

Tried giga with BLE lib:

starting Bluetooth® Low Energy module failed!

and in debug looks like its doing somthing:

uart:~$ sketch
[00:01:16.825,000] <inf> usb_cdc_acm: Device suspended
[00:01:17.068,000] <inf> usb_cdc_acm: Device configured
[00:01:17.217,000] <dbg> bt_driver: h4_open:
[00:01:17.222,000] <dbg> bt_driver: rx_thread: started
[00:01:17.227,000] <dbg> bt_driver: rx_thread: rx.buf 0
[00:01:17.233,000] <inf> bt_hci_raw: Lower HCI transport: H:4
[00:01:17.239,000] <inf> bt_hci_raw: Bluetooth enabled in RAW mode
[00:01:18.396,000] <dbg> bt_driver: h4_send: buf 0x24039f78 type 1 len 4
[00:01:18.404,000] <dbg> bt_driver: process_rx: remaining 0 discard 0 have_hdr 0 rx.buf 0 len 0
[00:01:18.413,000] <dbg> bt_driver: process_rx: remaining 2 discard 0 have_hdr 0 rx.buf 0 len 0
[00:01:18.422,000] <dbg> bt_driver: process_rx: remaining 1 discard 0 have_hdr 0 rx.buf 0 len 0
[00:01:18.431,000] <dbg> bt_driver: get_evt_hdr: Got event header. Payload 4 bytes
[00:01:18.439,000] <dbg> bt_driver: process_rx: remaining 4 discard 0 have_hdr 1 rx.buf 0 len 0
[00:01:18.448,000] <dbg> bt_driver: get_rx: type 0x04, evt 0x0e
[00:01:18.454,000] <dbg> bt_driver: read_payload: Allocated rx.buf 0x2403aa90
[00:01:18.462,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 3
[00:01:18.469,000] <dbg> bt_driver: read_payload: Payload (len 4): 040e0401
[00:01:18.476,000] <dbg> bt_driver: process_rx: remaining 3 discard 0 have_hdr 1 rx.buf 0x2403aa90 len 4
[00:01:18.486,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 2
[00:01:18.494,000] <dbg> bt_driver: read_payload: Payload (len 5): 040e040103
[00:01:18.501,000] <dbg> bt_driver: process_rx: remaining 2 discard 0 have_hdr 1 rx.buf 0x2403aa90 len 5
[00:01:18.511,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 1
[00:01:18.518,000] <dbg> bt_driver: read_payload: Payload (len 6): 040e0401030c
[00:01:18.526,000] <dbg> bt_driver: process_rx: remaining 1 discard 0 have_hdr 1 rx.buf 0x2403aa90 len 6
[00:01:18.536,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 0
[00:01:18.543,000] <dbg> bt_driver: read_payload: Payload (len 7): 040e0401030c00
[00:01:18.551,000] <dbg> bt_driver: read_payload: Putting buf 0x2403aa90 to rx fifo
[00:01:18.559,000] <dbg> bt_driver: rx_thread: Calling bt_recv(0x2403aa90)
[00:01:18.567,000] <dbg> bt_driver: rx_thread: rx.buf 0
[00:01:18.582,000] <dbg> bt_driver: h4_send: buf 0x24039f78 type 1 len 4

may look at over weekend

OH tried building for C33 and just fails

8000
@KurtE
Copy link
KurtE commented May 24, 2025

quick note: I also tried building: giga does build, but I have not tried running it yet.

C33 does not build - get the same errors as shown in the failing check.

@mjs513
Copy link
mjs513 commented May 24, 2025

UPDATE: seems to be failing on HCI.readLocalVersion in begin. Some debug:

Command tx ->  0x1 0x3 0xC 0x0
HCI event: E
E ncmd:   0x1
E opcode: 0xC03
E status: 0x0
0
Command tx ->  0x1 0x1 0x10 0x0
-1
Result from send command
failing on HCI readlocal
starting Bluetooth® Low Energy module failed!

first command is from HCI.begin().

from the debug monitor:


[00:00:10.069,000] <inf> usb_cdc_acm: Device suspended
[00:00:10.289,000] <inf> usb_cdc_acm: Device configured
[00:00:15.089,000] <dbg> bt_driver: h4_open:
[00:00:15.094,000] <dbg> bt_driver: rx_thread: started
[00:00:15.099,000] <dbg> bt_driver: rx_thread: rx.buf 0
[00:00:15.105,000] <inf> bt_hci_raw: Lower HCI transport: H:4
[00:00:15.111,000] <inf> bt_hci_raw: Bluetooth enabled in RAW mode
[00:00:16.268,000] <dbg> bt_driver: h4_send: buf 0x24039f78 type 1 len 4
[00:00:16.276,000] <dbg> bt_driver: process_rx: remaining 0 discard 0 have_hdr 0 rx.buf 0 len 0
[00:00:16.285,000] <dbg> bt_driver: process_rx: remaining 2 discard 0 have_hdr 0 rx.buf 0 len 0
[00:00:16.294,000] <dbg> bt_driver: process_rx: remaining 1 discard 0 have_hdr 0 rx.buf 0 len 0
[00:00:16.303,000] <dbg> bt_driver: get_evt_hdr: Got event header. Payload 4 bytes
[00:00:16.311,000] <dbg> bt_driver: process_rx: remaining 4 discard 0 have_hdr 1 rx.buf 0 len 0
[00:00:16.320,000] <dbg> bt_driver: get_rx: type 0x04, evt 0x0e
[00:00:16.326,000] <dbg> bt_driver: read_payload: Allocated rx.buf 0x2403aa90
[00:00:16.334,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 3
[00:00:16.341,000] <dbg> bt_driver: read_payload: Payload (len 4): 040e0401
[00:00:16.348,000] <dbg> bt_driver: process_rx: remaining 3 discard 0 have_hdr 1 rx.buf 0x2403aa90 len 4
[00:00:16.358,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 2
[00:00:16.366,000] <dbg> bt_driver: read_payload: Payload (len 5): 040e040103
[00:00:16.373,000] <dbg> bt_driver: process_rx: remaining 2 discard 0 have_hdr 1 rx.buf 0x2403aa90 len 5
[00:00:16.383,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 1
[00:00:16.390,000] <dbg> bt_driver: read_payload: Payload (len 6): 040e0401030c
[00:00:16.398,000] <dbg> bt_driver: process_rx: remaining 1 discard 0 have_hdr 1 rx.buf 0x2403aa90 len 6
[00:00:16.408,000] <dbg> bt_driver: read_payload: got 1 bytes, remaining 0
[00:00:16.415,000] <dbg> bt_driver: read_payload: Payload (len 7): 040e0401030c00
[00:00:16.423,000] <dbg> bt_driver: read_payload: Putting buf 0x2403aa90 to rx fifo
[00:00:16.431,000] <dbg> bt_driver: rx_thread: Calling bt_recv(0x2403aa90)
[00:00:16.439,000] <dbg> bt_driver: rx_thread: rx.buf 0
[00:00:16.454,000] <dbg> bt_driver: h4_send: buf 0x24039f78 type 1 len 4

Oh did try to build a zephyr test sketch but received error:

In file included from D:\Users\Merli\Documents\Arduino\Giga_zephyr\zephyr_bt\zephyr_bt.ino:6:
C:\Users\Merli\AppData\Local\Arduino15\packages\arduino\hardware\zephyr\0.3.1\variants\arduino_giga_r1_stm32h747xx_m7/llext-edk/include/zephyr/include/zephyr/bluetooth/gatt.h:1021:34: error: 'CONFIG_BT_MAX_PAIRED' was not declared in this scope; did you mean 'CONFIG_BT_MAX_CONN'?
 1021 |         #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
      |                                  ^~~~~~~~~~~~~~~~~~~~
C:\Users\Merli\AppData\Local\Arduino15\packages\arduino\hardware\zephyr\0.3.1\variants\arduino_giga_r1_stm32h747xx_m7/llext-edk/include/zephyr/include/zephyr/bluetooth/gatt.h:1021:34: note: in definition of macro 'BT_GATT_CCC_MAX'
 1021 |         #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
      |                                  ^~~~~~~~~~~~~~~~~~~~
exit status 1

@KurtE
Copy link
KurtE commented May 25, 2025

@mjs513 @facchinm - Did a little more debugging on trying to get the GIGA to work.
I don't even now enough to be dangerous 😆

But what I have so far been able to deduce is: (It dosn't work ;) )

I have confirmed that your HCIVirtualTransportZephyrClass::begin is being called:
The define is defined:
#if defined(CONFIG_BT_HCI_SETUP)
It calls through to bt_h4_vnd_setup in the file h4_ifx_cyw43xxx.c

It finds that #if DT_INST_NODE_HAS_PROP(0, bt_reg_on_gpios) is true
And it does the code to turn on the bt_reg_on_gpios first going low and then going high,
which matches I think the code within the ArduinoBT for the GIGA when zephyr is not defined.

It then gets to the if:
#if CONFIG_BT_HCI_HOST
Which is NOT defined, and so it does not use any of the other properties that were read in at the start of the function:

	uint32_t default_uart_speed = DT_PROP(DT_INST_BUS(0), current_speed);
	uint32_t hci_operation_speed = DT_INST_PROP_OR(0, hci_operation_speed, default_uart_speed);
	uint32_t fw_download_speed = DT_INST_PROP_OR(0, fw_download_speed, default_uart_speed);

Which is why we get compile warning about these not being used:

/home/kurte/git/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c: In function 'bt_h4_vnd_setup':
/home/kurte/git/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:220:18: warning: unused variable 'fw_download_speed' [-Wunused-variable]
  220 |         uint32_t fw_download_speed = DT_INST_PROP_OR(0, fw_download_speed, default_uart_speed);
      |                  ^~~~~~~~~~~~~~~~~
/home/kurte/git/zephyr/drivers/bluetooth/hci/h4_ifx_cyw43xxx.c:219:18: warning: unused variable 'hci_operation_speed' [-Wunused-variable]
  219 |         uint32_t hci_operation_speed = DT_INST_PROP_OR(0, hci_operation_speed, default_uart_speed);
      |                  ^~~~~~~~~~~~~~~~~~~
/home/kurte/git/zephyr/drivers/bluet
8000
ooth/hci/h4_ifx_cyw43xxx.c:218:18: warning: unused variable 'default_uart_speed' [-Wunused-variable]
  218 |         uint32_t default_uart_speed = DT_PROP(DT_INST_BUS(0), current_speed);
      |                  ^~~~~~~~~~~~~~~~~~
**[**

You can not define CONFIG_BT_HCI_HOST in the config files:
And from looking at:
https://bridle.tiac-systems.net/doc/3.0/kconfig/CONFIG_BT_HCI_HOST.html

I believe this will not be defined as long as BT_HCI_RAW is defined
and the GIGA config file has:

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_HCI_RAW_H4=y
CONFIG_BT_HCI_RAW_H4_ENABLE=y
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_CMD_TX_SIZE=255

Not sure what to do now.... Other than leave it to those who might know what this means!

@pillo79 pillo79 force-pushed the c33_wifi branch 4 times, most recently from cb8ec0f to 9462515 Compare May 26, 2025 12:22
@mjs513
Copy link
mjs513 commented May 26, 2025

@facchinm - @pillo79 - @KurtE
Well incorporated the changes to bootstrap and PortentaC33 now builds. Doesn't help with GIGA BLE working though.

@mjs513
Copy link
mjs513 commented May 26, 2025

Just as a quick update tried this on the PortentC33 and the scan example worked:


Reseting...
Command tx ->  0x1 0x3 0xC 0x0
HCI event: E
E ncmd:   0x5
E opcode: 0xC03
E status: 0x0
0
Reading local version...
Command tx ->  0x1 0x1 0x10 0x0
HCI event: E
E ncmd:   0x5
E opcode: 0x1001
E status: 0x0
0
Result from send command
Command tx ->  0x1 0x1 0xC 0x8 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x3F
HCI event: E
E ncmd:   0x5
E opcode: 0xC01
E status: 0x0
0
Command tx ->  0x1 0x1 0x20 0x8 0xFF 0x3 0x0 0x0 0x0 0x0 0x0 0x0
HCI event: E
E ncmd:   0x5
E opcode: 0x2001
E status: 0x0
0
Command tx ->  0x1 0x2 0x20 0x0
HCI event: E
E ncmd:   0x5
E opcode: 0x2002
E status: 0x0
0
Bluetooth® Low Energy Central scan
Command tx ->  0x1 0xC 0x20 0x2 0x0 0x1
HCI event: E
E ncmd:   0x5
E opcode: 0x200C
E status: 0x0
0
Command tx ->  0x1 0xB 0x20 0x7 0x1 0x20 0x0 0x20 0x0 0x0 0x0
HCI event: E
E ncmd:   0x5
E opcode: 0x200B
E status: 0x0
0
Command tx ->  0x1 0xC 0x20 0x2 0x1 0x1
HCI event: E
E ncmd:   0x5
E opcode: 0x200C
E status: 0x0
0
HCI event: 3E
	SubEvent: 0x2
Discovered a peripheral
-----------------------
Address: c0:6d:b4:76:5b:d4
RSSI: -99


Sorry all my debug code is still in.

UPDATE:
On the off chance it was something with config differences I changed the giga to the c33 and the giga still failed in the same place.

@KurtE
Copy link
KurtE commented May 26, 2025

Quick update/Side notes:

I also verified that the C33 worked with BT on my Ubuntu machine.

As part of this, I was curious if I could update the ArduinoBLE code again to fix the issues I found a while ago when
I was working more with UNO R4. At that time was seeing if I could talk at all to XBOX controller over BLE.

First step was to get the Peripheral Explorer sketch to communicate. This Hangs and/or failswith the released code for a
couple of reasons. a) discover attributes failed. Did not handle long UUID.
More in: arduino-libraries/ArduinoBLE#276

Ported in some of the changes into the zephyr_hci branch...

It worked:

Found c8:3f:26:b3:ac:16 'Xbox Wireless Controller' 1812
Connecting ...
Connected
Discovering attributes ...
Attributes discovered

Device name: Xbox Wireless Controll
Appearance: 0x0

Service 1800    //Generic Access service
    Characteristic 2a00, properties 0x2, value 0x58626F7820576972656C65737320436F6E74726F6C6C    //Device Name
        Descriptor 2803, value 0x020300002A    //Characteristic
        Descriptor 00002a00-0000-0000-0000-000000000000, value 0x58626F7820576972656C65737320436F6E74726F6C6C
    Characteristic 2a01, properties 0x2, value 0xC403    //Appearance
        Descriptor 2803, value 0x020500012A    //Characteristic
        Descriptor 00002a01-0000-0000-0000-000000000000, value 0xC403
    Characteristic 2a04, properties 0x2, value 0x0600060000002C01    //Peripheral Preferred Connection Parameters
        Descriptor 2803, value 0x020700042A    //Characteristic
        Descriptor 00002a04-0000-0000-0000-000000000000, value 0x0600060000002C01
Service 1801    //Generic Attribute service
Service 180a    //Device Information service
    Characteristic 2a29, properties 0x2, value 0x4D6963726F736F6674    //Manufacturer Name String
        Descriptor 2803, value 0x020B00292A    //Characteristic
        Descriptor 00002a29-0000-0000-0000-000000000000, value 0x4D6963726F736F6674
    Characteristic 2a50, properties 0x2, value 0x025E04200B2305    //PnP ID
        Descriptor 2803, value 0x020D00502A    //Characteristic
        Descriptor 00002a50-0000-0000-0000-000000000000, value 0x025E04200B2305
    Characteristic 2a26, properties 0x2, value 0x352E32332E362E30    //Firmware Revision String
        Descriptor 2803, value 0x020F00262A    //Characteristic
        Descriptor 00002a26-0000-0000-0000-000000000000, value 0x352E32332E362E30
    Characteristic 2a25, properties 0x2, value 0x3033363030303332393035363234    //Serial Number String
        Descriptor 2803, value 0x021100252A    //Characteristic
        Descriptor 00002a25-0000-0000-0000-000000000000, value 0x3033363030303332393035363234
Service 180f    //Battery service
    Characteristic 2a19, properties 0x12, value 0x32    //Battery Level
        Descriptor 2803, value 0x121400192A    //Characteristic
        Descriptor 00002a19-0000-0000-0000-000000000000, value 0x32
        Descriptor 2902, value 0x0000    //Client Characteristic Configuration
Service 1812    //Human Interface Device service
    Characteristic 2a4a, properties 0x2    //HID Information
        Descriptor 2803, value 0x0218004A2A    //Characteristic
        Descriptor 00002a4a-0000-0000-0000-000000000000, value 0x
    Characteristic 2a4c, properties 0x4    //HID Control Point
        Descriptor 2803, value 0x041A004C2A    //Characteristic
        Descriptor 00002a4c-0000-0000-0000-000000000000, value 0x
    Characteristic 2a4b, properties 0x2    //Report Map
        Descriptor 2803, value 0x021C004B2A    //Characteristic
        Descriptor 00002a4b-0000-0000-0000-000000000000, value 0x
    Characteristic 2a4d, properties 0x12    //Report
        Descriptor 2803, value 0x121E004D2A    //Characteristic
        Descriptor 00002a4d-0000-0000-0000-000000000000, value 0x
        Descriptor 2902, value 0x0000    //Client Characteristic Configuration
        Descriptor 2908, value 0x0101    //Report Reference
    Characteristic 2a4d, properties 0xE    //Report
        Descriptor 2803, value 0x0E22004D2A    //Characteristic
        Descriptor 00002a4d-0000-0000-0000-000000000000, value 0x
        Descriptor 2908, value 0x0302    //Report Reference
Service 00000001-5f60-4c4f-9c83-a7953298d40d
    Characteristic 00000002-5f60-4c4f-9c83-a7953298d40d, properties 0x2
        Descriptor 2803, value 0x0226000DD4983295A7839C4F4C605F02000000    //Characteristic
        Descriptor 00000002-5f60-4c4f-9c83-a7953298d40d, value 0x
    Characteristic 00000003-5f60-4c4f-9c83-a7953298d40d, properties 0x2
        Descriptor 2803, value 0x0228000DD4983295A7839C4F4C605F03000000    //Characteristic
        Descriptor 00000003-5f60-4c4f-9c83-a7953298d40d, value 0x
    Characteristic 00000004-5f60-4c4f-9c83-a7953298d40d, properties 0x8
        Descriptor 2803, value 0x082A000DD4983295A7839C4F4C605F04000000    //Characteristic
        Descriptor 00000004-5f60-4c4f-9c83-a7953298d40d, value 0x

Disconnecting ...
Disconnected
** Press any key to scan again: <optional device name> **

Note: I also updated the Peripheral Explorer code to print out more information,
like names for the different Characteristics/properties...

If anyone is curious, about the changes into another fork/branch:
https://github.com/KurtE/ArduinoBLE/tree/zephyr_hci_xbox
Would take a little cleanup as I have debug output.

But trying to have some fun.

@mjs513
Copy link
mjs513 commented May 27, 2025

Was double checking stuff and set debug(Serial). Seems like the 1dx accepts the reset command and polls correctly but anyother HCI command fails. For read version:

rxbuf available
Available
rxbuf available
Available
rxbuf available
Available
rxbuf available
Available
HCI EVENT RX <- 040E0401030C00
HCI event: E
E ncmd:   0x1
E opcode: 0xC03
E status: 0x0
Buf empty
0
Reading local version...
HCI COMMAND TX -> 01011000
Command tx ->  0x1 0x1 0x10 0x0
Polling
Buf empty
Polling
Buf empty

And it just keeps polling without receiving and data back.

@KurtE
Copy link
KurtE commented May 27, 2025

Sorry out doing some other stuff.

Where I am getting confused on, is wondering if there is some glue missing somewhere.

That is, where is the code that processes USART interrupts and gets the callback for data available...

For example looking at the zephyr example:
\wsl.localhost\Ubuntu-24.04\home\kurte\git\zephyr\samples\bluetooth\hci_uart_async\src
There is a function:

static int hci_uart_init(void)
{
	int err;

	k_poll_signal_init(&uart_h2c_rx_sig);
	k_poll_signal_init(&uart_c2h_tx_sig);

	LOG_DBG("");

	if (!device_is_ready(hci_uart_dev)) {
		LOG_ERR("HCI UART %s is not ready", hci_uart_dev->name);
		return -EINVAL;
	}

	BUILD_ASSERT(IS_ENABLED(CONFIG_UART_ASYNC_API));
	err = uart_callback_set(hci_uart_dev, callback, NULL);

	/* Note: Asserts if CONFIG_UART_ASYNC_API is not enabled for `hci_uart_dev`. */
	__ASSERT(!err, "err %d", err);

	return 0;
}

And this function handles the events... I know there must be some where in the h4_cyw43xxx.c... code base
But I am missing where it is and who is setting it up. Probably obvious, but...

EDIT: - Found the glue...
It is in the file zephyr\drivers\bluetooth\hci\h4.c
In the function h4_open,
Which is in the device struct:

static DEVICE_API(bt_hci, h4_driver_api) = {
	.open = h4_open,
	.send = h4_send,
	.close = h4_close,
#if defined(CONFIG_BT_HCI_SETUP)
	.setup = h4_setup,
#endif
};

And from the debug log it is called very early:

[00:00:01.344,000] <inf> usb_cdc_acm: Device suspended
[00:00:01.599,000] <inf> usb_cdc_acm: Device configured
[00:00:02.022,000] <dbg> bt_driver: h4_open:
[00:00:02.028,000] <dbg> bt_driver: rx_thread: started
[00:00:02.036,000] <dbg> bt_driver: rx_thread: rx.buf 0
[00:00:02.044,000] <inf> bt_hci_raw: Lower HCI transport: H:4
[00:00:02.052,000] <inf> bt_hci_raw: Bluetooth enabled in RAW mode

@mjs513
Copy link
mjs513 commented May 29, 2025

Been trying to debug more so decided to load it up on my newer Giga (in debug mode) and it never does a reset:

�[1;32muart:~$ �[msketch
[00:00:10.048,000] �[1;33m<wrn> usb_device: USB device support already enabled�[0m
[00:00:10.048,000] �[0m<dbg> bt_driver: h4_open: �[0m
[00:00:10.048,000] �[0m<dbg> bt_driver: rx_thread: started�[0m
[00:00:10.048,000] �[0m<dbg> bt_driver: rx_thread: rx.buf 0�[0m
[00:00:10.048,000] �[0m<inf> bt_hci_raw: Lower HCI transport: H:4�[0m
[00:00:10.048,000] �[0m<inf> bt_hci_raw: Bluetooth enabled in RAW mode�[0m
Begining Zephyr...
bt_h4_vnd_setup return code: sendcommand: 0
Reseting...
c03, 0
HCI COMMAND TX -> 01030C00

and now having issues on the older giga:

[00:00:07.896,000] <inf> usb_cdc_acm: Device suspended
[00:00:08.140,000] <inf> usb_cdc_acm: Device configured
[00:00:09.001,000] <dbg> bt_driver: h4_open:
[00:00:09.005,000] <dbg> bt_driver: rx_thread: started
[00:00:09.011,000] <dbg> bt_driver: rx_thread: rx.buf 0
[00:00:09.016,000] <inf> bt_hci_raw: Lower HCI transport: H:4
[00:00:09.022,000] <inf> bt_hci_raw: Bluetooth enabled in RAW mode
sendcommand: c03, 0
[00:00:10.081,000] <dbg> bt_driver: h4_send: buf 0x24039f78 type 1 len 4
[00:00:10.089,000] <dbg> bt_driver: process_rx: remaining 0 discard 0 have_hdr 0 rx.buf 0 len 0
[00:00:10.098,000] <dbg> bt_driver: process_rx: remaining 2 discard 0 have_hdr 0 rx.buf 0 len 0
[00:00:10.107,000] <err> os: ***** BUS FAULT *****
[00:00:10.112,000] <err> os:   Precise data bus error
[00:00:10.118,000] <err> os:   BFAR Address: 0xf8602991
[00:00:10.124,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x0000a1ae  r2/a3:  0x00000102
[00:00:10.132,000] <err> os: r3/a4:  0xf8602991 r12/ip:  0x0000bb80 r14/lr:  0x080584f7
[00:00:10.141,000] <err> os:  xpsr:  0x81000000
[00:00:10.146,000] <err> os: s[ 0]:  0x2401776c  s[ 1]:  0x24017a8c  s[ 2]:  0x00002b50  s[ 3]:  0x240135eb
[00:00:10.157,000] <err> os: s[ 4]:  0x240135c5  s[ 5]:  0x2401776c  s[ 6]:  0x00000c03  s[ 7]:  0x00002b50
[00:00:10.167,000] <err> os: s[ 8]:  0x2400dc90  s[ 9]:  0x2401615d  s[10]:  0x2400dc88  s[11]:  0x24013ebb
[00:00:10.178,000] <err> os: s[12]:  0x000c0301  s[13]:  0x24015cb9  s[14]:  0xfffffffe  s[15]:  0x000c0301
[00:00:10.188,000] <err> os: fpscr:  0x08065f1c
[00:00:10.193,000] <err> os: Faulting instruction address (r15/pc): 0x24014d88
[00:00:10.201,000] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:10.209,000] <err> os: Current thread: 0x24000d40 (shell_uart)
[00:00:10.216,000] <err> os: Halting system

so have more debugging to do

@mjs513
Copy link
mjs513 commented May 30, 2025

@facchinm - @pillo79 - @KurtE
was rebaseling everything and after I pulled in your latest changes to the c33 I am now getting build errors on Kconfig

7.14-1760.5: Warning (simple_bus_reg): /soc/trng: missing or empty reg/ranges property

warning: BT_CTLR_ADV_EXT (defined at subsys/bluetooth/controller/Kconfig:739) was assigned the value
'y' but got the value 'n'. Check these unsatisfied dependencies: BT_CTLR_ADV_EXT_SUPPORT (=n),
HAS_BT_CTLR (=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_CTLR_ADV_EXT
and/or look up BT_CTLR_ADV_EXT in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.


warning: BT_CTLR_ADV_PERIODIC (defined at subsys/bluetooth/controller/Kconfig:779) was assigned the
value 'y' but got the value 'n'. Check these unsatisfied dependencies: BT_CTLR_ADV_PERIODIC_SUPPORT
(=n), BT_CTLR_ADV_EXT (=n), HAS_BT_CTLR (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_CTLR_ADV_PERIODIC and/or look up
BT_CTLR_ADV_PERIODIC in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: LOG_PROCESS_THREAD_STACK_SIZE (defined at subsys/logging/Kconfig.processing:78) was
assigned the value '8192' but got the value ''. Check these unsatisfied dependencies:
LOG_PROCESS_THREAD (=n), LOG_MODE_DEFERRED (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_PROCESS_THREAD_STACK_SIZE and/or look
up LOG_PROCESS_THREAD_STACK_SIZE in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.


warning: NET_IF_MAX_IPV6_COUNT (defined at subsys/net/ip/Kconfig.ipv6:16) was assigned the value '3'
but got the value ''. Check these unsatisfied dependencies: NET_IPV6 (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_NET_IF_MAX_IPV6_COUNT and/or look up
NET_IF_MAX_IPV6_COUNT in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: NET_MGMT_EVENT_MONITOR_STACK_SIZE (defined at subsys/net/ip/Kconfig.mgmt:108) was assigned
the value '8192' but got the value ''. Check these unsatisfied dependencies: NET_MGMT_EVENT_MONITOR
(=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_NET_MGMT_EVENT_MONITOR_STACK_SIZE
and/or look up NET_MGMT_EVENT_MONITOR_STACK_SIZE in the menuconfig/guiconfig interface. The
Application Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices
sections of the manual might be helpful too.


warning: CDC_ACM_DTE_RATE_CALLBACK_SUPPORT (defined at subsys/usb/device/class/Kconfig.cdc:55) was
assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: USB_CDC_ACM
(=n), USB_DEVICE_STACK (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT and/or
look up CDC_ACM_DTE_RATE_CALLBACK_SUPPORT in the menuconfig/guiconfig interface. The Application
Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of
the manual might be helpful too.


warning: The choice symbol NET_CORE_LOG_LEVEL_DBG (defined at
subsys/net/Kconfig.template.log_config.net:36) was selected (set =y), but no symbol ended up as the
choice selection. See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_NET_CORE_LOG_LEVEL_DBG and/or look up
NET_CORE_LOG_LEVEL_DBG in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: NANOPB (defined at modules/nanopb/Kconfig:7) has direct dependencies 0 with value n, but is currently being y-selected by the following symbols:
 - WIFI_ESP_HOSTED (defined at boards/arduino/portenta_c33/Kconfig.defconfig:14, drivers/wifi/esp_hosted/Kconfig.esp_hosted:6), with value y, direct dependencies (NETWORKING && BOARD_ARDUINO_PORTENTA_C33) || (DT_HAS_ESPRESSIF_ESP_HOSTED_ENABLED && WIFI) (value: y), and select condition DT_HAS_ESPRESSIF_ESP_HOSTED_ENABLED && WIFI (value: y)
Parsing /home/my_new_zephyr_folder/zephyr/Kconfig
Loaded configuration '/home/my_new_zephyr_folder/zephyr/boards/arduino/portenta_c33/arduino_portenta_c33_defconfig'
Merged configuration '/home/my_new_zephyr_folder/ArduinoCore-zephyr/loader/prj.conf'
Merged configuration '/home/my_new_zephyr_folder/ArduinoCore-zephyr/loader/../variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.conf'

error: Aborting due to Kconfig warnings

CMake Error at /home/my_new_zephyr_folder/zephyr/cmake/modules/kconfig.cmake:373 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  /home/my_new_zephyr_folder/zephyr/cmake/modules/zephyr_default.cmake:131 (include)
  /home/my_new_zephyr_folder/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/my_new_zephyr_folder/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
  CMakeLists.txt:13 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/home/my_new_zephyr_folder/ArduinoCore-zephyr/venv/bin/python3 -B/home/my_new_zephyr_folder/ArduinoCore-zephyr/build/arduino_portenta_c33_r7fa6m5bh3cfc -GNinja -DBOARD=arduino_portenta_c33 -S/home/my_new_zephyr_folder/ArduinoCore-zephyr/loader

Just thought you should know

@pillo79
Copy link
pillo79 commented May 30, 2025

@facchinm - @pillo79 - @KurtE was rebaseling everything and after I pulled in your latest changes to the c33 I am now getting build errors on Kconfig

warning: NANOPB (defined at modules/nanopb/Kconfig:7) has direct dependencies 0 with value n, but is currently being y-selected by the following symbols:
 - WIFI_ESP_HOSTED (defined at boards/arduino/portenta_c33/Kconfig.defconfig:14, drivers/wifi/esp_hosted/Kconfig.esp_hosted:6), with value y, direct dependencies (NETWORKING && BOARD_ARDUINO_PORTENTA_C33) || (DT_HAS_ESPRESSIF_ESP_HOSTED_ENABLED && WIFI) (value: y), and select condition DT_HAS_ESPRESSIF_ESP_HOSTED_ENABLED && WIFI (value: y)

Just thought you should know

Yes, you now need the nanopb module. This should be fixed with a new run of extra/bootstrap.sh 😉

@mjs513
Copy link
mjs513 commented May 30, 2025

@pillo79
When I said I rebaselined I mean I pulled everything fresh and reran bootstrap.sh? and did a west update as well?

EDIT
something strange going when I did git clone my bootsrap is

#!/bin/bash

if [ ! -f platform.txt ]; then
  echo Launch this script from the root core folder as ./extra/bootstrap.sh
  exit 2
fi

NEEDED_HALS=$(grep 'build.zephyr_hals=' boards.txt | cut -d '=' -f 2 | xargs -n 1 echo | sort -u)

HAL_FILTER="-hal_.*"
for hal in $NEEDED_HALS; do
  HAL_FILTER="$HAL_FILTER,+$hal"
done

python3 -m venv venv
source venv/bin/activate
pip install west protobuf grpcio-tools
west init -l .
west config manifest.project-filter -- "$HAL_FILTER"
west update "$@"
west zephyr-export
pip install -r ../zephyr/scripts/requirements-base.txt
west sdk install --version 0.17.0 -t arm-zephyr-eabi
west blobs fetch $NEEDED_HALS

which is different than whats in core if I look at github

#!/bin/bash

if [ ! -f platform.txt ]; then
  echo Launch this script from the root core folder as ./extra/bootstrap.sh
  exit 2
fi

NEEDED_HALS=$(grep 'build.zephyr_hals=' boards.txt | cut -d '=' -f 2 | xargs -n 1 echo | sort -u)

HAL_FILTER="-hal_.*"
for hal in $NEEDED_HALS; do
  HAL_FILTER="$HAL_FILTER,+$hal"
done

python3 -m venv venv
source venv/bin/activate
pip install west
west init -l .
west config manifest.project-filter -- "$HAL_FILTER"
west update "$@"
west zephyr-export
pip install -r ../zephyr/scripts/requirements-base.txt
west sdk install --version 0.17.0 -t arm-zephyr-eabi

for hal in $NEEDED_HALS; do
	west blobs fetch $hal
done

Very strange

EDIT2: actually not strange - this PR changed it to what I shows where it added protobuf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0