-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
driver: bluetooth: Added Infineon AIROC CYW43xxx BT driver #55014
driver: bluetooth: Added Infineon AIROC CYW43xxx BT driver #55014
Conversation
8996183
to
b43af6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks pretty good! Just a few mainly style-related comments.
bool "MURATA_1YN" | ||
endchoice | ||
|
||
config CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where and how is this option used? I don't see any references to it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will push one more commit with zephyr\modules\hal_infineon\btstack-integration\CMakeLists.txt after #44211.
Zephyr\modules\hal_infineon\btstack-integration\CMakeLists.txt will use this.
So user in prj.conf should provide path to HCD blob file:
it can be relative path from Application folder:
CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB="BCM4343A1_001.002.009.0153.0000_Generic.hcd"
or absolute path:
CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB="c:/cyw43xxx_fw/BCM4343A1_001.002.009.0153.0000_Generic.hcd"
zephyr\modules\hal_infineon\btstack-integration\CMakeLists.txt will check CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB and generate c-array. See fragment of cmake below, full version i attached in post #55014 (comment):
....
....
# use user provided FIRMWARE HCD file (path must be defined in CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB)
if(CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB)
# Allowed to pass absolute path to HCD blob file, or relative path from Application folder.
if(IS_ABSOLUTE ${CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB})
set(blob_hcd_file ${CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB})
else()
set(blob_hcd_file ${APPLICATION_SOURCE_DIR}/${CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB})
endif()
endif()
# generate Bluetooth include blob from HCD binary
if(EXISTS ${blob_hcd_file})
message(INFO " generate include of blob Bluetooth file: ${blob_hcd_file}")
generate_inc_file_for_target(app ${blob_hcd_file} ${blob_gen_inc_file})
zephyr_library_sources(${CMAKE_CURRENT_SOURCE_DIR}/w_bt_firmware_controller.c)
endif()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added commits 2424db1 with Cmake where this option is used.
drivers/bluetooth/hci/cyw43xxx.c
Outdated
printk("Error %d: failed to configure bt_reg_on %s pin %d\n", | ||
err, bt_reg_on.port->name, bt_reg_on.pin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_ERR()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
drivers/bluetooth/hci/cyw43xxx.c
Outdated
printk("Error: failed to configure bt_reg_on %s pin %d\n", | ||
bt_reg_on.port->name, bt_reg_on.pin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_ERR()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
drivers/bluetooth/hci/cyw43xxx.c
Outdated
/* Allocate buffer for hci_write_ram/hci_launch_ram command. */ | ||
buf = bt_hci_cmd_create(op_code, data_length); | ||
if (buf == NULL) { | ||
printk("Unable to allocate command buffer\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_ERR()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
drivers/bluetooth/hci/cyw43xxx.c
Outdated
buf = bt_hci_cmd_create(BT_HCI_VND_OP_UPDATE_BAUDRATE, | ||
HCI_VSC_UPDATE_BAUD_RATE_LENGTH); | ||
if (buf == NULL) { | ||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bad idea to mix -1
with other negative error values that actually mean something specific (POSIX error numbers), like you do when passing the error back up e.g. from bt_hci_cmd_send_sync()
. Probably something like return -ENOMEM;
would make sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
It doesn't look like you did. Did you forget to commit the change?
drivers/bluetooth/hci/cyw43xxx.c
Outdated
static int bt_hci_uart_set_baudrate(const struct device *bt_uart_dev, uint32_t baudrate) | ||
{ | ||
struct uart_config uart_cfg; | ||
int err = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary initialisation upon declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
* ensure the integrity of the firmware image sent to the bluetooth chip. | ||
*/ | ||
while (remaining_length) { | ||
size_t data_length = data[2]; /* data length from firmware image block */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest adding a debug log line in the cycle, this hangs after the first command if the firmware is incorrect, may come in handy. Up to you.
b43af6a
to
0571c58
Compare
drivers/bluetooth/hci/cyw43xxx.c
Outdated
buf = bt_hci_cmd_create(BT_HCI_VND_OP_UPDATE_BAUDRATE, | ||
HCI_VSC_UPDATE_BAUD_RATE_LENGTH); | ||
if (buf == NULL) { | ||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
It doesn't look like you did. Did you forget to commit the change?
drivers/bluetooth/hci/cyw43xxx.c
Outdated
buf = bt_hci_cmd_create(BT_HCI_VND_OP_UPDATE_BAUDRATE, | ||
HCI_VSC_UPDATE_BAUD_RATE_LENGTH); | ||
if (buf == NULL) { | ||
printk("Unable to allocate command buffer\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_ERR()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
drivers/bluetooth/hci/cyw43xxx.c
Outdated
/* Allocate buffer for hci_write_ram/hci_launch_ram command. */ | ||
buf = bt_hci_cmd_create(op_code, data_length); | ||
if (buf == NULL) { | ||
LOG_ERR("Unable to allocate command buffer\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LOG_*()
macros automatically take care of line terminators, so you should remove the \n
here
drivers/bluetooth/hci/cyw43xxx.c
Outdated
return -ENOMEM; | ||
} | ||
net_buf_unref(rsp); | ||
net_buf_unref(buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a bug. The bt_hci_cmd_send*()
functions take ownership of the buffer passed to it. If you enabled net_buf asserts you'd probably trigger them when testing this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
drivers/bluetooth/hci/cyw43xxx.c
Outdated
/* Configure bt_reg_on as output */ | ||
err = gpio_pin_configure_dt(&bt_reg_on, GPIO_OUTPUT | GPIO_PULL_UP); | ||
if (err) { | ||
LOG_ERR("Error %d: failed to configure bt_reg_on %s pin %d\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the \n
west.yml
Outdated
@@ -73,7 +73,7 @@ manifest: | |||
groups: | |||
- hal | |||
- name: hal_infineon | |||
revision: 8485083ad91d3e2cc5d706da3464716718a6a42e | |||
revision: pull/7/head |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zephyrproject-rtos/hal_infineon#7 has been merged, can you update this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done with minor documentation updates in:
- dts/bindings/bluetooth/infineon,cyw43xxx-bt-hci.yaml (added note that CYW43xxx requires fetch binary files of BT controller)
- drivers/bluetooth/hci/Kconfig.infineon (update/simplified description for modules)
- Added Cmakefiles for modules\hal_infineon\btstack-integration\, where handle generation of Bluetooth include blob from HCD binary. - Supported following device/modules: -- CYW43012/MURATA-1LV module -- CYW4343W/MURATA-1DX module -- CYW43439/MURATA-1YN module -- CYW4373/STERLING-LWB5plus module - Added possibility to use user provided BT Firmware HCD file via kconfig (path must be defined in CONFIG_CYW43XX_CUSTOM_FIRMWARE_HCD_BLOB) - Updated top makefile Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
5a2826f
0fd68f2
to
5a2826f
Compare
5a2826f
to
13a2767
Compare
drivers/bluetooth/hci/cyw43xxx.c
Outdated
void *data_buf = net_buf_add(buf, data_length); | ||
|
||
(void)memcpy(data_buf, (void *)&data[3], data_length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
net_buf_add_mem(buf, &data[3], data_length);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added initial version of Infineon cyw43xxx BT ( H4 HCI extension drivers/bluetooth/hci/CMakeLists.txt) Add initial version of binding file for Infineon CYW43xx BT HCI extension driver. Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Enable BLE features for CY8CPROTO-062-4343W board. Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
13a2767
to
6828284
Compare
Added initial version of BT driver ( H4 HCI extension) for support Infineon AIROC CYW43xx devices.
dependency:
cc: @ifyall