The information about mmap() provided here works for Arch Linux kernel 4.1.13. I've not updated my kernel because I have the Cirrus/Element14 sound board and the driver comes as part of a pre-patched kernel. I currently have it running with the console UART port at 31250 baud. The "hack" uses the mmap() function to give access to the UART device registers directly which bypasses whatever they did in the kernel. Instead of changing the UART clock, the code instead leaves the UART clock at 3000000 and instead uses a clock divider of 6. This sets the bit clock at 3000000/6 or 500000 which just happens to be 16 times 31250.
I used the code posted by StuartF to first get ttymidi working at 31250. There were a couple of things missing from the code that StuartF kindly provided (all documented in this thread). And yes, once I got the code to compile, ttymidi stopped producing crap data. I used ZynAddSubFX to test it.
Currently, I've developed my own MIDI synthesizer (a 32 voice Karplus-Strong Synth) that uses the same technique to change the UART baud rate to 31250.
Unfortunately, it's not just a simple function call and your done, you have to understand what ttymidi is doing to set the UART up and modify it with the mmap() method. I would prefer not to post my ttymidi code because I don't feel I'm qualified to add to the project (which is where the code ought to be posted).
Re: RPi2 UART Baud Rate
Last edited by JovianPyx on Mon Feb 29, 2016 12:30 pm, edited 1 time in total.
Re: RPi2 UART Baud Rate
Thanks for your prompt answer JovianPyx!
I can imagine that it isn't as easy to cut/paste the code provided by StuartF in ttymidi.c and compile it to be done
...
Actually I don't know what to do with this piece of code.
Is there another way to make ttymidi working at 31250?
From what I understood in previous messages, the trick using Python script is not really working since ttymidi re-assigns baud rate when it is launched isn't it?
JBF
I can imagine that it isn't as easy to cut/paste the code provided by StuartF in ttymidi.c and compile it to be done

Actually I don't know what to do with this piece of code.
Is there another way to make ttymidi working at 31250?
From what I understood in previous messages, the trick using Python script is not really working since ttymidi re-assigns baud rate when it is launched isn't it?
JBF
Re: RPi2 UART Baud Rate
Yeah, I tried the Python code and it did not work as you say because ttymidi just over-writes the settings. Please see the PM I sent you.
Re: RPi2 UART Baud Rate
I've had same problems with my Rpi 2. Whatever settings I've put in cmdline.txt and config.txt the results have been the same. I'll test this next time I have time but if this works you're my hero!