Skip to content

NRF52 getting stuck using serial port #7415

@tanoc

Description

@tanoc

Description

After the merge of pull request #7323, trying to use the serial port before and after the BLE initialization causes the program to freeze.

The following code is working correctly in d3641fd, but hangs on the second printf (the one in bleInitComplete) in faa31de

#include <mbed.h>
#include "ble/BLE.h"

static EventQueue eventQueue(4 * EVENTS_EVENT_SIZE);
void onBleInitError(BLE& ble, ble_error_t error) {}

void bleInitComplete(BLE::InitializationCompleteCallbackContext* params) {
  BLE& ble = params->ble;
  ble_error_t error = params->error;

  MBED_ASSERT(error == BLE_ERROR_NONE);
  MBED_ASSERT(ble.getInstanceID() == BLE::DEFAULT_INSTANCE);

  printf("Init complete\r\n");
}

void scheduleBleEventsProcessing(
    BLE::OnEventsToProcessCallbackContext* context) {
  BLE& ble = BLE::Instance();
  eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
}

int main() {
  printf("Begin\r\n");
  BLE& ble = BLE::Instance();
  ble.onEventsToProcess(scheduleBleEventsProcessing);
  ble.init(bleInitComplete);

  eventQueue.dispatch_forever();

  return 0;
}

It looks like it is getting stuck in this loop waiting for tx_in_progress:

mutex = core_util_atomic_cas_u8((uint8_t *) &nordic_nrf5_uart_state[instance].tx_in_progress, &expected, desired);

The problem is not present removing the first printf in the main.

I'm using a custom board with an NRF52832, with console-uart-flow-control set to null, compiling with mbed cli using arm-gcc.

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions