{"id":297,"date":"2014-08-27T15:44:32","date_gmt":"2014-08-27T15:44:32","guid":{"rendered":"http:\/\/wphost.spider-e.com\/?p=297"},"modified":"2014-08-27T15:44:32","modified_gmt":"2014-08-27T15:44:32","slug":"windows-versus-linux-on-intel-galileo","status":"publish","type":"post","link":"https:\/\/wphost.spider-e.com\/?p=297","title":{"rendered":"Windows \u2122 versus Linux on intel Galileo"},"content":{"rendered":"<p style=\"color: #3d3d3d;\">Here is a really quick and dirty, non scientific comparison of a Galileo GEN1 board running Windows \u2122 against the same board running linux.<br \/>\nSPI Flash version is 1.0.2.<\/p>\n<pre style=\"color: #3d3d3d;\">Login to windows is via telnet.\r\nLogin to linux is via ssh.<\/pre>\n<p style=\"color: #3d3d3d;\">\u00a0<strong>Time taken from power-on to login:<\/strong><\/p>\n<pre style=\"color: #3d3d3d;\">Linux\u00a0 48 Seconds\r\nWindows 68 Seconds<\/pre>\n<p style=\"color: #3d3d3d;\"><strong>Time taken to power off:<\/strong><\/p>\n<pre style=\"color: #3d3d3d;\">Linux\u00a0\u00a0\u00a0 3.25 Seconds\u00a0\r\nWindows\u00a0 12.54 Seconds<\/pre>\n<p style=\"color: #3d3d3d;\">Next I wrote a simple &#8216;blink&#8217; executable thats sets up Pin 13 for GPIO and then turns it on\/off in a tight loop. Source code for both is below. Both are built in &#8216;release&#8217; mode.<\/p>\n<p style=\"color: #3d3d3d;\">To write the app for Windows on Galileo you need an external PC running Windows 7 or later, and Visual Studio 2013 or later, with the Microsoft IoT dev kit extensions installed.<\/p>\n<p style=\"color: #3d3d3d;\">To write the app for Linux, you need any PC or Terminal capable of attaching via telnet or RS232.<\/p>\n<p style=\"color: #3d3d3d;\"><strong>Size of simple &#8216;blink&#8217; executable<\/strong><\/p>\n<pre style=\"color: #3d3d3d;\">Linux\u00a0 10080 Bytes\r\nWindows 19456 Bytes<\/pre>\n<p style=\"color: #3d3d3d;\"><strong>Speed of executing GPIO Writes<br \/>\n<\/strong>The simple app after setting up the GPIO runs in a tight loop just switching the GPIO Pin to 1 and 0 continuously.<\/p>\n<p style=\"color: #3d3d3d;\">The Linux loop:<\/p>\n<pre style=\"color: #3d3d3d;\"><span style=\"color: #0000ff;\">while(1)\r\n<\/span>{\r\n\u00a0 \u00a0 write(fd,\"1\",1);\r\n\u00a0 \u00a0 write(fd,\"0\",1);\r\n}<\/pre>\n<p style=\"color: #3d3d3d;\">The windows loop:<\/p>\n<pre><span style=\"color: rgb(61, 61, 61);\">while(1){\r\n\u00a0 \u00a0 digitalWrite(led, LOW);\u00a0\u00a0\u00a0 \/\/ turn the LED off by making the voltage LOW\r\n\u00a0 \u00a0 digitalWrite(led, HIGH);\u00a0 \/\/ turn the LED on by making the voltage HIGH\r\n}<\/span><\/pre>\n<p style=\"color: #3d3d3d;\">These gave the following results:<\/p>\n<p style=\"color: #3d3d3d;\">The Linux version gave a steady 223.9 Hz square wave with a 50% duty cycle. Pulse width is about 2.24 ms.<\/p>\n<p style=\"color: #3d3d3d;\"><a href=\"https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-15.00.42.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-298\" src=\"https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-15.00.42.png?resize=650%2C93\" alt=\"Screen Shot 2014-08-27 at 15.00.42\" width=\"650\" height=\"93\" srcset=\"https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-15.00.42.png?w=672&amp;ssl=1 672w, https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-15.00.42.png?resize=300%2C43&amp;ssl=1 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p style=\"color: #3d3d3d;\">The Windows version gave a jittery 42.72 Hz wave with a 35% Duty cycle. Pulse width is about 14.97 ms, but there were occasional gaps in the wave form where it paused for 10 ms or so.<\/p>\n<p style=\"color: #3d3d3d;\"><a href=\"https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-14.36.39.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-299\" src=\"https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-14.36.39.png?resize=650%2C94\" alt=\"Screen Shot 2014-08-27 at 14.36.39\" width=\"650\" height=\"94\" srcset=\"https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-14.36.39.png?w=676&amp;ssl=1 676w, https:\/\/i0.wp.com\/wphost.spider-e.com\/wp-content\/uploads\/2014\/08\/Screen-Shot-2014-08-27-at-14.36.39.png?resize=300%2C43&amp;ssl=1 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p style=\"color: #3d3d3d;\">And finally, the full source code for each of the test apps.<\/p>\n<p style=\"color: #3d3d3d;\"><strong>Linux source code:<\/strong><\/p>\n<pre style=\"color: #3d3d3d;\">#include &lt;stdint.h&gt;\r\n#include &lt;unistd.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &lt;string.h&gt;\r\n#include &lt;fcntl.h&gt;\r\n\r\nvoid setGPIOPin(char* pin, char* dir, char* drive, char* val)\r\n{\r\n\u00a0 char buf[256];\r\n\u00a0 int fd;\r\n\r\n\u00a0 \/\/ Open the GPIO Export file\r\n\u00a0 fd = open(\"\/sys\/class\/gpio\/export\",O_WRONLY);\r\n\u00a0 if(fd == -1)\r\n\u00a0 \u00a0 exit(-1);\r\n\r\n\/\/ Export chosen pin\r\n\u00a0write(fd, pin, strlen(pin)); \/\/ Export GPIO pin\r\n\u00a0 close(fd);\r\n\r\n\u00a0 \/\/ Open exported pin DIRECTION file\r\n\u00a0 sprintf(buf,\"\/sys\/class\/gpio\/gpio%s\/direction\",pin);\r\n\u00a0 fd = open(buf,O_WRONLY); \/\/ open GPIOxx direction file\r\n\r\n\u00a0 if(fd==-1)\r\n\u00a0 exit(-1);\r\n\r\n\u00a0 \/\/ write out the direction\r\n\u00a0 write(fd,dir,strlen(dir)); \/\/ set GPIOxx direction to out\r\n\u00a0 close(fd);\r\n\r\n\u00a0 \/\/ open the drive file\r\n\u00a0 sprintf(buf,\"\/sys\/class\/gpio\/gpio%s\/drive\",pin);\r\n\u00a0 fd = open(buf,O_WRONLY); \/\/ open GPIO drive strength file\r\n\u00a0 if(fd==-1)\r\n\u00a0 \u00a0 exit(-1);\r\n\r\n\u00a0write(fd,drive,strlen(drive)); \/\/ set GPIO drive\r\n\u00a0 close(fd);\r\n\r\n\u00a0 sprintf(buf,\"\/sys\/class\/gpio\/gpio%s\/value\",pin);\r\n\u00a0 fd = open(buf,O_WRONLY);\r\n\u00a0 if(fd==-1)\r\n\u00a0 exit(-1);\r\n\r\n\u00a0 write(fd,val,strlen(val)); \/\/ set GPIO value\r\n\u00a0 close(fd);\r\n}\r\n\r\nvoid setMux(void)\r\n{\r\n\u00a0 \/\/ Switch all the SPI1 pins through to the header pins. And enable level shifter.\r\n\u00a0 setGPIOPin(\"55\",\"out\",\"pullup\",\"1\"); \/\/ mux\r\n\u00a0 setGPIOPin(\"39\",\"out\",\"pullup\",\"1\"); \/\/ Pin 13\r\n\u00a0 setGPIOPin(\"4\",\"out\",\"pullup\",\"1\"); \/\/ Level shifter\r\n}\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n\u00a0 int fd;\r\n\u00a0 setMux();\r\n\r\n\u00a0 fd = open(\"\/sys\/class\/gpio\/gpio39\/value\",O_WRONLY);\r\n\u00a0 if(fd==-1)\r\n\u00a0 {\r\n\u00a0 \u00a0 printf(\"Failed to open GPIO On pin 13\\n\");\r\n\u00a0 \u00a0 exit(-1);\r\n\u00a0 }\r\n\r\n\u00a0 while(1)\r\n\u00a0 {\r\n\u00a0 \u00a0 write(fd,\"1\",1);\r\n\u00a0 \u00a0 write(fd,\"0\",1);\r\n\u00a0 }\r\n\r\n\u00a0 return 0;\r\n}<\/pre>\n<p style=\"color: #3d3d3d;\">\n<p style=\"color: #3d3d3d;\"><strong>Windows Source code:<\/strong><\/p>\n<pre style=\"color: #3d3d3d;\"><span style=\"color: #0000ff;\">#include \"stdafx.h\"\r\n<\/span>#include \"arduino.h\"\r\n\r\nint _tmain(int argc, _TCHAR* argv[])\r\n{\r\n \u00a0 \u00a0return RunArduinoSketch();\r\n}\r\n\r\nint led = 13;\u00a0 \/\/ This is the pin the LED is attached to.\r\nvoid setup()\r\n{\r\n\u00a0 \u00a0 pinMode(led, OUTPUT);\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Configure the pin for OUTPUT so you can turn on the LED.\r\n}\r\n\r\n\/\/ the loop routine runs over and over again forever:\r\nvoid loop()\r\n{\r\n\u00a0 \u00a0 digitalWrite(led, LOW);\u00a0\u00a0\u00a0 \/\/ turn the LED off by making the voltage LOW\r\n\u00a0 \u00a0 digitalWrite(led, HIGH);\u00a0 \/\/ turn the LED on by making the voltage HIGH\r\n}<\/pre>\n<p style=\"color: #3d3d3d;\">\n","protected":false},"excerpt":{"rendered":"<p>Here is a really quick and dirty, non scientific comparison of a Galileo GEN1 board running Windows \u2122 against the same board running linux. SPI Flash version is 1.0.2. Login to windows is via telnet. Login to linux is via ssh. \u00a0Time taken from power-on to login: Linux\u00a0 48 Seconds Windows 68 Seconds Time taken [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[2,54,51,3],"tags":[73,57,61,74],"class_list":["post-297","post","type-post","status-publish","format-standard","hentry","category-electronics","category-galileo","category-hardware-2","category-software","tag-comparison","tag-galileo-2","tag-linux","tag-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p42WEU-4N","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts\/297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297"}],"version-history":[{"count":1,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts\/297\/revisions\/300"}],"wp:attachment":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}