{"id":145,"date":"2012-12-26T18:05:24","date_gmt":"2012-12-27T01:05:24","guid":{"rendered":"https:\/\/www.uniteng.com\/?p=145"},"modified":"2021-01-05T14:47:07","modified_gmt":"2021-01-05T06:47:07","slug":"part-3-using-serial-port-on-universal-expansion-board","status":"publish","type":"post","link":"https:\/\/www.uniteng.com\/index.php\/2012\/12\/26\/part-3-using-serial-port-on-universal-expansion-board\/","title":{"rendered":"Part 3: Using Serial Port on Universal Expansion Board"},"content":{"rendered":"<h2><strong>Prerequisites:<\/strong><\/h2>\n<ul type=\"disc\">\n<li><a title=\"Part 1: Using Serial Port on Universal Expansion Board\" href=\"https:\/\/www.uniteng.com\/index.php\/2012\/12\/25\/part-1-using-serial-port-on-universal-expansion-board\" target=\"_blank\" rel=\"noopener\">Part 1: Using Serial Port on Universal Expansion Board<\/a><\/li>\n<\/ul>\n<ul type=\"disc\">\n<li><a title=\"RaspberryPi Universal Expansion Board\" href=\"http:\/\/projects.archive.uniteng.com\/digital-system-projects\/raspberrypiuniversalexpansionboard\" target=\"_blank\" rel=\"noopener\">RaspberryPi Universal Expansion Board<\/a><\/li>\n<\/ul>\n<ul type=\"disc\">\n<li><a title=\"Raspberry Pi\" href=\"http:\/\/www.raspberrypi.org\" target=\"_blank\" rel=\"noopener\">Raspberry Pi<\/a><\/li>\n<\/ul>\n<h2><strong>Using Serial Port with the Raspberry Pi &#8211; Connecting Raspberry Pi&#8217;s Serial Port with the onboard STM32 MCU<\/strong><\/h2>\n<p>At first, we need to attach  the Raspberry Pi  to the Universal Expansion Board.<br \/>\n<a href=\"https:\/\/www.uniteng.com\/index.php\/2012\/12\/26\/part-3-using-serial-port-on-universal-expansion-board\/rpi-rs232-to-stm32r\/\" rel=\"attachment wp-att-150\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32r.png\" alt=\"RPI RS232 to STM32r\" width=\"1024\" height=\"726\" class=\"alignnone size-full wp-image-150\" srcset=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32r.png 1024w, https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32r-300x212.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<ol>\n<li value=\"1\"><strong>CPLD Configuration<\/strong><\/li>\n<p>This part is pretty easy since we only need to map the Raspberry Pi&#8217;s UART to the onboard STM32 MCU&#8217;s UART1 using the CPLD. The following Verilog code can implement the idea:<\/p>\n<pre class=\"brush:cpp;\">\r\nmodule RS232(RXD_in,TXD_in,RXD_out,TXD_out);\r\n\r\ninput   RXD_in, TXD_in;\r\noutput  RXD_out,TXD_out;\r\n\r\nassign RXD_out = RXD_in;\r\nassign TXD_out = TXD_in;\r\n\r\nendmodule\r\n<\/pre>\n<p>Navigate to Quartus  -> Assignments -> Pin Planner. The IO need to be configured as following picture.<br \/>\n<a href=\"https:\/\/www.uniteng.com\/index.php\/2012\/12\/26\/part-3-using-serial-port-on-universal-expansion-board\/rpi-rs232-to-stm32-cpld\/\" rel=\"attachment wp-att-152\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-CPLD.png\" alt=\"RPI RS232 to STM32 CPLD\" width=\"750\" height=\"82\" class=\"alignnone size-full wp-image-152\" srcset=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-CPLD.png 750w, https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-CPLD-300x32.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/a><br \/>\nWe can flash the design into the CPLD right now.<\/p>\n<li value=\"2\"><strong>Linux Configuration<\/strong><\/li>\n<p>Edit \/boot\/cmdline.txt:<\/p>\n<pre class=\"brush:cpp;\">\r\nsudo vim \/boot\/cmdline.txt\r\n<\/pre>\n<p>Originally it contained:<\/p>\n<pre class=\"brush:cpp;\">\r\ndwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=\/dev\/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait\r\n<\/pre>\n<p>Deleted the two parameters involving the serial port (ttyAMA0) to get the following:<\/p>\n<pre class=\"brush:cpp;\">\r\ndwc_otg.lpm_enable=0 console=tty1 root=\/dev\/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait\r\n<\/pre>\n<p>Edit \/etc\/inittab:<\/p>\n<pre class=\"brush:cpp;\">\r\nsudo vi \/etc\/inittab\r\n<\/pre>\n<p>We need to comment out following lines in \/etc\/inittab:<\/p>\n<pre class=\"brush:cpp;\">\r\n#Spawn a getty on Raspberry Pi serial line\r\nT0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100\r\n<\/pre>\n<li value=\"3\"><strong>Testing<\/strong><\/li>\n<p>Reboot (sudo reboot) to confirm that kernel output is no longer going to the serial. Only one line Uboot message will be printed out during the booting.<br \/>\n<a href=\"https:\/\/www.uniteng.com\/index.php\/2012\/12\/26\/part-3-using-serial-port-on-universal-expansion-board\/rpi-rs232-to-stm32-rs232-output1\/\" rel=\"attachment wp-att-157\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output1.png\" alt=\"RPI RS232 to STM32 RS232 Output1\" width=\"676\" height=\"48\" class=\"alignnone size-full wp-image-157\" srcset=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output1.png 676w, https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output1-300x21.png 300w\" sizes=\"auto, (max-width: 676px) 100vw, 676px\" \/><\/a><br \/>\nInstall the minicom on the Raspberry Pi:<\/p>\n<pre class=\"brush:cpp;\">\r\nsudo apt-get install minicom\r\n<\/pre>\n<p>And run it:<\/p>\n<pre class=\"brush:cpp;\">\r\nminicom -b 9600 -o -D \/dev\/ttyAMA0\r\n<\/pre>\n<p>Reset the onboard STM32 MCU, the following information will be printed out:<br \/>\n<a href=\"https:\/\/www.uniteng.com\/index.php\/2012\/12\/26\/part-3-using-serial-port-on-universal-expansion-board\/rpi-rs232-to-stm32-rs232-output2\/\" rel=\"attachment wp-att-159\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output2.png\" alt=\"RPI RS232 to STM32 RS232 Output2\" width=\"1158\" height=\"892\" class=\"alignnone size-full wp-image-159\" srcset=\"https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output2.png 1158w, https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output2-300x231.png 300w, https:\/\/www.uniteng.com\/wp-content\/uploads\/2012\/12\/RPI-RS232-to-STM32-RS232-Output2-1024x788.png 1024w\" sizes=\"auto, (max-width: 1158px) 100vw, 1158px\" \/><\/a><br \/>\nEventually, the raspberry Pi can talk to the onboard STM32 MCU now.<\/p>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites: Part 1: Using Serial Port on Universal Expansion Board RaspberryPi Universal Expansion Board Raspberry Pi Using Serial Port with the Raspberry Pi &#8211; Connecting Raspberry Pi&#8217;s Serial Port with the onboard STM32 MCU At first, we need to attach the Raspberry Pi to the Universal Expansion Board. CPLD Configuration This part is pretty easy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ngg_post_thumbnail":0,"footnotes":""},"categories":[5],"tags":[6,9,8,7],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-hardware-notes","tag-raspberrypi","tag-rs232","tag-serial-port","tag-universal-expansion-board"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"neilhao","author_link":"https:\/\/www.uniteng.com\/index.php\/author\/neilhao\/"},"uagb_comment_info":0,"uagb_excerpt":"Prerequisites: Part 1: Using Serial Port on Universal Expansion Board RaspberryPi Universal Expansion Board Raspberry Pi Using Serial Port with the Raspberry Pi &#8211; Connecting Raspberry Pi&#8217;s Serial Port with the onboard STM32 MCU At first, we need to attach the Raspberry Pi to the Universal Expansion Board. CPLD Configuration This part is pretty easy&hellip;","_links":{"self":[{"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/posts\/145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/comments?post=145"}],"version-history":[{"count":0,"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/posts\/145\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/media?parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/categories?post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.uniteng.com\/index.php\/wp-json\/wp\/v2\/tags?post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}