SiliconLabs / arduino

Arduino Core for Silicon Labs devices
74 stars 15 forks source link

[bug] Serial interface locks up on Arduino Nano Matter on Mac #73

Open technoblogy opened 1 month ago

technoblogy commented 1 month ago

Hardware

Arduino Nano Matter

Core version

2.0.0

Arduino IDE version

2.3.2

Operating system

macOS Catalina 10.15.7

Radio stack variant

Matter

OpenThread Border Router device (if using Matter)

N/A

Issue description

In some situations the Serial interface locks up on the Arduino Nano Matter, making further serial communication impossible until the board is reset.

I can demonstrate this in two different situations. These may have the same cause, or there may be two different problems:

Entering text into the Serial Monitor causes the Serial to hang up after about 384 characters.

Run the following sketch:

void setup() {  
  Serial.begin(9600);
}

int Count = 0;

void loop (void) {
  if (Serial.available()) {
    Serial.read(); Count++;
    if (Count % 64 == 0) Serial.println(Count);
  }
}

Then cut and paste all the following text (total 512 characters) into the Serial Monitor input field, and press Return:

$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

The Serial Monitor prints:

64 128 192 256 320 384

ie it hangs up after 384 characters and doesn't reach 512.

Once it hangs up the Serial is totally unresponsive, and the only solution seems to be to reset the processor.

This test works fine on all other Arduino boards I've tested.

Entering a string of exactly 63 characters into the Serial monitor causes it to lock up.

Install this program:

void setup() { 
Serial.begin(9600);
}

void loop (void) {
if (Serial.available()) Serial.write(Serial.read());
}

Repeatedly copy and paste this string of 63 characters into the Serial Monitor, and press Return:

0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&

After the first attempt the Serial Monitor locks up and becomes unresponsive.

I have verified that the issue doesn't occur on Windows 10.

I have previously reported a similar issue on the RP2040: https://github.com/arduino/ArduinoCore-mbed/issues/193

Serial output

See above.

RTT output (if using Matter)

N/A

Minimal reproducer code

See above.

leonardocavagnis commented 1 month ago

Dear @technoblogy, thanks for report! Do you encounter the same issue when using an external serial terminal (as screen, CoolTerm, ...)?

technoblogy commented 1 month ago

I've tested it with screen, and same result:

Screen Shot 2024-07-15 at 09 55 06
leonardocavagnis commented 1 month ago

I tested on my macOS Sonoma 14.5 and I encountered the same issue. Unlike you, it hangs up after the first 64 chars. After many attempts, I found out that issue occurs only if you send exactly 64 chars or a multiple of it (128, 192, ...) and only on macOS.

Thanks for check it and for your detailed report! I'm working on resolving it.

technoblogy commented 1 month ago

@leonardocavagnis any news about this?

I'd be happy to test a preliminary fix when you have one available.

leonardocavagnis commented 1 month ago

@technoblogy Unfortunately, it seems a bug of MacOS system. I'm investigating on it, I will be back to you if I find out something.

technoblogy commented 1 month ago

Unfortunately, it seems a bug of MacOS system.

I don't see how that can be possible. I've tested my application with a variety of other boards on MacOS and the problem doesn't occur with any of them. For examples of the boards that work see:

uLisp - Performance

technoblogy commented 3 weeks ago

@leonardocavagnis Any success with solving this? I'd love to make my Lisp system, uLisp, available on the Arduino Nano Matter, and this is the only remaining issue I need to resolve.