{"id":138,"date":"2012-06-16T15:13:33","date_gmt":"2012-06-16T20:13:33","guid":{"rendered":"http:\/\/fw.hardijzer.nl\/?p=138"},"modified":"2012-06-16T15:13:42","modified_gmt":"2012-06-16T20:13:42","slug":"getting-my-raspberry-pi-set-up-for-high-speed-serial-uart-communication","status":"publish","type":"post","link":"https:\/\/fw.hardijzer.nl\/?p=138","title":{"rendered":"Getting my Raspberry Pi set up for high-speed serial UART communication"},"content":{"rendered":"<p>I bought a Raspberry Pi to work together with my rooms moodlight. The current system uses an FTDI USB to RS485 converter cable with a full-blown linux PC pushing 1Mbps of data over that to drive the animations. I intended to replace that system with a Raspberry, seeing as it already has a UART on-board and would only need a small RS485 chip to drive the bus.<br \/>\nUnfortunately, out of the box the Raspberrys UART can only push 115200baud, and it spits out a shitload of debug data on the serial lines.<br \/>\nHere&#8217;s what I did to allow it to use the UART for other things, and to drive the UART at 1Mbps \ud83d\ude42<\/p>\n<p>The limiting factor on the UART speed is that UART Clock. It only allows baudrates of UART_CLK\/16, and the clock is set to 3Mhz by default, limiting it to 187500baud. To drive 1Mbps, we need a UART-clock of at least 16Mhz. To do this we need to:<\/p>\n<ul>\n<li>Set configuration parameters in \/boot\/config.txt<br \/>\ninit_uart_clock=16000000<\/li>\n<li>Update \/boot\/start.elf to the \u00a0<a href=\"https:\/\/github.com\/raspberrypi\/firmware\/tree\/master\/boot\">latest version<\/a>. (The version shipped with Debian doesn&#8217;t support the init_uart_clock option)<\/li>\n<li>Compile a kernel that is aware of the new uart_clock.<br \/>\nSources: <a href=\"https:\/\/github.com\/raspberrypi\/linux\/\">https:\/\/github.com\/raspberrypi\/linux\/<\/a><br \/>\nLine that needs changing: <a href=\"https:\/\/github.com\/raspberrypi\/linux\/blob\/rpi-patches\/arch\/arm\/mach-bcm2708\/bcm2708.c#L184\">https:\/\/github.com\/raspberrypi\/linux\/blob\/rpi-patches\/arch\/arm\/mach-bcm2708\/bcm2708.c#L184<\/a><br \/>\nRecompiling: <a href=\"http:\/\/elinux.org\/Rpi_kernel_compilation\">http:\/\/elinux.org\/Rpi_kernel_compilation<\/a><\/li>\n<\/ul>\n<p>This should then allow you to set the baudrate higher, to test run &#8216;sudo stty -F \/dev\/ttyAMA0 1000000&#8217;. If that runs without problems, it&#8217;s probably OK. You can test some more with &#8216;sudo bash&#8217;, and then &#8216;echo\u00a0\u00a0BOO &gt; \/dev\/ttyAMA0&#8217; and see if an attached FTDI device picks it up at 1Mbps.<\/p>\n<p>Next up is making sure nothing else is using the serial line.<\/p>\n<ul>\n<li>Edit \/boot\/cmdline.txt and remove all options mentioning ttyAMA0.<\/li>\n<li>Edit \/etc\/inittab and comment out any lines mentioning ttyAMA0, especially the getty one. (source:\u00a0<a href=\"http:\/\/baldwisdom.com\/preparing-for-a-la-mode-raspberry-pi-and-arduino\/\">http:\/\/baldwisdom.com\/preparing-for-a-la-mode-raspberry-pi-and-arduino\/<\/a>)<\/li>\n<\/ul>\n<p>Done! Now all that&#8217;s left is writing code to actually push something over that line and wire up a small rs485 chip \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I bought a Raspberry Pi to work together with my rooms moodlight. The current system uses an FTDI USB to RS485 converter cable with a full-blown linux PC pushing 1Mbps of data over that to drive the animations. I intended to replace that system with a Raspberry, seeing as it already has a UART on-board &hellip; <a href=\"https:\/\/fw.hardijzer.nl\/?p=138\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Getting my Raspberry Pi set up for high-speed serial UART communication<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-138","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts\/138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=138"}],"version-history":[{"count":3,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions\/141"}],"wp:attachment":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}