Mbed-os: UARTSerial output does not work with REALTEK_RTL8195AM

Created on 14 Mar 2018  路  6Comments  路  Source: ARMmbed/mbed-os

Description

  • Type: Bug
  • Target: REALTEK_RTL8195AM

Following example should work on all platforms, but crashes on REALTEK_RTL8195AM.

#include "mbed.h"

int main() {
    UARTSerial *serial = new UARTSerial(USBTX, USBRX);
    serial->set_baud(115200);

    FILE *out = fdopen(serial, "w");
    FILE *in = fdopen(serial, "r");

    fprintf(out, "Started!\r\n");

    while (true) {
        int c = fgetc(in);
        if (c != EOF) {
            fprintf(out, "Input: %c\r\n", c);
        } else {
            return 0;
        }
    }
}


This, however works:

#include "mbed.h"

int main() {
    UARTSerial *serial = new UARTSerial(USBTX, USBRX);
    serial->set_baud(115200);

    //FILE *out = fdopen(serial, "w");
    FILE *in = fdopen(serial, "r");

    printf("Started!\r\n");

    while (true) {
        int c = fgetc(in);
        if (c != EOF) {
            printf("Input: %c\r\n", c);
        } else {
            return 0;
        }
    }
}

Problem seems to be in the TX interrupt of the serial port.
Following code is able to crash the device using RawSerial:

#include "mbed.h"

int c = 0;
RawSerial *serial;

void tx_avail(void)
{
    while (serial->writeable())
        serial->putc((c++ % 95) + ' ');
}

int main() {
    serial = new RawSerial(USBTX, USBRX, 115200);

    core_util_critical_section_enter();
    serial->attach(tx_avail, SerialBase::TxIrq);
    tx_avail();
    core_util_critical_section_exit();

}
realtek bug

Most helpful comment

I can confirm that the fix is working.

To verify, follow the previous post on how to create an example application, then:

cd mbed-os
git fetch origin pull/6415/head:PR_6415
git checkout PR_6415
cd ..
mbed compile

And now the example code starts to work.

All 6 comments

Output in Realtek is always only 4 characters. Then it crashes.

@ARMmbed/team-realtek please review

Hi, @SeppoTakalo
I have used the latest Mbed-os to test with your first code example. There is no crashes on my side. Could you please double check and give more details on your first crash issue?

Hi,
I have uploaded a fix for LogUart Tx interrupt crash.
Please refer to #6415 .

To replicate the issue:

mbed new serial-test
cd serial-test
cd mbed-os
git checkout master
cd ..

Now create main.cpp based on the last example I posted earlier.

mbed target REALTEK_RTL8195AM
mbed toolchain GCC_ARM
mbed compile

I can confirm that the fix is working.

To verify, follow the previous post on how to create an example application, then:

cd mbed-os
git fetch origin pull/6415/head:PR_6415
git checkout PR_6415
cd ..
mbed compile

And now the example code starts to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bcostm picture bcostm  路  4Comments

1domen1 picture 1domen1  路  3Comments

cesarvandevelde picture cesarvandevelde  路  4Comments

pilotak picture pilotak  路  3Comments

davidantaki picture davidantaki  路  3Comments