Exception on read LPUART

On my STM32WLE5 target, when I try to read a byte from lpuart into a null pointer, I get an exception. If I do the same on uart2, it works fine without an exception. If I pass a pointer to a char to the read function, it also works.

So the combination of lpuart with a read into a null pointer fails.

I’ve also noticed it only fails after the first write.

#include "mbed.h"
// UnbufferedSerial loop(PA_2, PA_3); // uart2
UnbufferedSerial loop(PC_1, PC_0); // lpuart

DigitalOut led(PB_0);

int main()
{
    while (true) {
        printf("processing\n");
        led = !led;

        loop.write("test", 4); // do not send NUL at end of c string

        while(loop.readable()) {
            // char c;
            // loop.read(&c, 1); // no exception
            loop.read(NULL, 1); // exception
        }

        ThisThread::sleep_for(10s);
    }
}
[11:15:35:922] processing␍␊
[11:15:35:922] ␍␊
[11:15:35:922] ++ MbedOS Fault Handler ++␍␊
[11:15:35:922] ␍␊
[11:15:35:922] FaultType: HardFault␍␊
[11:15:35:922] ␍␊
[11:15:35:922] Context:␍␊
[11:15:35:922] R   0: 00000074␍␊
[11:15:35:922] R   1: 08009DC4␍␊
[11:15:35:922] R   2: 000000FF␍␊
[11:15:35:922] R   3: 00000008␍␊
[11:15:35:922] R   4: 2000172C␍␊
[11:15:35:922] R   5: 00000000␍␊
[11:15:35:922] R   6: 2000172C␍␊
[11:15:35:922] R   7: 000003E8␍␊
[11:15:35:922] R   8: 080065A8␍␊
[11:15:35:922] R   9: 080065B4␍␊
[11:15:35:922] R  10: 00000000␍␊
[11:15:35:922] R  11: 00000000␍␊
[11:15:35:922] R  12: 08009395␍␊
[11:15:35:922] SP   : 200014D8␍␊
[11:15:35:922] LR   : 08008853␍␊
[11:15:35:922] PC   : 08004202␍␊
[11:15:35:922] xPSR : 01000000␍␊
[11:15:35:922] PSP  : 200014B8␍␊
[11:15:35:922] MSP  : 2000FFD0␍␊
[11:15:35:922] CPUID: 410FC241␍␊
[11:15:35:922] HFSR : 40000000␍␊
[11:15:35:922] MMFSR: 00000082␍␊
[11:15:35:922] BFSR : 00000000␍␊
[11:15:35:922] UFSR : 00000000␍␊
[11:15:35:922] DFSR : 00000000␍␊
[11:15:35:975] AFSR : 00000000␍␊
[11:15:35:975] MMFAR: 00000000␍␊
[11:15:35:975] Mode : Thread␍␊
[11:15:35:975] Priv : Privileged␍␊
[11:15:35:975] Stack: PSP␍␊
[11:15:35:975] ␍␊
[11:15:35:975] -- MbedOS Fault Handler --␍␊
[11:15:35:975] ␍␊
[11:15:35:975] ␍␊
[11:15:35:975] ␍␊
[11:15:35:975] ++ MbedOS Error Info ++␍␊
[11:15:35:975] Error Status: 0x80FF013D Code: 317 Module: 255␍␊
[11:15:35:975] Error Message: Fault exception␍␊
[11:15:35:975] Location: 0x8004202␍␊
[11:15:35:975] Error Value: 0x20001820␍␊
[11:15:35:975] Current Thread: main Id: 0x20001BC4 Entry: 0x8007061 StackSize: 0x1000 StackMem: 0x200004F8 SP: 0x200014D8 ␍␊
[11:15:35:975] For more info, visit: https://mbed.com/s/error?error=0x80FF013D&tgt=LORA_E5␍␊
[11:15:35:975] -- MbedOS Error Info --␍␊