basj
Posts: 14
Joined: Tue Mar 03, 2015 1:37 pm

UART problem when data is already arriving during boot

Tue May 16, 2017 9:21 pm

Hi,
I'm using UART Rx since years, because of the project I started : http://www.samplerbox.org, to add a MIDI IN to the RaspberryPi. I wrote this guide 2 years ago. The new method:

Code: Select all

enable_uart=1
dtoverlay=pi3-miniuart-bt
dtoverlay=midi-uart0
works great :), far better than the old hack with init_uart_clock=2441406.

But I noticed a UART bug in the new version:

* When RPi boots, and receives no serial MIDI data during boot time, everything works, the MIDI arrives correctly

* When RPi boots, and receives serial MIDI during boot time (for example because RPi is connected to a drummachine already ON, already spitting MIDI sync messages to RPi), it doesn't work : further use of MIDI won't work.

Any idea?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1312
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: UART problem when data is already arriving during boot

Thu May 25, 2017 4:37 pm

I think uart0 (ttyAMA0) has a problem when the line isn't idle and it is started - it loses synchronisation. ttyS0 doesn't seem to have the same problem, but there isn't a midi-uart1 overlay for it, so I'm working on one.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1312
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: UART problem when data is already arriving during boot

Fri May 26, 2017 10:49 am

I've found a problem in the kernel that stops my midi-uart1 overlay from working, but a kludgy hack gets 31.25KHz from ttyS0. I'll have to ask the maintainers upstream how to fix it properly.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1312
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: UART problem when data is already arriving during boot

Thu Jun 01, 2017 10:03 am

Talking to some of the upstream folks has made two things clear:
1. They don't know how to fix the problem preventing my overlay from working.
2. This is the wrong solution to the MIDI baud rate issue.

They suggested using other means to set the baud rate - the termios API does permit random baud rates if you set the right flag, but stty doesn't expose that ability. Instead they suggested using "anybaud" - the source is here. Download it, compile with "gcc -o anybaud anybaud.c" then run with "anybaud /dev/ttyS0 31250" (after first removing the pi3-miniuart-bt overlay).

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1312
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: UART problem when data is already arriving during boot

Tue Jun 06, 2017 12:02 pm

With the help of one of the Linux maintainers I've got a working midi-uart1 overlay. It's in the rpi-4.9.y tree and will be in the next firmware release.

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 3 guests