{"id":1246,"date":"2015-05-29T14:34:29","date_gmt":"2015-05-29T14:34:29","guid":{"rendered":"http:\/\/www.dnclabs.com\/?p=1246"},"modified":"2015-05-29T14:34:29","modified_gmt":"2015-05-29T14:34:29","slug":"hlk-rm04-embedded-linux","status":"publish","type":"post","link":"http:\/\/www.dnclabs.com\/?p=1246","title":{"rendered":"HLK-RM04 Embedded Linux"},"content":{"rendered":"<style>\n<!--\n \/* Font Definitions *\/\n @font-face\n\t{font-family:\"Cambria Math\";\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;}\n@font-face\n\t{font-family:Cambria;\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;}\n@font-face\n\t{font-family:Calibri;\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;}\n@font-face\n\t{font-family:Tahoma;\n\tpanose-1:2 11 6 4 3 5 4 4 2 4;}\n@font-face\n\t{font-family:Courier New;\n\tpanose-1:2 11 6 4 3 5 4 4 2 4;}\n \/* Style Definitions *\/\nfixed\n\t{margin-top:0in;\n\tmargin-right:0in;\n\tmargin-bottom:10.0pt;\n\tmargin-left:0in;\n\tline-height:115%;\n\tfont-size:11.0pt;\n\tfont-family:\"Courier New\",\"monospace\";}\n p.MsoNormal, li.MsoNormal, div.MsoNormal\n\t{margin-top:0in;\n\tmargin-right:0in;\n\tmargin-bottom:10.0pt;\n\tmargin-left:0in;\n\tline-height:115%;\n\tfont-size:11.0pt;\n\tfont-family:\"Calibri\",\"sans-serif\";}\nh1\n\t{mso-style-link:\"Heading 1 Char\";\n\tmargin-top:24.0pt;\n\tmargin-right:0in;\n\tmargin-bottom:0in;\n\tmargin-left:0in;\n\tmargin-bottom:.0001pt;\n\tline-height:115%;\n\tpage-break-after:avoid;\n\tfont-size:14.0pt;\n\tfont-family:\"Cambria\",\"serif\";\n\tcolor:#365F91;}\nh2\n\t{mso-style-link:\"Heading 2 Char\";\n\tmargin-top:10.0pt;\n\tmargin-right:0in;\n\tmargin-bottom:0in;\n\tmargin-left:0in;\n\tmargin-bottom:.0001pt;\n\tline-height:115%;\n\tpage-break-after:avoid;\n\tfont-size:13.0pt;\n\tfont-family:\"Cambria\",\"serif\";\n\tcolor:#4F81BD;}\n-->\n<\/style>\n<p><a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_Linux.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_Linux-1024x768.png\" alt=\"Wifi_Linux\" width=\"555\" height=\"416\" class=\"alignleft size-large wp-image-1250\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_Linux.png 1024w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_Linux-300x225.png 300w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/a>As I continue to develop embedded Linux designs I needed a smaller design that can be deployed as a standalone project. The new design consists of a small 4x5cm PCB that acts as a carrier for the HLK_RM04 wifi module. I needed this PCB to provide a USB to serial port for debugging as well as an RJ45 Ethernet port and a USB-A host connector along with some LEDs. This board when equipped with an HLK_RM04 module forms a complete embedded Linux computer. <\/p>\n<p>This embedded Linux computer is not a Raspberry Pi or Beagle Bone Black competitor. The HLK-RM04 has no video output and provides limited processing (380MHz) and 32M memory. What the HLK-RM04 does provide is a very inexpensive $10-15 Linux computer that can be easily embedded in a project. With WiFi, USB and Ethernet it forms a great robotics platform or a remote telemetry and data logging devices. I am thinking of using it as an Internet radio and adding features to directly drive WS2812B RGB LED strips.<\/p>\n<p>For the last few months I have been building a development environment for this board and module. The development environment runs on Ubuntu and provides complete control of the software builds. Linux on an embedded computer is divided into two components; the Uboot loader and the kernel. I have infact created two build tool chains for each of these components. I can build and test new Uboot loaders or I can modify the Linux kernel as required. The Linux kernel is built using the OpenWRT build environment.<br \/>\nThe schematic for version 2 of the breakout board is located here. <a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_LinuxWifi_Linux_Schematic.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_LinuxWifi_Linux_Schematic-1024x706.png\" alt=\"Wifi_LinuxWifi_Linux_Schematic\" width=\"555\" height=\"383\" class=\"alignleft size-large wp-image-1251\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_LinuxWifi_Linux_Schematic-1024x706.png 1024w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_LinuxWifi_Linux_Schematic-300x207.png 300w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Wifi_LinuxWifi_Linux_Schematic.png 1236w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/a> <\/p>\n<p>I have provided a pin map for all of the GPIO available on this board. Note that some of the alternate functions are mutually exclusive so if you enable UARTF or I2C you are giving up the GPIO pins for those ports. As I proceed with my development of this board I am hoping to illustrate how each of these functions can be used to create your own custom application.<\/p>\n<p>I should explain the rational for the breakout board design. The HLK-RM04 comes with 2mm header pins which are not very standard in North America, so at a minimum I wanted to break out the GPIO pins to 0.1\u201d centers. I included a single RJ45 port initially so that I could TFTP load new images to the HLK module. The version of Uboot I installed only includes wired Ethernet support so I couldn\u2019t do this wirelessly for now. I hope that in time I will be able to remove the RJ45 connector by upgrading Uboot to support wireless TFTP or serial Kermit. The USB-A host port is a huge asset because it allows me to install Flash memory sticks, which are directly readable from the Linux OS. This feature is extremely useful for data logging. The USB host also accepts USB to serial dongles, USB cameras and pretty much anything else you might want to plug into a Linux computer. For control of the module the Uartlite interface is wired to a CH340 USB to serial converter. This allows me to configure the module even if I have no network connectivity. This is absolutely essential from a developer\u2019s point of view. Once your network is configured you can then remotely access the module using the SSH secure shell from anywhere in the world.<\/p>\n<p>I would be remiss not to mention a few of the web sites that helped me to get to this point. I started with the HLK-RM04 Openwrt web page. This was helpful but not all that clear and there were a number of documentation inconsistencies. <a href=\"http:\/\/wiki.openwrt.org\/toh\/hilink\/hlk-rm04\" title=\"Openwrt\">http:\/\/wiki.openwrt.org\/toh\/hilink\/hlk-rm04<\/a> The Australian site for the Carambola has lots of useful tips but it would appear they have moved on to supporting the Carambola2 which uses a different chipset. There are not a lot of new posts about the Carambola but what they have is very useful. <a href=\"http:\/\/www.8devices.com\/wiki\/carambola:1:demo_projects\" title=\"Carambola\">http:\/\/www.8devices.com\/wiki\/carambola:1:demo_projects<\/a><\/p>\n<p>The final nod goes to Vocore, which is current and has lots of detailed information. <a href=\"www.vogner.cn\" title=\"Vocore\">www.vogner.cn<\/a> I have purchased a few modules and they are great; still I prefer 0.1\u201d centers.<\/p>\n<p>I buy my modules directly from HiLink <a href=\"http:\/\/www.hlktech.net\/product_detail.php?ProId=49\" title=\"HLK-RM04\">http:\/\/www.hlktech.net\/product_detail.php?ProId=49<\/a> Pay extra for the 32M module, its worth it. Tell them I sent you. My goal is to provide a more fully documented design based specifically on the HLK-RM04 and Ralink RT5350 system on a chip.<\/p>\n<p>Over the next few months I will be publishing all of the details for configuring and controlling the module. The specifics will include details on the following:<\/p>\n<p>Step 1 Install Uboot over factory default<br \/>\nStep 2 Ubuntu_12_Install<br \/>\nStep 3 Build Uboot<br \/>\nStep 4 Install_Openwrt<br \/>\nStep 5 Build_Openwrt<br \/>\nStep 6 Compile_User_Program<br \/>\nStep 7 Fast_GPIO_in_C<br \/>\nStep 8 USB<br \/>\nStep 9 Writing a kernel driver<\/p>\n<p>So let&#8217;s get started by describing what it is that I have built for this project. My initial design of the support board has been tested and I am preparing to build version 2 of the board to address a few of the errata that I found. To put things into perspective I think a block diagram of the system is in order. The green PCB breaks out the 2mm module connectors to 0.1&#8243; solder tabs and provides the connectors for one Ethernet port and one USB host port. To provide a configuration port a USB to serial CDC interface has been added. The USB mini B port also doubles as the power source for the whole assembly.<\/p>\n<p><H2>GPIO<\/H2><br \/>\nEach of the GPIO pins has been equipped with an LED so that you can easily observe when the GPIO bit is toggled. I have also routed one of the GPIO to a WS2812B RGB LED so that I can provide some more interesting visual feedback from the board.<br \/>\n<a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/WiFi_block_diagram.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/WiFi_block_diagram.png\" alt=\"WiFi_block_diagram\" width=\"501\" height=\"637\" class=\"alignleft size-full wp-image-1249\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/WiFi_block_diagram.png 501w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/WiFi_block_diagram-236x300.png 236w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/a><\/p>\n<h2>Features<\/h2>\n<p>360MHzMips processor Ralink RA5350 system on a chip<br \/>\n8Mbyte flash\/ 32Mbyte SDRAM<br \/>\n802.3 wired ethernet port RJ45<br \/>\n802.11 wifi<br \/>\nUSB-A host port<br \/>\nLEDs on all I\/O<br \/>\n8 GPIO, UARTF (Rx,Tx)<br \/>\nI2C (SDA, SCL)<br \/>\nCH340 USB to serial converter<\/p>\n<h2>GPIO pins<\/h2>\n<p><a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Pinout.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Pinout.png\" alt=\"Pinout\" width=\"993\" height=\"424\" class=\"alignleft size-full wp-image-1258\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Pinout.png 993w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/05\/Pinout-300x128.png 300w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/a><\/p>\n<p>The following table is a modified version of the HLK-RM04 pin functions that are located on the Openwrt site. It corrects the USB polarity and properly names GPIO1, 2 as I2C pins. I have also removed the references to netgape, which is likely a translation of port, but for me it was confusing so I removed it.<br \/>\n<fixed><\/p>\n<h2>LED Definition<\/h2>\n<p>LED1 \u2013> power LED<br \/>\nLED2 \u2013> EPY_LED4_N<br \/>\nLED3 \u2013> WLAN_LED_N<br \/>\n<\/fixed><\/p>\n<h2>Pin Definition<\/h2>\n<p><fixed><\/p>\n<pre>\r\nNo.     Function        RT5350 Pin      Dir     Explanation\r\n1       VDD5V           -               I       Power input\r\n2 \tGND \t\tGND \t\t\tGND\r\n3 \tWLAN_LED \tWLAN_LED_N \tO \tWIFI LED\r\n4 \t3.3V \t\t-\t\tO \t3.3V power output <300mA\r\n5 \tLINK1 \t        EPHY_LED3_N \tI\/O \tLAN LED1\/ GPIO25\r\n6 \tUSB_M\t\tUPHY0_PADM\tD- \tUSB signal D-\r\n7 \tUSB_P\t\tUPHY0_PADP\tD+ \tUSB signal D+\r\n8 \tSDA\t\tI2C_SD \t\tI\/O \tSDA\/GPIO1\r\n9 \tSCL\t\tI2C_SCLK \tI\/O \tSCL\/GPIO2\r\n10 \tGPIO0 \t        GPIO0 \t\tI\/O \tGPIO0\r\n11 \tTXOP1 \t        EPHY_TXP_P3 \tI\/O \tLAN 1 TXP, Pin 1\r\n12 \tTXON1 \t        EPHY_TXN_P3 \tI\/O \tLAN 1 TXN, Pin 2\r\n13 \tRXIP2 \t        EPHY_RXP_P4 \tI\/O \tWAN RXP, Pin 3\r\n14 \tRXIN2 \t        EPHY_RXN_P4 \tI\/O \tWAN RXN, Pin 6\r\n15 \tRXIN1 \t        EPHY_RXN_P3 \tI\/O \tLAN 1 RXN, Pin 6\r\n16 \tRXIP1 \t        EPHY_RXP_P3 \tI\/O \tLAN 1 RXP, Pin 3\r\n17 \tTXON2 \t        EPHY_TXN_P4 \tI\/O \tWAN TXN, Pin 2\r\n18 \tTXOP2 \t        EPHY_TXP_P4 \tI\/O \tWAN TXP, Pin 1\r\n19 \tRTS_N \t        RTS_N \t\tI\/O \tRTS\/I2SCLK\/GPIO7\r\n20 \tUART_RX \tRXD2 \t\tI \tUartlite RX2\/GPIO16\r\n21 \tUART_TX \tTXD2 \t\tO \tUartliteTX2\/GPIO15\r\n22 \tRXD \t\tRXD \t\tI\/O \tRX\/I2SSDI\/GPIO10\r\n23 \tLINK2 \t        EPHY_LED4_N \tI\/O \tWAN LED2\/GPIO26\r\n24 \tCTS_N \t        CTS_N \t\tI\/O \tCTS\/I2SSDO\/GPIO9\r\n25 \tRIN \t\tRIN \t\tI\/O \tRING\/PCMDTX\/GPIO14\r\n26 \tTXD \t\tTXD \t\tI\/O \tTX\/I2SWS\/GPIO8\r\n27 \t1.8V \t\t- \t\tO\t1.8V output <300mA\r\n28 \tVDD5V \t        - \t\tI\t5V input\r\n<\/pre>\n<p><\/fixed><\/p>\n<h2>Resources<\/h2>\n<p><fixed><\/p>\n<pre>\r\n1 I2S (muxed with UARTF)\r\n1 PCM (muxed with UARTF, data only) - PCM clock, sync, and RX pin are not wired, \r\n  but PCMDTX is available and useful for timing-sensitive 1-wire serial protocols \r\n  at 19.531kHz~20MHz\r\n12 GPIOs (some features reserve GPIO: I2C[2], UART[2], UARTF[5], EPHY_LED[2], GPIO0[1] \r\n  and can be disabled for more GPIO).\r\n<\/pre>\n<p><\/fixed><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I continue to develop embedded Linux designs I needed a smaller design that can be deployed as a standalone project. The new design consists of a small 4x5cm PCB that acts as a carrier for the HLK_RM04 wifi module.&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.dnclabs.com\/?p=1246\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1246","post","type-post","status-publish","format-standard","hentry","category-embedded-linux"],"_links":{"self":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts\/1246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1246"}],"version-history":[{"count":11,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts\/1246\/revisions"}],"predecessor-version":[{"id":1361,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts\/1246\/revisions\/1361"}],"wp:attachment":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1246"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}