-
Notifications
You must be signed in to change notification settings - Fork 4
Extmod bluetooth addr mode unix h4 reliability #2
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
base: master
Are you sure you want to change the base?
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.
Also use correct format specifier for %zu. Always prefix with "btstack:" or "nimble:".
For commit "ports/esp32: Pin MP and NimBLE to core 0. " it adds debugging to esp32, and has unrelated changes to extmod/bluetooth that should be separated out (that makes it easier to revert when needed). |
CFLAGS_MOD += -DMICROPY_BLUETOOTH_BTSTACK_USB=1 | ||
endif | ||
|
||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK_H4),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.
does this commit for H4 belong here?
endif | ||
|
||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) | ||
MICROPY_BLUETOOTH_BTSTACK_H4 ?= 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.
is this needed at all?
ports/unix/mpbtstackport_common.c
Outdated
// hci_dump_open(NULL, HCI_DUMP_STDOUT); | ||
|
||
#if MICROPY_BLUETOOTH_BTSTACK_USB | ||
void mp_bluetooth_btstack_port_init_usb(void); |
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 decl can go
ports/unix/mpbtstackport_common.c
Outdated
// hci_dump_open(NULL, HCI_DUMP_STDOUT); | ||
|
||
#if MICROPY_BLUETOOTH_BTSTACK_H4 | ||
void mp_bluetooth_btstack_port_init_h4(void); |
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 decl can go
SRC_BTSTACK += \ | ||
lib/btstack/platform/libusb/hci_transport_h2_libusb.c | ||
|
||
CFLAGS_MOD += -DMICROPY_BLUETOOTH_BTSTACK_USB=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.
this duplicates the line just below
remove |
rename |
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.
Changes `BLE.config('mac')` to return a tuple (addr_mode, addr). Adds `BLE.config(addr_mode=...)` to set the addressing mode.
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.
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.
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.
0cd99ee
to
010ef44
Compare
This can be closed. |
asan considers that memcmp(p, q, N) is permitted to access N bytes at each of p and q, even for values of p and q that have a difference earlier. Accessing additional values is frequently done in practice, reading 4 or more bytes from each input at a time for efficiency, so when completing "non_exist<TAB>" in the repl, this causes a diagnostic: ==16938==ERROR: AddressSanitizer: global-buffer-overflow on address 0x555555cd8dc8 at pc 0x7ffff726457b bp 0x7fffffffda20 sp 0x7fff READ of size 9 at 0x555555cd8dc8 thread T0 #0 0x7ffff726457a (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xb857a) #1 0x555555b0e82a in mp_repl_autocomplete ../../py/repl.c:301 #2 0x555555c89585 in readline_process_char ../../lib/mp-readline/re #3 0x555555c8ac6e in readline ../../lib/mp-readline/readline.c:513 #4 0x555555b8dcbd in do_repl /home/jepler/src/micropython/ports/uni #5 0x555555b90859 in main_ /home/jepler/src/micropython/ports/unix/ #6 0x555555b90a3a in main /home/jepler/src/micropython/ports/unix/m #7 0x7ffff619a09a in __libc_start_main ../csu/libc-start.c:308 micropython#8 0x55555595fd69 in _start (/home/jepler/src/micropython/ports/uni 0x555555cd8dc8 is located 0 bytes to the right of global variable 'import_str' defined in '../../py/repl.c:285:23' (0x555555cd8dc0) of size 8 'import_str' is ascii string 'import ' Signed-off-by: Jeff Epler <[email protected]>
797ec80
to
e3c880a
Compare
706be67
to
7ea217c
Compare
No description provided.