Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jimmo
Copy link
Owner

@jimmo jimmo commented Sep 7, 2020

No description provided.

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:".
@dpgeorge
Copy link

dpgeorge commented Sep 7, 2020

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)
Copy link

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
Copy link

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?

// hci_dump_open(NULL, HCI_DUMP_STDOUT);

#if MICROPY_BLUETOOTH_BTSTACK_USB
void mp_bluetooth_btstack_port_init_usb(void);
Copy link

@dpgeorge dpgeorge Sep 7, 2020

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

// hci_dump_open(NULL, HCI_DUMP_STDOUT);

#if MICROPY_BLUETOOTH_BTSTACK_H4
void mp_bluetooth_btstack_port_init_h4(void);
Copy link

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
Copy link

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

@dpgeorge
Copy link

dpgeorge commented Sep 7, 2020

remove MP_WEAK in extmod/nimble/modbluetooth_nimble.c

@dpgeorge
Copy link

dpgeorge commented Sep 7, 2020

rename mphci* to mpbthci*, and possibly remove extmod/mphciport.c

jimmo and others added 15 commits September 7, 2020 14:47
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.
@jimmo jimmo force-pushed the extmod-bluetooth-addr-mode-unix-h4-reliability branch from 0cd99ee to 010ef44 Compare September 7, 2020 05:00
@dpgeorge
Copy link

dpgeorge commented Sep 8, 2020

This can be closed.

jimmo pushed a commit that referenced this pull request Jun 22, 2021
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]>
@jimmo jimmo force-pushed the master branch 2 times, most recently from 797ec80 to e3c880a Compare May 13, 2022 06:06
@jimmo jimmo force-pushed the master branch 4 times, most recently from 706be67 to 7ea217c Compare February 24, 2023 06:18
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.

3 participants