bug found in mbed feature-nrf52-sdk15

02 May 2019

Hi, I think I found a bug in the Nordic SDK15 feature branch of mbed.

I am using commit dbd38798f04d427ee63efed2a69c2ae06cb7379c.

when using serial->readable() in Interrupt context ( for example in a function attached to the Serial) mbed crashes with follwoing report:

++ Error Info ++ Error Status: 0x80010133 Code: 307 Module: 1

Error Message: Mutex: 0x200103F4, Not allowed in ISR context

Location: 0x3AC4F

Error Value: 0x200103F4

Current Thread: Id: 0x20007C8C Entry: 0x3AB51 StackSize: 0x200 StackMem: 0x20007FD0 SP: 0x2003FEB0

Error Info

++ Error Info ++ Error Status: 0x80010133 Code: 307 Module: 1

Error Message: Mutex: 0x2000B4BC, Not allowed in ISR context

Location: 0x3AC4F

Error Value: 0x2000B4BC

Current Thread: Id: 0x20007C8C Entry: 0x3AB51 StackSize: 0x200 StackMem: 0x20007FD0 SP: 0x2003FD30

Error Info

++ Error Info ++ Error Status: 0x80010134 Code: 308 Module: 1

Error Message: Semaphore: 0x80FF010F, Unknown

Location: 0x3AC71

Error Value: 0x80FF010F

Current Thread: Id: 0x20007C8C Entry: 0x3AB51 StackSize: 0x200 StackMem: 0x20007FD0 SP: 0x2003FD20

Error Info

Error decoder doesnt even know this code. its 100% reproducable, and didnt happen in the official release with the same code.

15 Jul 2019

Hi Jonas,

Since there is a known limitation, we will recommend you to use RawSerial instead of Serial, a more detailed explanation can be found here.

https://github.com/ARMmbed/mbed-os/issues/8518#issuecomment-442358692

A simple working example for your reference.

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);

RawSerial pc(USBTX, USBRX);

void callback_ex() {
    // Note: you need to actually read from the serial to clear the RX interrupt
    if (pc.readable()) {
        pc.putc(pc.getc());
    }
    led2 = !led2;
}

int main() {
    pc.attach(&callback_ex);

    while (1) {
        led1 = !led1;
        wait(0.5);
    }
}

You need to log in to post a reply