{"id":417,"date":"2015-04-19T16:46:06","date_gmt":"2015-04-19T14:46:06","guid":{"rendered":"http:\/\/paguilar.org\/?p=417"},"modified":"2015-04-19T16:46:51","modified_gmt":"2015-04-19T14:46:51","slug":"communicating-to-a-serial-interface-of-an-embedded-linux-device-using-kermit","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=417","title":{"rendered":"Communicating to a serial interface of an embedded Linux device using kermit"},"content":{"rendered":"<p>I have used kermit for connecting to serial interfaces for several years and it has always worked as expected. Even for sending a kernel image to U-Boot using the zmodem protocol (yes, it took ages, but there was no Ethernet) has worked quite well.<\/p>\n<p>Recently, a friend that is new to embedded Linux ask me how to connect to a serial interface, so this is a small and simple guide on how to do it.<\/p>\n<p>Just as an intro, a summary of what is kermit taken from the Fedora repo:<\/p>\n<blockquote><p>C-Kermit is a combined serial and network communication software package offering a consistent, medium-independent, cross-platform approach to connection establishment, terminal sessions, file transfer and management, character-set translation, and automation of communication tasks.<\/p><\/blockquote>\n<p><strong>Installation<\/strong><br \/>\nIf you have Fedora, CentOS, SuSE or other rpm based distribution<\/p>\n<pre lang=bash>\r\nyum install ckermit\r\n<\/pre>\n<p>If you have Debian, Mint, Ubuntu or other deb based distribution<\/p>\n<pre lang=bash>\r\napt-get install ckermit\r\n<\/pre>\n<p><strong>Configuration<\/strong><br \/>\nCreate the configuration file <em>.kermrc<\/em> in your home directory. These parameters are normally right for most systems. I&#8217;ve used it for SH4 and ARM based devices:<\/p>\n<pre lang=bash>\r\nset line \/dev\/ttyUSB0\r\nset speed 115200\r\nset carrier-watch off\r\nset handshake none\r\nset flow-control none\r\nrobust\r\nset file type bin\r\nset file name lit\r\nset rec pack 1000\r\nset send pack 1000\r\nset window 5\r\nconnect\r\n<\/pre>\n<p>The most important parameters here are the <em>line<\/em> parameter that indicates the serial device and the <em>speed<\/em> parameters that is it&#8217;s baud rate. If you have an USB-to-serial interface converter your device will be <em>\/dev\/ttyUSBx<\/em> where x is normally 0, but it depends on how may USB-to-serial converters you have. The same happens if you have a normal serial cable, except that your device will be named \/dev\/ttySx, where x is normally 0.<\/p>\n<p><strong>Permissions<\/strong><br \/>\nAdd your user to the <em>dialout<\/em> group in the <em>\/etc\/group<\/em> file<\/p>\n<pre lang=bash>\r\ndialout:x:18:paguilar\r\n<\/pre>\n<p>Logout and login again. This is needed since the group to which a user belongs are assigned when the user logs in.<\/p>\n<p><strong>Execution<\/strong><br \/>\nOpen a shell and execute kermit. The output should be something like this:<\/p>\n<pre lang=bash>\r\nConnecting to \/dev\/ttyUSB0, speed 115200\r\n Escape character: Ctrl-\\ (ASCII 28, FS): enabled\r\nType the escape character followed by C to get back,\r\nor followed by ? to see other options.\r\n----------------------------------------------------\r\n<\/pre>\n<p>By default, kermit searches the file .kermrc in your home directory. If you have several kermit config files (may be because you have several boards configured differently), you can specify it:<\/p>\n<p>kermit \/home\/paguilar\/.custom_kermrc<\/p>\n<p>If there are problems like the wrong serial interface, you may see a message like this one:<\/p>\n<pre lang=bash>\r\n?SET SPEED has no effect without prior SET LINE\r\nSorry, you must SET LINE or SET HOST first\r\nC-Kermit 9.0.302 OPEN SOURCE:, 20 Aug 2011, for Linux (64-bit)\r\n Copyright (C) 1985, 2011,\r\n  Trustees of Columbia University in the City of New York.\r\nType ? or HELP for help.\r\n<\/pre>\n<p>You can also have this problem if there is a lock file. This error happens if you try to access the serial interface whilst another process is already using it. It can also happen if you kill a previous kermit session when it was connected to the serial interface.<br \/>\nIn these cases you have to remove the lock file and execute kermit again.<\/p>\n<p>Assuming that everything went right and you happily used a busybox shell or similar you can disconnect from kermit by typing <em>Ctrl-\\ + q<\/em><\/p>\n<p>Just to be clear, the escape control sequence is <em>Ctrl<\/em> and <em>backslash<\/em> at the same time, then you enter the desired character.<br \/>\nFor example, if you are in your board&#8217;s shell, for connecting to the kermit shell just type <em>Ctrl-\\ + c<\/em>, then enter <em>connect<\/em> to go back to your board&#8217;s shell.<\/p>\n<p>That&#8217;s it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have used kermit for connecting to serial interfaces for several years and it has always worked as expected. Even for sending a kernel image to U-Boot using the zmodem protocol (yes, it took ages, but there was no Ethernet) has worked quite well. Recently, a friend that is new to embedded Linux ask me\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=417\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,45],"tags":[47,46,48],"class_list":["post-417","post","type-post","status-publish","format-standard","hentry","category-command-line-interface","category-linux","tag-kermit","tag-linux","tag-serial-interface"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=417"}],"version-history":[{"count":6,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions"}],"predecessor-version":[{"id":424,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions\/424"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}