Serial device with Netduino3

I try to communicate with device with serial communication.
My code is:

using System.Diagnostics;
using System.Threading;
using Bauland.Pins;
using GHIElectronics.TinyCLR.Devices.SerialCommunication;
using GHIElectronics.TinyCLR.Storage.Streams;

namespace TestNetduino3Serial
{
    static class Program
    {
        private static DataReader _dataReader;
        private static DataWriter _dataWriter;
        static void Main()
        {
            var serial = SerialDevice.FromId(Netduino3.UartPort.Uart6);
            serial.BaudRate = 9600;
            _dataWriter=new DataWriter(serial.OutputStream);
            _dataReader=new DataReader(serial.InputStream);

            Thread t=new Thread(Receiver);
            t.Start();

            while (true)
            {
                Thread.Sleep(20);
            }
            // ReSharper disable once FunctionNeverReturns
        }

        private static void Receiver()
        {
            while (true)
            {
                var count=_dataReader.Load(1);
                if (count > 0)
                {
                    byte b = _dataReader.ReadByte();
                    Debug.WriteLine("Data: 0x"+b.ToString("X"));
                }
                Thread.Sleep(20);
            }
        }
    }
}

When I execute it, I have an allocation failure message:

Found debugger!

Create TS.

Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: TestNetduino3Serial (1.0.0.0)  Attaching deployed file.

   Assembly: mscorlib (0.8.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices (0.8.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Storage (0.8.0.0)  Resolving.

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'GHIElectronics.TinyCLR.VisualStudio.dll' (Managed): Loaded 'd:\Documents\Visual Studio 2017\Projects\TestNetduino3Serial\TestNetduino3Serial\bin\Debug\pe\..\GHIElectronics.TinyCLR.Storage.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'GHIElectronics.TinyCLR.VisualStudio.dll' (Managed): Loaded 'd:\Documents\Visual Studio 2017\Projects\TestNetduino3Serial\TestNetduino3Serial\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'GHIElectronics.TinyCLR.VisualStudio.dll' (Managed): Loaded 'd:\Documents\Visual Studio 2017\Projects\TestNetduino3Serial\TestNetduino3Serial\bin\Debug\pe\..\TestNetduino3Serial.exe', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Failed allocation for 122041945 blocks, 1952671120 bytes

If I try with FEZPandaIII (by changing to Usart1), I don’t have this issue. Does someone have an explanation ? a clue ? or is it a bug ??? :bug:

Ehm… To me it seems that 1952671120 bytes are too much for a tinyclr device… If compilation works fine for Fez panda, it may be a netduino porting problem bug.
This failure happens only if you use uart code in the program?

If you are going to read one byte at a time, write a message to debug for each byte, and then sleep, I suspect you might have a buffer overrun issues. If overrun not handled properly by the driver, then you might have see a memory issue.

Try running the program without the debug messages and sleeps and see what happens.

Same results and what it seems Strange is that Netduino3 has 384 kb flash while FEZPandaIII as only 256, and Netduino3 has 164 kb of ram as FEZ Panda III has only 128kb. So board that would overrun must be FEZ panda III, and not netduino 3.

Finally, I have found the reason of error: it was in netduino3 firmware. Only 4 of 8 uart have buffer declarations.

4 of 8 was my favorite STTNG character.