summaryrefslogtreecommitdiff
path: root/samples/bluetooth
diff options
context:
space:
mode:
authorCarles Cufi <carles.cufi@nordicsemi.no>2016-10-31 11:39:12 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2016-11-11 07:59:15 +0200
commitf7d313b1544c4940a962e593d2549c52b901f824 (patch)
treed1404c33b01d3a4992ced3ea0828530b293b9302 /samples/bluetooth
parent3fc4fd53f6f3265003b00049ab67db9d9316d9a6 (diff)
Bluetooth: Controller: Add ASSERT info dump on HCI builds
When building Zephyr in the controller-only configuration, assertions that happen in the Link Layer code are not visible to the Host which is running on another HCI and connected via UART or USB to it. This patch allows the Controller code to output the assertion line number when in such a configuration, allowing the Host to view the event to help debugging. The event format used is temporary and will be replaced by a standardized Vendor Specific specification to come at a later time. Change-Id: I013ca6783a3fdedc47b171132919dd4798c66285 Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Diffstat (limited to 'samples/bluetooth')
-rw-r--r--samples/bluetooth/hci_uart/nrf5.conf1
-rw-r--r--samples/bluetooth/hci_uart/src/main.c44
2 files changed, 45 insertions, 0 deletions
diff --git a/samples/bluetooth/hci_uart/nrf5.conf b/samples/bluetooth/hci_uart/nrf5.conf
index 07c08d1f8..c51441adc 100644
--- a/samples/bluetooth/hci_uart/nrf5.conf
+++ b/samples/bluetooth/hci_uart/nrf5.conf
@@ -11,3 +11,4 @@ CONFIG_BLUETOOTH_CONTROLLER_RX_BUFFERS=4
CONFIG_BLUETOOTH_CONTROLLER_TX_BUFFERS=4
CONFIG_UART_NRF5_BAUD_RATE=1000000
CONFIG_UART_NRF5_FLOW_CONTROL=y
+CONFIG_BLUETOOTH_CONTROLLER_ASSERT_HANDLER=y
diff --git a/samples/bluetooth/hci_uart/src/main.c b/samples/bluetooth/hci_uart/src/main.c
index b103f0598..e534930a4 100644
--- a/samples/bluetooth/hci_uart/src/main.c
+++ b/samples/bluetooth/hci_uart/src/main.c
@@ -277,6 +277,50 @@ static int h4_send(struct net_buf *buf)
return 0;
}
+void bt_controller_assert_handle(char *file, uint32_t line)
+{
+ uint32_t len = 0, pos = 0;
+
+ /* Disable interrupts, this is unrecoverable */
+ (void)irq_lock();
+
+ uart_irq_rx_disable(hci_uart_dev);
+ uart_irq_tx_disable(hci_uart_dev);
+
+ if (file) {
+ while (file[len] != '\0') {
+ if (file[len] == '/') {
+ pos = len + 1;
+ }
+ len++;
+ }
+ file += pos;
+ len -= pos;
+ }
+
+ uart_poll_out(hci_uart_dev, H4_EVT);
+ /* Vendor-Specific debug event */
+ uart_poll_out(hci_uart_dev, 0xff);
+ /* 0xAA + strlen + \0 + 32-bit line number */
+ uart_poll_out(hci_uart_dev, 1 + len + 1 + 4);
+ uart_poll_out(hci_uart_dev, 0xAA);
+
+ if (len) {
+ while (*file != '\0') {
+ uart_poll_out(hci_uart_dev, *file);
+ file++;
+ }
+ uart_poll_out(hci_uart_dev, 0x00);
+ }
+
+ uart_poll_out(hci_uart_dev, line >> 0 & 0xff);
+ uart_poll_out(hci_uart_dev, line >> 8 & 0xff);
+ uart_poll_out(hci_uart_dev, line >> 16 & 0xff);
+ uart_poll_out(hci_uart_dev, line >> 24 & 0xff);
+
+ while (1) {
+ };
+}
static int hci_uart_init(struct device *unused)
{