-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
extmod/modbluetooth: Addressing modes, Unix H4 UART, reliability fixes #6343
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
Conversation
This will allow the HCI UART to use a non-heap mp_irq_obj_t, which avoids needing to make a root pointer for it. Misc cleanups to mpirq.c to remove unused functionality.
Also use correct format specifier for %zu. Always prefix with "btstack:" or "nimble:".
Previously the interaction between the different parts was different on each port and each stack. This commit defines common interfaces between them and implements them for cyw43, btstack, nimble, stm32, unix.
Generally a controller should either have its own public address hardcoded, or loaded by the driver (e.g. cywbt43). However, for a controller that has no public address where you still want a long-term stable address, this allows you to use a static address generated by the port. Typically on STM32 this will be an LAA, but a board might override this.
2ms used previously was not long enough and the result is that it loses HCI sync. Also print error on tx failure to make this more obvious in the future.
ports/unix/mphciport.c
Outdated
int flags = O_RDWR | O_NOCTTY | O_NONBLOCK; | ||
uart_fd = open(uart_device_name, flags); | ||
if (uart_fd == -1) { | ||
DEBUG_printf("Unable to open port %s", uart_device_name); |
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 would be better as an exception that's then user visible - currently if the port is missing or cannot be opened it's a silent fail here and the rest of the startup just looks broken
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 -- and added the plumbing to make this work for btstack and nimble. On btstack it can detect the init failure, on nimble it now leads to an init timeout.
uart_tx_data(&mp_bluetooth_hci_uart_obj, (void *)buf, len, &errcode); | ||
if (errcode != 0) { | ||
printf("\nmp_bluetooth_hci_uart_write: failed to write to UART %d\n", errcode); | ||
} |
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.
In my branch I've changed this if to assert(errcode == 0);
My updated commit is here, it includes your comment and removes the extra comment/printf below:
andrewleech@32bf807
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 think this is too important to be a debug-only notification...
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.
Ah yeah, I forgot that asserts are disabled in non-debug builds... yep perhaps a static flag that can be checked at a higher layer will be needed, perhaps something that can then trigger a stack/hci reset.
MP and NimBLE must be on the same core (for synchronisation of the BLE ringbuf and the MP scheduler). However, in the current IDF versions (3.3 and 4.0) there are issues (e.g. micropython#6343) with running NimBLE on core 1. This change makes it possible to reliably run the BLE multitests.
4a6a5a8
to
6546f70
Compare
This allows `ble.active(1)` to fail correctly if the HCI controller is unavailable. Also avoids an infine loop in the NimBLE event handler where NimBLE doesn't correctly detect that the HCI controller is unavailable and keeps trying to reset. Also fixes an issue where GATT service registrations were left allocated, which led to a bad realloc if the stack was activated multiple times.
The following commits from this PR have been applied to master (they are minor and fix existing bugs) (the hash refers to the commit in master): |
MP and NimBLE must be on the same core (for synchronisation of the BLE ringbuf and the MP scheduler). However, in the current IDF versions (3.3 and 4.0) there are issues (e.g. micropython#6343) with running NimBLE on core 1. This change makes it possible to reliably run the BLE multitests.
MP and NimBLE must be on the same core (for synchronisation of the BLE ringbuf and the MP scheduler). However, in the current IDF versions (3.3 and 4.0) there are issues (e.g. micropython#6343) with running NimBLE on core 1. This change makes it possible to reliably run the BLE multitests.
Superseded by #6405 (with some notes there about what was not included). |
MP and NimBLE must be on the same core (for synchronisation of the BLE ringbuf and the MP schedul 5D39 er). However, in the current IDF versions (3.3 and 4.0) there are issues (e.g. micropython#6343) with running NimBLE on core 1. This change makes it possible to reliably run the BLE multitests.
MP and NimBLE must be on the same core (for synchronisation of the BLE ringbuf and the MP scheduler). However, in the current IDF versions (3.3 and 4.0) there are issues (e.g. micropython#6343) with running NimBLE on core 1. This change makes it possible to reliably run the BLE multitests.
Thanks @jimmo and @andrewleech for all the effort! |
add board.LED to Metro M4 AirLift LIte and PyRuler
Work done in collaboration with @andrewleech
This started as just an implementation of NimBLE on Unix but ended up with lots of dependent changes and bugs fixed along the way. Ideally this would have been multiple PRs but I've tried to split each part into distinct commits. Other than the binding refactor (which is unfortunately very difficult to split), each commit is quite small.
Bug fixes:
Code cleanup:
Unix port:
This allows (for example) a Zephyr HCI controller running on an nRF to be used from the Unix port.
Addressing:
This is tested using the multitests on:
More testing required on
(I'm working on those right now)
TODO: