Skip to content

ports/rp2: Bluetooth HCI fixes. #11234

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

Merged
merged 5 commits into from
Sep 15, 2023
Merged

Conversation

iabdalkader
Copy link
Contributor

No description provided.

@dpgeorge
Copy link
Member

This will conflict with #10739.

@iabdalkader
Copy link
Contributor Author

This will conflict with #10739.

Why would it ? Seems unrelated

@iabdalkader
Copy link
Contributor Author

Ah I see the cancel_alarm fix is there too! However I think it's documented better here, plus the switch to static node, I can rebase though if that PR is merged first.

@iabdalkader
Copy link
Contributor Author

iabdalkader commented Apr 11, 2023

@dpgeorge Note I found a maybe minor issue with the HCI UART config, the baudrate was set as a positional arg, when it actually should be a keyword arg. Also related note both port and baudrate were never used, which is fine, but doesn't allow HCI drivers to change baudrate to higher one (i.e secondary baudrate). I fixed those issues and forced pushed, still doing some tests with the help of @robert-hh, you can merge the other PR first and I'll rebase.

EDIT: Actually might be easier to just implement mp_bluetooth_hci_uart_set_baudrate

@iabdalkader iabdalkader force-pushed the rp2_bt_fixes branch 2 times, most recently from 451e660 to 7d2a238 Compare April 12, 2023 16:55
@iabdalkader iabdalkader force-pushed the rp2_bt_fixes branch 2 times, most recently from bd98355 to 15c4531 Compare June 1, 2023 06:56
@iabdalkader iabdalkader marked this pull request as ready for review June 1, 2023 06:56
@iabdalkader
Copy link
Contributor Author

@dpgeorge @robert-hh Can we get these fixes merged especially the critical mpbthciport timer fix ? The other PR seems stalled and I would like to rebase some other work on those fixes.

@robert-hh
Copy link
Contributor

@iabdalkader What can I do in this respect? I can re-run the tests. The code changes are well known to me and look fine. Did the test coverage increase with these changes?

@iabdalkader
Copy link
Contributor Author

The code changes are well known to me and look fine. Did the test coverage increase with these changes?

I didn't do any more testing since last time, will revisit after this is merged. Just wanted to let you know these fixes are still pending here since you're adding WiFi/BT for another port, might want to rebase on this.

@robert-hh
Copy link
Contributor

robert-hh commented Jun 1, 2023

Two notes:

  • There is the PR number 2 to the mynewt-nimble lib, which prevents lock-up of the nimble stack in certain rare conditions.
  • For using the nina_bt_hci.c driver with samd and mimxrt boards, I had to add code at the start of nina_hci_cmd() to clear the input buffer before sending a command. That was needed since the physical connection of the NINA module to the mcu was different.

@robert-hh
Copy link
Contributor

since you're adding WiFi/BT for another port, might want to rebase on this.

Yes, this one and #10233. But I will add WiFi first. I'm still not overly happy with the BLE test coverage using the NINA module & software.

@iabdalkader
Copy link
Contributor Author

iabdalkader commented Jun 1, 2023

I'm still not overly happy with the BLE test coverage using the NINA module & software.

Yeah me neither but it seems that it's not an issue in the Nina module/driver/firmware. I have another board based on Renesas chip/port and an ESP32 module, the firmware is based on IDF 5.x and I added a nimble port, and the tests results are bad too:

18 tests performed
7 tests passed
1 tests skipped: multi_bluetooth/ble_deepsleep.py
10 tests failed: multi_bluetooth/ble_descriptor.py multi_bluetooth/ble_gap_advertise.py multi_bluetooth/ble_gap_connect.py multi_bluetooth/ble_gap_device_name.py multi_bluetooth/ble_gap_pair.py multi_bluetooth/ble_l2cap.py multi_bluetooth/ble_mtu.py multi_bluetooth/ble_mtu_peripheral.py multi_bluetooth/perf_l2cap.py multi_bluetooth/stress_log_filesystem.py

Note the firmware is an official firmware from espressif

@iabdalkader
Copy link
Contributor Author

@dpgeorge Rebased.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Fixes are:
- The baudrate argument is a keyword arg, it was passed before as a
  positional arg.
- Use the port and baudrate arguments passed from higher level code instead
  of the hard-coded port ID and baudrate, which would allow HCI drivers to
  change baudrates.
- Increase UART char timeout and RX buffer size.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Bluetooth code runs in the scheduler, so no locking/mutex is required.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Fixes are:
- Reset the module first before changing GPIO1 direction.
- Skip spurious bytes received after reset.
- Use HCI UART ID and baudrate when reinitializing UART.
- Disable all printf output which causes unit-tests to fail.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
@dpgeorge dpgeorge merged commit 5473200 into micropython:master Sep 15, 2023
@iabdalkader iabdalkader deleted the rp2_bt_fixes branch September 15, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants