8000 stm32/rfcore: Intercept addr-resolution HCI cmd to work around BLE bug. · micropython/micropython@2668337 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2668337

Browse files
committed
stm32/rfcore: Intercept addr-resolution HCI cmd to work around BLE bug.
The STM32WB has a problem when address resolution is enabled: under certain conditions the MCU can get into a state where it draws an additional 10mA or so and eventually ends up with a broken BLE RX path in the silicon. A simple way to reproduce this is to enable address resolution (which is the default for NimBLE) and start the device advertising. If there is enough BLE activity in the vicinity then the device will at some point enter the bad state and, if left long enough, will have permanent BLE RX damage. STMicroelectronics are aware of this issue. The only known workaround at this stage is to not enable address resolution, which is implemented by this commit. Work done in collaboration with Jim Mussared aka @jimmo. Signed-off-by: Damien George <damien@micropython.org>
1 parent dd62c52 commit 2668337

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ports/stm32/rfcore.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,24 @@ void rfcore_ble_hci_cmd(size_t len, const uint8_t *src) {
610610
tl_list_node_t *n;
611611
uint32_t ch;
612612
if (src[0] == HCI_KIND_BT_CMD) {
613+
// The STM32WB has a problem when address resolution is enabled: under certain
614+
// conditions the MCU can get into a state where it draws an additional 10mA
615+
// or so and eventually ends up with a broken BLE RX path in the silicon. A
616+
// simple way to reproduce this is to enable address resolution (which is the
617+
// default for NimBLE) and start the device advertising. If there is enough
618+
// BLE activity in the vicinity then the device will at some point enter the
619+
// bad state and, if left long enough, will have permanent BLE RX damage.
620+
//
621+
// STMicroelectronics are aware of this issue. The only known workaround at
622+
// this stage is to not enable address resolution. We do that here by
623+
// intercepting any command that enables address resolution and convert it
624+
// into a command that disables address resolution.
625+
//
626+
// OGF=0x08 OCF=0x002d HCI_LE_Set_Address_Resolution_Enable
627+
if (len == 5 && memcmp(src + 1, "\x2d\x20\x01\x01", 4) == 0) {
628+
src = (const uint8_t *)"\x01\x2d\x20\x01\x00";
629+
}
630+
613631
n = (tl_list_node_t *)&ipcc_membuf_ble_cmd_buf[0];
614632
ch = IPCC_CH_BLE;
615633
} else if (src[0] == HCI_KIND_BT_ACL) {

0 commit comments

Comments
 (0)
0