Skip to content

shell_print crashes the board on bt bonds and bt connections #41796

@MrOneTwo

Description

@MrOneTwo
  • board - Particle Xenon
  • Zephyr ver (using main ref in west.yml) - c51aa88
  • toolchain zephyr 0.13.2

My project is mostly (using the Just Works pairing method by not running bt_conn_auth_cb_register) the same as peripheral_hids. The problem is that:

  • I erase the flash nrfjprog -e
  • flash the board

Then I run following commands in the RTT shell:

rtt:~$ bt bonds
bt bonds
Bonded devices:
Total 0
rtt:~$ bt connections 
bt connections
Connected devices:
[00:00:19.206,909] <err> os: ***** USAGE FAULT *****
[00:00:19.206,909] <err> os:   Unaligned memory access
[00:00:19.206,909] <err> os: r0/a1:  0x00028d8f  r1/a2:  0x00001000  r2/a3:  0x00032f6f
[00:00:19.206,939] <err> os: r3/a4:  0x00028d8f r12/ip:  0x0000000a r14/lr:  0x0002626f
[00:00:19.206,939] <err> os:  xpsr:  0x21000000
[00:00:19.206,939] <err> os: Faulting instruction address (r15/pc): 0x00026076
[00:00:19.206,939] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:19.206,970] <err> os: Current thread: 0x200010a0 (shell_rtt)
[00:00:19.531,158] <err> os: Halting system

Running addr2line -e zephyr/zephyr.elf 0x00026076 puts me here /home/mc/gits/magknob-zephyr-ble/zephyr/include/sys/atomic_builtin.h:243

Assume I also paired the board with an iPhone. Then running bt bonds crashes the board also.

rtt:~$ Connected 6C:6D:7D:A0:83:C4 (random)
Security changed: 6C:6D:7D:A0:83:C4 (random) level 2
bt bonds
bt bonds
Bonded devices:
[00:00:54.425,994] <err> os: ***** USAGE FAULT *****
[00:00:54.425,994] <err> os:   Unaligned memory access
[00:00:54.425,994] <err> os: r0/a1:  0x00028d8f  r1/a2:  0x00001000  r2/a3:  0x00032f3f
[00:00:54.425,994] <err> os: r3/a4:  0x00028d8f r12/ip:  0x0000000a r14/lr:  0x0002626f
[00:00:54.426,025] <err> os:  xpsr:  0x21000000
[00:00:54.426,025] <err> os: Faulting instruction address (r15/pc): 0x00026076
[00:00:54.426,025] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:54.426,025] <err> os: Current thread: 0x200010a0 (shell_rtt)
[00:00:54.747,894] <err> os: Halting system

The address points me to /home/mc/gits/magknob-zephyr-ble/zephyr/include/sys/atomic_builtin.h:243 again.

The crash doesn't happen if I comment out the shell_print in this function (which gets run by cmd_bonds):

static void bond_info(const struct bt_bond_info *info, void *user_data)
{
    char addr[BT_ADDR_LE_STR_LEN];
    int *bond_count = user_data;

    bt_addr_le_to_str(&info->addr, addr, sizeof(addr));
    shell_print(ctx_shell, "Remote Identity: %s", addr);  // < if I comment this out, it works
    (*bond_count)++;
}

In general I can pair with iPhone for the first time (when prompted for pairing) but after disconnecting and trying to reconnect I get:

rtt:~$ Connected 78:7F:AE:13:34:85 (random)
Security failed: 78:7F:AE:13:34:85 (random) level 1 err 2
Disconnected from 78:7F:AE:13:34:85 (random) (reason 0x13)

That's for Just Works. When using setup reconnecting works fine. I need to pair without any pin though. This might be a separate issue but maybe connected...?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions